0 Replies Latest reply on Dec 6, 2006 10:54 AM by Michiel Trimpe

    Hot to make JBoss 5  EJB Remoting & Embedded EJB3 go togethe

    Michiel Trimpe Newbie

      I have the following scenario, that must arise more often in the future:

      A Swing Client App that; must be able to connect to an EJB3 service on a remote JBoss5; must be able to run that same EJB3 service locally via Embedded EJB3 container.

      I currently have the following maven dependencies:

       <!-- JBoss Microcontainer dependencies -->
       <dependency>
       <groupId>microcontainer.jboss.ejb3</groupId>
       <artifactId>hibernate-all</artifactId>
       </dependency>
       <dependency>
       <groupId>microcontainer.jboss.ejb3</groupId>
       <artifactId>jboss-ejb3-all</artifactId>
       </dependency>
       <dependency>
       <groupId>microcontainer.jboss.ejb3</groupId>
       <artifactId>thirdparty-all</artifactId>
       </dependency>
      
       <!-- JBoss Client dependencies - REFERENCE ${jboss.home}\client\...... -->
       <dependency>
       <groupId>jboss</groupId>
       <artifactId>all-client</artifactId>
       </dependency>
       <dependency>
       <groupId>jboss</groupId>
       <artifactId>ejb3-client</artifactId>
       </dependency>
       <dependency>
       <groupId>jboss</groupId>
       <artifactId>aop-jdk50-client</artifactId>
       </dependency>
       <dependency>
       <groupId>jboss</groupId>
       <artifactId>aspect-jdk50-client</artifactId>
       </dependency>
      
       <!-- JBoss EJB3 dependencies -->
       <dependency>
       <groupId>jboss</groupId>
       <artifactId>ejb3x</artifactId>
       </dependency>
       <dependency>
       <groupId>ejb3</groupId>
       <artifactId>persistence</artifactId>
       </dependency>
      


      However running the testcases that startup the embedded EJB3 container I now get:
      ERROR 06-12 16:48:25,234 (KernelErrors.java:validate:78) -Failed deployment: persistence.units:jar=classes.jar,unitName=Ga4EjbPrototype
      
      java.lang.NoClassDefFoundError: org/hibernate/engine/query/sql/NativeSQLQueryReturn
       at org.hibernate.cfg.annotations.QueryBinder.bindSqlResultsetMapping(QueryBinder.java:295)
       at org.hibernate.cfg.AnnotationBinder.bindQueries(AnnotationBinder.java:239)
       at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:404)
       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:1034)
      java.lang.RuntimeException: Problems scanning classpath
       at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.scanClasspath(EJB3StandaloneBootstrap.java:281)
       at org.growthanalyser.ga4.connection.LocalConnectionFactory.startupEJB3Container(LocalConnectionFactory.java:56)
       at org.growthanalyser.ga4.connection.LocalConnectionFactory.initialize(LocalConnectionFactory.java:25)
       at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1015)
       at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
       at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:751)
       at org.hibernate.ejb.Ejb3Configuration.createContainerEntityManagerFactory(Ejb3Configuration.java:350)
       at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:119)
       at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:264)
       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.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:55)
       at org.growthanalyser.ga4.connection.LocalConnectionFactoryTest.testConnectionFactory(LocalConnectionFactoryTest.java:9)
       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.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:107)
       at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)
       at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:75)
       at org.jboss.kernel.plugins.dependency.LifecycleAction.installAction(LifecycleAction.java:115)
       at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.install(KernelControllerContextAction.java:100)
       at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
       at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:226)
       at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:709)
       at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:429)
       at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:538)
       at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:472)
       at junit.framework.TestCase.runTest(TestCase.java:154)
       at junit.framework.TestCase.runBare(TestCase.java:127)
       at junit.framework.TestResult$1.protect(TestResult.java:106)
       at junit.framework.TestResult.runProtected(TestResult.java:124)
       at junit.framework.TestResult.run(TestResult.java:109)
       at junit.framework.TestCase.run(TestCase.java:118)
       at junit.framework.TestSuite.runTest(TestSuite.java:208)
       at junit.framework.TestSuite.run(TestSuite.java:203)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:274)
       at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:177)
       at org.jboss.kernel.plugins.dependency.AbstractKernelController.install(AbstractKernelController.java:79)
       at org.jboss.kernel.plugins.dependency.AbstractKernelController.install(AbstractKernelController.java:73)
       at org.jboss.ejb3.MCKernelAbstraction.install(MCKernelAbstraction.java:131)
       at org.jboss.ejb3.Ejb3Deployment.startPersistenceUnits(Ejb3Deployment.java:467)
       at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:317)
       at org.jboss.ejb3.embedded.EJB3StandaloneDeployer.start(EJB3StandaloneDeployer.java:478)
       at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.scanClasspath(EJB3StandaloneBootstrap.java:274)
       at org.growthanalyser.ga4.connection.LocalConnectionFactory.startupEJB3Container(LocalConnectionFactory.java:56)
      
       at org.growthanalyser.ga4.connection.LocalConnectionFactory.initialize(LocalConnectionFactory.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:210)
       at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:135
      )
       at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:122)
       at org.apache.maven.surefire.Surefire.run(Surefire.java:129)
       at org.growthanalyser.ga4.connection.LocalConnectionFactoryTest.testConnectionFactory(LocalConnectionFactoryTest
      .java:9)
       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 junit.framework.TestCase.runTest(TestCase.java:154)
       at junit.framework.TestCase.runBare(TestCase.java:127)
       at junit.framework.TestResult$1.protect(TestResult.java:106)
       at junit.framework.TestResult.runProtected(TestResult.java:124)
       at junit.framework.TestResult.run(TestResult.java:109)
       at junit.framework.TestCase.run(TestCase.java:118)
       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.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:269)
       at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:788)
       at junit.framework.TestSuite.runTest(TestSuite.java:208)
       at junit.framework.TestSuite.run(TestSuite.java:203)
       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.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:210)
       at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:135
      )
       at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:122)
       at org.apache.maven.surefire.Surefire.run(Surefire.java:129)
       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.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:269)
       at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:788)
      


      This error stops occurring when I remove the jboss-clientall dependency

      This is probably because the JBoss 5 client has a newer version of hibernate that conflicts with that of the Embedded EJB3 container, but how do I fix it?