2 Replies Latest reply on Dec 28, 2007 6:58 PM by wiggy

    help required please : problem with project packaging and pe

    wiggy

      wonder if some one can help. Think is simple but cant see the wood from the trees. Any help greatefully received.

      I'm in callisto eclipse /jboss 4.2.2 and I have a test app that i built as an ejb project (all in one) - and built all my entities, stateless session beans, generic EAO (variant of DAO pattern - from "ejb3 in action" book and a persistence unit.

      I deploy to server and all is well and i can find the services and call them from external client app. So far so good.

      I then come to refactor my project into manageable project chunks. I created two utility projects - one for the entities (no persistence unit defined here - just the marked up entity classes), then another utility project with the generic EAO code base.

      I then create an EJB project to house the real EAO (extend the generic) for each entity class in the domain model utility project.

      I set the java build path to include the two utility projects, and I also set the "project references" to include these also. (i cant set the j2ee depencies for the EJB project - it says "selected model not associated with an enterprise application module").

      my top level EJB project has the persistence facet set and my persistence xml is defined here.


      this all compiles without warning. so project dependency relationships set up as follows

      eao ejb proj (inc persistence xml defn)
      | |
      v v
      entity util proj generic eao util project

      However : if i try to publish this refactored project eao EJB project to the server I then get an error on the server


      01:10:43,770 ERROR [URLDeploymentScanner] Incomplete Deployment listing:

      --- MBeans waiting for other MBeans ---
      ObjectName: jboss.j2ee:service=EJB3,module=NeilsAppEAOEJBProject.jar
      State: FAILED
      Reason: java.lang.NoClassDefFoundError: eao/EAO

      --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
      ObjectName: jboss.j2ee:service=EJB3,module=NeilsAppEAOEJBProject.jar
      State: FAILED
      Reason: java.lang.NoClassDefFoundError: eao/EAO


      what i think this says is that the class loader for the EJB project cant see the utility projects. Why is that ?

      if I refactor like this do I have to package all the projects into an EAR? to get them to work ?

      when you run multiple projects like this - where should the persistence unit be defined? - I have defined it with the EAO instance definitions (concrete classes) that prsist my entities - rather than in the utility projects - is that right ? or does the persistence unit definition live with the entities in the util project (this doesnt seem right).

      so can some one help me understand why what works in on big EJB project doesnt work when i refactor into multiple projects.

      This is going to be easy (i think) and i shall feel stupid later - but its driving me nuts at present

      I am only using eclipse as the build tool at present - i have no ant/maven framework setup (requires more time to read about these) and i'd like to get the basics running from eclipse if i could first.



        • 1. Re: help required please : problem with project packaging  -
          wiggy

          tried creating an EAR project and including the EJB project and the two util projects and deployed that

          get essentially the same problem - somehow the EJB project cant see the util project its dependent upon (its still on the build path and the pakaage referenences lists though from the EJB project)

          off to bed - if any one can help me past this problemo i'd be ever so greatful. I can't carry on building all the logic in one project it'll get ridiculous.


          01:27:17,589 WARN [ServiceController] Problem creating service jboss.j2ee:service=EJB3,module=NeilsAppEAOEJBProject.jar
          java.lang.NoClassDefFoundError: eao/EAO
          at java.lang.ClassLoader.defineClass1(Native Method)
          at java.lang.ClassLoader.defineClass(Unknown Source)
          at java.security.SecureClassLoader.defineClass(Unknown Source)
          at java.net.URLClassLoader.defineClass(Unknown Source)
          at java.net.URLClassLoader.access$000(Unknown Source)
          at java.net.URLClassLoader$1.run(Unknown Source)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(Unknown Source)
          at org.jboss.mx.loading.RepositoryClassLoader.findClassLocally(RepositoryClassLoader.java:682)
          at org.jboss.mx.loading.RepositoryClassLoader.findClass(RepositoryClassLoader.java:662)
          at java.lang.ClassLoader.loadClass(Unknown Source)
          at org.jboss.mx.loading.RepositoryClassLoader.loadClassLocally(RepositoryClassLoader.java:200)
          at org.jboss.mx.loading.ClassLoadingTask$ThreadTask.run(ClassLoadingTask.java:131)
          at org.jboss.mx.loading.LoadMgr3.nextTask(LoadMgr3.java:399)
          at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:527)
          at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
          at java.lang.ClassLoader.loadClass(Unknown Source)
          at java.lang.ClassLoader.loadClassInternal(Unknown Source)
          at java.lang.ClassLoader.defineClass1(Native Method)
          at java.lang.ClassLoader.defineClass(Unknown Source)
          at java.security.SecureClassLoader.defineClass(Unknown Source)
          at java.net.URLClassLoader.defineClass(Unknown Source)
          at java.net.URLClassLoader.access$000(Unknown Source)
          at java.net.URLClassLoader$1.run(Unknown Source)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(Unknown Source)
          at org.jboss.mx.loading.RepositoryClassLoader.findClassLocally(RepositoryClassLoader.java:682)
          at org.jboss.mx.loading.RepositoryClassLoader.findClass(RepositoryClassLoader.java:662)
          at java.lang.ClassLoader.loadClass(Unknown Source)
          at org.jboss.mx.loading.RepositoryClassLoader.loadClassLocally(RepositoryClassLoader.java:200)
          at org.jboss.mx.loading.ClassLoadingTask$ThreadTask.run(ClassLoadingTask.java:131)
          at org.jboss.mx.loading.LoadMgr3.nextTask(LoadMgr3.java:399)
          at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:527)
          at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
          at java.lang.ClassLoader.loadClass(Unknown Source)
          at org.jboss.ejb3.Ejb3AnnotationHandler.populateBaseInfo(Ejb3AnnotationHandler.java:293)
          at org.jboss.ejb3.Ejb3AnnotationHandler.getContainers(Ejb3AnnotationHandler.java:138)
          at org.jboss.ejb3.Ejb3Deployment.deployElement(Ejb3Deployment.java:486)
          at org.jboss.ejb3.Ejb3Deployment.deployElement(Ejb3Deployment.java:442)
          at org.jboss.ejb3.Ejb3Deployment.deployUrl(Ejb3Deployment.java:423)
          at org.jboss.ejb3.Ejb3Deployment.deploy(Ejb3Deployment.java:384)
          at org.jboss.ejb3.Ejb3Deployment.create(Ejb3Deployment.java:327)
          at org.jboss.ejb3.Ejb3Module.createService(Ejb3Module.java:77)
          at org.jboss.system.ServiceMBeanSupport.jbossInternalCreate(ServiceMBeanSupport.java:260)
          at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:243)
          at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
          at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
          at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
          at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
          at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
          at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
          at $Proxy0.create(Unknown Source)
          at org.jboss.system.ServiceController.create(ServiceController.java:330)
          at org.jboss.system.ServiceController.create(ServiceController.java:273)
          at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
          at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
          at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
          at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
          at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
          at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
          at $Proxy33.create(Unknown Source)
          at org.jboss.ejb3.EJB3Deployer.create(EJB3Deployer.java:492)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
          at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
          at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
          at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
          at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
          at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
          at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
          at org.jboss.wsf.container.jboss42.DeployerInterceptor.create(DeployerInterceptor.java:76)
          at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.create(SubDeployerInterceptorSupport.java:180)
          at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:91)
          at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
          at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
          at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
          at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
          at $Proxy34.create(Unknown Source)
          at org.jboss.deployment.MainDeployer.create(MainDeployer.java:969)
          at org.jboss.deployment.MainDeployer.create(MainDeployer.java:959)
          at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:818)
          at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
          at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
          at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
          at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
          at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
          at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
          at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
          at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
          at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
          at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
          at $Proxy9.deploy(Unknown Source)
          at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
          at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
          at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
          at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
          at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
          01:27:17,609 INFO [EJB3Deployer] Deployed: file:/E:/jboss/jboss-4.2.2.GA/server/default/deploy/NeilsAppEar.ear/NeilsAppEAOEJBProject.jar/
          01:27:17,769 INFO [EARDeployer] Started J2EE application: file:/E:/jboss/jboss-4.2.2.GA/server/default/deploy/NeilsAppEar.ear/


          • 2. Re: well got somewhere???!!!
            wiggy

            spent a hard day on this and seem to have discovered some things.

            1. I need to build an ear project, and set the j2ee dependencies to include the projects i want in the ear. This is the only way i can see to set the J2EE dependencies on the individual projects themselves.

            2. create the various projects and set their respective dependencies.

            3. I tried to create the domainModel entity project as a utility jar (they are after all POJOs) - however, the persistence unit if using entity.class wont recognise the class with an @entity tag unless its in the same module -

            what this means is that that i had to define the persistence unit in the same project as the entity classes themselve.

            however whilst this compiles - I cant get the Ear to load in the server it says it cant start my persistence unit.

            4. Instead i had to rebuild the domainModel as an ejb file (not a utility) with its persistence unit - and include this into the EAR instead.

            This seemed to make it happy and it loads the EAR and my code seems to work.

            However I now have ejb projects not util projects for my pojo entities. This does feel kinda counter intuitive.

            5. I re read chapter 11 in "EJB in action" where it talks about peristence unit scoping - but i dont quite get it. It implies i can create an persistence unit in a JAR - but i have to put the jar in the /lib directory in the EAR.

            not sure how do do this - as my eclipse EAR project has an EARContent and META-INF dir but no lib - and how would put any jar file (with persistence.xml) into that /lib dir?

            do i have to create it by hand ? tried and tried to link to util project and got all messed up.

            All in all a hard day - Is it just me or does any else find the dearth of material on how to use eclipse for large persistence projects something frustracting?

            how any one focuses on code writing without getting stuck in build structure problems to distract one is a bit of a mystery.

            Would still appreciate anyone with a little more knowledeg than me explaining whether you can use utility projects for POJO entities and if so how.