1 Reply Latest reply: Sep 22, 2007 10:22 AM by 807605 RSS

    Duke's Bookstore EE5 and null.pointer.exception

    807605
      I'm trying to familiarize myself with the Persistance API by Running the Duke's Bookstore example. I keep getting a server error when the page comes up. The log file indicates a null pointer exception. The deploy looks clean. Here is a copy of the deploy output followed by the section of the server log with the error:

      C:\javaeetutorial5\examples\web\bookstore2>ant
      Buildfile: build.xml

      -pre-init:

      init:

      default-ear:

      build-common:

      -pre-init:

      init:

      default-ear:

      -pre-compile:

      bpp-actual-compilation:
      [echo] Compiling bookstore

      -post-compile:

      compile:

      package:
      [mkdir] Created dir: C:\javaeetutorial5\examples\web\bookstore\build\jar
      [copy] Copying 12 files to C:\javaeetutorial5\examples\web\bookstore\build\
      jar
      [delete] Deleting: C:\javaeetutorial5\examples\web\bookstore\build\bookstore.
      jar
      [jar] Building jar: C:\javaeetutorial5\examples\web\bookstore\build\bookst
      ore.jar
      [delete] Deleting directory C:\javaeetutorial5\examples\web\bookstore\build\j
      ar

      bpp-copy-dist:
      [copy] Copying 1 file to C:\javaeetutorial5\examples\web\bookstore\dist

      default-not-ear:

      default:

      copy-common-jars:
      [copy] Copying 1 file to C:\javaeetutorial5\examples\web\bookstore2\build\w
      eb\WEB-INF\lib

      -pre-compile:

      bpp-actual-compilation:
      [echo] Compiling bookstore2

      -post-compile:

      compile:

      package:
      [mkdir] Created dir: C:\javaeetutorial5\examples\web\bookstore2\build\war

      bp-copy-classes:
      [mkdir] Created dir: C:\javaeetutorial5\examples\web\bookstore2\build\war\WE
      B-INF\classes
      [copy] Copying 5 files to C:\javaeetutorial5\examples\web\bookstore2\build\
      war\WEB-INF\classes
      [copy] Copying 30 files to C:\javaeetutorial5\examples\web\bookstore2\build
      \war

      bpp-package-persistence-unit-war:
      [mkdir] Created dir: C:\javaeetutorial5\examples\web\bookstore2\build\war\WE
      B-INF\classes\META-INF
      [copy] Warning: Could not find file C:\javaeetutorial5\examples\web\booksto
      re2\src\conf\persistence.xml to copy.
      [copy] Warning: Could not find file C:\javaeetutorial5\examples\web\booksto
      re2\src\conf\persistence.xml to copy.

      bpp-package-persistence-unit-ejb-jar:

      package-persistence-unit:
      [delete] Deleting: C:\javaeetutorial5\examples\web\bookstore2\build\bookstore
      2.war
      [jar] Building jar: C:\javaeetutorial5\examples\web\bookstore2\build\books
      tore2.war
      [delete] Deleting directory C:\javaeetutorial5\examples\web\bookstore2\build\
      war

      bpp-copy-dist:
      [copy] Copying 1 file to C:\javaeetutorial5\examples\web\bookstore2\dist

      default-not-ear:

      default:

      BUILD SUCCESSFUL
      Total time: 2 seconds
      C:\javaeetutorial5\examples\web\bookstore2>ant deploy
      Buildfile: build.xml

      check:

      tools:

      -pre-deploy:

      -pre-init:

      init:

      check:

      tools:

      start-db:
      [exec] Database already started on host localhost, port 1527.
      [exec] Command start-database executed successfully.

      delete-tables:
      [sql] Executing file: C:\javaeetutorial5\examples\common\sql\javadb\delete
      .sql
      [sql] 1 of 1 SQL statements executed successfully

      create-tables:
      [sql] Executing file: C:\javaeetutorial5\examples\common\sql\javadb\tutori
      al.sql
      [sql] 8 of 8 SQL statements executed successfully

      deploy:
      [exec] Command deploy executed successfully.

      deploy-url-message:
      [echo] Application Deployed at: http://localhost:8080/bookstore2

      BUILD SUCCESSFUL
      Total time: 9 seconds
      C:\javaeetutorial5\examples\web\bookstore2>ant run
      Buildfile: build.xml

      -pre-init:

      init:

      default-ear:

      build-common:

      -pre-init:

      init:

      default-ear:

      -pre-compile:

      bpp-actual-compilation:
      [echo] Compiling bookstore

      -post-compile:

      compile:

      package:
      [mkdir] Created dir: C:\javaeetutorial5\examples\web\bookstore\build\jar
      [copy] Copying 12 files to C:\javaeetutorial5\examples\web\bookstore\build\
      jar
      [delete] Deleting: C:\javaeetutorial5\examples\web\bookstore\build\bookstore.
      jar
      [jar] Building jar: C:\javaeetutorial5\examples\web\bookstore\build\bookst
      ore.jar
      [delete] Deleting directory C:\javaeetutorial5\examples\web\bookstore\build\j
      ar

      bpp-copy-dist:
      [copy] Copying 1 file to C:\javaeetutorial5\examples\web\bookstore\dist

      default-not-ear:

      default:

      copy-common-jars:
      [copy] Copying 1 file to C:\javaeetutorial5\examples\web\bookstore2\build\w
      eb\WEB-INF\lib

      -pre-compile:

      bpp-actual-compilation:
      [echo] Compiling bookstore2

      -post-compile:

      compile:

      package:
      [mkdir] Created dir: C:\javaeetutorial5\examples\web\bookstore2\build\war

      bp-copy-classes:
      [mkdir] Created dir: C:\javaeetutorial5\examples\web\bookstore2\build\war\WE
      B-INF\classes
      [copy] Copying 5 files to C:\javaeetutorial5\examples\web\bookstore2\build\
      war\WEB-INF\classes
      [copy] Copying 30 files to C:\javaeetutorial5\examples\web\bookstore2\build
      \war

      bpp-package-persistence-unit-war:
      [mkdir] Created dir: C:\javaeetutorial5\examples\web\bookstore2\build\war\WE
      B-INF\classes\META-INF
      [copy] Warning: Could not find file C:\javaeetutorial5\examples\web\booksto
      re2\src\conf\persistence.xml to copy.
      [copy] Warning: Could not find file C:\javaeetutorial5\examples\web\booksto
      re2\src\conf\persistence.xml to copy.

      bpp-package-persistence-unit-ejb-jar:

      package-persistence-unit:
      [delete] Deleting: C:\javaeetutorial5\examples\web\bookstore2\build\bookstore
      2.war
      [jar] Building jar: C:\javaeetutorial5\examples\web\bookstore2\build\books
      tore2.war
      [delete] Deleting directory C:\javaeetutorial5\examples\web\bookstore2\build\
      war

      bpp-copy-dist:
      [copy] Copying 1 file to C:\javaeetutorial5\examples\web\bookstore2\dist

      default-not-ear:

      default:

      check:

      tools:

      -pre-deploy:

      -pre-init:

      init:

      check:

      tools:

      start-db:
      [exec] Database already started on host localhost, port 1527.
      [exec] Command start-database executed successfully.

      delete-tables:
      [sql] Executing file: C:\javaeetutorial5\examples\common\sql\javadb\delete
      .sql
      [sql] 1 of 1 SQL statements executed successfully

      create-tables:
      [sql] Executing file: C:\javaeetutorial5\examples\common\sql\javadb\tutori
      al.sql
      [sql] 8 of 8 SQL statements executed successfully

      deploy:
      [exec] Command deploy executed successfully.

      deploy-url-message:
      [echo] Application Deployed at: http://localhost:8080/bookstore2

      getBrowser:

      launch:
      [echo]
      [echo] Trying to launch the browser with the url
      [echo] http://localhost:8080/bookstore2
      [echo]
      [echo] If the above does not work, you may open a browser and c
      opy and paste the above URL.
      [echo]
      [echo] For non-windows and non-mac machines, make sure that you
      have specified
      [echo] valid browser for the property default.browser in bp-pro
      ject/build.properties
      [echo]
      [echo] Launching bookstore2.

      run:

      BUILD SUCCESSFUL
      Total time: 12 seconds
      C:\javaeetutorial5\examples\web\bookstore2>


      [#|2007-09-13T16:34:12.984-0700|WARNING|sun-appserver-pe9.0|javax.enterprise|_ThreadID=21;_ThreadName=RMI TCP Connection(54)-127.0.0.1;_RequestID=24b11497-d7fe-40aa-9c9a-4fc8366515e1;|LCM0203: Lifecycle module [JBIFramework] threw ServerLifecycleException
      com.sun.appserv.server.ServerLifecycleException: java.lang.NullPointerException
           at com.sun.jbi.framework.sun.SunASJBIFramework.handleEvent(SunASJBIFramework.java:138)
           at com.sun.appserv.server.ServerLifecycleModule.postEvent(ServerLifecycleModule.java:210)
           at com.sun.appserv.server.ServerLifecycleModule.onShutdown(ServerLifecycleModule.java:260)
           at com.sun.appserv.server.LifecycleModuleService.onShutdown(LifecycleModuleService.java:264)
           at com.sun.enterprise.server.ApplicationServer.onShutdown(ApplicationServer.java:440)
           at com.sun.enterprise.server.ondemand.OnDemandServer.onShutdown(OnDemandServer.java:123)
           at com.sun.enterprise.server.Shutdown.startShutdown(Shutdown.java:62)
           at com.sun.enterprise.admin.event.AdminEventMulticaster.invokeShutdownEventListener(AdminEventMulticaster.java:1481)
           at com.sun.enterprise.admin.event.AdminEventMulticaster.handleShutdownEvent(AdminEventMulticaster.java:1470)
           at com.sun.enterprise.admin.event.AdminEventMulticaster.processEvent(AdminEventMulticaster.java:464)
           at com.sun.enterprise.admin.event.AdminEventMulticaster.multicastEvent(AdminEventMulticaster.java:160)
           at com.sun.enterprise.admin.server.core.channel.AdminChannelServer.sendNotification(AdminChannelServer.java:108)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)
           at sun.rmi.transport.Transport$1.run(Transport.java:159)
           at java.security.AccessController.doPrivileged(Native Method)
           at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
           at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
           at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
           at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
           at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
           at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.NullPointerException
           at com.sun.jbi.framework.JBIFramework.shutdown(JBIFramework.java:383)
           at com.sun.jbi.framework.sun.SunASJBIFramework.handleEvent(SunASJBIFramework.java:117)
           ... 25 more

      I noticed that it is complaining about not being able to find the persistence.xml in the src/conf directory.
      I found the xml file in the bookstore directory and pasted it into the conf directory. When I ran the deploy the error
      message didn't appear, but the same problem occured - the null.pointer exception.
        • 1. Re: Duke's Bookstore EE5 and null.pointer.exception
          807605
          I fixed the problem by unifying the design into one build. The design uses the bookstore folder code and makes a jar file that bookstore2 uses. For reasons that I have not been able to determine this leads to a null pointer exception.

          To get the design to work, paste in all the code, including the exception, cart, and message folders into bookstore2. Be sure to change the package names to match bookstor2. Copy Books from the bookstore folder into the bookstore2 to database folder. Eliminate the import statement associated with it. Compile and run the unified design.