4 Replies Latest reply on Sep 4, 2008 10:37 PM by glad01

    Accessing Entity Beans that are included as a jar

      Environment: JBoss-4.2.2
      Seam 2.0.3
      maven2

      We have a webservice EJB3 application running in production and we want to build a tools application to support it.  We've separated the entity beans from the application as a jar thinking to include it in our seam application so we can access the same tables in the data base.  We are having problems getting seam to recognize these beans.

      Is there something needed in ejb-jar.xml to pick up the entity beans that are included as a jar to the ejb module?

      ejb-jar.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
               version="3.0">
              
         <interceptors>
           <interceptor>
             <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
           </interceptor>
         </interceptors>
        
         <assembly-descriptor>
            <interceptor-binding>
               <ejb-name>*</ejb-name>
               <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
            </interceptor-binding>
         </assembly-descriptor>
        
      </ejb-jar>


      Here is the stack trace

      java.lang.TypeNotPresentException: Type com.csg.mpg.model.CcsUser not present
              at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:98)
              at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:107)
              at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:31)
              at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:50)
              at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:120)
              at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:31)
              at sun.reflect.generics.repository.FieldRepository.getGenericType(FieldRepository.java:67)
              at java.lang.reflect.Field.getGenericType(Field.java:223)
              at java.lang.reflect.Field.toGenericString(Field.java:301)
              at org.jboss.injection.InjectionUtil.processFieldAnnotations(InjectionUtil.java:134)
              at org.jboss.injection.InjectionUtil.processAnnotations(InjectionUtil.java:174)
              at org.jboss.ejb3.EJBContainer.processMetadata(EJBContainer.java:358)
              at org.jboss.ejb3.SessionContainer.processMetadata(SessionContainer.java:140)
              at org.jboss.ejb3.Ejb3Deployment.processEJBContainerMetadata(Ejb3Deployment.java:292)
              at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:356)
              at org.jboss.ejb3.Ejb3Module.startService(Ejb3Module.java:91)
              at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
              at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
              at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              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.start(Unknown Source)
              at org.jboss.system.ServiceController.start(ServiceController.java:417)
              at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              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.start(Unknown Source)
              at org.jboss.ejb3.EJB3Deployer.start(EJB3Deployer.java:512)
              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.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.start(DeployerInterceptor.java:87)
              at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
              at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
              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.start(Unknown Source)
              at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
              at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1015)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
              at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              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 $Proxy10.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.startService(AbstractDeploymentScanner.java:336)
              at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
              at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
              at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              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.start(Unknown Source)
              at org.jboss.system.ServiceController.start(ServiceController.java:417)
              at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              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 $Proxy4.start(Unknown Source)
              at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
              at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
              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.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 $Proxy5.deploy(Unknown Source)
              at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
              at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
              at org.jboss.Main.boot(Main.java:200)
              at org.jboss.Main$1.run(Main.java:508)
              at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.ClassNotFoundException: No ClassLoaders found for: com.csg.mpg.model.CcsUser
              at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:306)
              at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:521)
              at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
              at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
              at java.lang.Class.forName0(Native Method)
              at java.lang.Class.forName(Class.java:247)
        • 1. Re: Accessing Entity Beans that are included as a jar
          gjeudy

          How, where did you package your entity jar within the EAR ? Are your entities also Seam components?

          • 2. Re: Accessing Entity Beans that are included as a jar

            We have a webapp module and a ejb module that are packaged into an ear.  The jar with the entity beans are included in the ejb module.  They are not seam components (since the are taken from the other application) just annotated with @Entity and @Table.

            • 3. Re: Accessing Entity Beans that are included as a jar
              gjeudy

              I think you are issue is more of jboss deployment issue than Seam issue. As you notice in the stacktrace it seems to occur during the JBoss deployment process.


              I assume you packaged the entities in an ejbmodule however the persistence unit will be only visible to that particular ejbmodule.


              Excerpts from EJB3 in Action:



              You can define a persistence unit in a WAR, EJB-JAR, or JAR at the EAR level. If you define a persistence unit in a module, it is only visible to that specific module. However, if you define the unit by placing a JAR file in the lib directory of the EAR, the persistence unit will automatically be visible to all modules in the EAR. For this to work, you must remember the restriction that if the same name is used by a persistence unit in the EAR level and at the module level, the persistence unit in the module level will win.

              If you don't need an EAR for your Seam application then package your entities jar directly in the WAR, otherwise you can try packaging it in the lib directory of the EAR.

              • 4. Re: Accessing Entity Beans that are included as a jar

                Thanks for pointing us in a direction.  We placed the entity jar in the lib from our ear pom and on deployment the classes are found.