We're successfully running Spring 3.0.x based applications in JBoss 7.1.1.Final without any problems. We do not use Snowdrop as it was only required to fix issues in Spring 2.5.x.
beanRefContext.xml is a naming convention associated with Spring Framework support for EJBs, but you don't mention them anywhere. Are you using EJBs? This file must be in the jar that references it. Spring will not find it anywhere else. (You will never find files in the classpath in EAR/, EAR/META-INF/, etc, as was the case in earlier versions of JBoss)
You may find Spring applications development and migration guide useful. Be sure to check out the link on classloading that is there too.
Thanks for the answer. I've read the migration guide, sure. I think, I also understand basic classpath concepts of Jboss 7. As I've already written that my problem is instability. I can not understand why the same configuration sometimes works and sometimes not. One thing makes me curious: beanRefContext and businessBeans files are located at the same place, always. It may be EAR, it may be Jar file inside lib folder in EAR, it may be jar file installed as a module. It does not really matter where I locate these files and how I configure it... sometimes it does not work, Spring finds the first file, but can not find the second one. Probably I have to change something in VFS configuratation, are there any options?
the most common case (which should works) looks like
/.. [different libs, camel, spring etc]
Could you please show me your working configuration?
Matteo Ts wrote:
One thing makes me curious: beanRefContext and businessBeans files are located at the same place, always. It may be EAR, it may be Jar file inside lib folder in EAR, it may be jar file installed as a module. It does not really matter where I locate these files and how I configure it... sometimes it does not work,
Actually, it does matter.
The beanRefContext.xml looks like:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd "> <!-- The EJB spring container context --> <bean class="org.springframework.context.support.ClassPathXmlApplicationContext"> <constructor-arg> <list> <value>com/foo/bar/services/config/spring/timers/timers.context.spring.xml</value> </list> </constructor-arg> </bean> </beans>
This finds timers.context.spring.xml in another jar in the EAR/lib directory. It's placed there because that's where it's associated classes happen to be.
Technically, it should also find the beanRefContext.xml in the root of any of the jars in the classpath. If you have more than one of these then you may get instability because Spring will use the first one it discovers, and the order is indeterminate.
Matteo Ts also wrote:
Probably I have to change something in VFS configuratation, are there any options?
I believe that VFS is irrelevant.
Please let me know the Sping version you use. It'sa nightmare, I may locate the files exactly as you describe, clean tmp and data folders and successfully deploy the application. Afterwards I may stop jboss server and start it again... it does not work as it can not find businessBeans.xml file. Nightmare, have no idea where to dig. If I clean standalone/data and standalone/tmp folders and redeploy the EAR, it may work, sometimes, sometimes not from the first time. Please give me an idea how to localisate the problem.
I've checked it many times, I have only one beanRefContext.xml inside EAR. I usually get NullPointerException with this message, referenced to the businessBeans.xml:
Message : org.springframework.beans.factory.access.BootstrapException: Unable to return specified BeanFactory instance: factory key [null], from group with resource name [classpath*:beanRefContext.xml]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ejb-businesslayer.application.context' defined in URL [vfs:/content/ejb3company-ear-1.0.ear/ejb3company-ejb-1.0.jar/beanRefContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.context.support.ClassPathXmlApplicationContext]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [my/company/businessBeans.xml]; nested exception is java.lang.NullPointerException
My businessBeanx.xml includes 2 XMLfiles from oher Projects, for iBATIS DAOs, these jar files also are also under EAR/lib folder,
set excplicit to
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:camel="http://camel.apache.org/schema/spring" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> <!-- CAMEL PART --> <camel:camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> <!-- routes will be here --> </camel:camelContext> <!-- MQ Series Part --> <bean id="mqseries" class="org.apache.camel.component.jms.JmsComponent"> <property name="configuration"> <bean class="org.apache.camel.component.jms.JmsConfiguration"> <property name="connectionFactory"> <bean class="com.ibm.mq.jms.MQQueueConnectionFactory"> <property name="hostName" value="mq.mycompany.com"/> <property name="port" value="1421"/> <property name="queueManager" value="QM01"/> <property name="channel" value="SYSTEM.DEF.SVRCONN"/> <property name="transportType" value="1"/> </bean> </property> </bean> </property> </bean> <!-- MQ Series Part END --> <bean id="producers" class="my.company.camel.producer.ProducersHandler"/> <!-- MySQLDB part, from mysqldb.jar file --> <import resource="classpath*:mysqldbDAOContext.xml" /> <!-- OraDB part, from oradb.jar file --> <import resource="classpath*:oradbDAOContext.xml" /> </beans>
I may deploy the EAR and it works. I may stop it, start it again, getting the exception shown above. Stop it again, call the script:
echo "CLEANING tmp/vfs DIRECTORY"
rm -r ../standalone/tmp/*
rm -r ../standalone/data/*
rm -r ../standalone/log/*
start it, does not work, stop it, clean the data again, start it and it works. It is completely inconsistent, I can only assume it has something with class loadng order to do, but have no idea how to check and fix it. Interesting is, that this configuration worked without any problems under Jboss 6.
I've tried to add this logger to my log4.xml and associate it with a file appender, the file is empty, but I get some information inside boot.log,I will try to post this long log file, probably you may give a hint in which direction should I search further. Could it be that I get these errors because of xmlns/namespace definitions inside my businessBeans.xml
can you please post your namespaces/headers?
boot.log.zip 17.6 K
My schema locations are definitely different to yours. You can see them in my second response above.
You definitely seem to have an XML parsing problem.
Also ensure that you have not packaged any XML related jars (xml-apis, xerces, xalan, jaxb, etc) in your application. JEE6 provides all of these services for you.
BINGO! xml-apis.jar was inside my EAR lib folder. That was a problem, now I've stopped and started it several times, deployed und undeployed it. No exception any more. Have to modify (and to find first) my POM file to exclude this transitive dependency.
oh... 7 times it was ok, and afterwards - the same story....
Just the same nullpointerException. The Boot.log attached. I will also list my current EAR/lib folder:
I have mqSeries JMS module, but there are no XML libs inside this module, I've checked it.
boot.log.zip 20.0 K
java version "1.6.0_24"
we do not use commons-logging, just log4j, I think these are transitive dependencies from maven, I should manually exclude some files.
removed thes 3 jars... the same exception. I wonder if this issue has something with classpath or not. It looks like the system may read the businessBeans.xml file, but get an exception processing it.