-
1. Re: Jboss 7.1.1 + Spring 3 + beanRefContext.xml = unstable CLASSPATH issue
sfcoy May 15, 2012 8:50 AM (in response to matvei)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.
-
2. Re: Jboss 7.1.1 + Spring 3 + beanRefContext.xml = unstable CLASSPATH issue
matvei May 16, 2012 5:35 AM (in response to sfcoy)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
EAR Structure:
/META-INF/
/MANIFEST.MF
/application.xml
/ejb-jar.xml
/jboss-deployment-structure.xml
/jboss.xml
/lib/
/.. [different libs, camel, spring etc]
/spring-config.jar
/beanRefContext.xml
/businessBeans.xml
/ejb3-ejbs.jar
/META-INF/
/[ejb3 classes]
/log4j.xml
Could you please show me your working configuration?
-
3. Re: Jboss 7.1.1 + Spring 3 + beanRefContext.xml = unstable CLASSPATH issue
sfcoy May 16, 2012 10:37 AM (in response to matvei)Hi,
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.
We use:
...
ejb3-ejbs.jar/
META-INF/
com/.../
beanRefContext.xml
The beanRefContext.xml looks like:
{code:xml}
<?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>
{code}
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.
-
4. Re: Jboss 7.1.1 + Spring 3 + beanRefContext.xml = unstable CLASSPATH issue
matvei May 25, 2012 4:36 AM (in response to matvei)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.
-
5. Re: Jboss 7.1.1 + Spring 3 + beanRefContext.xml = unstable CLASSPATH issue
sfcoy May 25, 2012 6:59 AM (in response to matvei)We're using Spring 3.0.6 for what its worth.
You need to be sure that there is only one beanRefContext.xml file in your application, otherwise you will get inconsistent behaviour.
-
6. Re: Jboss 7.1.1 + Spring 3 + beanRefContext.xml = unstable CLASSPATH issue
matvei May 25, 2012 7:49 AM (in response to sfcoy)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,
ear-subdeployments-isolated
set excplicit to
false.
<?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/*
rm ../standalone/deployments/*deployed
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.
-
7. Re: Jboss 7.1.1 + Spring 3 + beanRefContext.xml = unstable CLASSPATH issue
sfcoy May 26, 2012 9:16 AM (in response to matvei)Try enabling debug logging for the "org.springframework.beans" category, so we can see what it's doing.
-
8. Re: Jboss 7.1.1 + Spring 3 + beanRefContext.xml = unstable CLASSPATH issue
matvei May 29, 2012 4:17 AM (in response to sfcoy)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 KB
-
-
9. Re: Jboss 7.1.1 + Spring 3 + beanRefContext.xml = unstable CLASSPATH issue
sfcoy May 29, 2012 7:37 AM (in response to matvei)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.
-
10. Re: Jboss 7.1.1 + Spring 3 + beanRefContext.xml = unstable CLASSPATH issue
matvei May 29, 2012 8:05 AM (in response to sfcoy)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....
-
11. Re: Jboss 7.1.1 + Spring 3 + beanRefContext.xml = unstable CLASSPATH issue
sfcoy May 29, 2012 8:06 AM (in response to matvei)Are you still getting the same stack trace in the boot.log?
-
12. Re: Jboss 7.1.1 + Spring 3 + beanRefContext.xml = unstable CLASSPATH issue
matvei May 29, 2012 8:52 AM (in response to sfcoy)Just the same nullpointerException. The Boot.log attached. I will also list my current EAR/lib folder:
activation-1.1.jar
aopalliance-1.0.jar
camel-core-2.9.1.jar
camel-jms-2.9.1.jar
camel-spring-2.9.1.jar
commons-beanutils-1.6.jar
commons-beanutils-bean-collections-1.8.3.jar
commons-beanutils-core-1.7.0.jar
commons-betwixt-0.8.jar
commons-collections-2.0.jar
commons-dbcp-1.4.jar
commons-digester-1.7.jar
commons-logging-1.0.4.jar
commons-pool-1.5.4.jar
mysqldb-1.0.jar
oradb-1.0.jar
ibatis-sqlmap-2.3.4.726.jar
log4j-1.2.16.jar
mail-1.4.1.jar
mysql-connector-java-5.1.16.jar
ojdbc6-11.2.0.1.0.jar
spring-aop-3.0.7.RELEASE.jar
spring-asm-3.0.7.RELEASE.jar
spring-beans-3.0.7.RELEASE.jar
spring-context-3.0.7.RELEASE.jar
spring-core-3.0.7.RELEASE.jar
spring-expression-3.0.7.RELEASE.jar
spring-jdbc-3.0.7.RELEASE.jar
spring-jms-3.0.7.RELEASE.jar
spring-orm-3.0.7.RELEASE.jar
spring-tx-3.0.7.RELEASE.jar
myexceptions-1.0.jar
I have mqSeries JMS module, but there are no XML libs inside this module, I've checked it.
-
boot.log.zip 20.0 KB
-
-
13. Re: Jboss 7.1.1 + Spring 3 + beanRefContext.xml = unstable CLASSPATH issue
sfcoy May 29, 2012 9:28 AM (in response to matvei)You can also get rid of:
- activation-1.1.jar
- mail-1.4.1.jar
although I don't believe these are causing your problem.
commons-logging-1.0.x is also a known troublemaker. if you must use commons-logging, upgrade it to 1.1.1. (we use jcl-over-slf4j ourselves).
What version of Java are you using?
-
14. Re: Jboss 7.1.1 + Spring 3 + beanRefContext.xml = unstable CLASSPATH issue
matvei May 29, 2012 9:38 AM (in response to sfcoy)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.