javax.xml.bind.JAXBException..whats the solution?
843833Feb 8 2008 — edited Mar 17 2008I have created a webservice using NetBean IDE and have Sun Application Server 9.1.
when i am testing service using Test option in admin console I am getting following error ;
Service invocation threw an exception with message : null; Refer to the server log for more details
The server log file shows following errors;
Caused by: javax.xml.bind.JAXBException: class data.emp nor any of its super class is known to this context.
at com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:242)
at com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:257)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:649)
at com.sun.xml.bind.v2.runtime.property.ArrayElementNodeProperty.serializeItem(ArrayElementNodeProperty.java:65)
at com.sun.xml.bind.v2.runtime.property.ArrayElementProperty.serializeListBody(ArrayElementProperty.java:168)
at com.sun.xml.bind.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:152)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:322)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:681)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:277)
... 40 more
I have used following class ,
package data;
import java.io.Serializable;
public class emp implements Serializable {
public String empnm;
public String empid;
public emp(String empid, String empnm) {
this.empid=empid;
this.empnm=empnm;
}
}
and my webservice class is as follows,
package data;
import java.util.ArrayList;
import javax.jws.WebMethod;
import javax.jws.WebService;
import java.sql.*;
@WebService()
public class empDataService {
@WebMethod
public ArrayList show() {
ArrayList<emp> empArray = new ArrayList<emp>();
Connection con;
ResultSet rs;
Statement stmt;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = null;
con = DriverManager.getConnection("jdbc:odbc:EMPINFO");
stmt = con.createStatement();
rs = stmt.executeQuery("select * from emp");
while(rs.next())
{
//emp obj=new emp();
//obj.empid=rs.getString(1);
//obj.empnm=rs.getString(2);
empArray.add(new emp(rs.getString(1),rs.getString(2)));
}
}
catch(Exception e)
{
}
return empArray;
}
}
Will any one please reply me what the cause and solution ..