You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Eric Carlson <er...@group-technical.com> on 2004/03/09 19:55:03 UTC
Same client works as console app, fails as a servlet...
Servlet engine is Resin 2.12. Client code from console version:
public class Translate {
public static void main(String args[]) throws Exception {
try {
TranslationServiceSoapStub service
= new TranslationServiceSoapStub(
new
URL("http://www.webservicex.com/TranslateService.asmx"),
new org.apache.axis.client.Service());
System.out.println(service.translate(new
Language(args[0]), args[1]));
} catch (Exception e) {
e.printStackTrace();
}
} // main
}
Client code from Servlet:
public void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title></title></head>");
out.println("<body>");
try {
TranslationServiceSoapStub service
= new TranslationServiceSoapStub(
new
URL("http://www.webservicex.com/TranslateService.asmx"),
new org.apache.axis.client.Service());
String value = service.translate(new Language(mode),
source);
out.println(value);
cat.debug("Result: "+value);
} catch (Exception e) {
e.printStackTrace();
}
out.println("</body></html>");
}
And what I get is this:
java.lang.NoClassDefFoundError
com.myclient.soap.TranslateServlet.doPost(TranslateServlet.java:50)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:165)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
at
com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96)
at
com.caucho.server.http.Invocation.service(Invocation.java:315)
at
com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at
com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:246)
at
com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:164)
at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
at java.lang.Thread.run(Thread.java:534)
I know its failing at this call:
new org.apache.axis.client.Service();
Because when I explicitly bring it out like this:
org.apache.axis.client.Service srv = new
org.apache.axis.client.Service();
I start getting this :
java.lang.NoClassDefFoundError
at
org.apache.axis.client.Service.getAxisClient(Service.java:143)
at org.apache.axis.client.Service.<init>(Service.java:152)
All the right libraries are in the lib dir and it builds ok. Has
anyone seen this before please? Thanks in advance...
Re: Same client works as console app, fails as a servlet...
Posted by Eric Carlson <er...@group-technical.com>.
This is now fixed. For reference, there is a conflict between the XML
parser supplied with resin and the one axis uses. I downloaded the
latest Xerces and set the resin property to use it rather than the
default one and the code started working.
On Tue, 09 Mar 2004 18:55:03 +0000, you wrote:
>Servlet engine is Resin 2.12. Client code from console version:
>
>public class Translate {
>
> public static void main(String args[]) throws Exception {
> try {
> TranslationServiceSoapStub service
> = new TranslationServiceSoapStub(
> new
>URL("http://www.webservicex.com/TranslateService.asmx"),
> new org.apache.axis.client.Service());
>
> System.out.println(service.translate(new
>Language(args[0]), args[1]));
> } catch (Exception e) {
> e.printStackTrace();
> }
>
> } // main
>}
>
>Client code from Servlet:
>
> public void doPost(HttpServletRequest request, HttpServletResponse
>response) throws ServletException, IOException {
>
> response.setContentType(CONTENT_TYPE);
> PrintWriter out = response.getWriter();
> out.println("<html>");
> out.println("<head><title></title></head>");
> out.println("<body>");
> try {
> TranslationServiceSoapStub service
> = new TranslationServiceSoapStub(
> new
>URL("http://www.webservicex.com/TranslateService.asmx"),
> new org.apache.axis.client.Service());
>
> String value = service.translate(new Language(mode),
>source);
>
> out.println(value);
>
> cat.debug("Result: "+value);
>
> } catch (Exception e) {
> e.printStackTrace();
> }
> out.println("</body></html>");
> }
>
>And what I get is this:
>
>java.lang.NoClassDefFoundError
>com.myclient.soap.TranslateServlet.doPost(TranslateServlet.java:50)
> at
>javax.servlet.http.HttpServlet.service(HttpServlet.java:165)
> at
>javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
> at
>com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96)
> at
>com.caucho.server.http.Invocation.service(Invocation.java:315)
> at
>com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
> at
>com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:246)
> at
>com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:164)
> at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
> at java.lang.Thread.run(Thread.java:534)
>
>I know its failing at this call:
>
>new org.apache.axis.client.Service();
>
>Because when I explicitly bring it out like this:
> org.apache.axis.client.Service srv = new
>org.apache.axis.client.Service();
>
>I start getting this :
>
>java.lang.NoClassDefFoundError
> at
>org.apache.axis.client.Service.getAxisClient(Service.java:143)
> at org.apache.axis.client.Service.<init>(Service.java:152)
>
>All the right libraries are in the lib dir and it builds ok. Has
>anyone seen this before please? Thanks in advance...
>
>