You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Darryl <da...@vis.co.za> on 2001/03/23 10:16:00 UTC

Newbie Problem with Struts Configuration, I think...

Hi all,

I was wondering whether you could look at this stack trace below and see
if you
see anything that you've encountered before. I'm running Orion Server
1.4.5 and I wouldn't expect there to be a problem with JNDI. (see stack
trace line re: unknown protocol: jndi)
They (Orion) don't specify any setup needed for JNDI to be running as a
service. Furthermore, I've checked the struts-config.xml and it
seems fine. I've pasted it in below the stack trace.

I'd appreciate any help you could offer because I've been wrestling with
this thing for some time now and can't seem to find any
problems. My JSP form action works the same (i.e. breaks) whether I'm
using 'login.do' or '/login.do'.

thanks again,
Darryl

Stack Trace:

     3/23/01 10:55 AM Started
     3/23/01 10:58 AM login-web: org.apache.struts.action.ActionServlet:
init
     3/23/01 10:58 AM login-web: Error preloading servlet
     javax.servlet.ServletException: Parsing error processing resource
path /WEB-INF/struts-config.xml
             at
org.apache.struts.action.ActionServlet.initMapping(ActionServlet.java:1306)

             at
org.apache.struts.action.ActionServlet.init(ActionServlet.java:465)
             at
javax.servlet.GenericServlet.init(GenericServlet.java:232)
             at com.evermind.server.http.HttpApplication.w1(JAX)
             at com.evermind.server.http.HttpApplication.wj(JAX)
             at com.evermind.server.http.HttpApplication.wu(JAX)
             at com.evermind.server.http.HttpApplication.v4(JAX)
             at com.evermind.server.http.HttpApplication.<init>(JAX)
             at com.evermind.server.Application.ur(JAX)
             at com.evermind.server.http.el.ur(JAX)
             at com.evermind.server.http.ek.nm(JAX)
             at com.evermind.server.http.ef.s1(JAX)
             at com.evermind.server.http.ef.do(JAX)
             at com.evermind.util.f.run(JAX)
     Root cause is; java.net.MalformedURLException: unknown protocol:
jndi
             at
org.apache.struts.digester.Digester.resolveEntity(Digester.java:581)
             at
com.sun.xml.parser.ExternalEntity.getInputSource(ExternalEntity.java:46)

             at com.sun.xml.parser.Parser.pushReader(Parser.java:2768)
             at
com.sun.xml.parser.Parser.externalParameterEntity(Parser.java:2504)
             at
com.sun.xml.parser.Parser.maybeDoctypeDecl(Parser.java:1137)
             at com.sun.xml.parser.Parser.parseInternal(Parser.java:481)

             at com.sun.xml.parser.Parser.parse(Parser.java:284)
             at javax.xml.parsers.SAXParser.parse(SAXParser.java:155)
             at javax.xml.parsers.SAXParser.parse(SAXParser.java:77)
             at
org.apache.struts.digester.Digester.parse(Digester.java:716)
             at
org.apache.struts.action.ActionServlet.initMapping(ActionServlet.java:1301)

             at
org.apache.struts.action.ActionServlet.init(ActionServlet.java:465)
             at
javax.servlet.GenericServlet.init(GenericServlet.java:232)
             at com.evermind.server.http.HttpApplication.w1(JAX)
             at com.evermind.server.http.HttpApplication.wj(JAX)
             at com.evermind.server.http.HttpApplication.wu(JAX)
             at com.evermind.server.http.HttpApplication.v4(JAX)
             at com.evermind.server.http.HttpApplication.<init>(JAX)
             at com.evermind.server.Application.ur(JAX)
             at com.evermind.server.http.el.ur(JAX)
             at com.evermind.server.http.ek.nm(JAX)
             at com.evermind.server.http.ef.s1(JAX)
             at com.evermind.server.http.ef.do(JAX)
             at com.evermind.util.f.run(JAX)
     3/23/01 10:58 AM login-web: 1.4.5 Started
     3/23/01 10:58 AM login-web: Servlet error
     javax.servlet.jsp.JspException: Cannot find ActionMappings or
ActionFormBeans collection
             at
org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:703)
             at
org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:441)
             at /login.jsp._jspService(/login.jsp.java:40) (JSP page
line 8)
             at com.orionserver.http.OrionHttpJspPage.service(JAX)
             at com.evermind.server.http.HttpApplication.xj(JAX)
             at com.evermind.server.http.JSPServlet.service(JAX)
             at com.evermind.server.http.d3.sw(JAX)
             at com.evermind.server.http.d3.su(JAX)
             at com.evermind.server.http.ef.s1(JAX)
             at com.evermind.server.http.ef.do(JAX)
             at com.evermind.util.f.run(JAX)


