[jboss-user] [Beginners Corner] - Re: A new understanding of ClassLoaders...

mbabauer do-not-reply at jboss.com
Thu Feb 22 13:17:08 EST 2007


This is were my confussion lies.

In my example I have 4 units:
  - HG-DataAccess.jar, which has the DOAs (model) and a spring context called componentContext.xml defining the "parent" context for Spring, and a beenRefFactory.xml that setups up the DataSources and all the hibernate stuff, in the root.
  - HG-Service.jar that defines some service util classes (controller)
  - HG-Service.war, which is the WAR stuff, and has a web.xml that uses the ContextLoaderListener to bootstrap the Spring stuff.  This is done using an Spring context locally to build the requred stuff from the HG-Service.jar and the HG-Service.war, as well as defining the parent context as classpath:componentContext.xml
  - HG.ear which comprises some combination of the above.

Upon deploy, the WAR kicks off the web.xml, which in tern loads the ContextLoaderListener, which then loads the local applicationContext.xml (local to the WAR) and the componentContext.xml (which is defined as "classpath:componentContext.xml", and should be found).  I have tried putting HG-DataAccess.jar in the EAR, in the Server lib, and in the JBoss lib.  No matter where I put it, I get the folliowing spewage:
13:00:07,109 INFO  [XmlBeanDefinitionReader] Loading XML bean definitions from class path resource [applicationContext.xml]
  | 13:00:07,117 ERROR [ContextLoader] Context initialization failed
  | org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist
  | Caused by: 
  | java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist
  | 	at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:135)
  | ...

Hence the confussion.  If the WAR did indeed have visibility to the EAR, server lib, and JBoss lib, any one of the above combinations would not throw this error since anyone one of them would be visible *from* the WAR, which would then find the aformentioned componentContext.xml in the classpath.

When I put the HG-DataAccess.jar into the WAR, it loads just fine, but that defeats the whole "shared library" excercise.

My next step, I think, will be to add a dummy service to load the HG-DataAccess.jar's Spring context, have it put the classes that need to be shared in JNDI, and then pull them out on the WAR side from JNDI.  This is not what I consider ideal.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4020738#4020738

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4020738



More information about the jboss-user mailing list