@XmlJavaTypeAdapter在参数上抛出IllegalArgumentException

时间:2011-12-16 15:37:37

标签: java annotations jaxb

我有一个我在方法参数上指定的XML适配器,但是当我启动我的应用程序时,我收到了IllegalArgumentException。

我在任何地方都找不到任何这样的例子,我做错了什么?有没有人在这种情况下有一个这样的注释的例子?我的代码是:

@WebMethod
public List list(@XmlJavaTypeAdapter(MyAdapter.class) @WebParam(name = MY_PARAMETER) MyClass cls) {
    return service.list(cls);
}

我的适配器是:

public class MyAdapter extends XmlAdapter<String, MyClass> {
    @Override
    public MyClass unmarshal(String v) {
            return new MyClass(v);
    }

    @Override
    public String marshal(MyClass v) {
            return v.getName();
    }
}

例外是:

SEVERE: WSSERVLET11: failed to parse runtime descriptor: javax.xml.ws.WebServiceException: java.lang.IllegalArgumentException: value class com.xyz.jaxb.MyAdapter
javax.xml.ws.WebServiceException: java.lang.IllegalArgumentException: value class com.xyz.jaxb.MyAdapter
    at com.sun.xml.ws.model.WrapperBeanGenerator.createRequestWrapperBean(WrapperBeanGenerator.java:260)
    at com.sun.xml.ws.model.RuntimeModeler.getRequestWrapperClass(RuntimeModeler.java:297)
    at com.sun.xml.ws.model.RuntimeModeler.processDocWrappedMethod(RuntimeModeler.java:636)
    at com.sun.xml.ws.model.RuntimeModeler.processMethod(RuntimeModeler.java:574)
    at com.sun.xml.ws.model.RuntimeModeler.processClass(RuntimeModeler.java:402)
    at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:258)
    at com.sun.xml.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:322)
    at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:188)
    at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:467)
    at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parseAdapters(DeploymentDescriptorParser.java:253)
    at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parse(DeploymentDescriptorParser.java:147)
    at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:108)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
    at org.apache.catalina.core.StandardService.start(StandardService.java:519)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
    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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.IllegalArgumentException: value class com.xyz.jaxb.MyAdapter
    at com.sun.xml.ws.org.objectweb.asm.ClassWriter.newConstItem(ClassWriter.java:893)
    at com.sun.xml.ws.org.objectweb.asm.AnnotationWriter.visit(AnnotationWriter.java:185)
    at com.sun.xml.ws.model.WrapperBeanGenerator.createBeanImage(WrapperBeanGenerator.java:122)
    at com.sun.xml.ws.model.WrapperBeanGenerator.createRequestWrapperBean(WrapperBeanGenerator.java:256)

提前致谢!

0 个答案:

没有答案