You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Marcin Kwapisz <mk...@zsk.p.lodz.pl> on 2008/08/20 10:14:01 UTC
OpenEJB, Maven and Hibernate problem
Hi,
We have configured our Maven project to use different JPAs: Toplink, Hibernate and OpenJPA. We have managed to make them work properly and we have chosen Toplink as our primary JPA. After extensive application development I checked if other providers still work. And there was a surprise - Hibernate does not. When OpenEJB uses hibernate it does not registers EJBs. What influence can have JPA on EJB container?
>>>>>when OpenEJB uses OpenJPA or Toplink, ejbs are registered properly (log below) :
INFO - Jndi(name=AccountEntFacadeLocal) --> Ejb(deployment-id=AccountEntFacade)
INFO - Jndi(name=GroupFacadeLocal) --> Ejb(deployment-id=GroupFacade)
INFO - Jndi(name=PersonAccountFacadeLocal) --> Ejb(deployment-id=PersonAccountFacade)
INFO - Jndi(name=LecturerManagerLocal) --> Ejb(deployment-id=LecturerManager)
INFO - Jndi(name=StudentManagerLocal) --> Ejb(deployment-id=StudentManager)
INFO - Jndi(name=StudentEndpointRemote) --> Ejb(deployment-id=StudentEndpoint)
INFO - Created Ejb(deployment-id=AccountEntFacade, ejb-name=AccountEntFacade, container=Default Stateless Container)
INFO - Created Ejb(deployment-id=GroupFacade, ejb-name=GroupFacade, container=Default Stateless Container)
INFO - Created Ejb(deployment-id=PersonAccountFacade, ejb-name=PersonAccountFacade, container=Default Stateless Container)
INFO - Created Ejb(deployment-id=LecturerManager, ejb-name=LecturerManager, container=Default Stateless Container)
INFO - Created Ejb(deployment-id=StudentManager, ejb-name=StudentManager, container=Default Stateless Container)
INFO - Created Ejb(deployment-id=StudentEndpoint, ejb-name=StudentEndpoint, container=Default Stateful Container)
>>>>>When OpenEJB uses Hibernate:
INFO - Undeploying app: D:\JavaProg\MySamples\EJB\Sample5\JEEMavenProject2\EjbServiceCore\target\classes
ERROR - Application could not be deployed: D:\JavaProg\MySamples\EJB\Sample5\JEEMavenProject2\EjbServiceCore\target\classes
org.apache.openejb.OpenEJBException: createApplication.failed [D:\JavaProg\MySamples\EJB\Sample5\JEEMavenProject2\EjbServiceCore\target\classes]: null
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:592)
at org.apache.openejb.assembler.classic.Assembler.buildContainerSystem(Assembler.java:338)
at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:250)
at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:149)
at org.apache.openejb.OpenEJB.init(OpenEJB.java:288)
at org.apache.openejb.OpenEJB.init(OpenEJB.java:267)
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:597)
at org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
at org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:62)
at org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:51)
at org.apache.openejb.client.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:40)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:197)
at pl.zsk.sos.ejb.endpoint.StudentEndpointBeanTest.setUpClass(StudentEndpointBeanTest.java:63)
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:597)
at org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
at org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)
at org.junit.internal.runners20.B08ef-0or8-eA20nd 0Af9:te26rR:4un5 neplr..zrusknProtected(BeforeAndAfterRunner.java:33)
at org.junit.internal.runners20.B08ef-0or8-eA20nd 0Af9:te26rR:4un5 neplr..zrusknProtected(BeforeAndAfterRunner.java:33)
.sos.ejb.endpoint.StudentEndpointBeanTest setUpClass
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
fejsow
javax.naming.NameN aott FoundExorg.caeppactiheon.m: avNena.smure "PersonAccountFacadeLocal" not found.
javax.naming.NameN aott FoundExorg.caeppactiheon.m: avNena.smure "PersonAccountFacadeLocal" not found.
efire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at org.apache.openejb.core.ivm.naming.IvmContext.federate(IvmContext.java:172)
tDirectoryTestSuite.execute(AbstractDir ecatoryt orTg.eapstacShueit.oepe.nejajbva.c:1or27e.)
tDirectoryTestSuite.execute(AbstractDir ecatoryt orTg.eapstacShueit.oepe.nejajbva.c:1or27e.)
iv
m.naming.IvmContext.lookup(IvmContext.java:129)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at pl.zsk.sos.ejb.endpoint.StudentEndpointBeanTest.setUpClass(StudentEndpointBeanTest.java:64)
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:597)
at org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
at org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
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:597)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)
iv
m.n
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
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:597)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)
Caused by: java.lang.AssertionError
at org.hibernate.cfg.AnnotationBinder.getElementsToProcess(AnnotationBinder.java:770)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:622)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:452)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:268)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1233)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:869)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:407)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
at org.apache.openejb.assembler.classic.PersistenceBuilder.createEntityManagerFactory(PersistenceBuilder.java:183)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:454)
... 36 more
2008-08-20 09:26:45 pl.zsk.sos.ejb.endpoint.StudentEndpointBeanTest$1 call
INFO: TEST W KONTEKSCIE TRANZAKCJI
testCreateStudent[prepareCreateStudent]
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.391 sec <<< FAILURE!
Running pl.zsk.sos.ejb.manager.StudentManagerBeanTest
2008-08-20 09:26:45 pl.zsk.sos.ejb.manager.StudentManagerBeanTest setUpClass
INFO: Uruchomienie contextu do pobrania interfejsow
2008-08-20 09:26:45 pl.zsk.sos.ejb.manager.StudentManagerBeanTest setUpClass
INFO: Blad wyszukania EJB i pobrania interfejsow
javax.naming.NameNotFoundException: Name "PersonAccountFacadeLocal" not found.
at org.apache.openejb.core.ivm.naming.IvmContext.federate(IvmContext.java:172)
at org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:129)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at pl.zsk.sos.ejb.manager.StudentManagerBeanTest.setUpClass(StudentManagerBeanTest.java:67)
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:597)
at org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
at org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
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:597)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)
>>>>> Maven2 pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>JEEMavenProject</artifactId>
<groupId>zsk.samples</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>zsk.samples</groupId>
<artifactId>EjbServiceCore</artifactId>
<packaging>ejb</packaging>
<version>2.0</version>
<name>EjbServiceCore</name>
<url>http://maven.apache.org</url>
<profiles>
<profile>
<id>TestEJB_OpenJPA</id>
<activation>
<property>
<name>env</name>
<value>testOpenJPA</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
<version>1.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/test/resources/OpenJPA</directory>
</resource>
</resources>
</build>
</profile>
<profile>
<id>TestEJB_Hibernate</id>
<activation>
<property>
<name>env</name>
<value>testhibernate</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.2.5.ga</version>
<exclusions>
<exclusion>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
</exclusion>
<exclusion>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.1_3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>2.2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.2.1.ga</version>
<exclusions>
<exclusion>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/test/resources/Hibernate</directory>
</resource>
</resources>
</build>
</profile>
<profile>
<id>TestEJB_Toplink</id>
<activation>
<property>
<name>env</name>
<value>testtoplink</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>toplink.essentials</groupId>
<artifactId>toplink-essentials-agent</artifactId>
<version>2.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>toplink.essentials</groupId>
<artifactId>toplink-essentials</artifactId>
<version>2.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>zsk.samples</groupId>
<artifactId>ToplinkExternalContainer</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/test/resources/Toplink</directory>
</resource>
</resources>
</build>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-core</artifactId>
<version>3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>javaee-api</artifactId>
<version>5.0-1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.2.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.2.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>zsk.samples</groupId>
<artifactId>DataObjects</artifactId>
<version>2.3</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>process-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>zsk.samples</groupId>
<artifactId>DataObjects</artifactId>
<version>2.3</version>
<type>jar</type>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.2</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
<generateClient>true</generateClient>
<clientIncludes> <!--Dołącz do klienta tylko "zdalne interfejsy"-->
<clientInclude>zsk/samples/EjbService/*Remote.class</clientInclude>
</clientIncludes>
<ejbVersion>3.0</ejbVersion>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<netbeans.hint.deploy.server>J2EE</netbeans.hint.deploy.server>
</properties>
</project>
Thanks in advance
Regards
--
Marcin Kwapisz
Division of Computer Networks
Technical Univeristy of Lodz, Poland
RE: OpenEJB, Maven and Hibernate problem
Posted by Marcin Kwapisz <mk...@zsk.p.lodz.pl>.
> Also, we have an OpenEJB, Maven, Hibernate example here that may
> help.
> http://svn.apache.org/repos/asf/openejb/trunk/openejb3/examples/jpa-
> hibernate/
[Marcin Kwapisz]
Hi,
After a little investigation I am almost sure that the problem is with hibernate, not within OpenEJB. Hibernate cannot find (it should create) table PERSONENT (from annotation @SecondaryTable
(name="PERSONENT",pkJoinColumns={@PrimaryKeyJoinColumn(name= "ID")}) that why OpenEJB does not register my EJBs and I get lookup errors then. The only confusing thing was:
org.apache.openejb.OpenEJBException: createApplication.failed [D:\JavaProg\MySamples\EJB\Sample5\JEEMavenProject2\EjbServiceCore\target\classes]: null
but when I have updated Hibernate to version 3.2.6 and hibernate-entitymanager to 3.3.2, I get:
org.apache.openejb.OpenEJBException: createApplication.failed [D:\JavaProg\MySamples\EJB\OLD\JEEMavenProject2\EjbServiceCore\target\classes]: org.hibernate.AssertionFailure: Table PERSONENT not found.
I think this is the right exception.
Regards
--
Marcin Kwapisz
Division of Computer Networks
Technical Univeristy of Lodz, Poland
Re: OpenEJB, Maven and Hibernate problem
Posted by David Blevins <da...@visi.com>.
On Aug 20, 2008, at 9:15 AM, Marcin Kwapisz wrote:
> Hi,
>
> I tried to reproduce the problem with Hibernate and OpenEJB.
>
> The previous message in the log file was:
>> org.apache.openejb.OpenEJBException: createApplication.failed
>> [D:\JavaProg\MySamples\EJB\Sample5\JEEMavenProject2\EjbServiceCore
>> \targ
>> et\classes]: null
>
> Now I get:
> org.apache.openejb.OpenEJBException: createApplication.failed [D:
> \JavaProg\MySamples\EJB\OLD\JEEMavenProject2\EjbServiceCore\target
> \classes]: org.hibernate.AssertionFailure: Table PERSONENT not
> found: Table PERSONENT not found
>
> In that case the problem is with annotation processing and database
> schema creation:
> @Entity
> @Table(name="ACCOUTENT")
> @Inheritance(strategy=InheritanceType.JOINED)
> @DiscriminatorColumn(name="typ",
> discriminatorType=DiscriminatorType.STRING)
> @SecondaryTable
> (name="PERSONENT",pkJoinColumns={@PrimaryKeyJoinColumn(name= "ID")})
> public class PersonAccountEnt implements Serializable
>
> I found that inheritance JOINED and SecondaryTable does not work
> with Hibernate. So the problem is not with OpenEJB (I think).
>
> I don’t know why I get "null" in original project. Can it be the
> same problem or a different one?
Not sure, but the lack of tables seems to indicate that the magic
hibernate "create tables" property isn't set. If you can post your
hibernate persistence.xml and the OpenEJB log output that'd be great.
Also, we have an OpenEJB, Maven, Hibernate example here that may
help. http://svn.apache.org/repos/asf/openejb/trunk/openejb3/examples/jpa-hibernate/
-David
RE: OpenEJB, Maven and Hibernate problem
Posted by Marcin Kwapisz <mk...@zsk.p.lodz.pl>.
Hi,
I tried to reproduce the problem with Hibernate and OpenEJB.
The previous message in the log file was:
> org.apache.openejb.OpenEJBException: createApplication.failed
> [D:\JavaProg\MySamples\EJB\Sample5\JEEMavenProject2\EjbServiceCore\targ
> et\classes]: null
Now I get:
org.apache.openejb.OpenEJBException: createApplication.failed [D:\JavaProg\MySamples\EJB\OLD\JEEMavenProject2\EjbServiceCore\target\classes]: org.hibernate.AssertionFailure: Table PERSONENT not found: Table PERSONENT not found
In that case the problem is with annotation processing and database schema creation:
@Entity
@Table(name="ACCOUTENT")
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(name="typ", discriminatorType=DiscriminatorType.STRING)
@SecondaryTable(name="PERSONENT",pkJoinColumns={@PrimaryKeyJoinColumn(name= "ID")})
public class PersonAccountEnt implements Serializable
I found that inheritance JOINED and SecondaryTable does not work with Hibernate. So the problem is not with OpenEJB (I think).
I don’t know why I get "null" in original project. Can it be the same problem or a different one?
Regards
--
Marcin Kwapisz
Division of Computer Networks
Technical Univeristy of Lodz, Poland