我是新手使用jax-ws
我在生成Web服务WSDL文件时遇到了一些错误 来自newService按钮
我正在使用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
答案 0 :(得分:4)
由于错误中提到的原因(StackTracElement - Throwables需要 - 没有没有arg构造函数),不能序列化异常或Throwables。
您可能必须在login()中捕获其他异常并使用您自己的异常,该异常可以注释为Web错误。有关详细信息,请参阅this article: