7 Replies Latest reply on Aug 28, 2008 8:56 PM by zhengxi qu

    how to config the classloader

    zhengxi qu Newbie

      hi anyone can tell how to config these in jboss, thanks a log.

      i have a ear file, and the ear file includes two war files, A.war and B.war.
      A.war includes some jar files in the web-inf/lib directory.

      App.ear
      |--------A.war
      | |-----web-inf/lib----------a.jar, b.jar, c.jar....
      |--------B.war

      my target is:
      1, A.war share all the jar file with B.war
      2, we need to isolate the classes and jar of App.ear from other deployments and jboss's jar files.

        • 1. Re: how to config the classloader
          zhengxi qu Newbie

          jboss-app.xml
          <jboss-app>
          <loader-repository>
          com.example:archive=App.ear
          <loader-repository-config>
          java2ParentDelegation=false
          </loader-repository-config>
          </loader-repository>
          </jboss-app>

          I add this config file to App.ear. it can isolate the jars from jboss's jars.
          but B.war cannot use A.war's jars.

          • 2. Re: how to config the classloader
            Peter Johnson Master

            Classes in war files are isolated according to the spec. There is no way to get classes in a.war to use classes in b.war. If you want to share classes between the two war files, place them into a jar file within the ear file.

            • 3. Re: how to config the classloader
              zhengxi qu Newbie

              thanks PerterJ

              I tried to put all the jar files under the ear.
              then jboss will throw ClassCastException.

              • 4. Re: how to config the classloader
                Peter Johnson Master

                Did you need more help on this? I am asking because you did not provide any information on the exception.

                If you do need more help, please provide:

                * The full stack trace for the class cast exception
                * The source code that caused the exception, highlighting the line in error

                • 5. Re: how to config the classloader
                  zhengxi qu Newbie

                  yes, i need your help on this issue. and thank you very much.

                  the structure of my eaf file

                  App.ear
                  |--------A.war
                  |---------META-INF\MANIFEST.MF
                  |--------B.war
                  |--------a.jar, b.jar, c.jar....
                  |--------META-INF\jboss-app.xml

                  the content of MANIFEST.MF in A.war is:
                  Manifest-Version: 1.0
                  Ant-Version: Apache Ant 1.7.0
                  Created-By: 1.5.0_11-b03 (Sun Microsystems Inc.)
                  Plugin-Name: App
                  Plugin-Version: 2.0
                  Plugin-Description:
                  Plugin-DisplayName: Administrator UI
                  Plugin-ContextRoot: app
                  PackageNamespace: com.app
                  class-Path: ./a.jar
                  ./b.jar
                  ./c.jar


                  the content of jboss-app.xml in App.ear\META-INF
                  <jboss-app>
                  <loader-repository>
                  com.example:archive=App.ear
                  <loader-repository-config>
                  java2ParentDelegation=false
                  </loader-repository-config>
                  </loader-repository>
                  </jboss-app>




                  when i start the jboss, it will throw this exception:

                  08:23:15,484 INFO [TomcatDeployer] deploy, ctxPath=/app, warUrl=.../tmp/deploy/tmp12202app.ear-contents/app-exp.war/
                  08:23:15,796 INFO [[/app]] Marking servlet JBossAdapterInitializeServlet as unavailable
                  08:23:15,796 ERROR [[/app]] Servlet /app threw load() exception
                  java.lang.ClassCastException: com.app.administration.server.startup.JBossAdapterInitializeServlet
                  at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1104)
                  at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
                  at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4071)
                  at org.apache.catalina.core.StandardContext.start(StandardContext.java:4375)
                  at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:790)
                  at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:770)
                  at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
                  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.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
                  at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
                  at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                  at org.apache.catalina.core.StandardContext.init(StandardContext.java:5312)
                  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.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
                  at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
                  at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                  at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:301)
                  at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:104)
                  at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375)
                  at org.jboss.web.WebModule.startModule(WebModule.java:83)
                  at org.jboss.web.WebModule.startService(WebModule.java:61)
                  at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
                  at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
                  at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  at java.lang.reflect.Method.invoke(Method.java:585)
                  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.GeneratedMethodAccessor9.invoke(Unknown Source)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  at java.lang.reflect.Method.invoke(Method.java:585)
                  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 $Proxy44.start(Unknown Source)
                  at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:466)
                  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.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 $Proxy45.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.GeneratedMethodAccessor20.invoke(Unknown Source)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  at java.lang.reflect.Method.invoke(Method.java:585)
                  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.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.GeneratedMethodAccessor3.invoke(Unknown Source)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  at java.lang.reflect.Method.invoke(Method.java:585)
                  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.GeneratedMethodAccessor9.invoke(Unknown Source)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  at java.lang.reflect.Method.invoke(Method.java:585)
                  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:585)
                  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:595)

                  • 6. Re: how to config the classloader
                    shiva Newbie

                    zhengxi,
                    I am also running into same issue. did you find the solution!!
                    shiva

                    • 7. Re: how to config the classloader
                      zhengxi qu Newbie

                      pls check your jar files in your application, and delete the jars that jboss includes. for example, jsp_api.jar, tomcat related jars.

                      you can try a simple test firstly, make sure your configuration are correct.