This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JBoss/WildFly and the fly likes Class Loading Configuration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Class Loading Configuration" Watch "Class Loading Configuration" New topic
Author

Class Loading Configuration

Guy Roth
Ranch Hand

Joined: Aug 09, 2009
Posts: 74
I have got .war application that work totaly fine on TOMCAT and now I try to deploy it on JBoss 5.1.

I get errors that indicates on Class loading collisions.
I then found the following link for JBoss official documentation http://www.jboss.org/community/wiki/ClassLoadingconfiguration
That deals exactly with that issue.
according to it, as far as I unserstand, if I put the follwing code in jboss-web.xml:

the class loader regarding my new deployment will behvae in the following order:
The isolated EAR or WAR repository will load its libraries in this order:
WEB-INF/lib (for WARs)
libraries in server/default/lib
tomcat-libraries in server/default/deploy/jbossweb-tomcat50.sar (jboss-3.2.6).

Unfortunately, after doing so and running JBoss, nothing new happend.
My questions:
1. why?
2. is writing 'com.example:archive=unique-archive-name' is enough, or I have to write there something else such as specifying the exact class/jar files that I would like the class loader will isolate?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10067
    
163

Can you post the entire exception stacktrace? The jboss-web.xml configuration looks fine.


[My Blog] [JavaRanch Journal]
Guy Roth
Ranch Hand

Joined: Aug 09, 2009
Posts: 74
Current stack trace:
2009-09-29 16:56:44,515 INFO [org.jboss.ejb.deployers.EjbDeployer] (main) jndi:Sequence
2009-09-29 16:58:10,953 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (main) Error installing to Configured: name=jboss.j2ee:module="RCM.war",service=EjbModule state=Instantiated mode=Manual requiredState=Configured
java.lang.RuntimeException: Exception setting attribute WebServiceName on mbean jboss.j2ee:service=EjbModule,module="RCM.war"
at org.jboss.system.ServiceConfigurator.configure(ServiceConfigurator.java:170)
at org.jboss.system.ServiceConfigurator.configure(ServiceConfigurator.java:114)
at org.jboss.system.microcontainer.ConfigureAction.installAction(ConfigureAction.java:58)
at org.jboss.system.microcontainer.ConfigureAction.installAction(ConfigureAction.java:42)
at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:286)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
at org.jboss.system.ServiceController.doChange(ServiceController.java:688)
at org.jboss.system.ServiceController.install(ServiceController.java:274)
at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:90)
at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:46)
at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)
at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)
at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:361)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
at org.jboss.system.server.profileservice.repository.AbstractProfileService.activateProfile(AbstractProfileService.java:306)
at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:271)
at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)
at org.jboss.Main.boot(Main.java:221)
at org.jboss.Main$1.run(Main.java:556)
at java.lang.Thread.run(Thread.java:595)
Caused by: 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 BaseClassLoader@17a0b4d{vfszip:/C:/jboss-5.1.0.GA/server/default/deploy/RCM.war/}
at org.jboss.mx.interceptor.ModelMBeanAttributeInterceptor.checkAssignable(ModelMBeanAttributeInterceptor.java:229)
at org.jboss.mx.interceptor.ModelMBeanAttributeInterceptor.invoke(ModelMBeanAttributeInterceptor.java:88)
at org.jboss.mx.interceptor.PersistenceInterceptor.invoke(PersistenceInterceptor.java:76)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:90)
at org.jboss.mx.server.AbstractMBeanInvoker.setAttribute(AbstractMBeanInvoker.java:461)
at org.jboss.mx.server.MBeanServerImpl.setAttribute(MBeanServerImpl.java:617)
at org.jboss.system.ServiceConfigurator.configure(ServiceConfigurator.java:166)
... 51 more
Guy Roth
Ranch Hand

