geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sam Merrell" <merrell....@gmail.com>
Subject Resource Injection
Date Wed, 12 Dec 2007 17:25:48 GMT
I have been looking everywhere and can't find much information on how
resource injection works for JAX-WS 2.0 web services.  Any pointers in the
right direction on how to use the @WebServiceRef or @Resource annotation
would be great.

I have a Java client that I'm trying to get resource injection for but I
keep getting a NullPointerException.

Here is the client:

package aTest.client;

import java.io.IOException;

import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.ws.WebServiceRef;

import aTest.service.EJBHelloService;
import aTest.service.EJBHello;

/**
 * @author samerrel
 *
 */
public class TestEJBHello extends HttpServlet implements Servlet {

    @WebServiceRef( wsdlLocation = "
http://localhost:8080/EJBHello/EJBHelloService?wsdl" )
    static EJBHelloService myService;

    public TestEJBHello() {
        super();
    }

    @Override
    protected void service( HttpServletRequest req, HttpServletResponse resp
)
            throws ServletException, IOException {
        System.out.println( "Service Method..." );
        resp.getWriter().println( "Getting EJBHelloPort..." );
        EJBHello port = myService.getEJBHelloPort();
        String msg = port.sayHello( "Sam" );
        System.out.println( msg );
        resp.getWriter().println( msg );
    }
}
---------------------------------------------

Here is the stack trace:

java.lang.NullPointerException
        at aTest.client.TestEJBHello.service(TestEJBHello.java:50)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(Appl
icationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationF
ilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperV
alve.java:230)
        at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextV
alve.java:175)
        at org.apache.geronimo.tomcat.valve.DefaultSubjectValve.invoke
(DefaultSu
bjectValve.java:56)
        at
org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.
invoke(GeronimoStandardContext.java:353)
        at org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke
(Gero
nimoBeforeAfterValve.java:47)
        at org.apache.catalina.core.StandardHostValve.invoke(
StandardHostValve.j
ava:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(
ErrorReportValve.j
ava:104)
        at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineVal
ve.java:109)
        at org.apache.catalina.valves.AccessLogValve.invoke(
AccessLogValve.java:
563)
        at org.apache.catalina.connector.CoyoteAdapter.service(
CoyoteAdapter.jav
a:261)
        at org.apache.coyote.http11.Http11Processor.process(
Http11Processor.java
:844)
        at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ss(Http11Protocol.java:581)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(
JIoEndpoint.java:44
7)
        at java.lang.Thread.run(Thread.java:801)

When I check my code, the myService variable is always null, so the resource
is not being injected before I try to get the port. When I checked the
repository in geronimo, it looks like the generated web.xml does not include
the proper <service-ref> elements inside it but I can't figure out why they
aren't being generated. Thanks in advance for the help.

-- 
Sam Merrell

Mime
View raw message