Embedding Tomcat 7 in Apache OFBiz

2011-06-15 Thread mrisal...@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 ?

Thanks
Marco Risaliti 

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



Re: Embedding Tomcat 7 in Apache OFBiz

2011-06-16 Thread mrisal...@libero.it
Thanks Konstantin,

I'm using tomcat 7.0.14 and the code I'm migrate is actually done in this way.
Anyway I will check if it's working with your suggestions and if it's negative 
open a bug.

Marco

2011/6/16 mrisal...@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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

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