-
Jul 13th, 2005, 08:29 AM
#1
ClassPathXmlApplicationContext in EJB
I have created a singleton that uses ClassPathXmlApplicationContext. The singleton uses context path string of "**/*-context.xml". In a stand alone app, or a JUnit test script, this code works fine to load all the files matching the expression.
When I call this from my EJB, It does not find any context files to load. I get the following error.
[7/13/05 9:27:48:700 EDT] d1e4ebf XmlBeanDefini I org.springframework.beans.factory.xml.XmlBeanDefin itionReader Loading XML bean definitions from class path resource []
[7/13/05 9:15:02:443 EDT] 75e54c20 ClassPathXmlA I org.springframework.context.support.ClassPathXmlAp plicationContext Bean factory for application context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=527174711]: org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans []; root of BeanFactory hierarchy
[7/13/05 9:15:02:443 EDT] 75e54c20 ClassPathXmlA I org.springframework.context.support.ClassPathXmlAp plicationContext No beans defined in application context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=527174711]
When I change "**/*.context" to be the full path....al la...
com/test/customerservices/app/demandmanagement/orderstatusmanager/facade/DMOrderStatusManager-context.xml"
It works fine and the output looks like this:
[7/13/05 9:27:48:700 EDT] d1e4ebf XmlBeanDefini I org.springframework.beans.factory.xml.XmlBeanDefin itionReader Loading XML bean definitions from class path resource [com/test/customerservices/app/demandmanagement/orderstatusmanager/facade/DMOrderStatusManager-context.xml]
[7/13/05 9:27:49:060 EDT] d1e4ebf ClassPathXmlA I org.springframework.context.support.ClassPathXmlAp plicationContext Bean factory for application context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=1937936052]: org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [EvaluateInventoryRules]; root of BeanFactory hierarchy
[7/13/05 9:27:49:060 EDT] d1e4ebf ClassPathXmlA I org.springframework.context.support.ClassPathXmlAp plicationContext 1 beans defined in application context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=1937936052]
Can anyone tell me what is going on here? Why would it work appropriately for a stand alone app/JUnit test script, but not an EJB?
-
Jul 13th, 2005, 08:39 AM
#2
ClasspathXmlApplicationContext does not support ant-style filename resolution. It's meant to accept fully qualified resources that are on the classpath. Yours is a common misperception, something I wish could be made a little more clear in the documentation.
-
Jul 13th, 2005, 08:44 AM
#3
The javadoc says...
"Config locations can either denote concrete files like "/myfiles/context.xml" or Ant-style patterns like "/myfiles/*-context.xml" (see PathMatcher javadoc for pattern details)."
I that just when you override setConfigLocations with your own code?
-
Jul 13th, 2005, 09:39 AM
#4
You are correct. However, because of limitations in java.lang.ClassLoader this functionality doesn't work with JAR files, only the file system. You can find more detail in this JIRA issue
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules