tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Karsten.O...@t-systems.com>
Subject RE: OpenEJB - Missing required persistence.xml
Date Wed, 13 Feb 2008 14:26:52 GMT
Hi,

Thanks for the answer. OK, I'm a step further. Your hint led me in the right direction.

At the moment I have problems with the database.

When I initialize my test case with:

    @Before
    public void initContext() throws Exception {
        Properties properties = new Properties();
        properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
                "org.apache.openejb.client.LocalInitialContextFactory");

        if (DB_MODE == MYSQL) {
            properties.setProperty("Default\\ JDBC\\ Database.Password", "tpg");
            properties.setProperty("Default\\ JDBC\\ Database.JdbcUrl",
                    "jdbc:mysql://localhost:3306/tpg-server");
            properties.setProperty("Default\\ JDBC\\ Database.JdbcDriver",
                    "com.mysql.jdbc.Driver");
            properties.setProperty("Default\\ JDBC\\ Database.UserName", "tpg");
            properties.setProperty(
                    "Default\\ JDBC\\ Database.ConnectionInterface",
                    "javax.sql.DataSource");
        }
        if (DB_MODE == DERBY) {
            properties.setProperty("Default\\ JDBC\\ Database.JdbcUrl",
                    "jdbc:derby:derbyDB;create=true");
            properties.setProperty("Default\\ JDBC\\ Database.JdbcDriver",
                    "org.apache.derby.jdbc.EmbeddedDriver");
            properties.setProperty(
                    "Default\\ JDBC\\ Database.ConnectionInterface",
                    "javax.sql.DataSource");
        }

        InitialContext initialContext = new InitialContext(properties);
        Object ref = initialContext.lookup(TestFacadeImpl.class.getSimpleName()
                + "Remote");
        service = (TestFacade) ref;
    }

I get:

