Hi wlad, OpenJPA needs a connection to the database in order to create the database tables. This posted exception indicates a problem with getting a connection:
[java] <openjpa-2.2.0-r422266:1244990 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: There were errors initializing your configuration: <openjpa-2.2.0-r422266:1244990 fatal user error> org.apache.openjpa.util.UserException: A connection could not be obtained for driver class "null" and URL "null". You may have specified an invalid URL. According to your persistence.xml, you are trying to access this datasource: <jta-data-source>Vezbe09DS</jta-data-source> And, it looks like you are attempting to define this datasource via TomEE configuration. I am not a TomEE expert, but it would seem that you have an issue with defining this Vezbe09DS in the TomEE jndi name space. Normally, the jta-data-source would be qualified via the jdbc namespace, something like this: jdbc/Vezbe09DS. Or, if TomEE supports indirect references, then you would use this namespace: java:comp/env/jdbc/Vezbe09DS. OpenJPA is dependent on your datasource configuration. If you indicate that the jndi name is Vezbe09DS, then that's the only jdni location OpenJPA will look. When this fails, then OpenJPA will attempt to use alternate property settings to find an appropriate database (ie. javax.persistence.* properties). That's why the error message says it can't find a driver class or URL property... Good luck! Kevin On Mon, Dec 9, 2013 at 5:23 AM, wlad <vvo...@yahoo.com> wrote: > Hi, > I am trying to create database from annotated EJB entities. Using: Eclipse, > Ant tool, Apache Tomee server, OpenJPA, JEE/EJB's, MySQL, OpenJDK java 1.7. > > My app fails during injecting entity manager(that is suppose to trigger db > creation following annotated entity classes). Some crucial app parts: > > *Exception i am getting looks like this:* > > prepare-database: > [echo] Inserting default user into database. > [java] Dec 09, 2013 9:45:29 AM org.apache.openejb.client.EventLogger > log > [java] INFO: > RemoteInitialContextCreated{providerUri=http://127.0.0.1:8080/tomee/ejb} > [java] Bean found > [java] Exception in thread "main" javax.ejb.EJBException: The bean > encountered a non-application exception; nested exception is: > [java] <openjpa-2.2.0-r422266:1244990 nonfatal general error> > org.apache.openjpa.persistence.PersistenceException: There were errors > initializing your configuration: <openjpa-2.2.0-r422266:1244990 fatal user > error> org.apache.openjpa.util.UserException: A connection could not be > obtained for driver class "null" and URL "null". You may have specified an > invalid URL. > [java] at > > org.apache.openjpa.jdbc.schema.DataSourceFactory.newConnectException(DataSourceFactory.java:255) > [java] at > > org.apache.openjpa.jdbc.schema.DataSourceFactory.installDBDictionary(DataSourceFactory.java:241) > [java] at > > org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getConnectionFactory(JDBCConfigurationImpl.java:733) > [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native > Method) > [java] at > > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > [java] at > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > [java] at java.lang.reflect.Method.invoke(Method.java:606) > [java] at > > org.apache.openjpa.lib.conf.ConfigurationImpl.instantiateAll(ConfigurationImpl.java:295) > [java] at > > org.apache.openjpa.conf.OpenJPAConfigurationImpl.instantiateAll(OpenJPAConfigurationImpl.java:1671) > [java] at > > org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:646) > [java] at > > org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:203) > [java] at > > org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:156) > [java] at > > org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:227) > [java] at > > org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:60) > [java] at > > org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory.createEntityManager(ReloadableEntityManagerFactory.java:160) > [java] at > > org.apache.openejb.persistence.JtaEntityManagerRegistry.getEntityManager(JtaEntityManagerRegistry.java:115) > [java] at > > org.apache.openejb.persistence.JtaEntityManager.getEntityManager(JtaEntityManager.java:80) > [java] at > > org.apache.openejb.persistence.JtaEntityManager.persist(JtaEntityManager.java:126) > [java] at > > rs.ac.uns.ftn.informatika.mbs2.vezbe09.primer01.server.session.InitBean.init(InitBean.java:22) > [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native > Method) > > and so on .... > > *Ant task for triggering database generation:* > > <target name="prepare-database"> > <echo message="Inserting default user into database."/> > <java > > classname="rs.ac.uns.ftn.informatika.mbs2.vezbe09.primer01.client.InitClient" > fork="true"> > <classpath> > <pathelement path="${build}" /> > <fileset dir="${lib}"> > <include name="*.jar"/> > </fileset> > </classpath> > </java> > </target> > > *"InitClient" class (started from this ant task) has next code in its main > method:* > > Context ctx = new InitialContext(); > Init init = (Init) ctx.lookup("InitBeanRemote"); > System.out.println("Bean found!"); > init.init(); > > *"InitBean" class, where entity manager is being injected:* > > @Stateless > @Remote(Init.class) > public class InitBean implements Init { > > @PersistenceContext(unitName = "Vezbe09") > EntityManager em; > > public void init() { > > Korisnik korisnik = new Korisnik("Admin", "Admin", "admin", > "admin"); > em.persist(korisnik); > //... > } > } > > *persistence.xml - persistence unit definition:* > > <persistence-unit name="Vezbe09" transaction-type="JTA"> > > <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> > <jta-data-source>Vezbe09DS</jta-data-source> > <properties> > <property name="openjpa.jdbc.SynchronizeMappings" > value="buildSchema(ForeignKeys=true)" /> > <property name="openjpa.jdbc.DBDictionary" value="mysql" /> > <property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO" > /> > </properties> > </persistence-unit> > > *Data source definition in tomee.xml configuration file:* > > <Resource id="Vezbe09DS" type="DataSource"> > JdbcDriver com.mysql.jdbc.Driver > JdbcUrl jdbc:mysql://127.0.0.1:3306/Vezbe09 > UserName root > Password 123 > JtaManaged true > DefaultAutoCommit false > </Resource> > > (Strange thing is that I have run this application before, in the past, and > it was working fine. I was getting database, and running application.) > I am still new to JEE world, so this may be some trivial issue i am > missing. > Appreciate any suggestion. > > > > -- > View this message in context: > http://openjpa.208410.n2.nabble.com/OpenJPA-not-generating-mapping-DB-tables-from-EJB-entities-tp7585737.html > Sent from the OpenJPA Users mailing list archive at Nabble.com. >