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 James Black <jb...@ieee.org> on 2003/05/02 17:26:10 UTC

Re: servlets and services

eddie johnston wrote:

>No problems here, in a java application, but when I try and do the same in a servlet, I get the exception detailed below.
>It something to do with the engine Configuration (?), but how do I configure the engine etc? The source code is at the bottom of this message, it will run
>from the command line but not successfully as a servlet.
>I'd really appreciate some pointers on this hopefully straightforward problem!
>
  Looks like the servlet can't find the jar files needed for axis.

  Tomcat gives lousy error messages, but you may want to look in 
$TOMCAT_HOME/logs, esp at catalina.out, for any other messages that may 
have been printed, that may be helpful.

-- 
"We do not lose our identity in our relations with others; in part, at least, we achieve our identity by those relations." Tony Blair, 1993




Re: servlets and services

Posted by Andrew Vardeman <an...@iastate.edu>.
Are you saying you unjarred the jars and put the contents in /lib?  Tomcat 
expects .jar or .zip files in the /lib directory and unjarred classes in 
the /classes directory...

Also, I don't remember the exact circumstances under which this pops up, 
but a combination of certain Java (1.4.0?) versions with certain Tomcat 
versions keeps Tomcat from loading javax.* classes from the Axis jars 
unless they're in a special directory in the Tomcat root.  Something about 
"java endorsed dirs."

>Here's the output from log file: It seems to be a
>java.lang.ExceptionInInitializerError, I'm not sure that it's a problem
>with an unfound jar file as I've expanded all of the relevant jars in
>/lib.




Re: servlets and services

Posted by James Black <jb...@ieee.org>.
eddie johnston wrote:

>Here's the output from log file: It seems to be a
>java.lang.ExceptionInInitializerError, I'm not sure that it's a problem
>with an unfound jar file as I've expanded all of the relevant jars in
>/lib. 
>
>Thanks for the reply though, any more clues!?
>
  Try putting the axis jar files in JAVA_HOME/jre/lib/ext and all the 
java applications will find it. Then, restart the tomcat server.

  Hopefully you have the web service client as a bean, and you have used 
it in a command-line program for debugging, and then just reused the 
bean in the servlet.
  I have found it best to have classes I can test and reuse.

  You can also try using the cactus framework, 
http://jakarta.apache.org/cactus/index.html, and use unit testing. I 
haven't tried this yet, but it is on my list of things to do. <g>

-- 
"We do not lose our identity in our relations with others; in part, at least, we achieve our identity by those relations." Tony Blair, 1993




servlets and services - desperate!

Posted by eddie johnston <ed...@ucd.ie>.
Aargh!!! 
	I've tried all of the suggestions from those who replied (thanks very
