3 Replies Latest reply: May 10, 2012 12:14 PM by David Pugh RSS

Jboss 7 classloaders for a war within an ear

David Pugh Newbie

Hello, my company is updating from Jboss 4.2.3 to Jboss 7.

We have an ear that contains a war and an ejb jar as such:

 

AreaServer-ear

     contains:

                    1)ejb-jar

                    2)web-war

Some of the classes in the ejb jar are singletons. We need to only have one instance of them.

The only problem is that some of the jsp pages in the war need to access those singletons in the ejb-jar.

I printed the hashcode of one of the singletons that has an @startup annotation in the server logs and also printed the hashcode in one of the war's jsp pages.

They have different hashcodes, meaning that the ear spins up the singleton and later on the jsp page spins its own singleton object up.

The problem is that they are 2 seperate objects.

 

Before with jboss 4.2.3 we would create a jboss-service.xml page and put it in the jboss folder

deploy/jboss-web.deployer/META-INF.

in jboss-service.xml we would configure with

<attribute name="UseJBossWebLoader">true</attribute>

which would have the war use Jboss's class loader instead of its own.

This would allow there to be only one Singleton instantiated for use, which is what we need.

I read that deploy/jboss-web.deployer/META-INF is not where this goes anymore.

Im not really sure that its supported anymore.

I did find some people talking about MBeans in jboss-service.xml  (https://community.jboss.org/message/723796)

They said to put jboss-service.xml in the war's META-INF folder.

They weren't specifically talking about configuring the web app to use the jboss web loader though.

I tried to use the same jboss-service.xml and place that within my web-war's META-INF folder.

When I started up Jboss 7.1.1 I got this error

 

16:35:55,558 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.deployment.subunit."AreaServer-ear-0.9.9-SNAPSHOT.ear"."AreaServer-http-0.9.9-SNAPSHOT.war".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."AreaServer-ear-0.9.9-SNAPSHOT.ear"."AreaServer-http-0.9.9-SNAPSHOT.war".PARSE: Failed to process phase PARSE of subdeployment "AreaServer-http-0.9.9-SNAPSHOT.war" of deployment "AreaServer-ear-0.9.9-SNAPSHOT.ear"

        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_30]

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_30]

        at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_30]

Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS017224: Failed to parse service xml ["/content/AreaServer-ear-0.9.9-SNAPSHOT.ear/AreaServer-http-0.9.9-SNAPSHOT.war/META-INF/jboss-service.xml"]

        at org.jboss.as.service.ServiceDeploymentParsingProcessor.deploy(ServiceDeploymentParsingProcessor.java:95)

        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

        ... 5 more

Caused by: java.lang.IllegalStateException: Not a textual event (START_ELEMENT)

        at com.ctc.wstx.sr.BasicStreamReader.throwNotTextual(BasicStreamReader.java:5444)

        at com.ctc.wstx.sr.BasicStreamReader.getText(BasicStreamReader.java:833)

        at org.jboss.staxmapper.XMLExtendedStreamReaderImpl.getText(XMLExtendedStreamReaderImpl.java:275)

        at org.jboss.as.service.descriptor.JBossServiceXmlDescriptorParser.unexpectedContent(JBossServiceXmlDescriptorParser.java:622)

        at org.jboss.as.service.descriptor.JBossServiceXmlDescriptorParser.parseMBean(JBossServiceXmlDescriptorParser.java:212)

        at org.jboss.as.service.descriptor.JBossServiceXmlDescriptorParser.readElement(JBossServiceXmlDescriptorParser.java:183)

        at org.jboss.as.service.descriptor.JBossServiceXmlDescriptorParser.readElement(JBossServiceXmlDescriptorParser.java:46)

        at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110)

        at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69)

        at org.jboss.as.service.ServiceDeploymentParsingProcessor.deploy(ServiceDeploymentParsingProcessor.java:88)

        ... 6 more

 

Can someone tell me if this way of specifying the war to use Jboss class loader in the war's META-INF is correct.

If so, does anyone know why I would be getting this error?

 

Please help, oh please do.

 

Sincerely,

 

etc, etc