Hi all,
I'm using Glassfish, and more precisely its JMS implementation to send and
receive messages between my java applications. To do so, I'm running
Glassfish in standalone mode in Netbeans, and everything works like a
charm. I don't know anything about Message Driven Beans, Enterprise Java
Beans, and Web applications, I'm just writing a simple Java code with
JMSConsumers, JMSProducers and JMSContext, and it's enough for my java
applications to be able to communicate between themselves.
Now, I would like to test the JMS communication using Java unit tests, and
without having a Glassfish server running in standalone. I found here :
http://docs.oracle.com/cd/E18930_01/html/821-2424/giijw.html#scrolltoc how
to run an instance of Glassfish embedded in my test code.
But now I get the following runtime errors, because of the setClientID
method of JMSContext and the setMessageListener method of JMSConsumer :
"This method may not be called in a Java EE web or EJB container"
Looking at the doc, it seems indeed that those methods cannot be used in a
Java EE web application or EJB container. In other words, my code seems not
to be portable, whereas I thought it was standard and pretty simple JMS
that I was writing.
I tried to learn what EJB container and Java EE web was, but it's
completely obscure to me.
So I have the following options :
- rewrite my code so that I don't use setMessageListener and setClientID,
but I honestly don't know how I could do that
- find another way to embedd a Glassfish server so that I can run my tests.
Here as well, I don't know where to go.
If someone could help me find the right direction, it would be really
helpful, because I'm running out of ideas here.
Thanks a lot.
Regards,
Etienne