struts-config.xml:

     <?xml version="1.0" encoding="ISO-8859-1" ?>

     <!DOCTYPE struts-config PUBLIC
         "-//Apache Software Foundation//DTD Struts Configuration
1.0//EN"
         "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">

     <struts-config>

         <form-beans>
             <form-bean name="loginForm"
                 type="za.co.vis.modules.login.ui.LoginForm"/>
         </form-beans>

         <action-mappings>
             <action path="/login"
                 type="za.co.vis.modules.login.ui.LoginAction"
                 name="loginForm"
                 scope="session">
                 <forward name="success" path="/main.jsp"/>
             </action>
         </action-mappings>
     </struts-config>


Re: Newbie Problem solved with hack, but not ideal

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Fri, 23 Mar 2001, Darryl wrote:

> I searched the newsgroups and found that a number of you have already
> encountered and commented on this issue so my apologies for not determining
> that before I posted my previous note.
> 
> I found I did fix the problem by removing the DTD from struts.jar and placing
> it separately in the classpath. This is unfortunately a hack but I'll have to
> go with this for now until Orion fixes it... or is it necessarily an Orion
> bug? I found one posting that indicated that if you change some Struts code,
> it also fixes the problem.
> 
> Olli Poyry notes that in ActionServlet.java, if you replace (~line 881):
> 
>             URL url = this.getClass().getResource(registrations[i+1]);
> 
> with:
> 
>             URL url = getServletContext().getResource(registrations[i+1]);
> 
> the dtd is found and everything works. My question is, should Orion work
> regardless or would it be better to change Struts as indicated above?
> 
> Comments from anyone?
> 

Yes, it's a bug in Orion.

Servlet containers, among other things, provide a class loader for each
web application (so that the classes from WEB-INF/classes and WEB-INF/lib
are visible only within your app).  One of the responsibilities of a class
loader is to implement Class.getResource() and
Class.getResourceAsStream() also, so that an application can access
resource files via the classloader.  (This is what
java.util.ResourceBundle requires as well).

The class loader that Orion provides is broken because it does not handle
resource loading correctly from JAR files under WEB-INF/lib.  The hack
described above takes care of loading this particular file, but that just
defers the problem until you run into it somewhere else.

> thanks,
> Darryl
> 

Craig McClanahan


Re: Newbie Problem solved with hack, but not ideal

Posted by Darryl <da...@vis.co.za>.
I searched the newsgroups and found that a number of you have already
encountered and commented on this issue so my apologies for not determining
that before I posted my previous note.

I found I did fix the problem by removing the DTD from struts.jar and placing
it separately in the classpath. This is unfortunately a hack but I'll have to
go with this for now until Orion fixes it... or is it necessarily an Orion
bug? I found one posting that indicated that if you change some Struts code,
it also fixes the problem.

Olli Poyry notes that in ActionServlet.java, if you replace (~line 881):

            URL url = this.getClass().getResource(registrations[i+1]);

with:

            URL url = getServletContext().getResource(registrations[i+1]);

the dtd is found and everything works. My question is, should Orion work
regardless or would it be better to change Struts as indicated above?

Comments from anyone?

thanks,
Darryl



Darryl wrote:

