[JBoss/Spring Integration] - ContextSingletonBeanFactoryLocator and classloaders
by lucdew
Hi,
I have problems using SingletonBeanFactoryLocator and classloader issues.
Actually,
My application is packaged like this:
myapp.ear
--> spring.jar
--> mysar.sar
--> myjar.jar
My sar performs initialization tasks and one of them is to initialize spring contexts with the following code:
anonymous wrote : BeanFactoryLocator sbf = ContextSingletonBeanFactoryLocator.getInstance();
| BeanFactoryReference bf = sbf.useBeanFactory("common.context");
The problems is that Spring the common.context bean is not found and i figured out why it's because Spring can not find the beanRefContext.xml file which holds the bean definition because it uses a wrong classloader
I declared spring.jar and myjar.jar in application.xml as Java modules (ex: spring.jar)
In mysar.sar i displayed information of the current classloader and here's what i get:
11:58:54,765 INFO [DeployerListenerService] Current classloader = org.jboss.mx.
| loading.UnifiedClassLoader3@10d16b{ url=file:/D:/applications/jboss-4.0.
| 5.GA/server/default/deploy/myapp.ear/ ,addedOrder=40}
and if i execute the following code:
Enumeration<URL> resourcesEnum = this.getClass().getClassLoader().getResources("beanRefContext.xml");
the classloader find the resource beanRefContext.xml which is packaged in myjar.jar. It works as expected.
The problem is Spring library executes almost the same code in the PathMatchingResourcePatternResolver class it executes:
Code:
Enumeration resourceUrls = getClassLoader().getResources(path);
where path is "beanRefContext.xml"
and the getClassLoader() returned in debug mode has a path attribute of:
| /D:/applications/jboss-4.0.5.GA/server/default/conf/
and therefore is unable to see the beanRefContext.xml file packaged in my ear.
Note that i configured in my ear a loader repository :
Code:
<loader-repository>
| test.com:loader=myapp
| </loader-repository>
|
I don't understand why the classloader retrieved in Spring is the one associated with the universalrepository3 ? and not the HeirarchicalLoaderRepository3 of my ear???
I checked the CLASSPATH and my Jboss installation to see if there were Spring classes elsewhere and no the only Spring classes are in the spring.jar of myapp.ear.
Please i need help.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4071529#4071529
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4071529
18Â years, 11Â months
[JBoss Portal] - Can not start JBOSS Server
by georgy
Hi
When i try to start the server i get the following exception :
|
| =========================================================================
|
| JBoss Bootstrap Environment
|
| JBOSS_HOME: /home/dev/Desktop/jboss-portal-2.6.1.GA
|
| JAVA: /usr/java/j2sdk1.4.2_12/bin/java
|
| JAVA_OPTS: -Dprogram.name=run.sh -server -Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.net.preferIPv4Stack=true
|
| CLASSPATH: /home/dev/Desktop/jboss-portal-2.6.1.GA/bin/run.jar:/usr/java/j2sdk1.4.2_12/lib/tools.jar
|
| =========================================================================
|
| java.lang.UnsupportedClassVersionError: javax/management/NotificationEmitter (Unsupported major.minor version 49.0)
| at java.lang.ClassLoader.defineClass0(Native Method)
| at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
| at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
| at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
| at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
| at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
| at java.security.AccessController.doPrivileged(Native Method)
| at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
| at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
| at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
| at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
| at java.lang.ClassLoader.defineClass0(Native Method)
| at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
| at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
| at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
| at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
| at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
| at java.security.AccessController.doPrivileged(Native Method)
| at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
| at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
| at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
| at org.jboss.system.server.ServerLoader.createServer(ServerLoader.java:286)
| at org.jboss.system.server.ServerLoader.load(ServerLoader.java:268)
| at org.jboss.Main.boot(Main.java:194)
| at org.jboss.Main$1.run(Main.java:508)
| at java.lang.Thread.run(Thread.java:534)
|
|
I use VMWARE Player 2.0.0 and the "java -version" command displays
| java version "1.4.2_12"
| Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_12-b03)
| Java HotSpot(TM) Client VM (build 1.4.2_12-b03, mixed mode)
|
How can i resolve this whithout changing my VM version?
JBOSS Portal 2.6.1GA
VMWARE Player 2.0.0
Java 1.4
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4071520#4071520
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4071520
18Â years, 11Â months
[Installation, Configuration & DEPLOYMENT] - Re: Classloading problem (sar within ear)
by lucdew
Hi,
i have tried to debug the issues with classloader but one 's still remaining.
My application is packaged like this:
myapp.ear
--> spring.jar
--> mysar.sar
--> myjar.jar
I declared spring.jar and myjar.jar in application.xml as Java modules (ex: spring.jar)
In mysar.sar i displayed information of the current classloader and here's what i get:
11:58:54,765 INFO [DeployerListenerService] Current classloader = org.jboss.mx.
| loading.UnifiedClassLoader3@10d16b{ url=file:/D:/applications/jboss-4.0.
| 5.GA/server/default/deploy/myapp.ear/ ,addedOrder=40}
and if i execute the following code:
Enumeration<URL> resourcesEnum = this.getClass().getClassLoader().getResources("beanRefContext.xml");
the classloader find the resource beanRefContext.xml which is packaged in myjar.jar. It works as expected.
The problem is Spring library executes almost the same code in the PathMatchingResourcePatternResolver class it executes:
Enumeration resourceUrls = getClassLoader().getResources(path);
where path is "beanRefContext.xml"
and the getClassLoader() returned in debug mode has a path attribute of:
/D:/applications/jboss-4.0.5.GA/server/default/conf/
and therefore is unable to see the beanRefContext.xml file packaged in my ear.
Note that i configured in my ear a loader repository :
<loader-repository>
| test.com:loader=myapp
| </loader-repository>
I don't understand why the classloader retrieved in Spring is the one associated with the universalrepository3 ? and not the HeirarchicalLoaderRepository3 of my ear???
I checked the CLASSPATH and my Jboss installation to see if there were Spring classes elsewhere and no the only Spring classes are in the spring.jar of myapp.ear.
Please i need help.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4071519#4071519
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4071519
18Â years, 11Â months
[JBoss Seam] - @PersistenceContext in a SFSB created by a factory
by Newlukai
Hi there,
is it possible to have a PersistenceContext in a bean (don't really know which type it is, sorry, I'm a noob somedays :D) which is created by a factory?
The thing I want to do is to imlpement the possibility to switch the implementation of an interface. This works. In one of these implementations I want to obtain the PersistenceContext and that doesn't work.
But let me show you some code:
@Name("upDownloadFactory")
| @Scope(ScopeType.APPLICATION)
| @Startup
| public class UpDownloadFactory implements Serializable {
| private String className;
|
| @Out(required=false)
| private UpDownload upDownload;
|
| @Factory(value="upDownload", scope=ScopeType.SESSION, autoCreate=true)
| public UpDownload getUpDownload() {
| if(upDownload == null) {
| try {
| if(className == null || className.equals("")) {
| className = "com.idsscheer.ares.sessions.UpDownloadDatabase";
| }
| upDownload = (UpDownload) Class.forName(className).newInstance();
| ... and so on ...
| }
|
| return upDownload;
| }
|
| public void setClassName(String className) {
| this.className = className;
| }
| }
This is the factory I wrote. As you can see the implementation has to be set in components.xml and sets the className property. All those parameters I set in the @Factory annotation shall setup the "upDownload" as SFSB.
Here is one implementation of the managed bean:
@Scope(ScopeType.SESSION)
| @Stateful
| public class UpDownloadDatabase implements UpDownload, Serializable {
| @PersistenceContext(unitName = "aresDatabase")
| private transient EntityManager em;
|
| public boolean upload(UpDownloadFileinfo fileInfo) {
| ... do the upload with em ...
| }
|
| public List<UpDownloadFileinfo> getAttachedFiles(long testactionID) {
| ... show a list of attached files ...
| }
|
| @Remove @Destroy
| public void destroy() {
| }
| }
In this implementation the EntityManager is needed but on invokation of this bean the console tells me that
Caused by: java.lang.IllegalArgumentException: @PersistenceContext may only be used on session bean or message driven bean components: upDownload
| at org.jboss.seam.Component.initMembers(Component.java:663)
| at org.jboss.seam.Component.<init>(Component.java:253)
| at org.jboss.seam.Component.<init>(Component.java:203)
| at org.jboss.seam.init.Initialization.addComponent(Initialization.java:851)
| ... 93 more
Has anybody an idea how to implement such a factory?
Thanks in advance
Newlukai
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4071517#4071517
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4071517
18Â years, 11Â months