geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Janko Heilgeist <janko.heilge...@scai.fraunhofer.de>
Subject Missing resource injection in Tomcat/Axis vs Jetty/CXF
Date Thu, 13 Nov 2008 07:33:49 GMT
Hi,

I've got a problem when deploying web services under Geronimo
Tomcat/Axis. Not every instance of the stateless bean seems to receive
the @Resource that I would like to have injected into the bean. I create
a simple web service with an injected string that is accessed inside a
@PostConstruct method and inside an exposed web method.

// relevant excerpts ........
@Resource
private String someString = "DEFAULT";

@PostConstruct
public void init() {
    logger.info(String.format("init: EJB = '%08x', someString = '%s'",
hashCode(), this.someString));
}

public void doSomething(int counter) {
    logger.info(String.format("doSomething: EJB = '%08x', someString =
'%s'", hashCode(), this.someString));
}

Excerpts from ejb-jar.xml:

<session>
    <ejb-name>MyWebService</ejb-name>
    <ejb-class>
    com.heilgeist.tests.tst_ws_with_resource.ws_ejb.MyServiceEJBImpl
    </ejb-class>

    <env-entry>
        <env-entry-name>
com.heilgeist.tests.tst_ws_with_resource.ws_ejb.MyServiceEJBImpl/someString
        </env-entry-name>
        <env-entry-type>java.lang.String</env-entry-type>
        <env-entry-value>Hello, world!</env-entry-value>
    </env-entry>
</session>

When I access this web service I get the following lines in the server log:

08:12:41,381 INFO  [MyServiceEJBImpl] init: EJB = '00b6d31c', someString
= 'Hello, world!'
08:12:41,477 INFO  [MyServiceEJBImpl] init: EJB = '01c50523', someString
= 'DEFAULT'
08:12:41,745 INFO  [MyServiceEJBImpl] doSomething: EJB = '00b6d31c',
someString = 'Hello, world!'

The second line indicates, that there is an additional instance of the
stateless bean, that doesn't receive the injected string. It is only
created once directly following the deployment of the web service. Even
if further MYServiceEJBImpl instances are created later on to handle
concurrent requests there is only a single instance of the bean with the
default string. It's web service method is never called. Using the
Jetty/CXF package this additional stateless bean is not created:

08:09:54,557 INFO  [MyServiceEJBImpl] init: EJB = '015db507', someString
= 'Hello, world!'
08:09:54,558 INFO  [MyServiceEJBImpl] doSomething: EJB = '015db507',
someString = 'Hello, world!'

Can someone please shed some light on this funny behavior of Axis?

Regards, Janko

Mime
View raw message