> Hi all,
>
> I was wondering whether you could look at this stack trace below and see
> if you
> see anything that you've encountered before. I'm running Orion Server
> 1.4.5 and I wouldn't expect there to be a problem with JNDI. (see stack
> trace line re: unknown protocol: jndi)
> They (Orion) don't specify any setup needed for JNDI to be running as a
> service. Furthermore, I've checked the struts-config.xml and it
> seems fine. I've pasted it in below the stack trace.
>
> I'd appreciate any help you could offer because I've been wrestling with
> this thing for some time now and can't seem to find any
> problems. My JSP form action works the same (i.e. breaks) whether I'm
> using 'login.do' or '/login.do'.
>
> thanks again,
> Darryl
>
> Stack Trace:
>
>      3/23/01 10:55 AM Started
>      3/23/01 10:58 AM login-web: org.apache.struts.action.ActionServlet:
> init
>      3/23/01 10:58 AM login-web: Error preloading servlet
>      javax.servlet.ServletException: Parsing error processing resource
> path /WEB-INF/struts-config.xml
>              at
> org.apache.struts.action.ActionServlet.initMapping(ActionServlet.java:1306)
>
>              at
> org.apache.struts.action.ActionServlet.init(ActionServlet.java:465)
>              at
> javax.servlet.GenericServlet.init(GenericServlet.java:232)
>              at com.evermind.server.http.HttpApplication.w1(JAX)
>              at com.evermind.server.http.HttpApplication.wj(JAX)
>              at com.evermind.server.http.HttpApplication.wu(JAX)
>              at com.evermind.server.http.HttpApplication.v4(JAX)
>              at com.evermind.server.http.HttpApplication.<init>(JAX)
>              at com.evermind.server.Application.ur(JAX)
>              at com.evermind.server.http.el.ur(JAX)
>              at com.evermind.server.http.ek.nm(JAX)
>              at com.evermind.server.http.ef.s1(JAX)
>              at com.evermind.server.http.ef.do(JAX)
>              at com.evermind.util.f.run(JAX)
>      Root cause is; java.net.MalformedURLException: unknown protocol:
> jndi
>              at
> org.apache.struts.digester.Digester.resolveEntity(Digester.java:581)
>              at
> com.sun.xml.parser.ExternalEntity.getInputSource(ExternalEntity.java:46)
>
>              at com.sun.xml.parser.Parser.pushReader(Parser.java:2768)
>              at
> com.sun.xml.parser.Parser.externalParameterEntity(Parser.java:2504)
>              at
> com.sun.xml.parser.Parser.maybeDoctypeDecl(Parser.java:1137)
>              at com.sun.xml.parser.Parser.parseInternal(Parser.java:481)
>
>              at com.sun.xml.parser.Parser.parse(Parser.java:284)
>              at javax.xml.parsers.SAXParser.parse(SAXParser.java:155)
>              at javax.xml.parsers.SAXParser.parse(SAXParser.java:77)
>              at
> org.apache.struts.digester.Digester.parse(Digester.java:716)
>              at
> org.apache.struts.action.ActionServlet.initMapping(ActionServlet.java:1301)
>
>              at
> org.apache.struts.action.ActionServlet.init(ActionServlet.java:465)
>              at
> javax.servlet.GenericServlet.init(GenericServlet.java:232)
>              at com.evermind.server.http.HttpApplication.w1(JAX)
>              at com.evermind.server.http.HttpApplication.wj(JAX)
>              at com.evermind.server.http.HttpApplication.wu(JAX)
>              at com.evermind.server.http.HttpApplication.v4(JAX)
>              at com.evermind.server.http.HttpApplication.<init>(JAX)
>              at com.evermind.server.Application.ur(JAX)
>              at com.evermind.server.http.el.ur(JAX)
>              at com.evermind.server.http.ek.nm(JAX)
>              at com.evermind.server.http.ef.s1(JAX)
>              at com.evermind.server.http.ef.do(JAX)
>              at com.evermind.util.f.run(JAX)
>      3/23/01 10:58 AM login-web: 1.4.5 Started
>      3/23/01 10:58 AM login-web: Servlet error
>      javax.servlet.jsp.JspException: Cannot find ActionMappings or
> ActionFormBeans collection
>              at
> org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:703)
>              at
> org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:441)
>              at /login.jsp._jspService(/login.jsp.java:40) (JSP page
> line 8)
>              at com.orionserver.http.OrionHttpJspPage.service(JAX)
>              at com.evermind.server.http.HttpApplication.xj(JAX)
>              at com.evermind.server.http.JSPServlet.service(JAX)
>              at com.evermind.server.http.d3.sw(JAX)
>              at com.evermind.server.http.d3.su(JAX)
>              at com.evermind.server.http.ef.s1(JAX)
>              at com.evermind.server.http.ef.do(JAX)
>              at com.evermind.util.f.run(JAX)
>
> struts-config.xml:
>
>      <?xml version="1.0" encoding="ISO-8859-1" ?>
>
>      <!DOCTYPE struts-config PUBLIC
>          "-//Apache Software Foundation//DTD Struts Configuration
> 1.0//EN"
>          "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">
>
>      <struts-config>
>
>          <form-beans>
>              <form-bean name="loginForm"
>                  type="za.co.vis.modules.login.ui.LoginForm"/>
>          </form-beans>
>
>          <action-mappings>
>              <action path="/login"
>                  type="za.co.vis.modules.login.ui.LoginAction"
>                  name="loginForm"
>                  scope="session">
>                  <forward name="success" path="/main.jsp"/>
>              </action>
>          </action-mappings>
>      </struts-config>