Jump to content
Excelsior Forums
Sign in to follow this  
griffon

ExceptionInInitializerError when executing

Recommended Posts

I got this exception :"Exception in thread "main" .lang.ExceptionInInitializerError: java.lang.Throwable: Thread creation error" when I execute my application after compiling with JET.

In my code of method 'main', here's the line where it crashes :

URL u=BestAuthor.class.getResource("/resources/icons/tree.gif");

Is it a resource acces problem ? Does anyone know how I can solve this problem ?

thanks,

griffon

Share this post


Link to post
Share on other sites

Am I right that this code line is inside the class initializer? In this case it really may be the resource access problem. Otherwise, we need more information to say anything about it, so please send an example along with the full description of your problem to java@excelsior-usa.com.

As for resource access problem, such problems usually can be solved by setting of the CLASSPATH variable in the batch file executing your application. All jars or directories containing required resources should be listed in this CLASSPATH. You also can make it automatically with the help of the JET graphical front-end (see page 4 "Include resources").

Share this post


Link to post
Share on other sites

Greetings,

I'm also getting this same error (ExceptionInInitializerError) when I try to load a DB2 driver.  I've got the DB2Java.zip included in the executable (it's bound to the resource path).  And everything seems to be fine.

I can successfully execute the code (as an EXE) on the development machine (Win2K), but when I move it to the machine I want to schedule it on, it comes up with the error.  The production machine is a WinXP-Pro, though I wouldn't think that would make a difference.

The code executes as a command-line program, and here's the output...

C:\L10Balance>l10balance

L10Balance: Beginning

L10Balance: Connected to SQL Server

Exception in thread "main" java.lang.ExceptionInInitializerError

Caused by: java.lang.NullPointerException

C:\L10Balance>

The next message that should show up should be one about successfully loading the DB2 driver.  Obviously it doesn't.

Here's the code snippet itself...

     public static void main(String[] args)

     {

           System.out.println("L10Balance: Beginning");

           

           try

           {

                 Class.forName( sqlDriver ).newInstance();

                 connHost = DriverManager.getConnection( sqlURL, sqlUser, sqlPass );

                 System.out.println("L10Balance: Connected to SQL Server");

                 

                 Class.forName( db2Driver ).newInstance();

                 System.out.println("L10Balance: DB2 Driver Loaded");

                 connProd = DriverManager.getConnection( db2UrlProd, db2User, db2Password );

                 System.out.println("L10Balance: Connected to Prod Database");

                 connTest = DriverManager.getConnection( db2UrlTest, db2User, db2Password );

                 System.out.println("L10Balance: Connected to Test Database");

If anyone can give me some insight on this, I would greatly appreciate it.

Thanks,

Paul

Share this post


Link to post
Share on other sites
Sign in to follow this  

×