<!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;">
Loading Spring annotated beans from AbstractSpringAction in ESB ActionPipeline
</h3>
<span style="margin-bottom: 10px;">
created by <a href="https://community.jboss.org/people/bsingareddy">Bala Singareddy</a> in <i>JBoss ESB Development</i> - <a href="https://community.jboss.org/message/779710#779710">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>Hi,</p><p>          </p><p>         I have an issue loading Spring 3 Beans annotated with Stereotypes- @Component,@Repository,@Service.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        My current *applicationContext.xml* defined within the project has ComponentScanning enabled for a package using -</p><p>        {code:xml}</p><p>        <context:annotation-config/></p><p>        <context:component-scan base-package="classpath*:net.whatever.service"/></p><p>        {code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        I'm using the JBoss ESB 4.11 Server. Here I have a ServicePipeline which takes in an Action with an ActionClass extending the AbstractSpringAction that loads the SpringContext. Here's how I'm doing this - </p><p>  </p><p>        {code:xml}</p><p>         <service category="category" name="servicename"></p><p>         <listeners></p><p>         <jms-listener busidref="defined" name="listenername" /></p><p>         </listeners></p><p>          <actions mep="OneWay"></p><p>          <action name="actionname" class="net.whatever.custom.MySpringEnabledAction" process="processname"></p><p>              <property name="springContextXml" value="applicationContext.xml"/>     </p><p>          <action ... />  </p><p>          </actions>  </p><p>         </service></p><p>        {code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        Here's a piece of code of how I'm implementing the MySpringEnabledAction.java class - </p><p>          </p><p>        {code}</p><p>            public class MySpringEnabledAction extends AbstractSpringAction {</p><p>                     public MySpringEnabledAction(ConfigTree _config){</p><p>                             configTree = _config;</p><p>                        }</p><p>                    public processName ....</p><p>                           .....</p><p>            }</p><p>        {code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p> The problem I'm facing is with this now - </p><p> In the package *net.whatever.service* on which Spring does the ComponentScanning there is a class called MyServiceImpl.java which looks like this - </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>       {code}</p><p>             @Service(name="myservice_name")</p><p>            public class MyServiceImpl implements MyService{</p><p>                 ....</p><p>                 ....</p><p>             }</p><p>       {code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>MyService is an interface and there is no ambiguity between beans. This is the only Concrete implementation which implements this interface.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>This annotation is not being seen or not being detected because this Bean is not being Pre-initialized by the Spring Container.. as a result I keep getting an error of org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [net.whatever.service.MyService]... </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>This error pops-up because there is another Bean which is trying to use @Autowired annotation and injecting the MyService Bean into its implementation. This other bean looks like this - </p><p>                   {code}</p><p>                         public class Receiver {</p><p>                                  protected MyService myservice</p><p>                                @Autowired</p><p>                                    public class setMyService(MyService myservice){</p><p>                                         this.myservice = myservice;</p><p>                                    }</p><p>                               .....</p><p>                               .....</p><p>                         } </p><p>                   {code}</p><p> This bean is also loaded by Spring but the difference here is its not part of the ComponentScanning that Spring will use.. it has a bean definition as XML configuration within the applicationContext.xml.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p> All the Spring configuration worked fine when I deployed it as a WAR and used the Servlet context to load the Spring Context.. but now with this ESB Action loading the SpringContext.. all the basic annotations are falling apart. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>So could somebody help me figure out what the issue with the SpringContainer not pre-initializing the MyService Bean is?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Thanks.</p></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/779710#779710">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss ESB Development at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2032">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>