| Author |
Client-server problem
|
liliane fahmy
Greenhorn
Joined: Aug 24, 2012
Posts: 20
|
|
Hi all,
I have client and server projects.
The server project is a Message -driven project which receive message from the Client .
The problem is :I want to a add EJB module(EJB session bean) in Client project as the server(message driven bean project) can call this session bean .
I tried it by using Netbean:when the client attempt to connect to MDB ,it throw null pointer and the code is as follows:
Connection connection = connectionFactory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(queue);
Message message = session.createTextMessage();
the exception is :Exception in thread "main" java.lang.NullPointerException
at terminalserver.Main.main(Main.java:33)
Although I try to create Entreprise application client project to send a message to my MDB ,it work correctly.
The summary of my problem ,I want my 2 EJB Project,the first has MDB and the other has Session bean and can call each other.
Any help to make my project work .
Thanks and best regards.
|
 |
liliane fahmy
Greenhorn
Joined: Aug 24, 2012
Posts: 20
|
|
Dear all,
please I want reply to my problem ,as it 's serious.
Thanks and best regards
|
 |
Ranganathan Kaliyur Mannar
Bartender
Joined: Oct 16, 2003
Posts: 925
|
|
Please EaseUp. And UseCodeTags when posting code and trace.
I think your question is not clearly defined i.e people may have difficulty in understanding it.
You are mentioning client and server, but it is more of a logical project creation that you mention and not the general client-server.
Note that, you cannot 'call' a MDB. You only send a message to the queue/topic to which the MDB is listening to. When a message is delivered, the server invokes the listener method on the MDB.
You can invoke a session bean from MDB and you can send a message to a queue/topic from a session bean.
But, beware of recursion here. Suppose you have a method A in session bean which sends a message to the MDB and if the MDB in turn calls the method A on the session bean, it gets into a cycle.
Also, from the little stack trace you have provided, it seems to me that you are actually sending the message from a normal Java program (I see a <classname>.main in the trace). Are you sure you are connecting to the queue/topic from a session bean?
|
Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
|
 |
 |
|
|
subject: Client-server problem
|
|
|