Joined: Aug 09, 2009
Posts: 74
Actually the current error I am getting regarding the class-loading issue is:
2009-09-30 10:56:22,015 INFO [STDOUT] (main) - JBoss Cache version: JBossCache 'Cascabel' 3.1.0.GA
2009-09-30 10:56:22,687 ERROR [STDERR] (main) java.lang.RuntimeException: java.lang.ClassCastException: com.sun.crypto.provider.DESCipher
...
2009-09-30 10:56:22,703 ERROR [STDERR] (main) Caused by: java.lang.ClassCastException: com.sun.crypto.provider.DESCipher
2009-09-30 10:56:22,703 ERROR [STDERR] (main) at javax.crypto.Cipher.a(DashoA12275)
2009-09-30 10:56:22,703 ERROR [STDERR] (main) at javax.crypto.Cipher.init(DashoA12275)
2009-09-30 10:56:22,703 ERROR [STDERR] (main) at javax.crypto.Cipher.init(DashoA12275)
2009-09-30 10:56:22,703 ERROR [STDERR] (main) at com.actimize.infrastructure.encryption.PasswordManager.getDecryptedString(PasswordManager.java:125)

Again, this war file works excellent on Tomcat not through JBoss.
I tried 2 things:
-. adding the 'jboss-web.xml' file to web-inf to handle the order of class loading (see my first message in this thread)
-. putting jar files from wen-inf/lib that contain class related to Cipher in jboss-5.1.0.GA\server\default\lib folder
Those actions didn't help and I keep getting this error.
Guy Roth
Ranch Hand

Joined: Aug 09, 2009
Posts: 74
When I removed some jar files from the web-inf/lib of my application and restart JBoss I stopped getting this error message (and got the next place where the application's classes collides with the server classes)

I think that it mean that despite inserting the 'jboss-web.xml' file that suppose to make sure that classes will be loaded first from my application, it is still doesn't happend. What should I add/change in the jboss-web.xml file so that the class loading of my application will start to work fine and isolated?
I BTW currently run only this own application on the JBoss sever, it has NO nested application or any other complicated factor.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10067
    
163

and got the next place where the application's classes collides with the server classes


Do you mean that you are packaging JBoss specific jar files in your application? Or are you trying to package any thirdparty libraries in the application? If it's the former then it's highly recommended not to package them in your application. If it's the latter then please provide more details including the exact exception stacktrace (i know you already posted some of it, but please post the latest one) and the jars that you have packaged in your application. You can also post the output of



While posting logs or xml content or code, please remember to wrap it in a code block by using the Code button in the message editor window. Please use the Preview button to ensure that your post is correctly formatted.
Guy Roth
Ranch Hand

Joined: Aug 09, 2009
Posts: 74
yes, I have got the follwing jboss jars as part of the app's web-inf/lib:
jboss-aop.jar
jboss-common-core.jar
jboss-common.jar
jboss-j2ee.jar
jboss-jmx.jar
jboss-logging-spi.jar
jboss-system.jar
jbosscache-core.jar

that's because we are using JBoss cache as part of the application
So should I get rid of all those jars? Do JBoss has its own implementation of JBoss cache?

The current error BTW is:
2009-09-30 11:38:14,921 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/RCM22]] (main) StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'casesAutoFormController' defined in ServletContext resource [/WEB-INF/mvc-servlet.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.actimize.cases.controller.autoforms.CasesAutoFormController]: Constructor threw exception; nested exception is java.lang.LinkageError: loader constraints violated when linking javax/xml/namespace/NamespaceContext class
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:813)
...
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10067
    
163

You should definitely be able to remove these:

jboss-aop.jar
jboss-common-core.jar
jboss-common.jar
jboss-j2ee.jar
jboss-jmx.jar
jboss-logging-spi.jar
jboss-system.jar


As for the jbosscache-core.jar, you can package it in your application since it's a thirdparty jar and not an "internal" AS jar. By the way, jbosscache-core.jar is available in the "all" server configuration. But as i said, you can probably continue to package it in your application with proper classloading configuration.
Guy Roth
Ranch Hand

Joined: Aug 09, 2009
Posts: 74
thank you for your help and effort so far.

I followed your instructions and tried to delpoy a jar file without this list of jars.
I still getting the same error message

As far as I understand, the error talks about the class 'NamespaceContext class'
I searched and found out that my web-inf/lib contains the following list of jars that contain this class:
axiom-impl-1.2.7.jar
axis2-adb-1.4.1.jar
dom4j-1.6.1.jar
list.txt
saxon9he.jar
stax-1.2.0_rc2-dev.jar
stax-api-1.0.1.jar
XmlSchema-1.4.2.jar
xom-1.1.jar

