You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2015/11/20 10:08:12 UTC

[Bug 58629] New: Container is not initialized while starting tomcat in embedded mode.

https://bz.apache.org/bugzilla/show_bug.cgi?id=58629

            Bug ID: 58629
           Summary: Container is not initialized while starting tomcat in
                    embedded mode.
           Product: Tomcat 9
           Version: 9.0.0.M1
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: gandhi.sagar@live.com

Created attachment 33284
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=33284&action=edit
Patch for the solution.

For earliar versions, following code works. But for tomcat 9 , It is giving
null pointer exception while starting the server.

    Tomcat tomcat = new Tomcat();
    tomcat.setHostname("localhost");
    tomcat.setPort(8080);
    tomcat.setBaseDir("D:/softwares/servers/STUDY_TOMCAT");
    tomcat.start();


Exception in thread "main" org.apache.catalina.LifecycleException: Failed to
start component [StandardServer[-1]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:159)
    at org.apache.catalina.startup.Tomcat.start(Tomcat.java:345)
    at com.gandhisagar.test.TomcatStart.main(TomcatStart.java:13)
Caused by: org.apache.catalina.LifecycleException: Failed to start component
[StandardService[Tomcat]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:159)
    at
org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:769)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:155)
    ... 2 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component
[org.apache.catalina.mapper.MapperListener@685f4c2e]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:159)
    at
org.apache.catalina.core.StandardService.startInternal(StandardService.java:451)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:155)
    ... 4 more
Caused by: java.lang.NullPointerException
    at
org.apache.catalina.mapper.MapperListener.findDefaultHost(MapperListener.java:261)
    at
org.apache.catalina.mapper.MapperListener.startInternal(MapperListener.java:102)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:155)
    ... 6 more


Solution:

While debugging the issue we found that , Container is not getting initialized
properly. So we need to call corg.apache.catalina.startup.Tomcat.getEngine()
while starting the server in embedded mode. So that same code will work with
Tomcat 9.0

(Attaching the patch with the bug)

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 58629] Container is not initialized while starting tomcat in embedded mode.

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=58629

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #1 from Mark Thomas <ma...@apache.org> ---
This issue doesn't appear to be unique to 9.0.x

I've fixed it in 9.0.x for 9.0.0.M2 onwards and in 8.0.x for 8.0.30 onwards.

I took a different approach to fixing the NPE. The MapperListener now skips
registration if the engine is null.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 58629] Container is not initialized while starting tomcat in embedded mode.

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=58629

Sagar Gandhi <ga...@live.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 58629] Container is not initialized while starting tomcat in embedded mode.

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=58629

moer33 <27...@qq.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |271759231@qq.com

-- 
You are receiving this mail because:
You are the assignee for the bug.

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