Have a look at the section:
Why is It Different? The Concept of Classloaders
at the following link:
This might help in understanding the concept of classloader.
Briefly explaining, your classes are not yet loaded by your Application Classloader, at the time when the classes are being reffered(i guess by your Listener1)
If I use Classloader Isolation for a war, does that mean that all the classes it accesses must be under WEB-INF/lib? I cannot mix classes from WEB-INF/lib and server/lib because they have different classloaders?
Now when I try to start my app, my webapp says that it can't find the classes that are in myApp.jar
I assume by this you mean ClassNotFoundException. Reason why this is occuring may be(again assuming that this class is present in the jar), the ClassLoader that you have defined for your application hasnt yet started at the time when this specific class is being reffered
As far as, accessing classes that are present in a jar under server/lib from classes under WEB-INF/lib, is concerned, you can do that without any problems.
Please post the exception that you are seeing.
Here is the error message. My war file is conman.war
In my web.xml, I am trying to load this listener.
<listener> <listener-class>rupurt.lifecycle.RupurtApplicationLifecycleListenerJBoss</listener-class> </listener>
09:24:56,019 INFO [TomcatDeployer] deploy, ctxPath=/conman, warUrl=file:/z:/conman/deploy/conman.war/ 09:24:58,035 FATAL [ComponentConfiguration] Cannot load class : com.pga.conman.jobs.PersistantJobScheduler java.lang.ClassNotFoundException: No ClassLoaders found for: com.pga.conman.jobs.PersistantJobScheduler at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:198) at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:475) at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:377) at java.lang.ClassLoader.loadClass(Unknown Source) ....
The class that is not being found is in a war file under WEB-INF/lib. Since the listener is being loaded during the webapp initialization, shouldn't the webapp classloader have already loaded the classes under WEB-INF/lib?
Ya you are right, the webapp classloader should have loaded your class file, since control has already reached the webapp.
I am not sure whether that jar file containing the class, is ever getting loaded
Try out the following, not sure whether this might work:
In the MANIFEST.MF file in the META-INF folder of your conman.war include the following line:
where yourApp.jar is the name of the jar containing the class that is not found.
When you scoped the classloader for ur war, you might also have to set the java2ParentDelegation to be true. this property is by default set to false, and so when if the value is false, a NoParentClassLoader gets assigned as its parent class loader. When the class in the server/lib gets loaded and it requests for a class, you might want to let the server know that it should search the WEB-INF/lib also at that time by setting java2ParentDelegation to be true.
And, no, i dont think Jboss loads classes in the WEB-INF/lib during deployment. All classes are loaded when required and then added to the repository cache.
Well I figured out my missing class issue. In some of the classes under server/lib, I used Class.loadClass. If I changed that the Thread.getCurrentThread().loadClass it worked.
But now I still haven't gotten log4j to work. I am trying to use a custom log4j.xml inside my WEB-INF/classes, but it's not working.
Has anyone gotten multiple log4j configurations to work?
I've read over the Wiki Loggin page tons of times, but I still haven't gotten it working. I renamed the conf/log4j.xml file to jboss-log4j.xml and editted the jboss-service.xml file accordingly. Then I added my custom log4j.xml in my WEB-INF/classes. In my custom log4j file, I put a different logging pattern and appenders from the ones in the conf/jboss-log4j.xml. But no matter what I do, it seems like my custom log4j.xml is never loaded.
Have you placed log4j.jar in your WEB-INF/lib folder?
I had tried out with .ear packaging with a .war inside it. That had worked for me.
I haven't tried the ear. I have tried the RepositorySelector example from the Wiki, it it worked a little. I did get my custom logging configuration, but then I noticed that two of my webapps were cross-logging to each other. The log statements from one app would appear in the output log file of a different app.
To clarify, I have used the RepositorySelector before I enabled classloader scoping and that worked. But when I enable classloader scoping, the RepositorySelector breaks with the error:
java.lang.NullPointerException at java.util.Hashtable.put(Unknown Source) at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:141) at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:153) at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:415) at org.apache.log4j.xml.DOMConfigurator.parseRoot(DOMConfigurator.java:384) at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:783) at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:678) at rupurt.logging.LogRepositorySelector.loadLog4JConfig(LogRepositorySelector.java:75) at rupurt.logging.LogRepositorySelector.init(LogRepositorySelector.java:56)