tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mho <...@corybant.com>
Subject Re: question about using openEJB+tomcat with ear file -- clarification
Date Sun, 06 Sep 2009 04:28:09 GMT

Hello, I have to update an issue I described earlier. <br/>
The problem with including a webapp inside an EAR file seems to be a
sequencing issue. If I copy a .ear file into the Catalina webapp directory
Tomcat will look at the server.xml file before expanding the EAR file. If I
have a statement in there, for example <Context path="/ext"
docBase="aif6/ext" reloadable="true" > Tomcat won't be able to find /ext
since it has not expanded the EAR file yet.<br/>
In any case this is something that I had observed earlier but not central to
my question but I thought I should clear it up. (also a lesson to me to stay
on one topic per posting -- so sorry)<br/>


Mho wrote:
> 
> Hello,
> <br />
> 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.
> <br />
> Thank you in advance for your help
> <br />
> Mho
> <br /><br />
> 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)
> <br />
> To demonstrate this problem I have created a simple ear file that looks
> like this:
> <br /><br />
>  http://www.nabble.com/file/p25310121/aif6_ear.jpg 
> <br /><br />
> 
> 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".
> <br /><br />
> So I load up the ext.war file and also aif6.ear file in Tomcat and restart
> Tomcat. <br />( 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)
> <br /><br />
> 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  :
> <br /><br /><code>
> Properties p = new Properties();	<br />	
> p.put("java.naming.factory.initial","org.apache.openejb.client.RemoteInitialContextFactory");<br
> />
> p.put("java.naming.provider.url", "http://127.0.0.1:8080/openejb/ejb");<br
> />
> initialContext = new InitialContext(p); 			<br />
> try{<br />
> 	object = initialContext.lookup("ToDoSesBeanLocal");<br />
> }catch (Exception e){<br />
> 	logger.info("Cant open context "+e.toString());<br />
> 	return false;<br />
> }<br />
> </code><br /><br />
> (My specific question is about the counterpart to
> "java.naming.provider.url" that would let me use a local resource
> <br /><br />
> <br />
> The EJB has a session bean with a local interface. When I run the servlet
> I get this exception:
> <br /><br />
> ****** 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.
> <br /><br />
> 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
> overhead. 
> <br /><br />
> to complete the picture let me outline the rest. The session bean is
> really a front for a MDB and it looks like this
> <br /><br /><code>
> (some import stuff here)<br />
> @Stateless(mappedName = "ToDoSesBeanMapped")<br />
> public class ToDoSesBean implements ToDoSesBeanLocal {<br />
>     public ToDoSesBean() {<br />
>         // TODO Auto-generated constructor stub<br />
>     }<br />
> <br />
> 	@Resource<br />
> 	private ConnectionFactory connectionFactory;<br />
> <br />
> 	@Resource(name = "ToDoBean")<br />
> 	private Queue todoQueue;<br />
> <br />
> 	@Resource(name = "ToDo_AcknowlegeQueue")<br />
> 	private Queue todo_acknowlegeQueue;<br />
> <br />
> 	public void sendMessage(String text) throws JMSException {<br />
> <br />
> 		Connection connection = null;<br />
> 		Session session = null;<br />
> 		try {<br />
> 			connection = connectionFactory.createConnection();<br />
> 			connection.start();<br />
> <br />
> 			// Create a Session<br />
> 			session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);<br
> />
> <br />
> 			// Create a MessageProducer from the Session to the Topic or Queue<br
> />
> 			MessageProducer producer = session.createProducer(todoQueue);<br />
> 			producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);<br />
> <br />
> (and so on...)<br />
> </code><br />
> <br />
> The code snippet for the local test that works locally but for some reason
> does not work in the servlet looks like this
> <br /><br />
> <code>
> Properties properties = new Properties();<br />
> properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.apache.openejb.client.LocalInitialContextFactory");<br
> />
> <br />
> InitialContext initialContext = new InitialContext(properties);<br />
> Object object = initialContext.lookup("ToDoSesBeanLocal");<br />
> </code><br /><br />
> 
> 

-- 
View this message in context: http://www.nabble.com/question-about-using-openEJB%2Btomcat-with-ear-file-tp25310121p25314578.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Mime
View raw message