now what can I do? I can't just remove those jars just because they contain this class because they are probably needed for the business logic of my applicaiton?
Is there any basic solution that solves generally the class loading issue, or I should continue to struggle with each class seperately?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10067
    
163

Guy Roth wrote:

As far as I understand, the error talks about the class 'NamespaceContext class'
I searched and found out that my web-inf/lib contains the following list of jars that contain this class:
axiom-impl-1.2.7.jar
axis2-adb-1.4.1.jar
dom4j-1.6.1.jar
list.txt
saxon9he.jar
stax-1.2.0_rc2-dev.jar
stax-api-1.0.1.jar
XmlSchema-1.4.2.jar
xom-1.1.jar



You should be able to package all those jars in your application. Looking at your jboss-web.xml again, i think i see the issue. As per this wiki http://www.jboss.org/community/wiki/ClassLoadingconfiguration




For .war files, in your jboss-web.xml, the following template applies:





*Note: As of at least JBoss 4.2.1, the <class-loading> tag appears to no longer be supported as isolation is ignored. Instead, the following configuration appears to accomplish the same goal:





So edit your jboss-web.xml accordingly.
Guy Roth
Ranch Hand

Joined: Aug 09, 2009
Posts: 74
When I tried to use the follwing content in jboss-web.xml :


I recieved the following error I suppose it says that this is a wrong structure of this xml:
2009-09-30 13:46:00,078 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (main) Error installing to Parse: name=vfszip:/C:/jboss-5.1.0.GA/server/default/deploy/RCM22.war/ state=Not Installed mode=Manual requiredState=Parse
org.jboss.deployers.spi.DeploymentException: Error creating managed object for vfszip:/C:/jboss-5.1.0.GA/server/default/deploy/RCM22.war/
at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49)
...
Caused by: org.jboss.xb.binding.JBossXBException: Failed to parse source: loader-repository not found as a child of jboss-web in unordered_sequence: class-loading? message-destination* jacc-star-role-allow? depends* context-root? replication-config? virtual-host* servlet* passivation-config? use-session-cookies? webservice-description* security-role* security-domain? max-active-sessions? {unordered_sequence jndiEnvironmentRefsGroup}?
at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:203)
at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:168)
at org.jboss.xb.util.JBossXBHelper.parse(JBossXBHelper.java:189)
at org.jboss.xb.util.JBossXBHelper.parse(JBossXBHelper.java:166)
at org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer.parse(SchemaResolverDeployer.java:137)
at org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer.parse(SchemaResolverDeployer.java:121)
at org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer.parseAndInit(AbstractVFSParsingDeployer.java:256)
at org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer.parse(AbstractVFSParsingDeployer.java:188)
at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.createMetaData(AbstractParsingDeployerWithOutput.java:348)
... 35 more
Caused by: org.jboss.xb.binding.JBossXBRuntimeException: loader-repository not found as a child of jboss-web in unordered_sequence: class-loading? message-destination* jacc-star-role-allow? depends* context-root? replication-config? virtual-host* servlet* passivation-config? use-session-cookies? webservice-description* security-role* security-domain? max-active-sessions? {unordered_sequence jndiEnvironmentRefsGroup}?
at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.startElement(SundayContentHandler.java:383)
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10067
    
163

Change the DOCTYPE to


Also while posting logs or xml content or code, please remember to wrap it in a code block by using the Code button in the message editor window. Please use the Preview button to ensure that your post is correctly formatted.
Lal lal
Greenhorn

Joined: Jan 07, 2011
Posts: 1
Hi All
In My application there are some libraries are present in application lib and server lib but different version. But this makes problem in jboss5+ versions (jboss 4 it works fine)

What i have to do for resolving this problem. I cannot remove there libraries.I tried class loader configuration as follows

[commons-collections-3.2.jar,xerces-J_1.4.0.jar are the libraries in common]




<jboss-app>
<loader-repository>
org.apache.commons.collections:archive=commons-collections-3.2.jar
<loader-repository-config>
java2ParentDelegation=true
</loader-repository-config>
</loader-repository>
</jboss-app>
<jboss-app>
<loader-repository>
org.apache.xerces.jaxp:archive=xerces-J_1.4.0.jar
</loader-repository>
</jboss-app>


but it is giving error malformed configuration

Please help





 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Class Loading Configuration