Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting a remote JMS client to GlassFish 3

I am trying to connect to GlassFish 3's JMS service from a standalone remote client. However I am getting a java.lang.ClassNotFoundException: com.sun.messaging.jms.ra.ResourceAdapter. Any ideas on how to fix this?

Here's my setup so far:

  • Glassfish 3 JMS Service in LOCAL mode (I am assuming that EMBEDED mode will not work in this case because it bypasses the network stack)

  • JNDI properties are specified as follows:

    java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory java.naming.factory.url.pkgs=com.sun.enterprise.naming java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl

  • gf-client-module.jar (in GLASSFISH_HOME/modules) added to the standalone application's classpath. Also tried adding other jars present in the modules directory (such as jms-core.jar), but still getting the same ClassNotFoundException.

Any help would be much appreciated.

like image 247
Naresh Avatar asked Mar 30 '11 17:03

Naresh


People also ask

What resources are supported in the GlassFish server?

JMS resources are supported only in the full GlassFish Server, not in the Web Profile. See Using the Java Message Service. The Application Client Container (ACC) includes a set of Java classes, libraries, and other files that are required for and distributed with Java client programs that execute in their own Java Virtual Machine (JVM).

How do I package the GlassFish server system files for remote launch?

You can package the GlassFish Server system files required to launch application clients on remote systems into a single JAR file using the package-appclient script. This is optional. This script is located in the as-install`/bin` directory. For details, see the GlassFish Server Open Source Edition Reference Manual.

Can I use Java Web Start with GlassFish server?

For more information, see Using Java Web Start. In GlassFish Server 5.0, the downloaded appclient JAR file is smaller than in previous releases, with dependent classes in separate JAR files. When copying the downloaded appclient to another location, make sure to include the JAR files containing the dependent classes as well.

How do I authenticate a GlassFish server client?

This typically occurs when the client refers to an EJB component that requires authorization or when annotations in the client’s main class trigger injection which, in turn, requires contact with the GlassFish Server’s naming service. To authenticate the end user, the ACC prompts for any required information, such as a username and password.


2 Answers

Instead of using all of the individual Glassfish jar files that you might need (such as gf-client-module.jar, imqjmsra.jar, and imqbroker.jar), the preferred method is to use the gf-client.jar file. It can be found at $GLASSFISH_HOME/lib.

There is more information at http://glassfish.java.net/javaee5/ejb/EJB_FAQ.html#StandaloneRemoteEJB. That document pertains to using EJBs in standalone clients, but the solution is the same for using JMS.

like image 126
Matthew T. Staebler Avatar answered Sep 20 '22 18:09

Matthew T. Staebler


Ok. I found a solution. See here for details, but the short answer is that I needed to add two jars to the classpath: imqjmsra.jar and imqbroker.jar. These were available inside a rar called imqjmsra.rar which can be found under glassfish's mq directory. I had to extract the two jars from this rar!

like image 29
Naresh Avatar answered Sep 20 '22 18:09

Naresh