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:
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
in jboss-service.xml we would configure with
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.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)
... 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.
take a look at how classloading works in as7
there is also a description how to configure jboss-deployment-structure.xml for ear deployment to achive what you are looking for.
We found that although the ejb @Singleton and the war @Singleton showed different hashcodes, they were actually the same objects, its just that the war's istance of a singleton was a proxy to the ejb's @Singleton object.
The hashcodes were different because we were just performing a .hashCode method call on both singleton objects. We did a hashcode call on a member variable of the objects of the @Singletons and found that they were the same.
Hope this helps.