JBoss Community

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

created by Bas Ven in Snowdrop - View the full discussion

I got sportsclub working after I went to github to get the latest version of it. 

 

Like I said, I got past the stacktrace, it is just the the spring beans are always null although I know the beans I am asking for have been instantiated since my spring application is working fine:

 

 


@Spring(bean = "commanderServer", jndiName = "SpringCommander")

private commander.server.CommanderServer commanderServer;
public String getCommanderServer(){
    String status = "Did not get a server object";
    try {
        if ( commanderServer != null){  <== Always null
            status = "Hey I got something";
        }
    } catch (Exception e) {
        status = e.getLocalizedMessage();
    }
    return status;

 


}

 

One difference I have is that my EJB's live in one ear and the Spring beans in a separate war, each having their own jars.  Not sure if this bean injection has a container (as in each ear, war etc) or JVM scope.

The spring beans are created in a java class that has the @Configuration annotation and the beans themselves are annotated with the @Bean annotation, like this:

 

 

@Configuration

public class MyConfiguration{

 

     @Bean

     public MyInterface MyBean(){

          return new MyInterfaceImpl();

     }

 

}

Reply to this message by going to Community

Start a new discussion in Snowdrop at Community