开发者

how to endorse tomcat, jdk, jre?

i'm using Netbeans 6.8, jdk 1.6.0.21 and jre6u21....i developed a simple web service using nothing but sql connection, oracle datasource and when i try to deploy it it gives me the same exception each time:

SEVERE: Exception sending context initialized event to listener instance of class com.sun.xml.ws.transport.http.servlet.WSServletContextListener
com.sun.xml.ws.transport.http.servlet.WSServletException: WSSERVLET11: failed to parse runtime descriptor: javax.xml.ws.WebServiceException: Unable to create JAXBContext
    at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:139)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
    at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    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:443)
    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(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: javax.xml.ws.WebServiceException: Unable to create JAXBContext
    at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:166)
    at com.sun.xml.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:94)
    at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:258)
    at com.sun.xml.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:338)
    at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:201)
    at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:505)
    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:124)
    ... 24 more
Caused by: java.security.PrivilegedActionException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 3 counts of IllegalAnnotationExceptions
java.sql.Connection is an interface, and JAXB can't handle interfaces.
    this problem is related to the following location:
        at java.sql.Connection
        at public java.sql.Connection vas.gift.jaxws.LogHistory.arg0
        at vas.gift.jaxws.LogHistory
java.sql.Connection does not have a no-arg default constructor.
    this problem is related to the following location:
        at java.sql.Connection
        at public java.sql.Connection vas.gift.jaxws.LogHistory.arg0
        at vas.gift.jaxws.LogHistory
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 public java.sql.SQLException vas.gift.jaxws.SQLExceptionBean.nextException
        at vas.gift.jaxws.SQLExceptionBean

    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:153)
    ... 32 more
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 3 counts of IllegalAnnotationExceptions
java.sql.Connection is an interface, and JAXB can't handle interfaces.
    this problem is related to the following location:
        at java.sql.Connection
        at public java.sql.Connection vas.gift.jaxws.LogHistory.arg0
        at vas.gift.jaxws.LogHistory
java.sql.Connection does not have a no-arg default constructor.
    this problem is related to the following location:
        at java.sql.Connection
        at public java.sql.Connection vas.gift.jaxws.LogHistory.arg0
        at vas.gift.jaxws.LogHistory
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 public java.sql.SQLException vas.gift.jaxws.SQLExceptionBean.nextException
        at vas.gift.jaxws.SQLExceptionBean

    at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:102)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:472)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:302)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1140)
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:154)
    at com.sun.xml.bind.api.JAXBRIContext.newInstance(JAXBRIContext.java:106)
    at com.sun.xml.ws.developer.JAXBContextFactory$1.createJAXBContext(JAXBContextFactory.java:109)
    at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:161)
    at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:154)
    ... 34 more

now i know its something to do with endorsement and i've tried a lot of options like copying jaxws22 jars from netbeans to the endorsed directory in tomcat but nothing works.....i'm new to java and don't know the complex abbreviations yet..so kindly let me know the solution to this problem in simpler words please.......its really urgent....there is oracle jre also installed on the machine if that is of any importance.. :S :S

/* * To change this template, choose Tools | Templates * and open the template in the editor. */

package vms.wap;

import java.io.; import java.net.; import java.sql.; import java.util.; import javax.jws.*; import oracle.jdbc.pool.OracleDataSource;

