简体   繁体   中英

JAXWS exception when generating wsdl

i'm new to using jax-ws

i have got some error on generating web service WSDL file from newService button

i'm using java ee 6 and jdk 1.6

and i have recently created wsdl for java class that don't return anything

message :

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

full java class :

@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 .

}

Log File :

!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

Exceptions or Throwables can't be serialized for the reasons mentioned in the error (StackTracElement - needed for Throwables - doesn't have a no-arg constructor).

You will probably have to catch the other exceptions within login() and use your own exception which can be annotated as a web fault. See this article for more information:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM