Topic
  • 6 replies
  • Latest Post - ‏2013-08-21T21:45:51Z by bergmark
hampe98
hampe98
12 Posts

Pinned topic ServletContainerInitializer.onStartup not called

‏2013-04-26T12:11:17Z |

Hi,

I´ve got a web module and a utility jar in an EAR deployed in WS Liberty. The utility module packages a javax.servlet.ServletContainerInitializer (declared in META-INF/services and all) but it´s not getting called on the startup of the web module. I´ve tried the exact same EAR on a 8.0 full profile and there it works.

Is there something I must configure in Liberty with regards to lazy loading or something?

Regards,

Hampus

  • bergmark
    bergmark
    42 Posts

    Re: ServletContainerInitializer.onStartup not called

    ‏2013-04-26T19:58:03Z  

    Are you driving a request into the application?  By default the server lazy initializes the web application upon first request, so no ServletContainerInitializers or ServletContextListeners would be called until that point.

    You can turn off that behavior by setting

     

    
    <webContainer deferServletLoad="false"/>
    
  • hampe98
    hampe98
    12 Posts

    Re: ServletContainerInitializer.onStartup not called

    ‏2013-04-27T07:20:09Z  
    • bergmark
    • ‏2013-04-26T19:58:03Z

    Are you driving a request into the application?  By default the server lazy initializes the web application upon first request, so no ServletContainerInitializers or ServletContextListeners would be called until that point.

    You can turn off that behavior by setting

     

    <pre class="pre codeblock" dir="ltr" style="font-family: 'Courier New', Courier, monospace; font-size: 13px; background-color: rgb(218, 218, 218); padding: 5px; white-space: pre-wrap; word-wrap: break-word; color: rgb(0, 0, 0);"> <webContainer deferServletLoad="false"/> </pre>

    Yes, I'm driving requests into the application but it's still not called. I tried the defer-option as well but no luck there either. I'm running the latest beta refresh.

    Regards,

    Hampus

  • 5R7D_Moises_Lejter
    5R7D_Moises_Lejter
    2 Posts

    Re: ServletContainerInitializer.onStartup not called

    ‏2013-08-08T16:03:37Z  
    • hampe98
    • ‏2013-04-27T07:20:09Z

    Yes, I'm driving requests into the application but it's still not called. I tried the defer-option as well but no luck there either. I'm running the latest beta refresh.

    Regards,

    Hampus

    Hi!

    Did you ever get this to work?  I seem to be running into the same issue (a ServletContainerInitializer that won't be called within Liberty)...

    Thank you!
     

    Moises

  • bergmark
    bergmark
    42 Posts

    Re: ServletContainerInitializer.onStartup not called

    ‏2013-08-09T14:30:05Z  

    Hi!

    Did you ever get this to work?  I seem to be running into the same issue (a ServletContainerInitializer that won't be called within Liberty)...

    Thank you!
     

    Moises

    Can you provide a little more information about your application?

    Where is the ServletContainerInitializer defined?  Is it in your web module, or in a utility jar in the ear? If its in a utility jar, does moving it into the war cause it to work?

    Are you driving a request into the application, or have you set deferServletLoad to false?

  • 5R7D_Moises_Lejter
    5R7D_Moises_Lejter
    2 Posts

    Re: ServletContainerInitializer.onStartup not called

    ‏2013-08-21T18:14:59Z  
    • bergmark
    • ‏2013-08-09T14:30:05Z

    Can you provide a little more information about your application?

    Where is the ServletContainerInitializer defined?  Is it in your web module, or in a utility jar in the ear? If its in a utility jar, does moving it into the war cause it to work?

    Are you driving a request into the application, or have you set deferServletLoad to false?

    Hi!

     

    The ServletContainerInitializer is defined in a utility JAR file, with a META-INF/services/javax.servlet.ServletContainerInitializer file with the correct class name in it.  If I deploy this jar file in the WEB-INF/lib folder of the web app, then it works as it should.  If I deploy it as a shared library associated with the application (in the server.xml config file for the Liberty profile server), then it is ignored.

    As I understood it, jar files in shared libraries with the magic META-INF entry would also be detected.  I am thinking I may be missing some configuration option in server.xml to prompt Liberty to look into the shared libraries... (I also seem to remember there was a similar issue with Liberty not looking into shared libraries for JPA-annotated classes, but I am not sure about that...).

    To test it, I do send a request into the application that (should) include this utility jar.

    I've attached a zip file with a copy of the Eclipse project for this utility jar...

    Thank you!

    Moises

    Attachments

  • bergmark
    bergmark
    42 Posts

    Re: ServletContainerInitializer.onStartup not called

    ‏2013-08-21T21:45:51Z  

    This appears to be a defect.  If would suggest opening a PMR to further investigate the root cause and resolution.