GlassFish 3.1.1で実行されているejbとWebモジュールを備えたJEE6アプリケーションがあります。WebService(JAX-WS)を(Session Beanとして)いくつかのマネージドBeanに注入することでアクセスしたいと思いました。
@Stateless
public class AnyService implements AnyServiceLocal {
@WebServiceRef(wsdlLocation = "META-INF/wsdl/AnyService/Any.wsdl")
private AnyService service;
@Override
public String findLastname(Integer key) {
Any port = service.getAnyPort();
AnyPerson sp = port.findAnynumber(key);
return sp.getLastname();
}
}
アクセスしようとすると:
@ManagedBean
@SessionScoped
public class UserBean {
@EJB
private AnyServiceLocal any;
public void findLastname() {
name = any.findLastname(Integer.valueOf(key));
}
}
これらの例外を取得します
WARNUNG: A system exception occurred during an invocation on EJB AnyService method public java.lang.String de.mizui.anytest.ejb.bean.AnyService.findLastname(java.lang.Integer)
javax.ejb.EJBException
at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:5193)
at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5091)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4879)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2039)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1990)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:213)
at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:79)
at $Proxy430.findLastname(Unknown Source)
..blabla..
Caused by: javax.xml.ws.soap.SOAPFaultException: java.lang.NullPointerException
at com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:193)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:134)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:123)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:93)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:144)
at $Proxy431.findEmployeenumber(Unknown Source)
at de.mizui.anytest.ejb.bean.AnyService.findLastname(AnyService.java:25)
..blabla..
Caused by: javax.xml.ws.WebServiceException: java.lang.NullPointerException
at com.sun.enterprise.security.jmac.provider.config.PipeHelper.makeFaultResponse(PipeHelper.java:321)
..blabla..
Caused by: java.lang.NullPointerException
at com.sun.xml.ws.tx.coordinator.CoordinationManager.lookupOrCreateCoordinator(CoordinationManager.java:175)
(somewhat shortened..)
しかし、UserBean 内から直接 WS にアクセスすると、動作します..あなたのアイデアを楽しみにしています :)
※初投稿です(^^)