You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by "mrisaliti@libero.it" <mr...@libero.it> on 2011/06/16 08:50:07 UTC

Embedding Tomcat 7 in Apache OFBiz

Hi all,

I'm one of the Apache OFBiz committer and I'm trying to migrate our embedded
version of Tomcat 6 to 7 and I have discover a small issue when try to do this
code:

StandardWrapper defaultServlet = new StandardWrapper();
defaultServlet.setServletClass("org.apache.catalina.servlets.DefaultServlet");
defaultServlet.setServletName("default");
defaultServlet.setLoadOnStartup(1);
defaultServlet.addInitParameter("debug", "0");
defaultServlet.addInitParameter("listing", "true");
defaultServlet.addMapping("/");

I'll receive an NullPointerException on org.apache.catalina.core.
StandardWrapper.addMapping(StandardWrapper.java:755).

Any hint to solve it ?

Thanks
Marco Risaliti 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: Embedding Tomcat 7 in Apache OFBiz

Posted by Konstantin Kolinko <kn...@gmail.com>.
2011/6/16 mrisaliti@libero.it <mr...@libero.it>:
> Hi all,
>
> I'm one of the Apache OFBiz committer and I'm trying to migrate our embedded
> version of Tomcat 6 to 7 and I have discover a small issue when try to do this
> code:
>
> StandardWrapper defaultServlet = new StandardWrapper();
> defaultServlet.setServletClass("org.apache.catalina.servlets.DefaultServlet");
> defaultServlet.setServletName("default");
> defaultServlet.setLoadOnStartup(1);
> defaultServlet.addInitParameter("debug", "0");
> defaultServlet.addInitParameter("listing", "true");
> defaultServlet.addMapping("/");
>
> I'll receive an NullPointerException on org.apache.catalina.core.
> StandardWrapper.addMapping(StandardWrapper.java:755).
>
> Any hint to solve it ?

1. What exactly version of Tomcat 7.0.x ?

2. Why are you using this internal Tomcat class? What do you do with
StandardWrapper later?

3. Apparently the line that fails is the following:
(line numbers in the most recent Tomcat version differ from the one
you are mentioning)

if(parent.getState().equals(LifecycleState.STARTED))

I think it fails because parent is null.


So either
a) Add StandardWrapper as a child to a context.

- See StandardContext#createWrapper()
- See
 - o.a.c.startup.Tomcat#addServlet(..) (a helper class for embedding Tomcat)
 - o.a.c.deploy.WebXml#configureContext(..)
 - o.a.c.core.ApplicationContext#addServlet(String, Class)

b) If you want to change Tomcat code, file an issue in Bugzilla.

It should be easy to fix:  do not see why not to add parent!=null
check there. Though I do not know whether it will fail further down
the road.
The same may be said about similar code in removeMapping() method.


Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org