4 Replies Latest reply on Jan 31, 2006 2:11 AM by Frank LaRosa

    Undesirable class interaction between EARs

    Frank LaRosa Newbie

      Hi,

      I'm deploying two EARs on a JBoss instance. The EARs share some classes, but each is deployed with its own copy.

      It's my understanding that a J2EE server is obligated to use a different classloader for each EAR it deployes in order to prevent undesirable interaction between applications.

      This does not seem to be what is happening with JBoss. I'm seeing data stored in static class members in one application appear in the other one.

      Is private classloading an option in JBoss that is turned off by default? If so, how do I enable it? If not, is this a bug?

      Thanks.

        • 1. Re: Undesirable class interaction between EARs
          Frank LaRosa Newbie

          I tried what it says in this Wiki page;

          http://www.jboss.org/wiki/Wiki.jsp?page=ClassLoadingConfiguration

          However, this utterly fails; my entire JBoss server explodes with a mass of stack traces when I add this stuff to my xml file.

          If someone can show me a concrete example of how to configure a project to have isolated classloading, I would appreciate it.

          Why is isolated classloading not the default behavior? It seems very counter to the spirit of an EAR file that two otherwise unrelated applications could end up interacting with one another.

          • 2. Re: Undesirable class interaction between EARs
            Scott Stark Master

            Set Isolated to true in deploy/ear-deployer.xml

             <!-- EAR deployer, remove if you are not using Web layers -->
             <mbean code="org.jboss.deployment.EARDeployer" name="jboss.j2ee:service=EARDeployer">
             <!-- Isolate all ears in their own classloader space -->
             <attribute name="Isolated">true</attribute>
             <!-- Enforce call by value to all remote interfaces -->
             <attribute name="CallByValue">true</attribute>
             </mbean>
            



            • 3. Re: Undesirable class interaction between EARs
              Frank LaRosa Newbie

              Thanks,

              I tried that, but my application will not start. The problem seems to occur as JBoss is instantiating my data source.

              00:02:55,869 INFO [ServiceConfigurator] Problem configuring service jboss.jca:service=ManagedConnectionFactory,name=ArticlesDB
              org.jboss.deployment.DeploymentException: Exception setting attribute javax.management.Attribute@1f88953 on mbean jboss.jca:service=ManagedConnectionFactory,name=ArticlesDB; - nested throwable: (javax.management.InvalidAttributeValueException: Set attribute has class class javax.management.ObjectName loaded from null
              that is not assignable to attribute class class javax.management.ObjectName loaded from org.jboss.mx.loading.UnifiedClassLoader3@9b04ac{ url=file:/P:/jboss-4.0.
              2/server/default/deploy/ezoffice.ear/ ,addedOrder=40})
              at org.jboss.system.ServiceConfigurator.setAttribute(ServiceConfigurator
              .java:573)
              at org.jboss.system.ServiceConfigurator.configure(ServiceConfigurator.ja
              va:323)
              at org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigura
              tor.java:164)
              at org.jboss.system.ServiceConfigurator.processDependency(ServiceConfigu
              rator.java:536)
              at org.jboss.system.ServiceConfigurator.configure(ServiceConfigurator.ja
              va:300)
              at org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigura
              tor.java:164)
              at org.jboss.system.ServiceConfigurator.processDependency(ServiceConfigu
              rator.java:536)
              at org.jboss.system.ServiceConfigurator.configure(ServiceConfigurator.ja
              va:300)
              at org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigura
              tor.java:164)
              at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java
              :118)
              at org.jboss.system.ServiceController.install(ServiceController.java:202
              )
              at sun.reflect.GeneratedMethodAccessor41.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
              sorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
              er.java:141)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
              java:249)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
              at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
              at $Proxy4.install(Unknown Source)
              at org.jboss.deployment.SARDeployer.create(SARDeployer.java:220)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
              java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
              sorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
              er.java:141)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
              at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractIntercept
              or.java:121)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
              at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelM
              BeanOperationInterceptor.java:127)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
              java:249)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
              at org.jboss.mx.util.JMXInvocationHandler.invoke(JMXInvocationHandler.ja
              va:273)
              at $Proxy35.create(Unknown Source)
              at org.jboss.deployment.XSLSubDeployer.create(XSLSubDeployer.java:224)
              at org.jboss.deployment.MainDeployer.create(MainDeployer.java:918)
              at org.jboss.deployment.MainDeployer.create(MainDeployer.java:910)
              at org.jboss.deployment.MainDeployer.create(MainDeployer.java:910)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:774)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738)
              at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
              sorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
              er.java:141)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
              at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractIntercept
              or.java:121)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
              at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelM
              BeanOperationInterceptor.java:127)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
              java:249)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
              at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
              at $Proxy8.deploy(Unknown Source)
              at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymen
              tScanner.java:325)
              at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentS
              canner.java:501)
              at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
              doScan(AbstractDeploymentScanner.java:204)
              at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(A
              bstractDeploymentScanner.java:277)
              at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanS
              upport.java:272)
              at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMB
              eanSupport.java:222)
              at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
              sorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
              er.java:141)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
              java:249)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
              at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceControl
              ler.java:897)
              at $Proxy0.start(Unknown Source)
              at org.jboss.system.ServiceController.start(ServiceController.java:418)
              at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
              sorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
              er.java:141)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
              java:249)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
              at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
              at $Proxy4.start(Unknown Source)
              at org.jboss.deployment.SARDeployer.start(SARDeployer.java:273)
              at org.jboss.deployment.MainDeployer.start(MainDeployer.java:964)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:775)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:722)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
              java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
              sorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
              er.java:141)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
              at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractIntercept
              or.java:121)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
              at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelM
              BeanOperationInterceptor.java:127)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
              java:249)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
              at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
              at $Proxy5.deploy(Unknown Source)
              at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:434)
              at org.jboss.system.server.ServerImpl.start(ServerImpl.java:315)
              at org.jboss.Main.boot(Main.java:195)
              at org.jboss.Main$1.run(Main.java:463)
              at java.lang.Thread.run(Thread.java:595)
              Caused by: javax.management.InvalidAttributeValueException: Set attribute has c
              lass class javax.management.ObjectName loaded from null that is not assignable t
              o attribute class class javax.management.ObjectName loaded from org.jboss.mx.loa
              ding.UnifiedClassLoader3@9b04ac{ url=file:/P:/jboss-4.0.2/server/default/deploy/
              ezoffice.ear/ ,addedOrder=40}
              at org.jboss.mx.interceptor.ModelMBeanAttributeInterceptor.checkAssignab
              le(ModelMBeanAttributeInterceptor.java:214)
              at org.jboss.mx.interceptor.ModelMBeanAttributeInterceptor.invoke(ModelM
              BeanAttributeInterceptor.java:73)
              at org.jboss.mx.interceptor.PersistenceInterceptor.invoke(PersistenceInt
              erceptor.java:61)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
              at org.jboss.mx.server.AbstractMBeanInvoker.setAttribute(AbstractMBeanIn
              voker.java:446)
              at org.jboss.mx.server.MBeanServerImpl.setAttribute(MBeanServerImpl.java
              :593)
              at org.jboss.system.ServiceConfigurator.setAttribute(ServiceConfigurator
              .java:569)
              ... 105 more

              • 4. Re: Undesirable class interaction between EARs
                Frank LaRosa Newbie

                I rearranged my deployment a bit and solved the datasource error, but now my EJBs fail to deploy with a similar problem. I suspect that I'm not deploying my classes correctly.

                My EAR consists of three common jars - two ejb jars - and a war. I declared everything in application.xml as either a "java" module, an "ejb" module or a "web" module.

                I'm operating under the assumption that the ejb and web modules ought to be able to access all the classes in the java modules - is this correct assuming an isolated deployment strategy? If not, would packaging copies of all the common jars into each EJB and WAR be the recommended approach? I had thought that it was possible to share these classes even with a strict classloader.