Injecting Spring bean into non-EJB class on JBoss EAP 4.3

Solution Verified - Updated -

Environment

  • JBoss Enterprise Application Platform 4.3
  • Spring-deployer 2.x

Issue

Can I use the JBoss-Spring integration to inject a Spring bean into a non-EJB class?

Resolution

Are you using JBoss AOP? If so, you just need to add the SpringInjectionInterceptor to your mbean. To do so, you can create a file META-INF/jboss-aop.xml with the following contents, and it should then process the @Spring annotations on your mbean - replacing "my.MbeanClass" with the fully-qualified name of your class.

<?xml version="1.0" encoding="UTF-8"?>
<aop xmlns="urn:jboss:aop-beans:1.0">
   <interceptor class="org.jboss.spring.interceptor.SpringInjectionInterceptor"/>

   <bind pointcut="construct(my.MbeanClass->new(*))">
       <interceptor-ref name="org.jboss.spring.interceptor.SpringInjectionInterceptor"/>
   </bind>
</aop>

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.