Apache OpenEJB 3.0-beta-2    build: 20080131-03:38
http://openejb.apache.org/
- openejb.home = C:\workspace\TestFacade\target
- openejb.base = C:\workspace\TestFacade\target
- Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default
Security Service)
- Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default
Transaction Manager)
- Configuring Service(id=My DataSource, type=Resource, provider-id=Default JDBC Database)
- Configuring Service(id=My Unmanaged DataSource, type=Resource, provider-id=Default JDBC
Database)
- Configuring Service(id=My JMS Resource Adapter, type=Resource, provider-id=Default JMS Resource
Adapter)
- Configuring Service(id=My JMS Connection Factory, type=Resource, provider-id=Default JMS
Connection Factory)
- Configuring Service(id=Default JDK 1.3 ProxyFactory, type=ProxyFactory, provider-id=Default
JDK 1.3 ProxyFactory)
- Configuring Service(id=My CMP Container, type=Container, provider-id=Default CMP Container)
- Configuring Service(id=My BMP Container, type=Container, provider-id=Default BMP Container)
- Configuring Service(id=My Stateful Container, type=Container, provider-id=Default Stateful
Container)
- Configuring Service(id=My Stateless Container, type=Container, provider-id=Default Stateless
Container)
- Configuring Service(id=My MDB Container , type=Container, provider-id=Default MDB Container)
- Found EjbModule in classpath: C:\workspace\TestFacade\target\classes
- Configuring app: C:\workspace\TestFacade\target\classes
- Configuring PersistenceUnit(name=testFacadePu, provider=null)
- Loaded Module: C:\workspace\TestFacade\target\classes
- Creating ProxyFactory(id=Default JDK 1.3 ProxyFactory)
- Creating TransactionManager(id=Default Transaction Manager)
- Creating SecurityService(id=Default Security Service)
- Creating Resource(id=My DataSource)
- Creating Resource(id=My Unmanaged DataSource)
- Creating Resource(id=My JMS Resource Adapter)
- Creating Resource(id=My JMS Connection Factory)
- Creating ConnectionManager for Resource(id=My JMS Connection Factory)
- Creating Container(id=My CMP Container)
- Creating Container(id=My BMP Container)
- Creating Container(id=My Stateful Container)
- Creating Container(id=My Stateless Container)
- Creating Container(id=My MDB Container )
- Assembling app: C:\workspace\TestFacade\target\classes
- PersistenceUnit(name=testFacadePu, provider=null)
- Jndi(name=TestFacadeImplRemote) --> Ejb(deployment-id=TestFacadeImpl)
- Created Ejb(deployment-id=TestFacadeImpl, ejb-name=TestFacadeImpl, container=My Stateless
Container)
- Deployed Application(path=C:\workspace\TestFacade\target\classes)
- OpenEJB ready.
OpenEJB ready.
- Unexpected exception from beforeCompletion; transaction will roll back
<openjpa-1.0.1-r420667:592145 nonfatal general error> org.apache.openjpa.persistence.PersistenceException:
null
	at org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq.getConnection(AbstractJDBCSeq.java:162)
	at org.apache.openjpa.jdbc.kernel.TableJDBCSeq.allocateSequence(TableJDBCSeq.java:366)
	at org.apache.openjpa.jdbc.kernel.TableJDBCSeq.nextInternal(TableJDBCSeq.java:266)
	at org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq.next(AbstractJDBCSeq.java:60)
	at org.apache.openjpa.util.ImplHelper.generateValue(ImplHelper.java:160)
	at org.apache.openjpa.util.ImplHelper.generateFieldValue(ImplHelper.java:144)
	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.assignField(JDBCStoreManager.java:557)
	at org.apache.openjpa.util.ApplicationIds.assign(ApplicationIds.java:450)
	at org.apache.openjpa.util.ApplicationIds.assign(ApplicationIds.java:426)
	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.assignObjectId(JDBCStoreManager.java:541)
	at org.apache.openjpa.kernel.DelegatingStoreManager.assignObjectId(DelegatingStoreManager.java:134)
	at org.apache.openjpa.kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:501)
	at org.apache.openjpa.kernel.StateManagerImpl.preFlush(StateManagerImpl.java:2770)
	at org.apache.openjpa.kernel.PNewState.beforeFlush(PNewState.java:39)
	at org.apache.openjpa.kernel.StateManagerImpl.beforeFlush(StateManagerImpl.java:940)
	at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1892)
	at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1852)
	at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1770)
	at org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:514)
	at org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:499)
	at org.apache.geronimo.transaction.manager.TransactionImpl.beforePrepare(TransactionImpl.java:400)
	at org.apache.geronimo.transaction.manager.TransactionImpl.commit(TransactionImpl.java:257)
	at org.apache.geronimo.transaction.manager.TransactionManagerImpl.commit(TransactionManagerImpl.java:245)
	at org.apache.openejb.core.transaction.TransactionPolicy.commitTransaction(TransactionPolicy.java:141)
	at org.apache.openejb.core.transaction.TxRequired.afterInvoke(TxRequired.java:75)
	at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:233)
	at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:188)
	at org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:165)
	at org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:217)
	at org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:77)
	at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:245)
	at org.apache.openejb.util.proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:49)
	at $Proxy28.persistStrecke(Unknown Source)
	at foo.bar.testfacade.TestFacadeImplOpenEJBTest.testPersistStrecke(TestFacadeImplOpenEJBTest.java:58)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
	at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
	at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
	at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
	at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
	at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
	at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
	at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
	at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
	at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
	at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: javax.transaction.SystemException
	at org.apache.openjpa.ee.RegistryManagedRuntime$TransactionManagerRegistryFacade.suspend(RegistryManagedRuntime.java:176)
	at org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq.getConnection(AbstractJDBCSeq.java:158)
	... 55 more


For some strange reason when I was editing and using the openejb.xml the error was different;
the tables in the database were not created.


