tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mho <>
Subject question about using openEJB+tomcat with ear file
Date Sat, 05 Sep 2009 16:34:21 GMT


Can anyone tell me about the magic incantations to use so that a servlet in
a web app can find the local interface of a session bean in a EJB where both
are in the same Enterprise application (EAR file). Below is the detail.

Thank you in advance for your help


I am using tomcat 6.0.20 and openEJB 3.1.1 . (BTW I am using Eclipse J2EE
Galileo as an IDE which even allowing for my lack of experties I think may
have some issues of its own but this problem I am pretty sure is not caused
by the IDE)

To demonstrate this problem I have created a simple ear file that looks like

ext is a web app with a servlet "Agent" that just tries to talk to a session
bean that is in an EJB called "service".

So I load up the ext.war file and also aif6.ear file in Tomcat and restart
( Note: I need to load the war file separately because Catalina looks for
the document root for web app in /ext. Naturally when the EAR file is
expanded the document root is in /aif6/ext and Catalina throws an exception
saying it cant find the web app. To make it happy I have to put the war file
in the webapp directory. -- that is another problem that I will have to fix 
-- I am not sure this is related to the problem I am asking about in this
email if anyone has a suggestion I will be grateful)

The closest I have come to making this work is to use a snippet that I found
in a previous response to someone in this forum. The Agen servlet has code
in it that looks like this  :

Properties p = new Properties();	

p.put("java.naming.provider.url", "");

initialContext = new InitialContext(p); 			


	object = initialContext.lookup("ToDoSesBeanLocal");

}catch (Exception e){"Cant open context "+e.toString());

	return false;


(My specific question is about the counterpart to "java.naming.provider.url"
that would let me use a local resource

The EJB has a session bean with a local interface. When I run the servlet I
get this exception:

****** Cant open context javax.naming.NamingException: Not remotable:
'ToDoSesBeanLocal'. Business Local interfaces are not remotable as per the
EJB specification.  To disable this restriction, set the system property
'openejb.remotable.businessLocals=true' in the server.

It seems to me that doing what the exception says (BTW thank you openEJB
folks for the very informative Exception) will create a remote interface but
I should be able to hook this up with a local interface and avoid the

to complete the picture let me outline the rest. The session bean is really
a front for a MDB and it looks like this

(some import stuff here)

@Stateless(mappedName = "ToDoSesBeanMapped")

public class ToDoSesBean implements ToDoSesBeanLocal {

    public ToDoSesBean() {

        // TODO Auto-generated constructor stub



	private ConnectionFactory connectionFactory;

	@Resource(name = "ToDoBean")

	private Queue todoQueue;

	@Resource(name = "ToDo_AcknowlegeQueue")

	private Queue todo_acknowlegeQueue;

	public void sendMessage(String text) throws JMSException {

		Connection connection = null;

		Session session = null;

		try {

			connection = connectionFactory.createConnection();


			// Create a Session

			session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

			// Create a MessageProducer from the Session to the Topic or Queue

			MessageProducer producer = session.createProducer(todoQueue);


(and so on...)

The code snippet for the local test that works locally but for some reason
does not work in the servlet looks like this

Properties properties = new Properties();


InitialContext initialContext = new InitialContext(properties);

Object object = initialContext.lookup("ToDoSesBeanLocal");

View this message in context:
Sent from the OpenEJB User mailing list archive at

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message