<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Re: Accessing spring beans that are deployed in a war.
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/batter">Bas Ven</a> in <i>Snowdrop</i> - <a href="https://community.jboss.org/message/829855#829855">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Ok, getting furhter once again.&#160; 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.</p><p>As posted before, I had this defined as:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><blockquote class="jive-quote"><blockquote class="jive-quote"><p>&lt;?xml version="1.0" encoding="UTF-8"?&gt;</p><p>&lt;!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "<a class="jive-link-external-small" href="http://www.springframework.org/dtd/spring-beans.dtd" rel="nofollow" target="_blank">http://www.springframework.org/dtd/spring-beans.dtd</a>"&gt;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><strong>&lt;beans&gt;</strong></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; &lt;description&gt;BeanFactory=(Commander)&lt;/description&gt;</p><p>&#160;&#160;&#160; &lt;bean id="dataSourceManager" class="database.DataSourceManagerImpl" /&gt;</p><p>&lt;/beans&gt;</p></blockquote></blockquote><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>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:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><blockquote class="jive-quote"><p>&lt;?xml version="1.0" encoding="UTF-8"?&gt;</p><p><strong><span>&lt;beans xmlns="</span><a class="jive-link-external-small" href="http://www.springframework.org/schema/beans" rel="nofollow" target="_blank">http://www.springframework.org/schema/beans</a><span>"</span></strong></p><p><strong><span>&#160;&#160;&#160;&#160;&#160;&#160; xmlns:xsi="</span><a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance" rel="nofollow" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a><span>"</span></strong></p><p><strong><span>&#160;&#160;&#160;&#160;&#160;&#160; xsi:schemaLocation="</span><a class="jive-link-external-small" href="http://www.springframework.org/schema/beans" rel="nofollow" target="_blank">http://www.springframework.org/schema/beans</a><span> </span><a class="jive-link-external-small" href="http://www.springframework.org/schema/beans/spring-beans.xsd" rel="nofollow" target="_blank">http://www.springframework.org/schema/beans/spring-beans.xsd</a><span>" default-lazy-init="true"&gt;</span></strong></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; &lt;description&gt;BeanFactory=(SpringCommander)&lt;/description&gt;</p><p>&#160;&#160;&#160; &lt;bean id="dataSourceManager" class="com.electriccloud.database.DataSourceManagerImpl" /&gt;</p><p>&#160;&#160;&#160; &lt;bean id="commanderServer" class="com.electriccloud.commander.server.CommanderServerImpl" /&gt;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&lt;/beans&gt;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p></blockquote><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Now when I look in the jBoss console I indeed see that the factory is registered with JNDI.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><strong>However </strong>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.&#160; This is the exception:</p><blockquote class="jive-quote"><p>java.lang.IllegalArgumentException: Cannot retrieve an org.springframework.beans.factory.BeanFactory from java:jboss/SpringCommander - a org.jboss.spring.factory.NamedXmlApplicationContext found instead</p><p> org.jboss.spring.support.SpringInjectionSupport.lookup(SpringInjectionSupport.java:175)</p><p> org.jboss.spring.support.SpringInjectionSupport.getObjectFromBeanFactory(SpringInjectionSupport.java:136)</p><p> org.jboss.spring.support.SpringInjectionSupport.injectToField(SpringInjectionSupport.java:202)</p><p> org.jboss.spring.support.SpringInjectionSupport.inject(SpringInjectionSupport.java:80)</p><p> org.jboss.spring.callback.SpringLifecycleInterceptor.postConstruct(SpringLifecycleInterceptor.java:43)</p></blockquote></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/829855#829855">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in Snowdrop at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2082">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>