Re: question about using openEJB+tomcat with ear file -- clarification
Hello, I have to update an issue I described earlier. 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 Tomcat won't be able to find /ext since it has not expanded the EAR file yet. 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) Mho wrote: > > Hello, > > 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 > > Mho > > 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 this: > > http://www.nabble.com/file/p25310121/aif6_ear.jpg > > > 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 > Tomcat. ( 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.factory.initial","org.apache.openejb.client.RemoteInitialContextFactory"); /> > p.put("java.naming.provider.url", "http://127.0.0.1:8080/openejb/ejb";); /> > initialContext = new InitialContext(p); > try{ > object = initialContext.lookup("ToDoSesBeanLocal"); > }catch (Exception e){ > logger.info("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 > overhead. > > 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 > } > > @Resource > 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(); > connection.start(); > > // Create a Session > session = connection.createSession(false, > Session.AUTO_ACKNOWLEDGE); /> > > // Create a MessageProducer from the Session t
question about using openEJB+tomcat with ear file
Hello, 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 Mho 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 this: http://www.nabble.com/file/p25310171/aif6_ear.jpg 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 Tomcat. ( 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.factory.initial","org.apache.openejb.client.RemoteInitialContextFactory"); p.put("java.naming.provider.url", "http://127.0.0.1:8080/openejb/ejb";); initialContext = new InitialContext(p); try{ object = initialContext.lookup("ToDoSesBeanLocal"); }catch (Exception e){ logger.info("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 overhead. 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 } @Resource 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(); connection.start(); // 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); producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); (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(); properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.apache.openejb.client.LocalInitialContextFactory"); InitialContext initialContext = new InitialContext(properties); Object object = initialContext.lookup("ToDoSesBeanLocal"); -- View this message in context: http://www.nabble.com/question-about-using-openEJB%2Btomcat-with-ear-file-tp25310171p25310171.html Sent from the OpenEJB User mailing list archive at Nabble.com.
question about using openEJB+tomcat with ear file
Hello, 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 Mho 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 this: http://www.nabble.com/file/p25310144/aif6_ear.jpg 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 Tomcat. ( 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.factory.initial","org.apache.openejb.client.RemoteInitialContextFactory"); p.put("java.naming.provider.url", "http://127.0.0.1:8080/openejb/ejb";); initialContext = new InitialContext(p); try{ object = initialContext.lookup("ToDoSesBeanLocal"); }catch (Exception e){ logger.info("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 overhead. 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 } @Resource 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(); connection.start(); // 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); producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); (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(); properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.apache.openejb.client.LocalInitialContextFactory"); InitialContext initialContext = new InitialContext(properties); Object object = initialContext.lookup("ToDoSesBeanLocal"); -- View this message in context: http://www.nabble.com/question-about-using-openEJB%2Btomcat-with-ear-file-tp25310144p25310144.html Sent from the OpenEJB User mailing list archive at Nabble.com.
question about using openEJB+tomcat with ear file
Hello, 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 Mho 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 this: http://www.nabble.com/file/p25310121/aif6_ear.jpg 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 Tomcat. ( 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.factory.initial","org.apache.openejb.client.RemoteInitialContextFactory"); p.put("java.naming.provider.url", "http://127.0.0.1:8080/openejb/ejb";); initialContext = new InitialContext(p); try{ object = initialContext.lookup("ToDoSesBeanLocal"); }catch (Exception e){ logger.info("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 overhead. 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 } @Resource 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(); connection.start(); // 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); producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); (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(); properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.apache.openejb.client.LocalInitialContextFactory"); InitialContext initialContext = new InitialContext(properties); Object object = initialContext.lookup("ToDoSesBeanLocal"); -- View this message in context: http://www.nabble.com/question-about-using-openEJB%2Btomcat-with-ear-file-tp25310121p25310121.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Using openejb-examples-3.1.1 and Eclipse -- "javax.naming.NameNotFoundException"
I ran into this by mistake but it had me wrapped around the axle for a while so I am posting it in case someone else has fat fingers. If you are following the movie that David Blevins made about using Eclipse to run the examples you notice that you need to add src\main\resources\ to the build path. I was loading up simple-mdb project and by mistake I added src\main\resources\META-INF\ to the build path. I got an error when running the test that said "javax.naming.NameNotFoundException: Name "MessagingClientBeanLocal" not found. That was the only error that I got so it took a while to track it but once I pointed the path to src\main\resources\ it got all better. What I learned is that javax.naming.NameNotFoundException may mean that it can't find the ejb-jar.xml file. I am running this on a Windows XP box so I am not sure if this behaves the same on Linux Mho -- View this message in context: http://www.nabble.com/Using-openejb-examples-3.1.1-and-Eclipse%22javax.naming.NameNotFoundException%22-tp24928470p24928470.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: How to use log4j.xml in Tomcat-openEJB environment
Thanks Jean Louis Just two more questions: (1) Where does this directive go? Is this going to be inserted in the file [tomcat_home]/conf/logging.properties in the place of the default logging configurations? (2) I am guessing that the way to make this work would be to create a web app with just one servlet that initializes log4j and have it come up, then openEJB and then the rest of applications. What is the correct way to control the deployment order? Thanks again for your help Mho Jean-Louis MONTEIRO wrote: > > Hi, > > If you need to control Log4j initialisation, you could set the system > property > > openejb.logger.external=true > > Hope it helps. > Jean-Louis > > > Mho wrote: >> >> Hello, >> I am familiar with tomcat but new to openEJB. Also I saw the thread from >> Sieg but could not figure out what I needed so I am posting this. In >> case there is a shortcut, I am using Eclipse for development. >> >> Is there a way to setup the Tomcat-openEJB environment so that when >> Tomcat comes up and fires up openEJB it looks at a log4j.xml file that I >> can edit and add my own stuff (like nightly rolling file and sending log >> traces from different packages to different files etc.) >> >> It looks like openEJB adds some directives for log4j to the file >> [tomcat_home]/conf/logging.properties and it seems that it would be a >> great thing if there is a way to tell it to use a log4j.xml file and I >> can put my stuff in that same file and if there is a system problem I can >> see whatever openEJB has to say right next to my log trace. >> >> My specific problem is that I am porting some applications from JBOSS to >> openEJB/Tomcat environment and in JBOSS we would modify log4j.xml file >> tht JBOSS used and I am just used to that approach. For example >> in my Web applications that use Tomcat (w/O openEJB) I make a web >> application that just initializes the environment and starts log4j and I >> tell Tomcat to start it as soon as it comes up. >> >> Thanks in advance for your help. >> >> > > -- View this message in context: http://www.nabble.com/How-to-use-log4j.xml-in-Tomcat-openEJB-environment-tp23807412p23833136.html Sent from the OpenEJB User mailing list archive at Nabble.com.
How to use log4j.xml in Tomcat-openEJB environment
Hello, I am familiar with tomcat but new to openEJB. Also I saw the thread from Sieg but could not figure out what I needed so I am posting this. In case there is a shortcut, I am using Eclipse for development. Is there a way to setup the Tomcat-openEJB environment so that when Tomcat comes up and fires up openEJB it looks at a log4j.xml file that I can edit and add my own stuff (like nightly rolling file and sending log traces from different packages to different files etc.) It looks like openEJB adds some directives for log4j to the file [tomcat_home]/conf/logging.properties and it seems that it would be a great thing if there is a way to tell it to use a log4j.xml file and I can put my stuff in that same file and if there is a system problem I can see whatever openEJB has to say right next to my log trace. My specific problem is that I am porting some applications from JBOSS to openEJB/Tomcat environment and in JBOSS we would modify log4j.xml file tht JBOSS used and I am just used to that approach. For example in my Web applications that use Tomcat (w/O openEJB) I make a web application that just initializes the environment and starts log4j and I tell Tomcat to start it as soon as it comes up. Thanks in advance for your help. -- View this message in context: http://www.nabble.com/How-to-use-log4j.xml-in-Tomcat-openEJB-environment-tp23807412p23807412.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: building MDB with Eclipse using openEJB embeded in Tomcat
Thank you. That worked. I appreciate your help. Best regards Mho Mho wrote: > > Hello, > I am new to openEJB and Eclipse. I am not new to Tomcat. > I am porting an application that used to run under JBOSS and it appears > that openEJB/Tomcat should be just a great environment. > > I am using Eclipse with WTP and have successfully loaded up Tomcat with > OpenEJB and now I am trying to bring on line the MDB. > > What I can't figure out is where I would put the XML that describes the > queue for the MDB For example in JBOSS I would have a file that would look > like > >name="jboss.mq.destination:service=Queue,name=myqueueName"> > optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager > > > Any help would be appreciated > Thanks > Mho > -- View this message in context: http://www.nabble.com/building-MDB-with-Eclipse-using-openEJB-embeded-in-Tomcat-tp23715480p23716581.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: building MDB with Eclipse using openEJB embeded in Tomcat
Thank you that explanation makes sense. I added those and then found out that ejb.jar (or at least the copy that I could find) does not include javax.ejb.MessageDriven or javax.ejb.ActivationConfigProperty. I found ejb-3_0-api.jar at http://java.sun.com/products/ejb/docs.html under 3.0 Final release (download class files) --> ejb-3_0-fr-api.zip and that zip file expands into ejb-3_0-api.jar that includes those class files and makes the compiler happy. However by all rights this qualifies as beeing burried deep and I am wondering if I am really lost. Is there a place where the appropriate libraries for ejb 3.0 are kept? Thanks again for your help. Mho David Blevins wrote: > > > On May 25, 2009, at 6:15 PM, Mho wrote: > >> >> Hello, >> I am new to openEJB and Eclipse. I am not new to Tomcat. >> I am porting an application that used to run under JBOSS and it >> appears that >> openEJB/Tomcat should be just a great environment. >> >> I am using Eclipse with WTP and have successfully loaded up Tomcat >> with >> OpenEJB and now I am trying to bring on line the MDB. >> >> What I can't figure out is where I would put the XML that describes >> the >> queue for the MDB For example in JBOSS I would have a file that >> would look >> like >> >> >>jboss.mq:service=DestinationManager > > There are a couple options for specifying the queue name for an MDB. > > The first is to name the MDB after the queue and we will automatically > hook the bean up to the queue with that name. So if the queue name is > "DestinationManager", it'd be like so: > > @MessageDriven > public class DestinationManager implements MessageListener { >//... > } > > or ... > > @MessageDriven(name = "DestinationManager") > public class MyMdbBean implements MessageListener { >//... > } > > The other option is to use an ActivationConfig like so: > > @MessageDriven(activationConfig = { > @ActivationConfigProperty(propertyName="destinationType", > propertyValue = "javax.jms.Queue"), > @ActivationConfigProperty(propertyName="destination", > propertyValue = "DestinationManager")}) > public class MyMdbBean implements MessageListener { >//... > } > > Hope this helps! > > > -David > > > -- View this message in context: http://www.nabble.com/building-MDB-with-Eclipse-using-openEJB-embeded-in-Tomcat-tp23715480p23716386.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: building MDB with Eclipse using openEJB embeded in Tomcat
Sorry it looks like the mailer ate my XML script. what I meant to say was the JBOSS deployment descriptor looked like >server> < mbean code="org.jboss.mq.server.jmx.Queue" name="jboss.mq.destination:service=Queue,name=fclient"> <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends> </mbean> </server> Mho Mho wrote: > > Hello, > I am new to openEJB and Eclipse. I am not new to Tomcat. > I am porting an application that used to run under JBOSS and it appears > that openEJB/Tomcat should be just a great environment. > > I am using Eclipse with WTP and have successfully loaded up Tomcat with > OpenEJB and now I am trying to bring on line the MDB. > > What I can't figure out is where I would put the XML that describes the > queue for the MDB For example in JBOSS I would have a file that would look > like > >name="jboss.mq.destination:service=Queue,name=myqueueName"> > optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager > > > Any help would be appreciated > Thanks > Mho > -- View this message in context: http://www.nabble.com/building-MDB-with-Eclipse-using-openEJB-embeded-in-Tomcat-tp23715480p23715582.html Sent from the OpenEJB User mailing list archive at Nabble.com.
building MDB with Eclipse using openEJB embeded in Tomcat
Hello, I am new to openEJB and Eclipse. I am not new to Tomcat. I am porting an application that used to run under JBOSS and it appears that openEJB/Tomcat should be just a great environment. I am using Eclipse with WTP and have successfully loaded up Tomcat with OpenEJB and now I am trying to bring on line the MDB. What I can't figure out is where I would put the XML that describes the queue for the MDB For example in JBOSS I would have a file that would look like jboss.mq:service=DestinationManager Any help would be appreciated Thanks Mho -- View this message in context: http://www.nabble.com/building-MDB-with-Eclipse-using-openEJB-embeded-in-Tomcat-tp23715480p23715480.html Sent from the OpenEJB User mailing list archive at Nabble.com.