我一直很难将一个简单的Web服务部署到GlassFish 3.1.1我在部署时遇到以下异常:
引起:java.lang.ClassCastException:com.sun.enterprise.deployment.annotation.context.WebBundleContext无法强制转换为com.sun.enterprise.deployment.annotation.context.EjbContext 在org.glassfish.webservices.annotation.handlers.WebServiceProviderHandler.processAnnotation(WebServiceProviderHandler.java:158) 在org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:344) ......还有42个
这是我的WebService类:
@Stateless
@WebServiceProvider(
serviceName = "HelloWorldProviderService",
portName = "HelloWorldProviderPort",
targetNamespace = "http://mydomain.com/wsdl"
)
@ServiceMode(value= Service.Mode.PAYLOAD)
public class HelloWorldProvider implements Provider<Source>
{
@Override
public Source invoke(Source request)
{
StringWriter requestXmlWriter = new StringWriter();
try
{
Transformer copier = TransformerFactory.newInstance().newTransformer();
copier.transform(request, new StreamResult(requestXmlWriter));
System.out.println(requestXmlWriter.toString());
return new StreamSource(new StringReader("<HelloBack/>"));
}
catch (TransformerException e)
{
throw new RuntimeException("Failed to convert");
}
}
}
战争布局是
|__ WEB-INF
| |__ web.xml
|
|__ classes
| |__ META-INF
| | |__ ejb-jar.xml
| |
| |__ <classfile>
|
|__ lib
| |__ <empty>
这可以在我的测试环境中使用OpenEjb但我需要它来对抗GlassFish并且建议会很棒。
谢谢 -kurt