JBoss Community

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

created by Tejas Mehta in Snowdrop - View the full discussion

Just to make sure attempted to deploy an ear with an ejb getting a spring injected by snowdrop from a *.spring deployment. The following was the configuration:

 

The EJB:

@Stateful

@Interceptors({SpringLifecycleInterceptor.class})

public class GreeterEJB implements IGreeterEJB {

    @Spring(bean = "springBean", jndiName = "MyApp")

    private Object memberDao;

 

/** rest of class **/

 

}

 

In the ear pom.xml:

Note scope is not set provided:

 

<dependency>

     <groupId>org.jboss.snowdrop</groupId

     <artifactId>snowdrop-deployers-core</artifactId>

      <version>2.1.1.SNAPSHOT</version>

</dependency>

Content of resources/META-INF/jboss-deployment-structure.xml:

Make sure this at the top level of the ear.

 

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">

    <deployment>

        <dependencies>

            <module name="org.springframework.spring" slot="snowdrop" export="true">

                <exports>

                    <include path="META-INF**"/>

                    <include path="org**"/>

                </exports>

                <imports>

                    <include path="META-INF**"/>

                    <include path="org**"/>

                </imports>

            </module>

            <module name="org.jboss.snowdrop" export="true"/>

        </dependencies>

    </deployment> 

</jboss-deployment-structure>

In META-INF/jboss-spring.xml of either the ear top level or a seperate *.spring application:

 

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

 

 

          <description>BeanFactory=(MyApp)</description>

 

/** beans or imports etc. **/

 

 

</beans>

 

Hopefully this helps you out. If not I can send over this sample working solution (much smaller than sporstclub) and hopefully you can take it from there.

 

Cheers,

 

Tejas M.

Reply to this message by going to Community

Start a new discussion in Snowdrop at Community