/** * * @author muhammad.awais */ @WebService() public class giftingService {

/**
 * Web service operation
 */
  private String parameterFile;


//return codes

private String VMSUserName;
private String VMSPassword;
private String VMSjdbcUrl;
private String sendSMSUrl;
private String xmsFrom;
private int sessionLA;
private String partyAmessage;
private String partyBmessage;
private String MTLA;
private String tID;
private String mode;

/**
 *
 */
public giftingService(){
     parameterFile=giftingService.class.getClassLoader()
     .getResource("parameters.conf").getPath()
    .replaceAll("%20", " ");

     LoadParameters();
}

/**
 *
 * @param username
 * @param password
 * @param partyA
 * @param partyB
 * @param serviceID
 * @param serviceName
 * @param channel
 * @return
 * @throws SQLException
 */
@WebMethod(operationName = "giftRequest")
public String giftRequest(@WebParam(name = "username")
String username, @WebParam(name = "password")
String password, @WebParam(name = "partyA")
String partyA, @WebParam(name = "partyB")
String partyB, @WebParam(name = "serviceID")
String serviceID, @WebParam(name = "serviceName")
String serviceName, @WebParam(name = "channel")
String channel) throws SQLException {
    //TODO write your implementation code here:

    String UserAuthResp ="";
    String response="0";
    String lookupResp="";
    String createSessResp="";
    //String lookupArr[];
    int correlationid=0;
    String sendSMSResp = "";


    int LA=0;
    Connection vmsConn = createVMSConnection(VMSUserName, VMSPassword, VMSjdbcUrl);

    UserAuthResp = verifyCredentials (vmsConn,username,password,channel);
    if(UserAuthResp.equals("1"))
    {
        lookupResp=lookUpSession (vmsConn, partyB, serviceID);
        if(!lookupResp.equals("-8"))
        {
            LA=getNewSessionLA(LA, sessionLA);
            correlationid = getCorrelationID (vmsConn);
            createSessResp=createSession(vmsConn, partyA, partyB, correlationid, serviceID,String.valueOf(LA));
            if(createSessResp.equals("1"))
            {
                sendSMSResp=sendSMS(partyB, partyBmessage, correlationid, serviceID, MTLA, createSessResp);
                if(sendSMSResp.equals("1"))
                    response="1";
            }
        }
    }
    logHistory (vmsConn, partyA, partyB, partyBmessage, correlationid, serviceID, LA, UserAuthResp, lookupResp, createSessResp, sendSMSResp,response);
    vmsConn.close();
    return response;
}


/**
 *
 * @param VMSUsername
 * @param VMSPassword
 * @param VMSUrl
 * @return
 * @throws SQLException
 */
public Connection createVMSConnection(String VMSUsername, String VMSPassword, String VMSUrl) throws SQLException
{
    Connection vmsConn = null;
    OracleDataSource vmsDS = new OracleDataSource();
    //vmsConn=null;
    try
    {
        vmsDS.setURL(VMSUrl);
        vmsConn = vmsDS.getConnection(VMSUsername, VMSPassword);
    }
    catch (SQLException ex)
    {

    }
    return vmsConn;
}

/**
 *
 * @param vmsConn
 * @param username
 * @param password
 * @param channel
 * @return
 * @throws SQLException
 */
public String verifyCredentials(Connection vmsConn, String username, String password, String channel) throws SQLException
{
    ResultSet rs = null;
    Statement stmt=null;
    String sql="";
    String response = "";
    try
    {
        stmt = vmsConn.createStatement();
        sql = "select * from lu_vms_wap_users where WAP_Uname = '"+username+"' and WAP_Pwd='"+password+"'and Channel ='"+channel+"' and status = '1'";
        rs = stmt.executeQuery(sql);
        if(rs.next())
        {
            response = "1";
        }
    }
    catch (SQLException ex)
    {
        response="-4";
    }

    return response;
}

/**
 *
 * @param vmsConn
 * @param partyB
 * @param serviceid
 * @return
 * @throws SQLException
 */
public String lookUpSession(Connection vmsConn, String partyB, String serviceid) throws SQLException
{
    ResultSet rs=null;
    Statement stmt=null;
    String sql="";
    String response="";
    try
    {
        stmt = vmsConn.createStatement();
        sql = "select LA from tbl_vms_wap_sessions where partyB='"+partyB+"' /*and serviceid='"+serviceid+"'*/ and status = '0' order by LA desc";
        rs = stmt.executeQuery(sql);
        if(rs.next())
        {
            response = rs.getString("LA");
        }
        else
            response = "0";
    }
    catch (SQLException ex)
    {
        response = "-8";
    }
    return response;
}

/**
 *
 * @param LA
 * @param sessionLA
 * @return
 */
public int getNewSessionLA(int LA, int sessionLA)
{
    if(LA == 0)
    {
        LA=sessionLA;
    }
    return LA + 1;
}

/**
 *
 * @param vmsConn
 * @return
 * @throws SQLException
 */
public int getCorrelationID(Connection  vmsConn) throws SQLException
{
    ResultSet rs=null;
    Statement stmt=null;
    String sql="";
    int ret=0;
    try
    {
        stmt = vmsConn.createStatement();
        sql = "select SEQ_TBLCPAMSGS_ID.nextval from dual";
        rs = stmt.executeQuery(sql);
        if(rs.next())
        {
            ret=Integer.parseInt(rs.getString(1));
            return ret;
        }
        else
            return 0;
    }
    catch (SQLException ex)
    {
        return -5;
    }
}

/**
 *
 * @param vmsConn
 * @param partyA
 * @param partyB
 * @param correlationid
 * @param serviceid
 * @param LA
 * @return
 * @throws SQLException
 */
public String createSession(Connection vmsConn, String partyA, String partyB, int correlationid, String serviceid, String LA) throws SQLException
{
    Statement stmt=null;
    String sql="";
    String response="1";
    try
    {
        stmt = vmsConn.createStatement();
        sql = "insert into tbl_vms_wap_sessions (id, partyA, partyB, correlationid, serviceid, LA, status) values (seq_vms_wap_session.nextval, '"+partyA+"','"+partyB+"','"+correlationid+"','"+ serviceid+"','"+ LA+"','0')";
        stmt.executeQuery(sql);
    }
    catch (SQLException ex)
    {
        response="-5";
    }

    return response;
}

/**
 *
 * @param vmsConn
 * @param partyA
 * @param partyB
 * @param partyBmessage
 * @param correlationid
 * @param serviceid
 * @param LA
 * @param UserAuthResp
 * @param lookupResp
 * @param createSessResp
 * @param sendSMSResp
 * @param ReturnCode
 * @return
 * @throws SQLException
 */
public String logHistory(Connection vmsConn, String partyA, String partyB, String partyBmessage, int correlationid, String serviceid, int LA, String UserAuthResp, String lookupResp, String createSessResp, String sendSMSResp, String ReturnCode)  throws SQLException
{
    Statement stmt=null;
    String sql="";
    String response="1";
    try
    {
        stmt = vmsConn.createStatement();
   开发者_JAVA百科     sql = "insert into tbl_vms_wap_hist (id, partyA, partyB, partyBmessage, correlationid, serviceid, LA, UserAuthResp, lookupResp, createSessResp, sendSMSResp, ReturnCode) values (seq_vms_wap_history.nextval, '"+partyA+"','"+partyB+"','"+partyBmessage+"','"+correlationid+"','"+ serviceid+"','"+ LA+"','"+UserAuthResp+"','"+lookupResp+"','"+createSessResp+"','"+sendSMSResp+"','"+ReturnCode+"')";
        stmt.executeQuery(sql);
    }
    catch (SQLException ex)
    {
        response="-5";
    }

    return response;
}

/**
 *
 * @param partyB
 * @param partyBmessage
 * @param correlationid
 * @param serviceid
 * @param MTLA
 * @param ErrorCode
 * @return
 */
public String sendSMS(String partyB, String partyBmessage, int correlationid, String serviceid, String MTLA, String ErrorCode)
{
   URL url=null;
   URLConnection connection=null;
   PrintStream outStream=null;
   InputStreamReader isr=null;
   BufferedReader inStream=null;
   String cgi_Response="";
   String inputLine="";

       try{
            url = new URL(sendSMSUrl);
            connection = url.openConnection();
            connection.setDoOutput(true);
            connection.setUseCaches(false);
            outStream = new PrintStream(connection.getOutputStream());
            outStream.println((new StringBuilder()).append("to=").append(URLEncoder.encode(partyB, "UTF-8")).append("&from=").append(URLEncoder.encode(xmsFrom, "UTF-8")).append("&service=").append(URLEncoder.encode(String.valueOf(serviceid), "UTF-8")).append("&LA=").append(URLEncoder.encode(MTLA, "UTF-8")).append("&message=").append(URLEncoder.encode(partyBmessage, "UTF-8")).append("&correlationID=").append(URLEncoder.encode(String.valueOf(correlationid), "UTF-8")).append("&serviceID=").append(URLEncoder.encode(String.valueOf(serviceid), "UTF-8")).append("&mode=").append(URLEncoder.encode(String.valueOf(mode), "UTF-8")).append("&tid=").append(URLEncoder.encode(String.valueOf(tID), "UTF-8")).toString());
            outStream.flush();
            outStream.close();
            isr = new InputStreamReader(connection.getInputStream());
            inStream = new BufferedReader(isr);

            cgi_Response = "";
            while ((inputLine = inStream.readLine())!=null){
                cgi_Response = cgi_Response+inputLine;
            }
        }
        catch (Exception ex)
        {

        }
        return cgi_Response;
}

private void LoadParameters(){
    String Token=null;
    String fileLine=null;

    try{
        FileReader fr= new FileReader(parameterFile);
        BufferedReader br= new BufferedReader(fr);
        //open file
        do{//while not end of file
        //read from file
            fileLine=br.readLine();
            if (fileLine!=null){
                //tokenize the line read
                StringTokenizer st= new StringTokenizer(fileLine);
                //get first token
                Token=st.nextToken("=");
                if (Token.equals("VMSUserName")){
                    VMSUserName =st.nextToken();
                }else if (Token.equals("VMSPassword")){
                    VMSPassword =st.nextToken();
                }else if (Token.equals("VMSjdbcUrl")){
                    VMSjdbcUrl =st.nextToken();
                }else if (Token.equals("sendSMSUrl")){
                sendSMSUrl =st.nextToken();
                }else if (Token.equals("xmsFrom")){
                    xmsFrom =st.nextToken();
                }else if (Token.equals("MTLA")){
                    MTLA =st.nextToken();
                }else if (Token.equals("TID")){
                    tID =st.nextToken();
                }else if (Token.equals("MODE")){
                    mode =st.nextToken();
                }else if (Token.equals("sessionLA")){
                    sessionLA =Integer.parseInt(st.nextToken());
                }else if (Token.equals("partyBmessage")){
                    partyBmessage = st.nextToken();
                }
            }
        }
        while(fileLine!=null);
        br.close();
    }catch(FileNotFoundException e){

    }catch(IOException e){

    }
}

}


It seems that you try to serialize a Connection to XML which leads to

java.sql.Connection is an interface, and JAXB can't handle interfaces.

Check your annotations, if you don't find the problem, you should append the code to your question.


In createVMSConnection, if you get a SQLException on the lines:

vmsDS.setURL(VMSUrl);
vmsConn = vmsDS.getConnection(VMSUsername, VMSPassword);

then the exception is not shown and the method returns null instead of a connection. This could cause trouble.

You should log exceptions or leave a short comment, if there's no need to implement the catch clause.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