Connecting a Netbeans EE application to a glassfish server.

Ok I pulled my hair out doing this – it seemed whatever I did I got a Null Pointer Exception when I ran the client, so here’s the solution. Sorry Sun, but I couldn’t get it working using the menu in the IDE that created this code:-

@EJB
IntelligenceRemote intelligenceremote;

In this case my remote class is called IntelligenceRemote and I have a method called TransferJob(Jobnumber,Depot); 

        try{
         InitialContext ctx = new InitialContext();        
         IntelligenceRemote  test = (IntelligenceRemote ) ctx.lookup(IntelligenceRemote.class.getName());        
       
        
        System.out.println(test.TransferJob("12303", "OHH"));
        } catch (Exception e) {
        System.out.println("Could not transfer job");
    }

Ofcourse Netbeans being wonderful it will already give you the option to add the import.

import javax.naming.InitialContext;  
Advertisements

About Paul C

I am a Senior Java programmer/Web Technologies, Play in a band called Mandolin Monday, I have a cat and I live on a boat.

Posted on February 12, 2008, in Howto and tagged . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: