NullPointerException

2012-08-30
2013-05-23
  • Andrig Miller

    Andrig Miller - 2012-08-30

    I had a working One Jar executable built from inside Eclipse, but using the "Project Archives" capability.  I'm using JBoss Developer Studio (upstream is JBoss Tools), and that capability may be apart of that, and not base Eclipse, but I'm not sure.  Essentially it should work the same as if you build the executable jar from the command-line.

    Like I said, I had it working.

    After doing some code refactoring I started getting the following:

    Exception in thread "main" java.lang.NullPointerException
    at com.simontuffs.onejar.Boot.run(Boot.java:275)
    at com.simontuffs.onejar.Boot.main(Boot.java:168)

    Nothing changed, except my code, but I can no longer execute the jar.  I have triple checked that everything was good, and the same as before, which it is, but still no joy.  The output of jar -tvf is as follows:

    $ jar -tvf MonitorResources.jar
       129 Thu Aug 30 13:31:22 MDT 2012 boot-manifest.mf
      1700 Wed May 04 12:58:04 MDT 2011 com/simontuffs/onejar/Boot$1.class
      1905 Wed May 04 12:58:04 MDT 2011 com/simontuffs/onejar/Boot$2.class
      1398 Wed May 04 12:58:04 MDT 2011 com/simontuffs/onejar/Boot$3.class
    17398 Wed May 04 12:58:04 MDT 2011 com/simontuffs/onejar/Boot.class
      1771 Wed May 04 12:05:36 MDT 2011 com/simontuffs/onejar/Handler$1.class
       863 Wed May 04 12:05:36 MDT 2011 com/simontuffs/onejar/Handler.class
       280 Wed May 04 12:40:00 MDT 2011 com/simontuffs/onejar/IProperties.class
      2532 Wed May 04 12:40:00 MDT 2011 com/simontuffs/onejar/JarClassLoader$1.class
       848 Wed May 04 12:40:00 MDT 2011 com/simontuffs/onejar/JarClassLoader$2.class
       974 Wed May 04 12:40:00 MDT 2011 com/simontuffs/onejar/JarClassLoader$ByteCode.class
      1072 Wed May 04 12:40:00 MDT 2011 com/simontuffs/onejar/JarClassLoader$FileURLFactory$1.class
      2320 Wed May 04 12:40:00 MDT 2011 com/simontuffs/onejar/JarClassLoader$FileURLFactory.class
       430 Wed May 04 12:40:00 MDT 2011 com/simontuffs/onejar/JarClassLoader$IURLFactory.class
      1414 Wed May 04 12:40:00 MDT 2011 com/simontuffs/onejar/JarClassLoader$OneJarURLFactory.class
    29043 Wed May 04 12:40:00 MDT 2011 com/simontuffs/onejar/JarClassLoader.class
       543 Wed May 04 12:05:36 MDT 2011 com/simontuffs/onejar/OneJarFile$1.class
      1298 Wed May 04 12:05:36 MDT 2011 com/simontuffs/onejar/OneJarFile$2.class
      3529 Wed May 04 12:05:36 MDT 2011 com/simontuffs/onejar/OneJarFile.class
      1638 Wed May 04 12:05:36 MDT 2011 com/simontuffs/onejar/OneJarURLConnection.class
        87 Thu Aug 30 13:32:22 MDT 2012 detectloader.mf
        23 Wed May 04 15:00:42 MDT 2011 .version
      1781 Thu Jul 15 16:33:50 MDT 2010 doc/one-jar-license.txt
      1046 Wed May 04 12:05:36 MDT 2011 OneJar.class
      3304 Wed May 04 15:00:42 MDT 2011 wrap/wraploader.jar
        62 Thu Aug 30 13:31:28 MDT 2012 META-INF/MANIFEST.MF
    89426 Tue May 29 15:18:16 MDT 2012 lib/jboss-dmr-1.1.1.Final-redhat-1.jar
    231045 Tue May 29 15:18:16 MDT 2012 lib/jboss-remoting-3.2.8.GA-redhat-1.jar
    129388 Tue May 29 15:18:24 MDT 2012 lib/jboss-as-protocol-7.1.2.Final-redhat-1.jar
    89097 Tue May 29 15:18:32 MDT 2012 lib/jboss-sasl-1.0.1.Final-redhat-1.jar
    240871 Tue May 29 15:18:32 MDT 2012 lib/xnio-api-3.0.4.GA-redhat-1.jar
    80182 Tue May 29 15:18:32 MDT 2012 lib/xnio-nio-3.0.4.GA-redhat-1.jar
    60969 Tue May 29 15:18:16 MDT 2012 lib/jboss-logging-3.1.1.GA-redhat-1.jar
    119795 Tue May 29 15:18:36 MDT 2012 lib/jboss-threads-2.0.0.GA-redhat-1.jar
    230120 Tue May 29 15:18:34 MDT 2012 lib/jboss-marshalling-1.3.14.GA-redhat-1.jar
    82220 Tue May 29 15:18:34 MDT 2012 lib/jboss-marshalling-river-1.3.14.GA-redhat-1.jar
    191116 Tue May 29 15:18:26 MDT 2012 lib/jboss-as-controller-client-7.1.2.Final-redhat-1.jar
    41123 Mon Mar 16 01:31:20 MDT 2009 lib/commons-cli-1.2.jar
      8498 Thu Aug 30 13:33:22 MDT 2012 main/main.jar
         0 Thu Aug 30 13:33:22 MDT 2012 main/
         0 Thu Aug 30 13:33:22 MDT 2012 lib/
         0 Thu Aug 30 13:33:22 MDT 2012 META-INF/
         0 Thu Aug 30 13:33:22 MDT 2012 wrap/
         0 Thu Aug 30 13:33:22 MDT 2012 com/
         0 Thu Aug 30 13:33:22 MDT 2012 com/simontuffs/
         0 Thu Aug 30 13:33:22 MDT 2012 com/simontuffs/onejar/
         0 Thu Aug 30 13:33:22 MDT 2012 doc/

    I'm not seeing anything wrong.  My boot-manifest.mf file is as follows:

    Manifest-Version: 1.0
    Main-Class: com.simontuffs.onejar.Boot
    One-Jar-Main-Class: org.jboss.performance.monitor.MonitorResources

    My top level META-INF/MANIFEST.MF is as follows:

    Manifest-Version: 1.0
    Main-Class: com.simontuffs.onejar.Boot

    My main.jar META-INF/MANIFEST.MF is as follows:

    Manifest-Version: 1.0
    Main-Class: org.jboss.performance.monitor.MonitorResources

    I made sure on all the *.mf *.MF files that there was a carriage-return at the end, as that seems to cause problems with the Main-Class entry (at least that is what I read).

    Finally, I also have the detectloader.mf file as follows:

    Manifest-Version: 1.0
    Wrap-Class-Loader: com.simontuffs.onejar.DetectClassLoader

    Any pointer as to what might be wrong would be helpful.

    Thanks.

     
  • P. Simon Tuffs

    P. Simon Tuffs - 2012-08-31

    The source-code for Boot.java should be inside the one-jar.   If you can, attach one-jar.jar as a source repository to your project, and then click on the exception location (line 275).  Otherwise, expand one-jar into a directory tree and use the Eclipse editor.  This will give you a clue about what's going on. 

    Otherwise, it is possible to launch and debug one-jar projects in Eclipse using the "jar-plug" plugin: checkout http://jar-plug.sourceforge.net/ 

    I use this myself to debug one-jar deployments.  It's also helpful when you want to look inside/manipuate any jar/zip file. 

     
  • Andrig Miller

    Andrig Miller - 2012-08-31

    Interesting.  I installed the jar-plug/jarlaunch stuff, and attached the source for One Jar to my project.  Everything worked without issue.  When first trying to get thing running with Jarlaunch, it did complain about not finding stuff, and I noticed it was stopping where there was a space in the directory name of my project.  I changed my project to not have a space in the name, and then it worked fine.  No issues at all.  Then I tried it again from the command line, and it worked there too.

    Perhaps the space in my Eclipse project name was the culprit all along?  Seems strange, but I did have it working with the space previously.  At this point, its working again, so I'm not sure if that was the problem or not.

    I guess if I have another problem, at least now I can bring things up in a debugger and see what is happening.

    Thanks for the pointer to the jar-plug stuff.  That's quite handy for this type of project.

     

Log in to post a comment.