本文介绍了无法创建 JAXBContext 创建我的 wsdl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为 Web 服务生成我的 WSDL,但出现此错误:

注:ap 轮数:2线程main"中的异常 javax.xml.ws.WebServiceException:无法创建 JAXBContext在 com.sun.xml.internal.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:153)在 com.sun.xml.internal.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:83)在 com.sun.xml.internal.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:244)在 com.sun.tools.internal.ws.wscompile.WsgenTool.buildModel(WsgenTool.java:229)在 com.sun.tools.internal.ws.wscompile.WsgenTool.run(WsgenTool.java:112)在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)在 java.lang.reflect.Method.invoke(Method.java:597)在 com.sun.tools.internal.ws.Invoker.invoke(Invoker.java:105)在 com.sun.tools.internal.ws.WsGen.main(WsGen.java:41)引起:java.security.PrivilegedActionException: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptionsjava.lang.StackTraceElement 没有无参数的默认构造函数.此问题与以下位置有关:在 java.lang.StackTraceElement在公共 java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()在 java.lang.Throwable在 java.lang.Exception在 java.sql.SQLException在私有 java.sql.SQLException wsdb.jaxws.SQLExceptionBean.nextException在 wsdb.jaxws.SQLExceptionBean在 java.security.AccessController.doPrivileged(Native Method)在 com.sun.xml.internal.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:140)……还有 10 个引起:com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 个 IllegalAnnotationExceptionsjava.lang.StackTraceElement 没有无参数的默认构造函数.此问题与以下位置有关:在 java.lang.StackTraceElement在公共 java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()在 java.lang.Throwable在 java.lang.Exception在 java.sql.SQLException在私有 java.sql.SQLException wsdb.jaxws.SQLExceptionBean.nextException在 wsdb.jaxws.SQLExceptionBean在 com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91)在 com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:436)在 com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:277)在 com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1100)在 com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:143)在 com.sun.xml.internal.bind.api.JAXBRIContext.newInstance(JAXBRIContext.java:95)在 com.sun.xml.internal.ws.developer.JAXBContextFactory$1.createJAXBContext(JAXBContextFactory.java:97)在 com.sun.xml.internal.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:148)在 com.sun.xml.internal.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:140)……还有 12 个

我在互联网上看到了一些关于这个的讨论,从为所有类构建一个构造函数开始,直到创建另一个 xml 规范.事实是对此没有真正的答案,或者我测试的解决方案不起作用.

我在这里阅读了有关此问题的讨论,但未终止,我不知道如何解决.如果有人对此有所了解,我非常感谢向我指出正确的方向以避免这种情况发生.

我在 JDK 6 中使用 Debian Squezze、Java 1.6_20、JAX-WS JAX-WS RI 2.1.6 和 wsgen 来生成 wsdl.第一步它做对了,用bean类生成jaxws目录.

解决方案

Throwable 对象(即异常和错误)不能直接传输,因为它们不能序列化为 XML (StackTraceElement 没有 JAXB 要求的无参数构造函数.

为此您必须使用 SOAP 错误.请参阅这个问题.它指向您应该放在异常类上的 @WebFault 注释.(也可能检查 thisthis)

I am trying to generate my WSDL for webservices but I get this error:

Note:   ap round: 2
Exception in thread "main" javax.xml.ws.WebServiceException: Unable to create JAXBContext
        at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:153)
        at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:83)
        at com.sun.xml.internal.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:244)
        at com.sun.tools.internal.ws.wscompile.WsgenTool.buildModel(WsgenTool.java:229)
        at com.sun.tools.internal.ws.wscompile.WsgenTool.run(WsgenTool.java:112)
        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 com.sun.tools.internal.ws.Invoker.invoke(Invoker.java:105)
        at com.sun.tools.internal.ws.WsGen.main(WsGen.java:41)
Caused by: java.security.PrivilegedActionException: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
java.lang.StackTraceElement does not have a no-arg default constructor.
        this problem is related to the following location:
                at java.lang.StackTraceElement
                at public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()
                at java.lang.Throwable
                at java.lang.Exception
                at java.sql.SQLException
                at private java.sql.SQLException wsdb.jaxws.SQLExceptionBean.nextException
                at wsdb.jaxws.SQLExceptionBean

        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:140)
        ... 10 more
Caused by: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
java.lang.StackTraceElement does not have a no-arg default constructor.
        this problem is related to the following location:
                at java.lang.StackTraceElement
                at public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()
                at java.lang.Throwable
                at java.lang.Exception
                at java.sql.SQLException
                at private java.sql.SQLException wsdb.jaxws.SQLExceptionBean.nextException
                at wsdb.jaxws.SQLExceptionBean

        at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91)
        at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:436)
        at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:277)
        at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1100)
        at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:143)
        at com.sun.xml.internal.bind.api.JAXBRIContext.newInstance(JAXBRIContext.java:95)
        at com.sun.xml.internal.ws.developer.JAXBContextFactory$1.createJAXBContext(JAXBContextFactory.java:97)
        at com.sun.xml.internal.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:148)
        at com.sun.xml.internal.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:140)
        ... 12 more

I saw a few discusion in internet about this begin with build a constructor for all classes until create another xml specification. The truth is there is no a real answer for this or the solutions that I test doesnt work any.

I read a discussion here about this problem but it was unterminated and I dont know how to resolve. If somebody has a cluee about this I so appreciated to addrees me into rigth direction to avoid this.

I am using Debian Squezze, Java 1.6_20, JAX-WS JAX-WS RI 2.1.6 in JDK 6 and wsgen to generate the wsdl. The first step it did correct, generate the jaxws directory with bean classes.

解决方案

Throwable objects (that means exceptions and errors) can't be transferred directly, because they can't be serialized to XML (the StackTraceElement doesn't have a no-arg constructor, which is required by JAXB).

You have to use SOAP faults for that. See this question. It points you to the @WebFault annotation which you should put on your exception class. (Also probably check this and this)

这篇关于无法创建 JAXBContext 创建我的 wsdl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 11:02