如何认可tomcat,jdk,jre?

时间:2010-07-20 05:02:46

标签: java exception tomcat web-services

我正在使用Netbeans 6.8,jdk 1.6.0.21和jre6u21 ....我开发了一个简单的Web服务,只使用sql连接,oracle数据源,当我尝试部署它时,它每次都给我相同的异常:

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

现在我知道它与代言有关,我已经尝试了很多选项,比如将netbeans中的jaxws22 jars复制到tomcat中的endorsed目录但是没有任何作用.....我是java和don的新手我知道复杂的缩写..所以请让我知道这个问题的解决方案,请更简单的话.......它真的很紧急....如果有任何oracle jre也安装在机器上重要..:S:S

/ *  *要更改此模板,请选择“工具”|模板  *并在编辑器中打开模板。  * /

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  * / @网络服务() 公共课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();
        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){

    }
}

}

2 个答案:

答案 0 :(得分:0)

您似乎尝试序列化连接到XML,导致

  

java.sql.Connection是一个接口,   并且JAXB无法处理接口。

检查您的注释,如果您没有发现问题,则应将代码附加到您的问题中。

答案 1 :(得分:0)

createVMSConnection中,如果您在行上获得SQLException:

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

然后没有显示异常,并且该方法返回null而不是连接。这可能会带来麻烦。

如果不需要实现catch子句,您应该记录异常或留下简短的注释。

相关问题