Glassfish ClassCastException WebBundleContext和EjbContext

时间:2011-11-05 01:37:27

标签: web-services glassfish-3 ejb-3.1

我一直很难将一个简单的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

1 个答案:

答案 0 :(得分:0)

您使用的是NetBeans吗?我问,因为这是一个已知的bug,并在NetBeans版本6.9中得到修复。尝试升级NetBeans,看看它是否适合您。