You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-users@xml.apache.org by gilles <gi...@ign.fr> on 2005/01/25 17:03:37 UTC

loading xindice servlet configuration under cocoon

Hi,

Trying to deploy cocoon (2.1.6) webapp under an already installed jetty 
server (5.1.1), I met some problems with Xindice (1.1b4) servlet
configuration embedded in cocoon.

I had error messages saying that the configuration file of xindice
could not be loaded (the trace is listed below).

The Xindice servlet declaration in web.xml is as follow :

----
  <servlet>
    <servlet-name>Xindice</servlet-name>
    <display-name>Xindice XML-RPC Server</display-name>
    <servlet-class>org.apache.xindice.server.XindiceServlet</servlet-class>
    <init-param>
      <param-name>xindice.configuration</param-name>
      <param-value>WEB-INF/xindice.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
----

I had a look at Xindice source code and found that the
following statement in  org/apache/xindice/server/XindiceServlet.java
,loadConfiguration() method  (near line #240) :

------

  String path = servletConfig.getInitParameter(Xindice.PROP_XINDICE_CONFIGURA
TION);
  if (path != null) {
    InputStream inputStream = null;
    if (path.startsWith("/")) {
        // Absolute file path
        ...
     } else {
        // Relative (to the context) path
        log.debug("Loading configuration from context path " + path) ;
        ServletContext context = servletConfig.getServletContext();
        inputStream = context.getResourceAsStream(path);
     }
    ...
  }
-------
returned a null InputStream when the path is relative, causing the error
messages...

I changed the line 

----
inputStream = context.getResourceAsStream(path) ;
----

by

----
inputStream = new FileInputStream(context.getRealPath(path)) ;
----

And the loading of Xindice servlet configuration file now works fine.

I don't know if this modification is accurate, but it solved my problem.
I join the modified XindiceServlet.java to this mail if someone is
interested in it...

Cheers

Gilles


P.S. : Here is (part of) the trace I had in jetty logs at startup :

-----
14:46:04.770 WARN!! [main] org.mortbay.jetty.Server.main(Server.java:438) >08> 
EXCEPTION
org.mortbay.util.MultiException[org.apache.xindice.util.ConfigurationException: 
Failed to load configuration.]
        at org.mortbay.http.HttpServer.doStart(HttpServer.java:673)
        at org.mortbay.util.Container.start(Container.java:72)
        at org.mortbay.jetty.Server.main(Server.java:433)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at org.mortbay.start.Main.invokeMain(Main.java:151)
        at org.mortbay.start.Main.start(Main.java:480)
        at org.mortbay.start.Main.main(Main.java:94)
org.apache.xindice.util.ConfigurationException: Failed to load configuration.
        at 
org.apache.xindice.server.XindiceServlet.loadConfiguration(XindiceServlet.java:273)
        at 
org.apache.xindice.server.XindiceServlet.init(XindiceServlet.java:103)
        at 
org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:369)
        at 
org.mortbay.jetty.servlet.ServletHolder.start(ServletHolder.java:243)
        at 
org.mortbay.jetty.servlet.ServletHandler.initializeServlets(ServletHandler.java:445)
        at 
org.mortbay.jetty.servlet.WebApplicationHandler.initializeServlets(WebApplicationHandler.java:310)
        at 
org.mortbay.jetty.servlet.WebApplicationContext.doStart(WebApplicationContext.java:512)
        at org.mortbay.util.Container.start(Container.java:72)
        at org.mortbay.http.HttpServer.doStart(HttpServer.java:695)
        at org.mortbay.util.Container.start(Container.java:72)
        at org.mortbay.jetty.Server.main(Server.java:433)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at org.mortbay.start.Main.invokeMain(Main.java:151)
        at org.mortbay.start.Main.start(Main.java:480)
        at org.mortbay.start.Main.main(Main.java:94)
Caused by: java.lang.NullPointerException
        at 
org.apache.xindice.server.XindiceServlet.loadConfiguration(XindiceServlet.java:261)
...
-----



Re: loading xindice servlet configuration under cocoon

Posted by gilles <gi...@ign.fr>.
Oooops, it seems I haven't browsed the right web resources before
posting !
sory

Gilles



Le Mardi 25 Janvier 2005 17:45, Tim Larson a écrit :
> On Tue, Jan 25, 2005 at 05:03:37PM +0100, gilles wrote:
> > Hi,
> >
> > Trying to deploy cocoon (2.1.6) webapp under an already installed jetty
> > server (5.1.1), I met some problems with Xindice (1.1b4) servlet
> > configuration embedded in cocoon.
> >
> > I had error messages saying that the configuration file of xindice
> > could not be loaded (the trace is listed below).
>
> Since you are using Jetty 5.x, this bug may apply:
>   http://issues.apache.org/bugzilla/show_bug.cgi?id=30891
> It says this is fixed in cvs, but not in any released versions yet:
>  
> http://cvs.apache.org/viewcvs.cgi/xml-xindice/java/src/org/apache/xindice/s
>erver/XindiceServlet.java?r1=1.30&r2=1.31&diff_format=h
>
>
> HTH,
> --Tim Larson


Re: loading xindice servlet configuration under cocoon

Posted by Tim Larson <ti...@keow.org>.
On Tue, Jan 25, 2005 at 05:03:37PM +0100, gilles wrote:
> Hi,
> 
> Trying to deploy cocoon (2.1.6) webapp under an already installed jetty 
> server (5.1.1), I met some problems with Xindice (1.1b4) servlet
> configuration embedded in cocoon.
> 
> I had error messages saying that the configuration file of xindice
> could not be loaded (the trace is listed below).

Since you are using Jetty 5.x, this bug may apply:
  http://issues.apache.org/bugzilla/show_bug.cgi?id=30891
It says this is fixed in cvs, but not in any released versions yet:
  http://cvs.apache.org/viewcvs.cgi/xml-xindice/java/src/org/apache/xindice/server/XindiceServlet.java?r1=1.30&r2=1.31&diff_format=h


HTH,
--Tim Larson