Thanks,
Karsten

-----Urspr√ľngliche Nachricht-----
Von: David Blevins [mailto:david.blevins@visi.com] 
Gesendet: Mittwoch, 13. Februar 2008 00:54
An: users@openejb.apache.org
Betreff: Re: OpenEJB - Missing required persistence.xml

It seems like what's happening is eclipse isn't configured to copy in  
the src/*/resources files into the related build output directories.

To see if I could replicate the issue, I grabbed our injection-of- 
entitymanager example from the examples zip and generated an eclipse  
project for it using 'mvn eclipse:eclipse' on the command line.  Then  
I added the M2_REPO variable[1].  When it asked me if I wanted to  
rebuild everything I said yes.  After I was able to run the test case  
in eclipse.

Here's the relevant part of my .classpath file when all that was done:

   <classpathentry kind="src" path="src/main/java"/>
   <classpathentry kind="src" path="src/main/resources" excluding="**/ 
*.java"/>
   <classpathentry kind="src" path="src/test/java" output="target/test- 
classes"/>
   <classpathentry kind="output" path="target/classes"/>

The goal is that "src/main/java" and "src/main/resources" should  
output into "target/classes".  And "src/test/java" and "src/test/ 
resources" should output into "target/test-classes".  If both of those  
happen correctly, you shouldn't need any <Deployments> entries in your  
openejb.xml file at all.

If you can post your .classpath file for pattern-management-impl  
that'd be great.

On a side note, you can configure data sources from within your test  
case (and delete your openejb.xml entirely) like so:

         Properties p = new Properties();
         p.put(Context.INITIAL_CONTEXT_FACTORY,  
"org.apache.openejb.client.LocalInitialContextFactory");

         p.put("myDataSource", "new://Connector?type=DataSource");
         p.put("myDataSource.JdbcDriver",  
"org.apache.derby.jdbc.EmbeddedDriver");
         p.put("myDataSource.JdbcUrl",  
"jdbc:derby:derbyDB;create=true");

         Context context = new InitialContext(p);

-David

[1]  http://people.apache.org/~dblevins/eclipse-howto/new-variable.tiff

On Feb 11, 2008, at 10:34 AM, <Karsten.Ohme@t-systems.com> <Karsten.Ohme@t-systems.com

 > wrote:

