• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem accessing ejb3 from jsp in JBOSS

 
anilkumar potu
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to do a jdni lookup from my jsp to a session bean which will post a message on to jms queue.

private sessionMDBRemote sessionmdb = null;

public void jspInit() {
try{
InitialContext ic = new InitialContext();
sessionmdb = (sessionMDBRemote)ic.lookup(sessionMDBRemote.class.getName());
//sessionmdb = (sessionMDBRemote)ic.lookup("");
//sessionmdb = (Calculator) ctx.lookup("EJB3Trail/StatelessCalculator/local");

} catch (Exception NamingException) {
NamingException.printStackTrace();
}
}

This is my sessionMDBRemote.
*******************
package com.ejb3.stateless;

import java.lang.annotation.*;
import javax.ejb.Stateless;
import javax.ejb.Remote;

@Remote
public interface sessionMDBRemote {
public void sendMessage(String xmlString);
}
*******************

And when i tried to access it through jsp call, JBOSS is throwing werror " javax.naming.NameNotFoundException: com.ejb3.stateless.sessionMDBRemote not bound".

Can some one help please?
 
Uli Hofstoetter
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MDBs do not work this way.

You don't access MDBs directly.

You send message to your JMS queue or topic.

The MDS has an @MessageDriven Annotation, which is configured with the queue or topic and should implement the MessageListener Interface.

Check out Chapter 23 of the Sun JEE Tutorial.

Regards,
Uli

PS: Btw ... event if it was a session bean, you tried to invoke, please do not do the lookup from the JSP. At least move it to a servlet, but better would be a Service Locator. Please check out the Core J2EE Patterns, espceially the Service Locator, Session Facade and Business Delegate patterns
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!