[jboss-user] [Snowdrop] - Re: Accessing spring beans that are deployed in a war.

Bas Ven do-not-reply at jboss.com
Thu Jul 25 16:55:15 EDT 2013


Bas Ven [https://community.jboss.org/people/batter] created the discussion

"Re: Accessing spring beans that are deployed in a war."

To view the discussion, visit: https://community.jboss.org/message/829855#829855

--------------------------------------------------------------
Ok, getting furhter once again.  The problem about the BeanFactory not being registered was due to the fact that your jboss-spring.xml definition has changed from the examples I found on the site to what is actually needed.
As posted before, I had this defined as:


> > <?xml version="1.0" encoding="UTF-8"?>
> > <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" " http://www.springframework.org/dtd/spring-beans.dtd http://www.springframework.org/dtd/spring-beans.dtd">
> > 
> > *<beans>*
> > 
> >     <description>BeanFactory=(Commander)</description>
> >     <bean id="dataSourceManager" class="database.DataSourceManagerImpl" />
> > </beans>


I looked thru some of the newer source and noticed that you defined them differently and I updated my jboss-spring.xml file to reflect that change:


> <?xml version="1.0" encoding="UTF-8"?>
> *<beans xmlns=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans"*
> *       xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance"*
> *       xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/beans/spring-beans.xsd" default-lazy-init="true">*
> 
>     <description>BeanFactory=(SpringCommander)</description>
>     <bean id="dataSourceManager" class="com.electriccloud.database.DataSourceManagerImpl" />
>     <bean id="commanderServer" class="com.electriccloud.commander.server.CommanderServerImpl" />
> 
> </beans>
> 

Now when I look in the jBoss console I indeed see that the factory is registered with JNDI.

*However* I still get an exception when I actually try to have the spring bean injected in my EJB and I hope you can help me out there.  This is the exception:
> java.lang.IllegalArgumentException: Cannot retrieve an org.springframework.beans.factory.BeanFactory from java:jboss/SpringCommander - a org.jboss.spring.factory.NamedXmlApplicationContext found instead
>  org.jboss.spring.support.SpringInjectionSupport.lookup(SpringInjectionSupport.java:175)
>  org.jboss.spring.support.SpringInjectionSupport.getObjectFromBeanFactory(SpringInjectionSupport.java:136)
>  org.jboss.spring.support.SpringInjectionSupport.injectToField(SpringInjectionSupport.java:202)
>  org.jboss.spring.support.SpringInjectionSupport.inject(SpringInjectionSupport.java:80)
>  org.jboss.spring.callback.SpringLifecycleInterceptor.postConstruct(SpringLifecycleInterceptor.java:43)
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/829855#829855]

Start a new discussion in Snowdrop at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2082]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20130725/db392640/attachment.html 


More information about the jboss-user mailing list