> Hi,
>
> I'm experimenting for one day with OpenEJB 3.0-beta-2, but I'm  
> stuck. I
> have tried different approaches to test EJBs, ejb3unit, JBoss
> embeddable, but OpenEJB seems to be the best, although it also does  
> not
> work for me.
>
> I always get a
>
> - FAIL ... PatternManagementDaoImpl:	Missing required persistence.xml
> for @PersistenceContext ref "em" to unit "pattern-managementPu"
>
> What's wrong? It is there. And where should it be placed? In META-INF
> like usually? It seems that it is later found.
>
> What I want to do is to use an Apache Derby database (in memory) which
> is automatically initilialized. What do I have to define and where,  
> that
> this works?
>
> Can I define the order in which the EJB modules are loaded?
>
> Thanks,
> Karsten
>
> Apache OpenEJB 3.0-beta-2    build: 20080131-03:38
> http://openejb.apache.org/
> - openejb.home = C:\workspace\pattern-management\pattern-management- 
> impl
> - openejb.base = C:\workspace\pattern-management\pattern-management- 
> impl
> - Configuring Service(id=Default Security Service,  
> type=SecurityService,
> provider-id=Default Security Service)
> - Configuring Service(id=Default Transaction Manager,
> type=TransactionManager, provider-id=Default Transaction Manager)
> - Configuring Service(id=Derby Database, type=Resource,
> provider-id=Default JDBC Database)
> - Configuring Service(id=Default JDK 1.3 ProxyFactory,
> type=ProxyFactory, provider-id=Default JDK 1.3 ProxyFactory)
> - Configuring Service(id=Default Stateless Container, type=Container,
> provider-id=Default Stateless Container)
> - Found EjbModule in classpath:
> C:\workspace\pattern-management\pattern-management-impl\src\main 
> \resourc
> es
> - Found EjbModule in classpath:
> C:\workspace\pattern-management\pattern-management-impl\src\test 
> \resourc
> es
> - Configuring app:
> C:\workspace\networkstorage-management\networkstorage-management-impl 
> \ta
> rget\classes
> - Loaded Module:
> C:\workspace\networkstorage-management\networkstorage-management-impl 
> \ta
> rget\classes
> - Configuring app:
> C:\workspace\pattern-management\pattern-management-impl\target\classes
> - FAIL ... PatternManagementDaoImpl:	Missing required persistence.xml
> for @PersistenceContext ref "em" to unit "pattern-managementPu"
> - FAIL ... TestFacadeImpl:	Missing required persistence.xml for
> @PersistenceContext ref "em" to unit "pattern-managementPu"
> - Jar not loaded.
> C:\workspace\pattern-management\pattern-management-impl\target 
> \classes.
> Module failed validation.
> AppModule(path=C:\workspace\pattern-management\pattern-management- 
> impl\t
> arget\classes)
> - Configuring app:
> C:\workspace\pattern-management\pattern-management-impl\src\main 
> \resourc
> es
> - Configuring PersistenceUnit(name=pattern-managementPu,  
> provider=null)
> - Loaded Module:
> C:\workspace\pattern-management\pattern-management-impl\src\main 
> \resourc
> es
> - Configuring app:
> C:\workspace\pattern-management\pattern-management-impl\src\test 
> \resourc
> es
> - Configuring PersistenceUnit(name=pattern-managementPu,  
> provider=null)
> - Loaded Module:
> C:\workspace\pattern-management\pattern-management-impl\src\test 
> \resourc
> es
> - Creating ProxyFactory(id=Default JDK 1.3 ProxyFactory)
> - Creating TransactionManager(id=Default Transaction Manager)
> - Creating SecurityService(id=Default Security Service)
> - Creating Resource(id=Derby Database)
> - Creating Container(id=Default Stateless Container)
> - Assembling app:
> C:\workspace\networkstorage-management\networkstorage-management-impl 
> \ta
> rget\classes
> - Jndi(name=NetworkStorageServiceImplRemote) -->
> Ejb(deployment-id=NetworkStorageServiceImpl)
> - Created Ejb(deployment-id=NetworkStorageServiceImpl,
> ejb-name=NetworkStorageServiceImpl, container=Default Stateless
> Container)
> - Deployed
> Application(path=C:\workspace\networkstorage-management 
> \networkstorage-m
> anagement-impl\target\classes)
> - Assembling app:
> C:\workspace\pattern-management\pattern-management-impl\src\main 
> \resourc
> es
> - PersistenceUnit(name=pattern-managementPu, provider=null)
> - JAVA AGENT NOT INSTALLED. The JPA Persistence Provider requested
> installation of a ClassFileTransformer which requires a JavaAgent.   
> See
> http://openejb.apache.org/3.0/javaagent.html
> - Deployed
> Application(path=C:\workspace\pattern-management\pattern-management- 
> impl
> \src\main\resources)
> - Assembling app:
> C:\workspace\pattern-management\pattern-management-impl\src\test 
> \resourc
> es
> - PersistenceUnit(name=pattern-managementPu, provider=null)
> - JAVA AGENT NOT INSTALLED. The JPA Persistence Provider requested
> installation of a ClassFileTransformer which requires a JavaAgent.   
> See
> http://openejb.apache.org/3.0/javaagent.html
> - Deployed
> Application(path=C:\workspace\pattern-management\pattern-management- 
> impl
> \src\test\resources)
> - OpenEJB ready.
> OpenEJB ready.
>


Mime
View raw message