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 Reynardine <re...@loveable.com> on 2002/10/31 15:57:32 UTC
Problem consuming web services from a servlet
Hi,
I am quite new to Axis and can deploy and test some simple services from the command line. I want to consume these services from a servlet.
For example, I've tried Eric Jung's example on
http://marc.theaimsgroup.com/?l=axis-user&m=102942726001805&w=2
I'm using Tomcat and 'normal' servlets work fine. But when I convert my Axis service test code to a servlet with Axis import statements I get run time errors when I run it from the browser. For example, my servlet is like this...
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import javax.xml.rpc.ParameterMode;
import javax.xml.namespace.QName;
import java.net.URL;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class StockQuoteServiceClient extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
PrintWriter out = response.getWriter();
Object o = request.getParameter("symbol");
Service service = new Service();
but running from a browser under Tomcat I get...
javax.servlet.ServletException: Cannot allocate servlet instance ...
java.lang.NoClassDefFoundError: org/apache/axis/client/Service
at java.lang.Class.newInstance0(Native Method)
Is my JVM wrong ? Do I need to change server.xml or web.xml ?
Any help appreciated..
- Rey
--
__________________________________________________________
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup
Re: Problem consuming web services from a servlet
Posted by Francisco Andrades Grassi <bi...@nextj.com>.
Greeting,
You need to add the axis related jars to the servlet runtime classpath
(ie: WEB-INF/lib). The NoClassDefFoundError implies that the class was
found at compile time but it's not found at runtime.
Regards
Francisco Andrades Grassi
www.NextJ.com
On Thu, 2002-10-31 at 10:57, Reynardine wrote:
> Hi,
>
> I am quite new to Axis and can deploy and test some simple services from the command line. I want to consume these services from a servlet.
>
> For example, I've tried Eric Jung's example on
> http://marc.theaimsgroup.com/?l=axis-user&m=102942726001805&w=2
>
> I'm using Tomcat and 'normal' servlets work fine. But when I convert my Axis service test code to a servlet with Axis import statements I get run time errors when I run it from the browser. For example, my servlet is like this...
>
> import org.apache.axis.client.Call;
> import org.apache.axis.client.Service;
> import org.apache.axis.encoding.XMLType;
> import javax.xml.rpc.ParameterMode;
> import javax.xml.namespace.QName;
> import java.net.URL;
> import java.io.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
> public class StockQuoteServiceClient extends HttpServlet {
> public void doPost(HttpServletRequest request, HttpServletResponse response)
> throws IOException, ServletException {
> PrintWriter out = response.getWriter();
> Object o = request.getParameter("symbol");
> Service service = new Service();
>
> but running from a browser under Tomcat I get...
>
> javax.servlet.ServletException: Cannot allocate servlet instance ...
> java.lang.NoClassDefFoundError: org/apache/axis/client/Service
> at java.lang.Class.newInstance0(Native Method)
>
> Is my JVM wrong ? Do I need to change server.xml or web.xml ?
>
> Any help appreciated..
>
> - Rey
> --
> __________________________________________________________
> Sign-up for your own FREE Personalized E-mail at Mail.com
> http://www.mail.com/?sr=signup
>
>
>
Re: Problem consuming web services from a servlet
Posted by Bahman Kalali <bk...@csg.uwaterloo.ca>.
I was actually trying to get the Eric's example work. Here is my problem:
1) I created the html form and saved it to
%CATALINA_HOME%/webapps/axis/GetStock.htm.
2) I created the StockQuoteServlet to handle form requests and call the Axis
StockQuoteService
3) I compiled the code and saved it in
%CATALINA_HOME%/webapps/axis/classes/StockQuoteServlet.class
4) I adjusted the %CATALINA_HOME$/webapps/axis/WEB-INF/web.xml to start
StockQuoteServlet in addition to Axis, and to map /quote URIs to the
StockQuoteServlet:
Here are two ways that I did this adjustment. In both cases Tomcat gives me
the following erros.
4.1) I copied what Eric suggested into the web.xml.
<servlet>
<servlet-name>StockQuoteServlet</servlet-name>
<servlet-class>StockQuoteServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>StockQuoteServlet</servlet-name>
<url-pattern>/quote</url-pattern>
</servlet-mapping>
4.2) I tried to adust the web.xml in my way, but still Tomcat gives the same
errors.
<servlet>
<servlet-name>quote</servlet-name>
<servlet-class>StockQuoteServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>quote</servlet-name>
<url-pattern>/servlet/StockQuoteServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>quote</servlet-name>
<url-pattern>/quote/*</url-pattern>
</servlet-mapping>
Here is the Tomcat's errors
[INFO] Registry - -Loading registry information
[INFO] Registry - -Creating new Registry instance
[INFO] Registry - -Creating MBeanServer
[INFO] Http11Protocol - -Initializing Coyote HTTP/1.1 on port 8080
Starting service Tomcat-Standalone
Apache Tomcat/4.1.10
org.xml.sax.SAXParseException: The content of element type "web-app" must
match
"(icon?,display-name?,description?,distributable?,context-param*,servlet*,se
rvle
t-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,tagl
ib*,
resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,e
jb-r
ef*)".
at
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Er
rorHandlerWrapper.java:232)
at
org.apache.xerces.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.
java:173)
at
org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.
java:362)
at
org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.
java:296)
I really appreciate to help me on this.
Regards,
---Bahman
----- Original Message -----
From: " Reynardine" <re...@loveable.com>
To: <ax...@xml.apache.org>
Sent: Thursday, October 31, 2002 9:57 AM
Subject: Problem consuming web services from a servlet
> Hi,
>
> I am quite new to Axis and can deploy and test some simple services from
the command line. I want to consume these services from a servlet.
>
> For example, I've tried Eric Jung's example on
> http://marc.theaimsgroup.com/?l=axis-user&m=102942726001805&w=2
>
> I'm using Tomcat and 'normal' servlets work fine. But when I convert my
Axis service test code to a servlet with Axis import statements I get run
time errors when I run it from the browser. For example, my servlet is like
this...
>
> import org.apache.axis.client.Call;
> import org.apache.axis.client.Service;
> import org.apache.axis.encoding.XMLType;
> import javax.xml.rpc.ParameterMode;
> import javax.xml.namespace.QName;
> import java.net.URL;
> import java.io.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
> public class StockQuoteServiceClient extends HttpServlet {
> public void doPost(HttpServletRequest request, HttpServletResponse
response)
> throws IOException, ServletException {
> PrintWriter out = response.getWriter();
> Object o = request.getParameter("symbol");
> Service service = new Service();
>
> but running from a browser under Tomcat I get...
>
> javax.servlet.ServletException: Cannot allocate servlet instance ...
> java.lang.NoClassDefFoundError: org/apache/axis/client/Service
> at java.lang.Class.newInstance0(Native Method)
>
> Is my JVM wrong ? Do I need to change server.xml or web.xml ?
>
> Any help appreciated..
>
> - Rey
> --
> __________________________________________________________
> Sign-up for your own FREE Personalized E-mail at Mail.com
> http://www.mail.com/?sr=signup
>