0

I've followed the instructions here to create a client to a remote SessionBean. I run the client on the same machine that Glassfish 3.1.2 beta is running on. When I use the gf-client.jar from the 3.1.2 beta Glassfish I get the following Exception which is the same Exception if I leave the gf-client.jar out of the classpath:

javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial

If I use a 3.1.1 gf-client.jar from a Maven repository I get a huge stack trace with complaints about it not being able to find some .jar files from Derby which I'm not even using. Apparently a version mismatch problem.

Has anyone gotten a standalone client to connect to Glassfish 3.1.2 beta? Did this change in JavaEE 6?

Here's the code:

@Stateless
public class LockTestDeadlockService implements LockTestDeadlockServiceI {
  public int getP1Id() throws SQLException {
    int parentId = -1;
    return parentId;
  }
}


@Remote
public interface LockTestDeadlockServiceI {
  public int getP1Id() throws SQLException;
  public void insertChildUpdateParent(int parentId) throws SQLException;
}

Here's my client:

public class LoadTestClient {
  static Logger logger = Logger.getLogger(LoadTestClient.class);
  public static void main(String[] args) {
    String jndiName = "java:global/locktest-0.0.1-SNAPSHOT/LockTestDeadlockService";
    try {
      LockTestDeadlockServiceI lockTestService =
       (LockTestDeadlockServiceI) new InitialContext().lookup(jndiName);
      logger.info("Got lockTestService Remote Interface");
    } catch (NamingException e) {
      logger.info("Failed to get lockTestService Remote Interface: " + e);
    }
  }
}
Dean Schulze
  • 9,633
  • 24
  • 100
  • 165

1 Answers1

0

The short answer is that to connect to GF 3.x from a client, you need a mini-glassfish install via the Application Client Container (ACC) using either webstart or the package-appclient script. Open up the gf-client.jar and look at its classpath in the manifest file. There are a ton of files listed in there. This was similar in GF 2.x, but it seemed to need less dependencies on the client (though it was 15MB with that version).

See these:

Create an "Application Client" with Maven in Java EE

With which maven dependencies can i create a standalone JMS client for Glassfish?

http://docs.oracle.com/cd/E18930_01/html/821-2418/beakt.html#scrolltoc

http://docs.oracle.com/cd/E18930_01/html/821-2418/beakv.html#beakz

Community
  • 1
  • 1
Jim
  • 3,476
  • 4
  • 23
  • 33