much by the way, I do appreciate the help and pointers!), but
unfortunately I'm still getting the error - "Unable to locate a valid
EngineConfigurationFactory" in my logs. There were some suggestions that
tomcat might not be able to find some classes, but I'm pretty sure that
it's something different thats the matter. The init methods below looks
like it should create that EngineConfigurationFactory, and I think that
its probably similar to what I should have, but I don't want to deploy a
service, just use one! Is there something obvious I'm missing (I'm quite
new to axis) - the code below points to a deploy.wsdd file, should I be
pointing to a similar file, only one used for consuming services that
are already deployed (I tried substituting the file below with the
client-deploy.wsdd but it still didn't work :-(

yours in frustration!
Eddie

On Fri, 2003-05-02 at 20:19, Sree Pillai wrote:
> Well.. I took the same code from the archives (thanks
> to somebody!) and was able to deploy a webservice as
> part of the init method. 
> 
> Here it goes - part of my DeploymentServlet.
> 
>     /** Initializes the servlet.
>      */
>     public void init(ServletConfig sconfig) throws
> ServletException {
>        super.init(sconfig);
> 		AxisServlet axisServlet = new AxisServlet();
>        ServletConfig sc = getServletConfig();
>        ServletContext context =
> this.getServletContext();
>        try {
>            axisServlet.init( sc );
>        } catch (ServletException e) {
> 		   getServletContext().log( "Exception " +
> e.toString() );
>        }
>        try {
>            AxisEngine engine =
> axisServlet.getEngine();
> 
>            String[] services = {"EnrollmentService"};
> 
>            for(int i=0; i<services.length; i++)
>            {
>                URL deployURL =
> context.getResource("/wsdd/"+services[i]+"-deploy.wsdd");
> 
> 				DocumentBuilderFactory dfactory =
> DocumentBuilderFactory.newInstance();
> 				DocumentBuilder docBuilder =
> dfactory.newDocumentBuilder();
> 				dfactory.setNamespaceAware(true);
> 				Document doc = docBuilder.parse(new InputSource(
> deployURL.toExternalForm()) );
> 
>                Element element =
> doc.getDocumentElement();
>                WSDDDocument wsddDoc = new
> WSDDDocument(element);
>                EngineConfiguration config =
> (EngineConfiguration)engine.getConfig();
> 
>                if ( config instanceof
> WSDDEngineConfiguration) {
>                    WSDDDeployment deployment =
> ((WSDDEngineConfiguration)config).getDeployment();
>                    wsddDoc.deploy(deployment);
>                }
>                engine.refreshGlobalOptions();
>                engine.saveConfiguration();
>            }
>        }
>        catch (Exception e) {
> 		   getServletContext().log( "Exception " +
> e.toString() );
>        }
>     }
> 
> 
> 
> 
> 
> 
> --- eddie johnston <ed...@ucd.ie> wrote:
> > I found something that may be relevant to the
> > problem I'm having in the archives.
> > As far as I can piece together, I have to use or
> > create an engine configuration when using 
> > axis with a servlet.I thought perhaps that the
> > adding the init method below to my servlet might
> > create an engine, but I'm stabbing blindly at this!
> > It doesn't work either. Would anyone 
> > know how I should go about creating (or retrieving)
> > an engine configuration for axis
> > so that I can use it with my servlet ? 
> > 
> > 
> > public void init(ServletConfig sconfig) throws
> > ServletException {
> >         super.init(sconfig);
> >         AxisServlet axisServlet = new AxisServlet();
> >         ServletConfig sC = getServletConfig();
> >         ServletContext context =
> > this.getServletContext();
> >         try{axisServlet.init(sC);}
> > catch(ServletException e){ e.printStackTrace(); }
> >         try{
> >             AxisEngine engine =
> > axisServlet.getEngine();
> >             EngineConfiguration config =
> > (EngineConfiguration)engine.getConfig();
> >             engine.refreshGlobalOptions();
> >             engine.saveConfiguration();
> >         }
> >         catch(Exception e){
> >             e.printStackTrace();
> >         }
> >     }
> > }
> > 
> 
> 
> __________________________________
> Do you Yahoo!?
> The New Yahoo! Search - Faster. Easier. Bingo.
> http://search.yahoo.com
-- 
~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
Once in a while you get shown the Light,
In the Strangest of places if you look at it right
Grateful Dead, Scarlet Begonias


Re: servlets and services

Posted by Sree Pillai <sr...@yahoo.com>.
Well.. I took the same code from the archives (thanks
to somebody!) and was able to deploy a webservice as
part of the init method. 

Here it goes - part of my DeploymentServlet.

    /** Initializes the servlet.
     */
    public void init(ServletConfig sconfig) throws
ServletException {
       super.init(sconfig);
		AxisServlet axisServlet = new AxisServlet();
       ServletConfig sc = getServletConfig();
       ServletContext context =
this.getServletContext();
       try {
           axisServlet.init( sc );
       } catch (ServletException e) {
		   getServletContext().log( "Exception " +
e.toString() );
       }
       try {
           AxisEngine engine =
axisServlet.getEngine();

           String[] services = {"EnrollmentService"};

           for(int i=0; i<services.length; i++)
           {
               URL deployURL =
context.getResource("/wsdd/"+services[i]+"-deploy.wsdd");

				DocumentBuilderFactory dfactory =
DocumentBuilderFactory.newInstance();
				DocumentBuilder docBuilder =
dfactory.newDocumentBuilder();
				dfactory.setNamespaceAware(true);
				Document doc = docBuilder.parse(new InputSource(
deployURL.toExternalForm()) );

               Element element =
doc.getDocumentElement();
               WSDDDocument wsddDoc = new
WSDDDocument(element);
               EngineConfiguration config =
(EngineConfiguration)engine.getConfig();

               if ( config instanceof
WSDDEngineConfiguration) {
                   WSDDDeployment deployment =
((WSDDEngineConfiguration)config).getDeployment();
                   wsddDoc.deploy(deployment);
               }
               engine.refreshGlobalOptions();
               engine.saveConfiguration();
           }
       }
       catch (Exception e) {
		   getServletContext().log( "Exception " +
e.toString() );
       }
    }






--- eddie johnston <ed...@ucd.ie> wrote:
> I found something that may be relevant to the
> problem I'm having in the archives.
> As far as I can piece together, I have to use or
> create an engine configuration when using 
> axis with a servlet.I thought perhaps that the
> adding the init method below to my servlet might
> create an engine, but I'm stabbing blindly at this!
> It doesn't work either. Would anyone 
> know how I should go about creating (or retrieving)
> an engine configuration for axis
> so that I can use it with my servlet ? 
> 
> 
> public void init(ServletConfig sconfig) throws
> ServletException {
>         super.init(sconfig);
>         AxisServlet axisServlet = new AxisServlet();
>         ServletConfig sC = getServletConfig();
>         ServletContext context =
> this.getServletContext();
>         try{axisServlet.init(sC);}
> catch(ServletException e){ e.printStackTrace(); }
>         try{
>             AxisEngine engine =
> axisServlet.getEngine();
>             EngineConfiguration config =
> (EngineConfiguration)engine.getConfig();
>             engine.refreshGlobalOptions();
>             engine.saveConfiguration();
>         }
>         catch(Exception e){
>             e.printStackTrace();
>         }
>     }
> }
> 


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

Re: servlets and services

Posted by eddie johnston <ed...@ucd.ie>.
I found something that may be relevant to the problem I'm having in the archives.
As far as I can piece together, I have to use or create an engine configuration when using 
axis with a servlet.I thought perhaps that the adding the init method below to my servlet might
create an engine, but I'm stabbing blindly at this! It doesn't work either. Would anyone 
know how I should go about creating (or retrieving) an engine configuration for axis
so that I can use it with my servlet ? 


public void init(ServletConfig sconfig) throws ServletException {
        super.init(sconfig);
        AxisServlet axisServlet = new AxisServlet();
        ServletConfig sC = getServletConfig();
        ServletContext context = this.getServletContext();
        try{axisServlet.init(sC);} catch(ServletException e){ e.printStackTrace(); }
        try{
            AxisEngine engine = axisServlet.getEngine();
            EngineConfiguration config = (EngineConfiguration)engine.getConfig();
            engine.refreshGlobalOptions();
            engine.saveConfiguration();
        }
        catch(Exception e){
            e.printStackTrace();
        }
    }
}


Re: servlets and services

Posted by eddie johnston <ed...@ucd.ie>.
On Fri, 2003-05-02 at 15:26, James Black wrote:
> eddie johnston wrote:
> 
> >No problems here, in a java application, but when I try and do the same in a servlet, I get the exception detailed below.
> >It something to do with the engine Configuration (?), but how do I configure the engine etc? The source code is at the bottom of this message, it will run
> >from the command line but not successfully as a servlet.
> >I'd really appreciate some pointers on this hopefully straightforward problem!
> >
>   Looks like the servlet can't find the jar files needed for axis.
> 
>   Tomcat gives lousy error messages, but you may want to look in 
> $TOMCAT_HOME/logs, esp at catalina.out, for any other messages that may 
> have been printed, that may be helpful.

Here's the output from log file: It seems to be a
java.lang.ExceptionInInitializerError, I'm not sure that it's a problem
with an unfound jar file as I've expanded all of the relevant jars in
/lib. 

Thanks for the reply though, any more clues!?
Eddie

2003-05-02 17:12:26 myproblem: init
2003-05-02 17:12:26 StandardWrapperValve[myproblem]: Servlet.service() for servlet myproblem threw exception
javax.servlet.ServletException: Servlet execution threw an exception
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
        at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java)
        at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
        at java.lang.Thread.run(Thread.java:536)
----- Root Cause -----
java.lang.ExceptionInInitializerError
        at org.apache.axis.utils.Messages.<clinit>(Messages.java:75)
        at org.apache.axis.configuration.FileProvider.configureEngine(FileProvider.java:205)
        at org.apache.axis.AxisEngine.init(AxisEngine.java:186)
        at org.apache.axis.AxisEngine.<init>(AxisEngine.java:171)
        at org.apache.axis.client.AxisClient.<init>(AxisClient.java:88)
        at org.apache.axis.client.Service.getAxisClient(Service.java:140)
        at org.apache.axis.client.Service.<init>(Service.java:182)
        at Problem.doGet(Unknown Source)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	...	
	...