Topic
5 replies Latest Post - ‏2013-05-13T14:46:57Z by 20WR_Amey_Kamat
20WR_Amey_Kamat
20WR_Amey_Kamat
3 Posts
ACCEPTED ANSWER

Pinned topic Getting NullPointerException when instantiating a Session EJB on Liberty Profile V8.5_Next

‏2013-05-08T21:05:46Z |

Hi all, 

I am new to JavaEE and EJBs. I am trying to deploy a sample app on Liberty Profile V8.5_Next. I am getting the NullPointerException when trying to instantiate the session bean. The base exception is javax.naming.NameNotFoundException. The following is the stack trace: 

 

til.getEJBLocalHome(): Exception: javax.naming.NameNotFoundException: java:global/PlantsByWebSphereEAR-3.0.0.3/PlantsByWebSphereEJB3/SampleStatelessBean
[ERROR   ] SRVE0777E: Exception thrown by application class 'com.ibm.websphere.samples.pbwweb.EJBServlet.doGet:39'
java.lang.NullPointerException
at com.ibm.websphere.samples.pbwweb.EJBServlet.doGet(EJBServlet.java:39)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:575)
at [internal classes]
 
[ERROR   ] SRVE0315E: An execption occurred: com.ibm.ws.webcontainer.webapp.WebAppErrorReport: java.lang.NullPointerException
at com.ibm.websphere.samples.pbwweb.EJBServlet.doGet(EJBServlet.java:39)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:575)
at [internal classes]
Caused by: java.lang.NullPointerException
... 4 more
 
[AUDIT   ] CWWKE0055I: Server shutdown requested on Wednesday, May 8, 2013 at 4:45 PM. The server PBWServer is shutting down.
[AUDIT   ] CWWKT0017I: Web application removed (default_host): http://localhost:9080/PlantsByWebSphere/

 

I have attached a couple of files with this post:

- EJB (SampeStatelessBean.java)

- Interface implemented by the samplestatelessbean class.

- Also attaching the application.xml file.

 

Also the application is packaged as EAR file. The name of the EAR is PlantsByWebsphereEAR-3.0.0.3.ear

The bean class and interface are packaged as PlantsByWebSphereEJB3.jar

and the servlet is packaged in PlantsByWebSphereWEB.war

Please let me know if anything else is required . 

 

Thanks

 

  • RohitK
    RohitK
    6 Posts
    ACCEPTED ANSWER

    Re: Getting NullPointerException when instantiating a Session EJB on Liberty Profile V8.5_Next

    ‏2013-05-08T21:29:22Z  in response to 20WR_Amey_Kamat

    Can you please also send your server.xml and console.log

     

    -Thanks,

    Rohit

  • 20WR_Amey_Kamat
    20WR_Amey_Kamat
    3 Posts
    ACCEPTED ANSWER

    Re: Getting NullPointerException when instantiating a Session EJB on Liberty Profile V8.5_Next

    ‏2013-05-08T21:41:15Z  in response to 20WR_Amey_Kamat

    yeah sure.. I forgot to add that to the previous mail . 

    Thanks

     

    • RohitK
      RohitK
      6 Posts
      ACCEPTED ANSWER

      Re: Getting NullPointerException when instantiating a Session EJB on Liberty Profile V8.5_Next

      ‏2013-05-09T14:56:31Z  in response to 20WR_Amey_Kamat

      One last thing... can you upload the app as well.

       

      -Thanks

    • RohitK
      RohitK
      6 Posts
      ACCEPTED ANSWER

      Re: Getting NullPointerException when instantiating a Session EJB on Liberty Profile V8.5_Next

      ‏2013-05-10T15:23:46Z  in response to 20WR_Amey_Kamat

      Amey,

      There are multiple issues with the application.

      1. The web and ejb module descriptors are at versions that are not supported by Liberty -

      <web-app id="WebApp_1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">

      <ejb-jar id="ejb-jar_ID" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2.1.xsd" version="2.1">

       

      2. The EJBs are 2.x or seem to use 2.x code. Liberty only supports EJB 3.x and above

      3. There are some missing prereq libraries like javamail that are referenced by the web application.

      How to Resolve these issues

      1. - My advice is to start small.. Break down the app into some core functions and migrate those modules over to web app 3.x and ejb 3.x

      2. - Leverage the Rational -WDT tooling to suck in your app and do some validation before deploying to Liberty

      - Without changing src code you will not be able to get this application runing in Liberty 855 beta

      -good luck and ping us if you have more questions

      -Rohit

      Thanks to Brett Kail who assisted in the triage . We needed to enable com.ibm.ws.logging.trace.specification=*=info=enabled:EJBContainer=all in bootstrap.properties to figure debug this issue.

       

      • 20WR_Amey_Kamat
        20WR_Amey_Kamat
        3 Posts
        ACCEPTED ANSWER

        Re: Getting NullPointerException when instantiating a Session EJB on Liberty Profile V8.5_Next

        ‏2013-05-13T14:46:57Z  in response to RohitK

        Thanks for all the help Rohit . Will let you know if I come with more doubts .