gpt4 book ai didi

java - 生成 wsdl 时出现 JAXWS 异常

转载 作者:行者123 更新时间:2023-11-29 03:26:13 25 4
gpt4 key购买 nike

我是 jax-ws 的新手

我在生成网络服务 WSDL 文件时遇到了一些错误来自新服务按钮

我正在使用 java ee 6 和 jdk 1.6

我最近为不返回任何内容的 java 类创建了 wsdl

留言:

An internal error occurred during: "Generating JAX-WS Web Services".
Unable to create JAXBContext

完整的java类:

@WebService
public class LoginWs {

// Take two strings from android TextFields .

public LoginWs() {

}

@WebMethod(operationName = "login", action = "urn:Login")
public String login(String username, String password)
throws ClassNotFoundException, SQLException, Exception,
IllegalAccessException {

// Make new Connection to database .
int TID = -1;
try {

Dbconnection NewConnect = new Dbconnection();
Connection con = NewConnect.MakeConnect();
Statement stmt = con.createStatement();

ResultSet rs = stmt
.executeQuery("SELECT Teacher_id FROM teacher where User_Name = "
+ "'"
+ username
+ "'"
+ "and Pass = "
+ "'"
+ password + "'");

while (rs.next()) {

TID = rs.getInt(1);

}
rs.close();
stmt.close();
con.close();

} catch (SQLException e) {
return "-1";
}

return String.valueOf(TID);

} // End of login MethodWS .

日志文件:

!ENTRY org.eclipse.core.jobs 4 2 2013-12-31 13:30:34.762
!MESSAGE An internal error occurred during: "Generating JAX-WS Web Services".
!STACK 0
javax.xml.ws.WebServiceException: Unable to create JAXBContext
at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:158)
at com.sun.xml.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:87)
at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:262)
at com.sun.tools.ws.wscompile.WsgenTool.buildModel(WsgenTool.java:225)
at com.sun.tools.ws.wscompile.WsgenTool.run(WsgenTool.java:124)
at com.genuitec.eclipse.ws.jaxws.JaxWSBUJob.wsGen(JaxWSBUJob.java:229)
at com.genuitec.eclipse.ws.jaxws.JaxWSBUJob.run(JaxWSBUJob.java:125)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.security.PrivilegedActionException: com.sun.xml.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 private java.lang.Throwable com.sams.ws.jaxws.ClassNotFoundExceptionBean.exception
at com.sams.ws.jaxws.ClassNotFoundExceptionBean

at java.security.AccessController.doPrivileged(Native Method)
at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:148)
... 7 more
Caused by: com.sun.xml.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 private java.lang.Throwable com.sams.ws.jaxws.ClassNotFoundExceptionBean.exception
at com.sams.ws.jaxws.ClassNotFoundExceptionBean

at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnn otationsException.java:102)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:438)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init> (JAXBContextImpl.java:286)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:139)
at com.sun.xml.bind.api.JAXBRIContext.newInstance(JAXBRIContext.java:105)
at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:153)
at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:149)
... 9 more

最佳答案

由于错误中提到的原因,无法序列化异常或 Throwable(StackTracElement - Throwable 需要 - 没有无参数构造函数)。

您可能必须在 login() 中捕获其他异常并使用您自己的异常,该异常可以被注释为 Web 错误。参见 this article了解更多信息:

关于java - 生成 wsdl 时出现 JAXWS 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20856880/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com