-
1. Re: webservice class injecting EJB, nullpointerexception
ropalka Jan 14, 2008 11:29 AM (in response to htroeng)Hi,
your webservice must be EJB3 bean too. Just annotate it with @Stateless annotation -
2. Re: webservice class injecting EJB, nullpointerexception
ropalka Jan 14, 2008 11:35 AM (in response to htroeng)Take a look to http://jira.jboss.org/jira/browse/JBWS-1822 too
-
3. Re: webservice class injecting EJB, nullpointerexception
htroeng Jan 14, 2008 1:51 PM (in response to htroeng)Oh, thanks for the replies! Will try that tomorrow.
-
4. Re: webservice class injecting EJB, nullpointerexception
htroeng Jan 15, 2008 4:49 AM (in response to htroeng)I have done exactly according to the http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossws/stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1822/ example, but no success, still got a Nullpointerexception.
The SurveillanceService is located in the same jar as the webservice.
Annotated the webservice impl class with @Remote(MyService.class) and @Stateless.
Any ideas? -
5. Re: webservice class injecting EJB, nullpointerexception
ropalka Jan 15, 2008 4:56 AM (in response to htroeng)Hi,
could you post the stacktrace and minimized version of your application to reproduce your problem? -
6. Re: webservice class injecting EJB, nullpointerexception
htroeng Jan 15, 2008 5:25 AM (in response to htroeng)Ok, starting with the EJB service:
Interface:
@Local
public interface FunnyService {
public String getFunnyMessage();
}
Impl:
@Stateless
@LocalBinding(jndiBinding = "FunnyService")
public class FunnyServiceImpl implements FunnyService {
public String getFunnyMessage() {
return "Hello my name is earl!";
}
}
Webservice interface:
@WebService
public interface MyService {
public String echoMsg();
}
Impl:
@WebService(endpointInterface = "com.package.MyService")
@SOAPBinding(style = Style.RPC)
@Remote(MyService.class)
@Stateless
public class MyServiceImpl implements MyService {
@EJB
private FunnyService funnyService;
@WebMethod(operationName = "echoMsg")
public String echoMsg() {
String s = funnyService.getFunnyMessage();
return s;
}
}
web.xml:
<servlet-name>MyService</servlet-name>
<servlet-class>com.mypackage.MyServiceImpl</servlet-class>
<servlet-mapping>
<servlet-name>MyService</servlet-name>
<url-pattern>/MyService</url-pattern>
</servlet-mapping>
Stacktrace:
11:24:17,546 INFO org.jboss.deployment.EARDeployer.init(EARDeployer.java:142)
Init J2EE application: file:/C:/devel/jboss-4.2.1.GA-2/server/default/deploy/ear-3.0-SNAPSHOT.ear
11:24:24,375 INFO org.jboss.deployment.EARDeployer.start(EARDeployer.java:368)
Started J2EE application: file:/C:/devel/jboss-4.2.1.GA-2/server/default/deploy/ear-3.0-SNAPSHOT.ear
11:24:31,625 ERROR org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.exceptionToFaultMessage(SOAPFaultHelperJAXWS.java:146)
SOAP request exception
java.lang.NullPointerException
at com.mypackage.impl.MyServiceImpl.echoMsg(MyServiceImpl.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.wsf.container.jboss42.DefaultInvocationHandler.invoke(DefaultInvocationHandler.java:102)
at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:220)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:408)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:272)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:189)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:122)
at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java:84)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
11:24:31,734 ERROR org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.exceptionToFaultMessage(SOAPFaultHelperJAXWS.java:146)
SOAP request exception
java.lang.NullPointerException
at com.mypackage.impl.MyServiceImpl.echoMsg(MyServiceImpl.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.wsf.container.jboss42.DefaultInvocationHandler.invoke(DefaultInvocationHandler.java:102)
at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:220)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:408)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:272)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:189)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:122)
at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java:84)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619) -
7. Re: webservice class injecting EJB, nullpointerexception
htroeng Jan 15, 2008 5:26 AM (in response to htroeng)The nullpointerexception is on the row:
String s = funnyService.getFunnyMessage();
so I guess the FunnyService is never set. -
8. Re: webservice class injecting EJB, nullpointerexception
ropalka Jan 15, 2008 5:46 AM (in response to htroeng)Hi,
remove the web.xml it is not necessary because your webservice is EJB3 (not POJO) -
9. Re: webservice class injecting EJB, nullpointerexception
ropalka Jan 15, 2008 5:47 AM (in response to htroeng)You can annotate your webservice impl with WebContext annotation to specify the context path and other staff
-
10. Re: webservice class injecting EJB, nullpointerexception
htroeng Jan 15, 2008 6:50 AM (in response to htroeng)Thanks, it worked!