0

I have a standalone client that I do not want to deploy on my Glassfish server. With the client I want to post message via the Point to Point communication pattern. I found this great tutorial, which uses annotations I cannot use because I have a standalone client. I found the following solution on stackoverflow:

Context jndiContext;
private ConnectionFactory connectionFactory;
private static Queue queue;

public TweetSender() throws NamingException{
    jndiContext = new InitialContext();
    connectionFactory = (ConnectionFactory) jndiContext.lookup("JMS/KwetterConnectionFactory");
    queue = (Queue) jndiContext.lookup("JMS/KwetterQueue");
}

I also found out that I had to import some libraries from the glassfish directory. So I did: Project properties

I get the following error:

javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterprise.naming.impl.SerialInitContextFactory [Root exception is java.lang.ClassNotFoundException: com.sun.enterprise.naming.impl.SerialInitContextFactory]

What am I doing wrong?

EDIT

I found a temporary solution for the problem though I feel it's not the right one (I think I might get problems when I want to migrate the project. I removed the libraries which I retrieved from the Glassfish lib folder and added them using the "Absolute path".

Bart Burg
  • 4,786
  • 7
  • 52
  • 87

1 Answers1

0

A solution can be packing your standalone client application in a jar file, eg: myclient.jar. And run it as an application client using appclient utility of GlassFish:

applcient -client myclient.jar

The appclient utility can be found here: [glassfish home dir]/glassfish/bin.

Donato Szilagyi
  • 4,279
  • 4
  • 36
  • 53