You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by zark <bo...@web.de> on 2016/04/01 11:27:12 UTC

Config-Problem: org.apache.openjpa.persistence.ArgumentException upon accessing entityManager

Hi there,

I am in the progress of making my first steps with Tomee and Spring. I am
trying to recreate a WebSphere/DB2/Spring-based project I once worked on.

I want to create a JTA/container managed DataSource and my
Spring-MVC-Controllers shall run (Spring-)@Transactional, so that I obtain
the EntityManager from the container and I don't need to worry about
beginning/committing transaction as the container does it for me. So Spring
must be integrated into the configuration.

Setup of the current environment ist: Tomee 1.7.4, MariaDB, Spring, Gradle,
IDE is Eclipse, all on Ubuntu-OS.

I am fidelling with the configuration quite some time (days...). Searching
the net gave some partial hints, but none led to a working solution.

 With the actual code, I get an ArgumentException every time I want to
obtain the entityManager, moaning about an unset 
openjpa.ConnectionDriverName or javax.persistence.jdbc.driver property.
Afaik, I don't need to provide openjpa.Connection-Data (Driver, URL,
usr+pwd) as this is condigured in Tomee.

Any help gladly apreciated...

The dirty details (config, classes and logs):

tomee.xml (copied to Eclipse Servers/runtime):


/WebContent/WEB-INF/web.xml: 
http://pastebin.com/ygqHh1dq <http://pastebin.com/ygqHh1dq>  

/WebContent/WEB-INF/config/extranet-spring-servlet.xml (Spring
config/"applicationContext.xml"):
http://pastebin.com/rsLQArsz <http://pastebin.com/rsLQArsz>  

/src/META-INF/persistence.xml:


Java-Classes:
* All Controllers are transactional through custom Annotation
@VeaController:  http://pastebin.com/T3r5bgae <http://pastebin.com/T3r5bgae>  
* Within the specific controller, a service is injected:

* UserService recieves EntityManager from abstract parent-class 
http://pastebin.com/sLbFjU1f <http://pastebin.com/sLbFjU1f>  
* When in UserService

  is hit, I recive the ArgumentException

Log-Output:
http://pastebin.com/xgX5eQUM <http://pastebin.com/xgX5eQUM>  

Sorry for reading that much code, but I don't know where the error resides.
Thanks, Mark





--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Config-Problem-org-apache-openjpa-persistence-ArgumentException-upon-accessing-entityManager-tp4678042.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Config-Problem: org.apache.openjpa.persistence.ArgumentException upon accessing entityManager

Posted by zark <bo...@web.de>.
Got it working!

As reference for any new commers, here's a list of issues I had:

* Permission Problem: I had  a DataSource configured for  root running under
a IDE as normal user.
* Wrong JNDI-Name in persistence.xml:
<jta-data-source>java:openejb/Resource/ExtranetTestDS</jta-data-source>
(instead of <jta-data-source>ExtranetTestDS</jta-data-source>)
* As for the Spring Integration:
In order for Spring to access the EntityManagerFactory (ie. when using
@Transactional) I assume you need to create a TransactionManager in
tomee.xml:

and in Spring applicationContext.xml:


Side note: I found the OpenJPA-Exceptions not to be very exact, the thrown
exception may just be the result of configurational problem residing
somewhere else, see hints in Stackoverflow-answer:
http://stackoverflow.com/questions/2983248/com-mysql-jdbc-exceptions-jdbc4-communicationsexception-communications-link-fai





--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Config-Problem-org-apache-openjpa-persistence-ArgumentException-upon-accessing-entityManager-tp4678042p4678066.html
Sent from the TomEE Users mailing list archive at Nabble.com.