You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by TomeeUser <pa...@gmail.com> on 2013/04/12 23:30:49 UTC
Can not connect to Message Bean from remote client : Null pointer
I created a simple message bean from example and tried to connect it from
remote. but getting error not able to connect. Getting Null pointer. Below
is the code: Please help
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.xerox.TomEE.beans;
import javax.annotation.Resource;
import javax.ejb.MessageDriven;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.DeliveryMode;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
/**
*
*
*/
@MessageDriven
public class CachedInfoMessageHandlerBean implements MessageListener
{
//@Resource
@Resource(name = "CachedInfoMessageHandlerBeanFactory", type =
ConnectionFactory.class)
private ConnectionFactory connectionFactory;
@Resource(name = "AnswerQueue")
private Queue answerQueue;
@Override
public void onMessage(Message message) {
try {
final TextMessage textMessage = (TextMessage) message;
final String question = textMessage.getText();
if ("Hello World!".equals(question))
{
respond("Hello, Test Case!");
} else if ("How are you?".equals(question))
{
respond("I'm doing well.");
} else if ("Still spinning?".equals(question))
{
respond("Once every day, as usual.");
}
} catch (JMSException e) {
throw new IllegalStateException(e);
}
}
private void respond(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(answerQueue);
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
// Create a message
TextMessage message = session.createTextMessage(text);
// Tell the producer to send the message
producer.send(message);
} finally
{
// Clean up
if (session != null)
{
session.close();
}
if (connection != null)
{
connection.close();
}
}
}
}
Client code :
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package tomeeappclient;
import com.xerox.TomEE.headers.*;
import java.util.Properties;
import javax.annotation.Resource;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
/**
*
*
*/
public class TomEEAppClient
{
// @Resource
// @Resource(name = "jms/CachedInfoMessageHandlerBeanFactory", type =
ConnectionFactory.class)
@Resource
private ConnectionFactory connectionFactory;
@Resource(name = "CachedInfoMessageHandlerBeanFactory")
private Queue questionQueue;
@Resource(name = "AnswerQueue")
private Queue answerQueue;
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception
{
TomEEAppClient client = new TomEEAppClient();
client.process();
}
private void process() throws Exception
{
// TODO code application logic here
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/tomee/ejb");
//p.put(Context.PROVIDER_URL, "ejbd://127.0.0.1:61616");
InitialContext ctx = new InitialContext(p);
CalculatorRemote calc = (CalculatorRemote)
ctx.lookup("CalculatorBeanRemote");
System.out.println( calc.add(10, 10) );
// System.out.println( calc.divide(4, 2) );
// String factory = "remote:CachedInfoMessageHandlerBeanFactory";
// javax.jms.ConnectionFactory cf = (ConnectionFactory)
ctx.lookup(factory);
// final Connection connection = cf.createConnection();
final Connection connection = connectionFactory.createConnection();
connection.start();
final Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
final MessageProducer questions =
session.createProducer(questionQueue);
final MessageConsumer answers =
session.createConsumer(answerQueue);
sendText("Hello World!", questions, session);
// assertEquals("Hello, Test Case!", receiveText(answers));
String answer = receiveText(answers);
System.out.println("Answer received : " + answer);
}
private void sendText(String text, MessageProducer questions, Session
session) throws JMSException {
questions.send(session.createTextMessage(text));
}
private String receiveText(MessageConsumer answers) throws JMSException
{
return ((TextMessage) answers.receive(1000)).getText();
}
}
Error :
C:\AppServers\tomee\webapps>java -jar
"C:\experiments\TomEEAppClient\dist\TomEEAppClient.jar"
Apr 12, 2013 5:27:59 PM org.apache.openejb.client.EventLogger log
INFO:
RemoteInitialContextCreated{providerUri=http://127.0.0.1:8080/tomee/ejb}
20
Exception in thread "main" java.lang.NullPointerException
at tomeeappclient.TomEEAppClient.process(TomEEAppClient.java:66)
at tomeeappclient.TomEEAppClient.main(TomEEAppClient.java:44)
--
View this message in context: http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Can not connect to Message Bean from remote client : Null pointer
Posted by Romain Manni-Bucau <rm...@gmail.com>.
IIRC the key is more or less the jndi name
Le 14 avr. 2013 17:17, "TomeeUser" <pa...@gmail.com> a écrit :
> Hi Romain,
> Not sure I understood correctly. I changed the scheme to IIRC but still get
> the following error:
>
>
>
> Resource/javax.jms.ConnectionFactory=activemq:IIRC:MyJmsConnectionFactory:org.apache.activemq.ActiveMQConnectionFactory:tcp://localhost:61616
>
> ---------------------------------------------------------------------------------
> Getting the OpenEJB InitialContext
> ----------------------------------
> Apr 14, 2013 11:04:08 AM org.apache.openejb.client.EventLogger log
> INFO:
> RemoteInitialContextCreated{providerUri=http://localhost:8080/tomee/ejb}
>
> {java.naming.factory.initial=org.apache.openejb.client.RemoteInitialContextFactory,
> java.naming.provider.url=http://localhost:8080/tomee/ejb}
>
> ----------------------------------
> Looking up MyJmsConnectionFactory
> ----------------------------------
> *javax.naming.NamingException: Unknown JNDI name prefix
> 'openejb/remote/iirc:'
> at
> org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:130)*
> at
>
> org.apache.openejb.server.ejbd.JndiRequestHandler.doLookup(JndiRequestHandler.java:214)
> at
>
> org.apache.openejb.server.ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java:147)
> at
>
> org.apache.openejb.server.ejbd.EjbDaemon.processJndiRequest(EjbDaemon.java:271)
> at
> org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:194)
> at
> org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:81)
> at
>
> org.apache.openejb.server.httpd.ServerServlet.service(ServerServlet.java:56)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
> at
>
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
> at
>
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> at
>
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
> at
>
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
> at
> org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:45)
> at
>
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
> at
>
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
> at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
> at
>
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
> at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
> at
>
> org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
> at
>
> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
> at
>
> org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
> at
>
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
> at
>
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
> at java.lang.Thread.run(Thread.java:722)
> ConnectionFactory: null
>
> ----------------------------------
> Listing all Context Entries
> ----------------------------------
> -> . : java.lang.String
> -> openejb : javax.naming.Context
> -> -> UserBusinessRemote :
> org.apache.openejb.core.ivm.naming.BusinessRemoteReference
> -> -> DeployerBusinessRemote :
> org.apache.openejb.core.ivm.naming.BusinessRemoteReference
> -> -> ConfigurationInfoBusinessRemote :
> org.apache.openejb.core.ivm.naming.BusinessRemoteReference
> -> CachedInfoMessageHandlerBean :
> org.apache.openejb.core.ivm.naming.IntraVmJndiReference
> -> MEJB : org.apache.openejb.core.ivm.naming.ObjectReference
> -> CalculatorBeanRemote :
> org.apache.openejb.core.ivm.naming.BusinessRemoteReference
>
> ---------------------------------------------------------------------------------
>
>
> ---------------------------------------------------------------------------------
> Getting the ActiveMQ InitialContext
> ----------------------------------
>
> {java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory,
> java.naming.provider.url=http://localhost:61616}
>
> ----------------------------------
> Looking up MyJmsConnectionFactory
> ----------------------------------
> *javax.naming.NamingException: scheme iirc not recognized*
> at
> org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:221)
> at javax.naming.InitialContext.lookup(Unknown Source)
> at
>
> tomeeappclient.TomEEAppClient.lookupConnectionFactory(TomEEAppClient.java:88)
> at
> tomeeappclient.TomEEAppClient.testActiveMqJNDI(TomEEAppClient.java:41)
> at tomeeappclient.TomEEAppClient.main(TomEEAppClient.java:29)
> ConnectionFactory: null
>
> ----------------------------------
> Listing all Context Entries
> ----------------------------------
> -> dynamicTopics : org.apache.activemq.jndi.ActiveMQInitialContextFactory$2
> -> TopicConnectionFactory : org.apache.activemq.ActiveMQConnectionFactory
> -> ConnectionFactory : org.apache.activemq.ActiveMQConnectionFactory
> -> XAConnectionFactory : org.apache.activemq.ActiveMQXAConnectionFactory
> -> dynamicQueues : org.apache.activemq.jndi.ActiveMQInitialContextFactory$1
> -> QueueConnectionFactory : org.apache.activemq.ActiveMQConnectionFactory
>
> ---------------------------------------------------------------------------------
>
>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662236.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
Re: Can not connect to Message Bean from remote client : Null pointer
Posted by Romain Manni-Bucau <rm...@gmail.com>.
You can define several queues/names and loop over them (not sure i got it
right)
Le 14 avr. 2013 18:24, "TomeeUser" <pa...@gmail.com> a écrit :
> Hi Romain,
>
> Thanks for your help. I got it resolved. One more question how connect to
> multiple servers? My client needs to send messes to series of servers.
>
> Regards,
> -Shan
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662240.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
Re: Can not connect to Message Bean from remote client : Null pointer
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Great it works.
For the sample can you migrate it to maven? Then we can include it in our
samples
Le 24 avr. 2013 01:27, "TomeeUser" <pa...@gmail.com> a écrit :
> Hi Romain & Smith,
>
> Thanks for being patient with me and providing solutions. Finally I got
> everything working. I am attaching herewith the zip file containing working
> example.
>
> Smith.. I too don't have consumer, just used producer. But it should not be
> a problem now.
>
> I would request you guys if you could post this example, it would be
> helpful
> to somebody else.
>
> Again my sincere thanks for the help provided.
>
> -Shan
>
> I LOVE TOMEE EVEN MORE!!!
>
> JMSTestWorking.zip
> <http://openejb.979440.n4.nabble.com/file/n4662418/JMSTestWorking.zip>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662418.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
Re: Can not connect to Message Bean from remote client : Null pointer
Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
On Tue, Apr 23, 2013 at 7:25 PM, TomeeUser <pa...@gmail.com> wrote:
>
> Smith.. I too don't have consumer, just used producer. But it should not be
> a problem now.
>
>
I reviewed your test-case/example, and I see that Romain's recommendation
(below) solved your problem. Thanks for sharing. I think I have a need for
this in my app.
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destination",
propertyValue = "AnswerQueue")
})
public class CachedInfoMessageHandlerBean implements MessageListener
{
@Override
public void onMessage(Message message)
{
>
> I LOVE TOMEE EVEN MORE!!!
>
Me too! I absolutely love TOMEE and TOMEE committers AND users! :)
When you get a chance, please click on URL below and share your 'tomee user
story/experience' with others.
https://plus.google.com/communities/105208241852045684449/stream/ca33d312-8470-4f0b-a5a2-8ade02160bb2
Re: Can not connect to Message Bean from remote client : Null
pointer
Posted by TomeeUser <pa...@gmail.com>.
Hi Romain & Smith,
Thanks for being patient with me and providing solutions. Finally I got
everything working. I am attaching herewith the zip file containing working
example.
Smith.. I too don't have consumer, just used producer. But it should not be
a problem now.
I would request you guys if you could post this example, it would be helpful
to somebody else.
Again my sincere thanks for the help provided.
-Shan
I LOVE TOMEE EVEN MORE!!!
JMSTestWorking.zip
<http://openejb.979440.n4.nabble.com/file/n4662418/JMSTestWorking.zip>
--
View this message in context: http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662418.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Can not connect to Message Bean from remote client : Null pointer
Posted by Romain Manni-Bucau <rm...@gmail.com>.
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destination",
propertyValue = "test/ejb/AnswerQueue")
})
public class CachedInfoMessageHandlerBean implements MessageListener
*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*
2013/4/23 Howard W. Smith, Jr. <sm...@gmail.com>
> Yes, I used the TomEE 'simple MDB' example code to develop my MDB code, but
> honestly, I 'only' have 'producer' queues and rely on MDB's onMessage() to
> process the message. ATM, I am 'not' using 'consumer' queues at all.
>
>
>
>
> On Tue, Apr 23, 2013 at 4:27 PM, Howard W. Smith, Jr. <
> smithh032772@gmail.com> wrote:
>
> > MessageListener invokes just fine in my app. Two differences between your
> > MDB and my MDB.
> >
> > 1. I added an empty constructor that accepts no arguments. For some
> > weeks/months now, one MDB did 'not' have an empty constructor, while the
> > other MDB had empty constructor.
> >
> > 2. I don't @Override the onMessage(...)
> >
> > Below is one of my MDBs, and they both are pretty much defined this way.
> >
> > @MessageDriven
> > public class EmailMessageDrivenBean implements MessageListener {
> >
> > private final Boolean debug = true;
> >
> > private final Logger logger = LoggerFactory.getLogger(getClass());
> >
> > @Inject
> > private ApplicationScopeBean applicationScopeBean;
> >
> > /*
> > * 2013-03-19 DO NOT USE @EJB AddEmailRequest; use @Inject, since NO
> > DEADLOCK
> > * ONLY USE @EJB after testing, and if there are NO
> DEADLOCK
> > */
> > @EJB
> > private AddEmailRequest addEmailRequestBean;
> >
> > public EmailMessageDrivenBean() {
> > /*
> > * since MDB is pooled, do NOT use to initialize values!!!
> > */
> > }
> >
> > public void onMessage(Message message) {
> >
> >
> >
> >
> >
> > On Tue, Apr 23, 2013 at 1:08 PM, TomeeUser <pa...@gmail.com> wrote:
> >
> >>
> >> I see all messages are send to right queue ( in activeMQ webconsole )
> but
> >> MessageListner is not being invoked... I put log statements nothing
> >> appears
> >> in log...and same client and app works just fine in JBoss...
> >>
> >> I would really hate to switch back to JBoss as love Tomee for its
> >> simplicity.
> >>
> >> Below are the logs:
> >>
> >>
> >>
> >> 20130423 11:43:03 INFO (HostConfig)
> >> org.apache.catalina.startup.HostConfig [deployWAR]:Deploying web
> >> application
> >> archive C:\AppServers\tomee\webapps\TomEEApp.war
> >> 20130423 11:43:03 INFO (root)
> >> org.apache.tomee.catalina.TomcatWebAppBuilder
> >> [init]:------------------------- localhost -> /TomEEApp
> >> 20130423 11:43:03 INFO (root) org.apache.openejb.util.JarExtractor
> >> [extract]:Extracting jar: C:\AppServers\tomee\webapps\TomEEApp.war
> >> 20130423 11:43:03 INFO (root) org.apache.openejb.util.JarExtractor
> >> [extract]:Extracted path: C:\AppServers\tomee\webapps\TomEEApp
> >> 20130423 11:43:03 INFO (root)
> >>
> >>
> org.apache.openejb.config.ConfigurationFactory[configureApplication]:Configuring
> >> enterprise application: C:\AppServers\tomee\webapps\TomEEApp
> >> 20130423 11:43:04 INFO (root)
> >> org.apache.openejb.config.InitEjbDeployments [deploy]:Auto-deploying ejb
> >> CalculatorBean: EjbDeployment(deployment-id=CalculatorBean)
> >> 20130423 11:43:04 INFO (root)
> >> org.apache.openejb.config.InitEjbDeployments [deploy]:Auto-deploying ejb
> >> CachedInfoMessageHandlerBean:
> >> EjbDeployment(deployment-id=CachedInfoMessageHandlerBean)
> >> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
> >> [resolveDestinationLinks]:Auto-configuring a message driven bean
> >> CachedInfoMessageHandlerBean destination CachedInfoMessageHandlerBean to
> >> be
> >> destinationType javax.jms.Queue
> >> 20130423 11:43:04 INFO (root)
> >>
> >>
> org.apache.openejb.config.ConfigurationFactory[configureService]:Configuring
> >> Service(id=Default JMS Connection Factory, type=Resource,
> >> provider-id=Default JMS Connection Factory)
> >> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
> >> [logAutoCreateResource]:Auto-creating a Resource with id 'Default JMS
> >> Connection Factory'of type 'javax.jms.ConnectionFactory for
> >> 'CalculatorBean'.
> >> 20130423 11:43:04 INFO (root)
> >>
> >>
> org.apache.openejb.config.ConfigurationFactory[configureService]:Configuring
> >> Service(id=Default JMS Resource Adapter, type=Resource,
> >> provider-id=Default
> >> JMS Resource Adapter)
> >> 20130423 11:43:04 INFO (root)
> >>
> >>
> org.apache.openejb.config.ConfigurationFactory[configureService]:Configuring
> >> Service(id=Default Unmanaged JDBC Database, type=Resource,
> >> provider-id=Default Unmanaged JDBC Database)
> >> 20130423 11:43:04 INFO (root)
> >> org.apache.openejb.assembler.classic.Assembler[createRecipe]:Creating
> >> Resource(id=Default Unmanaged JDBC Database)
> >> 20130423 11:43:04 INFO (root)
> >> org.apache.openejb.assembler.classic.Assembler[createRecipe]:Creating
> >> Resource(id=Default JMS Resource Adapter)
> >> 20130423 11:43:04 INFO (root)
> >> org.apache.openejb.resource.activemq.ActiveMQ5Factory
> >> [createBroker]:ActiveMQ5Factory creating broker
> >> 20130423 11:43:04 INFO (root)
> >> org.apache.openejb.resource.activemq.ActiveMQ5Factory
> [createBroker]:Using
> >> ActiveMQ startup timeout of 10000ms
> >> 20130423 11:43:04 INFO (root)
> >> org.apache.openejb.resource.activemq.ActiveMQ5Factory$1 [run]:Starting
> >> ActiveMQ BrokerService
> >> 20130423 11:43:04 INFO (BrokerService)
> >> org.apache.activemq.broker.BrokerService
> [doStartPersistenceAdapter]:Using
> >> Persistence Adapter: MemoryPersistenceAdapter
> >> 20130423 11:43:04 INFO (BrokerService)
> >> org.apache.activemq.broker.BrokerService [doStartBroker]:Apache ActiveMQ
> >> 5.7.0 (localhost, ID:CND1222QY1-4861-1366731730439-0:2) is starting
> >> 20130423 11:43:04 INFO (TransportServerThreadSupport)
> >> org.apache.activemq.transport.TransportServerThreadSupport
> >> [doStart]:Listening for connections at: tcp://localhost:61616
> >> 20130423 11:43:04 INFO (TransportConnector)
> >> org.apache.activemq.broker.TransportConnector [start]:Connector
> >> tcp://localhost:61616 Started
> >> 20130423 11:43:04 INFO (BrokerService)
> >> org.apache.activemq.broker.BrokerService [doStartBroker]:Apache ActiveMQ
> >> 5.7.0 (localhost, ID:CND1222QY1-4861-1366731730439-0:2) started
> >> 20130423 11:43:04 INFO (BrokerService)
> >> org.apache.activemq.broker.BrokerService [doStartBroker]:For help or
> more
> >> information please see: http://activemq.apache.org
> >> 20130423 11:43:04 INFO (root)
> >> org.apache.openejb.resource.activemq.ActiveMQ5Factory$1 [run]:Starting
> >> ActiveMQ checkpoint
> >> 20130423 11:43:04 INFO (root)
> >> org.apache.openejb.resource.activemq.ActiveMQ5Factory
> >> [createBroker]:ActiveMQ broker started
> >> 20130423 11:43:04 INFO (root)
> >> org.apache.openejb.assembler.classic.Assembler[createRecipe]:Creating
> >> Resource(id=Default JMS Connection Factory)
> >> 20130423 11:43:04 INFO (root)
> >> org.apache.openejb.assembler.classic.Assembler[createResource]:Creating
> >> ConnectionManager for Resource(id=Default JMS Connection Factory)
> >> 20130423 11:43:04 INFO (GenericConnectionManager)
> >>
> >>
> org.apache.geronimo.connector.outbound.GenericConnectionManager$InterceptorsImpl
> >> [<init>]:No runtime TransactionSupport
> >> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
> >> [processResourceRef]:Auto-linking resource-ref
> >>
> >>
> 'java:comp/env/test.ejbs.TomEE.beans.CachedInfoMessageHandlerBean/connectionFactory'
> >> in bean CalculatorBean to Resource(id=Default JMS Connection Factory)
> >> 20130423 11:43:04 INFO (root)
> >>
> >>
> org.apache.openejb.config.ConfigurationFactory[configureService]:Configuring
> >> Service(id=AnswerQueue, type=Resource, provider-id=Default Queue)
> >> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
> >> [logAutoCreateResource]:Auto-creating a Resource with id 'AnswerQueue'
> of
> >> type 'javax.jms.Queue for 'CalculatorBean'.
> >> 20130423 11:43:04 INFO (root)
> >> org.apache.openejb.assembler.classic.Assembler[createRecipe]:Creating
> >> Resource(id=AnswerQueue)
> >> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
> >> [processResourceEnvRef]:Auto-linking resource-env-ref
> >> 'java:comp/env/AnswerQueue' in bean CalculatorBean to
> >> Resource(id=AnswerQueue)
> >> 20130423 11:43:04 INFO (root)
> >>
> >>
> org.apache.openejb.config.ConfigurationFactory[configureService]:Configuring
> >> Service(id=Default MDB Container, type=Container, provider-id=Default
> MDB
> >> Container)
> >> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
> >> [createContainer]:Auto-creating a container for bean
> >> CachedInfoMessageHandlerBean: Container(type=MESSAGE, id=Default MDB
> >> Container)
> >> 20130423 11:43:04 INFO (root)
> >> org.apache.openejb.assembler.classic.Assembler[createRecipe]:Creating
> >> Container(id=Default MDB Container)
> >> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
> >> [processResourceRef]:Auto-linking resource-ref
> >>
> >>
> 'java:comp/env/test.ejbs.TomEE.beans.CachedInfoMessageHandlerBean/connectionFactory'
> >> in bean CachedInfoMessageHandlerBean to Resource(id=Default JMS
> Connection
> >> Factory)
> >> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
> >> [processResourceEnvRef]:Auto-linking resource-env-ref
> >> 'java:comp/env/AnswerQueue' in bean CachedInfoMessageHandlerBean to
> >> Resource(id=AnswerQueue)
> >> 20130423 11:43:04 INFO (root)
> >>
> >>
> org.apache.openejb.config.ConfigurationFactory[configureService]:Configuring
> >> Service(id=CachedInfoMessageHandlerBean, type=Resource,
> >> provider-id=Default
> >> Queue)
> >> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
> >> [logAutoCreateResource]:Auto-creating a Resource with id
> >> 'CachedInfoMessageHandlerBean' of type 'javax.jms.Queue for
> >> 'CachedInfoMessageHandlerBean'.
> >> 20130423 11:43:04 INFO (root)
> >> org.apache.openejb.assembler.classic.Assembler[createRecipe]:Creating
> >> Resource(id=CachedInfoMessageHandlerBean)
> >> 20130423 11:43:04 INFO (root)
> org.apache.openejb.config.AppInfoBuilder
> >> [build]:Enterprise application "C:\AppServers\tomee\webapps\TomEEApp"
> >> loaded.
> >> 20130423 11:43:04 INFO (root)
> >>
> >>
> org.apache.openejb.assembler.classic.Assembler[createApplication]:Assembling
> >> app: C:\AppServers\tomee\webapps\TomEEApp
> >> 20130423 11:43:04 INFO (root)
> >> org.apache.openejb.assembler.classic.JndiBuilder
> >> [bind]:Jndi(name=CalculatorBeanLocalBean) -->
> >> Ejb(deployment-id=CalculatorBean)
> >> 20130423 11:43:04 INFO (root)
> >> org.apache.openejb.assembler.classic.JndiBuilder
> >>
> >>
> [bind]:Jndi(name=global/TomEEApp/CalculatorBean!test.ejbs.TomEE.beans.CalculatorBean)
> >> --> Ejb(deployment-id=CalculatorBean)
> >> 20130423 11:43:04 INFO (root)
> >> org.apache.openejb.assembler.classic.JndiBuilder
> >> [bind]:Jndi(name=CalculatorBeanRemote) -->
> >> Ejb(deployment-id=CalculatorBean)
> >> 20130423 11:43:04 INFO (root)
> >> org.apache.openejb.assembler.classic.JndiBuilder
> >>
> >>
> [bind]:Jndi(name=global/TomEEApp/CalculatorBean!test.ejbs.TomEE.headers.CalculatorRemote)
> >> --> Ejb(deployment-id=CalculatorBean)
> >> 20130423 11:43:04 INFO (root)
> >> org.apache.openejb.assembler.classic.JndiBuilder
> >>
> >>
> [bind]:Jndi(name=global/TomEEApp/CalculatorBean!test.ejbs.TomEE.headers.CalculatorLocal)
> >> --> Ejb(deployment-id=CalculatorBean)
> >> 20130423 11:43:04 INFO (root)
> >> org.apache.openejb.assembler.classic.JndiBuilder
> >> [bind]:Jndi(name=global/TomEEApp/CalculatorBean) -->
> >> Ejb(deployment-id=CalculatorBean)
> >> 20130423 11:43:04 INFO (root)
> >> org.apache.openejb.assembler.classic.JndiBuilder
> >> [bind]:Jndi(name=CachedInfoMessageHandlerBean) -->
> >> Ejb(deployment-id=CachedInfoMessageHandlerBean)
> >> 20130423 11:43:04 INFO (root) org.apache.openejb.cdi.CdiBuilder
> >> [initSingleton]:Existing thread singleton service in SystemInstance():
> >> org.apache.openejb.cdi.ThreadSingletonServiceImpl@15c97a42013042311
> :43:04
> >> INFO (root) org.apache.openejb.cdi.OpenEJBLifecycle
> >> [startApplication]:OpenWebBeans Container is starting...
> >> 20130423 11:43:04 INFO (PluginLoader)
> >> org.apache.webbeans.plugins.PluginLoader [startUp]:Adding
> >> OpenWebBeansPlugin
> >> : [CdiPlugin]
> >> 20130423 11:43:04 INFO (PluginLoader)
> >> org.apache.webbeans.plugins.PluginLoader [startUp]:Adding
> >> OpenWebBeansPlugin
> >> : [OpenWebBeansJsfPlugin]
> >> 20130423 11:43:04 INFO (root) org.apache.openejb.cdi.BeansDeployer
> >> [validateInjectionPoints]:All injection points are validated
> successfully.
> >> 20130423 11:43:04 INFO (root) org.apache.openejb.cdi.OpenEJBLifecycle
> >> [startApplication]:OpenWebBeans Container has started, it took 16 ms.
> >> 20130423 11:43:04 INFO (root)
> >> org.apache.openejb.assembler.classic.Assembler[startEjbs]:Created
> >> Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean,
> >> container=Default
> >> Stateless Container)
> >> 20130423 11:43:04 INFO (ActiveMQEndpointWorker)
> >> org.apache.activemq.ra.ActiveMQEndpointWorker [start]:Starting20130423
> >> 11:43:04 INFO (root)
> >> org.apache.openejb.assembler.classic.Assembler[startEjbs]:Created
> >> Ejb(deployment-id=CachedInfoMessageHandlerBean,
> >> ejb-name=CachedInfoMessageHandlerBean, container=Default MDB Container)
> >> 20130423 11:43:04 INFO (WorkerContext)
> >> org.apache.geronimo.connector.work.WorkerContext [run]:Removing
> >> non-required
> >> WorkContextHandler with no context:
> >> org.apache.geronimo.connector.work.TransactionContextHandler@7ed6f6
> >> 20130423 11:43:04 INFO (WorkerContext)
> >> org.apache.geronimo.connector.work.WorkerContext [run]:Removing
> >> non-required
> >> WorkContextHandler with no context:
> >> org.apache.openejb.core.security.SecurityContextHandler@14949e620130423
> >> 11:43:04 INFO (root)
> >> org.apache.openejb.assembler.classic.Assembler[startEjbs]:Started
> >> Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean,
> >> container=Default
> >> Stateless Container)
> >> 20130423 11:43:04 INFO (WorkerContext)
> >> org.apache.geronimo.connector.work.WorkerContext [run]:Removing
> >> non-required
> >> WorkContextHandler with no context:
> >> org.apache.geronimo.connector.work.HintsContextHandler@1c88d9c
> >> 20130423 11:43:04 INFO (root)
> >> org.apache.openejb.assembler.classic.Assembler[startEjbs]:Started
> >> Ejb(deployment-id=CachedInfoMessageHandlerBean,
> >> ejb-name=CachedInfoMessageHandlerBean, container=Default MDB Container)
> >> 20130423 11:43:04 INFO (ActiveMQEndpointWorker)
> >> org.apache.activemq.ra.ActiveMQEndpointWorker$1 [run]:Establishing
> >> connection to broker [vm://localhost?waitForStart=20000&async=true]
> >> 20130423 11:43:04 INFO (root)
> >> org.apache.tomee.catalina.TomcatWebAppBuilder [deployWebApps]:using
> >> context
> >> file C:\AppServers\tomee\webapps\TomEEApp\META-INF\context.xml
> >> 20130423 11:43:04 INFO (root)
> >>
> org.apache.openejb.assembler.classic.Assembler[createApplication]:Deployed
> >> Application(path=C:\AppServers\tomee\webapps\TomEEApp)
> >> 20130423 11:43:04 INFO (TransportConnector)
> >> org.apache.activemq.broker.TransportConnector [start]:Connector
> >> vm://localhost Started
> >> 20130423 11:43:04 INFO (ActiveMQEndpointWorker)
> >> org.apache.activemq.ra.ActiveMQEndpointWorker$1 [run]:Successfully
> >> established connection to broker
> >> [vm://localhost?waitForStart=20000&async=true]
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662407.html
> >> Sent from the OpenEJB User mailing list archive at Nabble.com.
> >>
> >
> >
>
Re: Can not connect to Message Bean from remote client : Null pointer
Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
Yes, I used the TomEE 'simple MDB' example code to develop my MDB code, but
honestly, I 'only' have 'producer' queues and rely on MDB's onMessage() to
process the message. ATM, I am 'not' using 'consumer' queues at all.
On Tue, Apr 23, 2013 at 4:27 PM, Howard W. Smith, Jr. <
smithh032772@gmail.com> wrote:
> MessageListener invokes just fine in my app. Two differences between your
> MDB and my MDB.
>
> 1. I added an empty constructor that accepts no arguments. For some
> weeks/months now, one MDB did 'not' have an empty constructor, while the
> other MDB had empty constructor.
>
> 2. I don't @Override the onMessage(...)
>
> Below is one of my MDBs, and they both are pretty much defined this way.
>
> @MessageDriven
> public class EmailMessageDrivenBean implements MessageListener {
>
> private final Boolean debug = true;
>
> private final Logger logger = LoggerFactory.getLogger(getClass());
>
> @Inject
> private ApplicationScopeBean applicationScopeBean;
>
> /*
> * 2013-03-19 DO NOT USE @EJB AddEmailRequest; use @Inject, since NO
> DEADLOCK
> * ONLY USE @EJB after testing, and if there are NO DEADLOCK
> */
> @EJB
> private AddEmailRequest addEmailRequestBean;
>
> public EmailMessageDrivenBean() {
> /*
> * since MDB is pooled, do NOT use to initialize values!!!
> */
> }
>
> public void onMessage(Message message) {
>
>
>
>
>
> On Tue, Apr 23, 2013 at 1:08 PM, TomeeUser <pa...@gmail.com> wrote:
>
>>
>> I see all messages are send to right queue ( in activeMQ webconsole ) but
>> MessageListner is not being invoked... I put log statements nothing
>> appears
>> in log...and same client and app works just fine in JBoss...
>>
>> I would really hate to switch back to JBoss as love Tomee for its
>> simplicity.
>>
>> Below are the logs:
>>
>>
>>
>> 20130423 11:43:03 INFO (HostConfig)
>> org.apache.catalina.startup.HostConfig [deployWAR]:Deploying web
>> application
>> archive C:\AppServers\tomee\webapps\TomEEApp.war
>> 20130423 11:43:03 INFO (root)
>> org.apache.tomee.catalina.TomcatWebAppBuilder
>> [init]:------------------------- localhost -> /TomEEApp
>> 20130423 11:43:03 INFO (root) org.apache.openejb.util.JarExtractor
>> [extract]:Extracting jar: C:\AppServers\tomee\webapps\TomEEApp.war
>> 20130423 11:43:03 INFO (root) org.apache.openejb.util.JarExtractor
>> [extract]:Extracted path: C:\AppServers\tomee\webapps\TomEEApp
>> 20130423 11:43:03 INFO (root)
>>
>> org.apache.openejb.config.ConfigurationFactory[configureApplication]:Configuring
>> enterprise application: C:\AppServers\tomee\webapps\TomEEApp
>> 20130423 11:43:04 INFO (root)
>> org.apache.openejb.config.InitEjbDeployments [deploy]:Auto-deploying ejb
>> CalculatorBean: EjbDeployment(deployment-id=CalculatorBean)
>> 20130423 11:43:04 INFO (root)
>> org.apache.openejb.config.InitEjbDeployments [deploy]:Auto-deploying ejb
>> CachedInfoMessageHandlerBean:
>> EjbDeployment(deployment-id=CachedInfoMessageHandlerBean)
>> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
>> [resolveDestinationLinks]:Auto-configuring a message driven bean
>> CachedInfoMessageHandlerBean destination CachedInfoMessageHandlerBean to
>> be
>> destinationType javax.jms.Queue
>> 20130423 11:43:04 INFO (root)
>>
>> org.apache.openejb.config.ConfigurationFactory[configureService]:Configuring
>> Service(id=Default JMS Connection Factory, type=Resource,
>> provider-id=Default JMS Connection Factory)
>> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
>> [logAutoCreateResource]:Auto-creating a Resource with id 'Default JMS
>> Connection Factory'of type 'javax.jms.ConnectionFactory for
>> 'CalculatorBean'.
>> 20130423 11:43:04 INFO (root)
>>
>> org.apache.openejb.config.ConfigurationFactory[configureService]:Configuring
>> Service(id=Default JMS Resource Adapter, type=Resource,
>> provider-id=Default
>> JMS Resource Adapter)
>> 20130423 11:43:04 INFO (root)
>>
>> org.apache.openejb.config.ConfigurationFactory[configureService]:Configuring
>> Service(id=Default Unmanaged JDBC Database, type=Resource,
>> provider-id=Default Unmanaged JDBC Database)
>> 20130423 11:43:04 INFO (root)
>> org.apache.openejb.assembler.classic.Assembler[createRecipe]:Creating
>> Resource(id=Default Unmanaged JDBC Database)
>> 20130423 11:43:04 INFO (root)
>> org.apache.openejb.assembler.classic.Assembler[createRecipe]:Creating
>> Resource(id=Default JMS Resource Adapter)
>> 20130423 11:43:04 INFO (root)
>> org.apache.openejb.resource.activemq.ActiveMQ5Factory
>> [createBroker]:ActiveMQ5Factory creating broker
>> 20130423 11:43:04 INFO (root)
>> org.apache.openejb.resource.activemq.ActiveMQ5Factory [createBroker]:Using
>> ActiveMQ startup timeout of 10000ms
>> 20130423 11:43:04 INFO (root)
>> org.apache.openejb.resource.activemq.ActiveMQ5Factory$1 [run]:Starting
>> ActiveMQ BrokerService
>> 20130423 11:43:04 INFO (BrokerService)
>> org.apache.activemq.broker.BrokerService [doStartPersistenceAdapter]:Using
>> Persistence Adapter: MemoryPersistenceAdapter
>> 20130423 11:43:04 INFO (BrokerService)
>> org.apache.activemq.broker.BrokerService [doStartBroker]:Apache ActiveMQ
>> 5.7.0 (localhost, ID:CND1222QY1-4861-1366731730439-0:2) is starting
>> 20130423 11:43:04 INFO (TransportServerThreadSupport)
>> org.apache.activemq.transport.TransportServerThreadSupport
>> [doStart]:Listening for connections at: tcp://localhost:61616
>> 20130423 11:43:04 INFO (TransportConnector)
>> org.apache.activemq.broker.TransportConnector [start]:Connector
>> tcp://localhost:61616 Started
>> 20130423 11:43:04 INFO (BrokerService)
>> org.apache.activemq.broker.BrokerService [doStartBroker]:Apache ActiveMQ
>> 5.7.0 (localhost, ID:CND1222QY1-4861-1366731730439-0:2) started
>> 20130423 11:43:04 INFO (BrokerService)
>> org.apache.activemq.broker.BrokerService [doStartBroker]:For help or more
>> information please see: http://activemq.apache.org
>> 20130423 11:43:04 INFO (root)
>> org.apache.openejb.resource.activemq.ActiveMQ5Factory$1 [run]:Starting
>> ActiveMQ checkpoint
>> 20130423 11:43:04 INFO (root)
>> org.apache.openejb.resource.activemq.ActiveMQ5Factory
>> [createBroker]:ActiveMQ broker started
>> 20130423 11:43:04 INFO (root)
>> org.apache.openejb.assembler.classic.Assembler[createRecipe]:Creating
>> Resource(id=Default JMS Connection Factory)
>> 20130423 11:43:04 INFO (root)
>> org.apache.openejb.assembler.classic.Assembler[createResource]:Creating
>> ConnectionManager for Resource(id=Default JMS Connection Factory)
>> 20130423 11:43:04 INFO (GenericConnectionManager)
>>
>> org.apache.geronimo.connector.outbound.GenericConnectionManager$InterceptorsImpl
>> [<init>]:No runtime TransactionSupport
>> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
>> [processResourceRef]:Auto-linking resource-ref
>>
>> 'java:comp/env/test.ejbs.TomEE.beans.CachedInfoMessageHandlerBean/connectionFactory'
>> in bean CalculatorBean to Resource(id=Default JMS Connection Factory)
>> 20130423 11:43:04 INFO (root)
>>
>> org.apache.openejb.config.ConfigurationFactory[configureService]:Configuring
>> Service(id=AnswerQueue, type=Resource, provider-id=Default Queue)
>> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
>> [logAutoCreateResource]:Auto-creating a Resource with id 'AnswerQueue' of
>> type 'javax.jms.Queue for 'CalculatorBean'.
>> 20130423 11:43:04 INFO (root)
>> org.apache.openejb.assembler.classic.Assembler[createRecipe]:Creating
>> Resource(id=AnswerQueue)
>> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
>> [processResourceEnvRef]:Auto-linking resource-env-ref
>> 'java:comp/env/AnswerQueue' in bean CalculatorBean to
>> Resource(id=AnswerQueue)
>> 20130423 11:43:04 INFO (root)
>>
>> org.apache.openejb.config.ConfigurationFactory[configureService]:Configuring
>> Service(id=Default MDB Container, type=Container, provider-id=Default MDB
>> Container)
>> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
>> [createContainer]:Auto-creating a container for bean
>> CachedInfoMessageHandlerBean: Container(type=MESSAGE, id=Default MDB
>> Container)
>> 20130423 11:43:04 INFO (root)
>> org.apache.openejb.assembler.classic.Assembler[createRecipe]:Creating
>> Container(id=Default MDB Container)
>> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
>> [processResourceRef]:Auto-linking resource-ref
>>
>> 'java:comp/env/test.ejbs.TomEE.beans.CachedInfoMessageHandlerBean/connectionFactory'
>> in bean CachedInfoMessageHandlerBean to Resource(id=Default JMS Connection
>> Factory)
>> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
>> [processResourceEnvRef]:Auto-linking resource-env-ref
>> 'java:comp/env/AnswerQueue' in bean CachedInfoMessageHandlerBean to
>> Resource(id=AnswerQueue)
>> 20130423 11:43:04 INFO (root)
>>
>> org.apache.openejb.config.ConfigurationFactory[configureService]:Configuring
>> Service(id=CachedInfoMessageHandlerBean, type=Resource,
>> provider-id=Default
>> Queue)
>> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
>> [logAutoCreateResource]:Auto-creating a Resource with id
>> 'CachedInfoMessageHandlerBean' of type 'javax.jms.Queue for
>> 'CachedInfoMessageHandlerBean'.
>> 20130423 11:43:04 INFO (root)
>> org.apache.openejb.assembler.classic.Assembler[createRecipe]:Creating
>> Resource(id=CachedInfoMessageHandlerBean)
>> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AppInfoBuilder
>> [build]:Enterprise application "C:\AppServers\tomee\webapps\TomEEApp"
>> loaded.
>> 20130423 11:43:04 INFO (root)
>>
>> org.apache.openejb.assembler.classic.Assembler[createApplication]:Assembling
>> app: C:\AppServers\tomee\webapps\TomEEApp
>> 20130423 11:43:04 INFO (root)
>> org.apache.openejb.assembler.classic.JndiBuilder
>> [bind]:Jndi(name=CalculatorBeanLocalBean) -->
>> Ejb(deployment-id=CalculatorBean)
>> 20130423 11:43:04 INFO (root)
>> org.apache.openejb.assembler.classic.JndiBuilder
>>
>> [bind]:Jndi(name=global/TomEEApp/CalculatorBean!test.ejbs.TomEE.beans.CalculatorBean)
>> --> Ejb(deployment-id=CalculatorBean)
>> 20130423 11:43:04 INFO (root)
>> org.apache.openejb.assembler.classic.JndiBuilder
>> [bind]:Jndi(name=CalculatorBeanRemote) -->
>> Ejb(deployment-id=CalculatorBean)
>> 20130423 11:43:04 INFO (root)
>> org.apache.openejb.assembler.classic.JndiBuilder
>>
>> [bind]:Jndi(name=global/TomEEApp/CalculatorBean!test.ejbs.TomEE.headers.CalculatorRemote)
>> --> Ejb(deployment-id=CalculatorBean)
>> 20130423 11:43:04 INFO (root)
>> org.apache.openejb.assembler.classic.JndiBuilder
>>
>> [bind]:Jndi(name=global/TomEEApp/CalculatorBean!test.ejbs.TomEE.headers.CalculatorLocal)
>> --> Ejb(deployment-id=CalculatorBean)
>> 20130423 11:43:04 INFO (root)
>> org.apache.openejb.assembler.classic.JndiBuilder
>> [bind]:Jndi(name=global/TomEEApp/CalculatorBean) -->
>> Ejb(deployment-id=CalculatorBean)
>> 20130423 11:43:04 INFO (root)
>> org.apache.openejb.assembler.classic.JndiBuilder
>> [bind]:Jndi(name=CachedInfoMessageHandlerBean) -->
>> Ejb(deployment-id=CachedInfoMessageHandlerBean)
>> 20130423 11:43:04 INFO (root) org.apache.openejb.cdi.CdiBuilder
>> [initSingleton]:Existing thread singleton service in SystemInstance():
>> org.apache.openejb.cdi.ThreadSingletonServiceImpl@15c97a42013042311:43:04
>> INFO (root) org.apache.openejb.cdi.OpenEJBLifecycle
>> [startApplication]:OpenWebBeans Container is starting...
>> 20130423 11:43:04 INFO (PluginLoader)
>> org.apache.webbeans.plugins.PluginLoader [startUp]:Adding
>> OpenWebBeansPlugin
>> : [CdiPlugin]
>> 20130423 11:43:04 INFO (PluginLoader)
>> org.apache.webbeans.plugins.PluginLoader [startUp]:Adding
>> OpenWebBeansPlugin
>> : [OpenWebBeansJsfPlugin]
>> 20130423 11:43:04 INFO (root) org.apache.openejb.cdi.BeansDeployer
>> [validateInjectionPoints]:All injection points are validated successfully.
>> 20130423 11:43:04 INFO (root) org.apache.openejb.cdi.OpenEJBLifecycle
>> [startApplication]:OpenWebBeans Container has started, it took 16 ms.
>> 20130423 11:43:04 INFO (root)
>> org.apache.openejb.assembler.classic.Assembler[startEjbs]:Created
>> Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean,
>> container=Default
>> Stateless Container)
>> 20130423 11:43:04 INFO (ActiveMQEndpointWorker)
>> org.apache.activemq.ra.ActiveMQEndpointWorker [start]:Starting20130423
>> 11:43:04 INFO (root)
>> org.apache.openejb.assembler.classic.Assembler[startEjbs]:Created
>> Ejb(deployment-id=CachedInfoMessageHandlerBean,
>> ejb-name=CachedInfoMessageHandlerBean, container=Default MDB Container)
>> 20130423 11:43:04 INFO (WorkerContext)
>> org.apache.geronimo.connector.work.WorkerContext [run]:Removing
>> non-required
>> WorkContextHandler with no context:
>> org.apache.geronimo.connector.work.TransactionContextHandler@7ed6f6
>> 20130423 11:43:04 INFO (WorkerContext)
>> org.apache.geronimo.connector.work.WorkerContext [run]:Removing
>> non-required
>> WorkContextHandler with no context:
>> org.apache.openejb.core.security.SecurityContextHandler@14949e620130423
>> 11:43:04 INFO (root)
>> org.apache.openejb.assembler.classic.Assembler[startEjbs]:Started
>> Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean,
>> container=Default
>> Stateless Container)
>> 20130423 11:43:04 INFO (WorkerContext)
>> org.apache.geronimo.connector.work.WorkerContext [run]:Removing
>> non-required
>> WorkContextHandler with no context:
>> org.apache.geronimo.connector.work.HintsContextHandler@1c88d9c
>> 20130423 11:43:04 INFO (root)
>> org.apache.openejb.assembler.classic.Assembler[startEjbs]:Started
>> Ejb(deployment-id=CachedInfoMessageHandlerBean,
>> ejb-name=CachedInfoMessageHandlerBean, container=Default MDB Container)
>> 20130423 11:43:04 INFO (ActiveMQEndpointWorker)
>> org.apache.activemq.ra.ActiveMQEndpointWorker$1 [run]:Establishing
>> connection to broker [vm://localhost?waitForStart=20000&async=true]
>> 20130423 11:43:04 INFO (root)
>> org.apache.tomee.catalina.TomcatWebAppBuilder [deployWebApps]:using
>> context
>> file C:\AppServers\tomee\webapps\TomEEApp\META-INF\context.xml
>> 20130423 11:43:04 INFO (root)
>> org.apache.openejb.assembler.classic.Assembler[createApplication]:Deployed
>> Application(path=C:\AppServers\tomee\webapps\TomEEApp)
>> 20130423 11:43:04 INFO (TransportConnector)
>> org.apache.activemq.broker.TransportConnector [start]:Connector
>> vm://localhost Started
>> 20130423 11:43:04 INFO (ActiveMQEndpointWorker)
>> org.apache.activemq.ra.ActiveMQEndpointWorker$1 [run]:Successfully
>> established connection to broker
>> [vm://localhost?waitForStart=20000&async=true]
>>
>>
>>
>> --
>> View this message in context:
>> http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662407.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>
>
Re: Can not connect to Message Bean from remote client : Null pointer
Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
MessageListener invokes just fine in my app. Two differences between your
MDB and my MDB.
1. I added an empty constructor that accepts no arguments. For some
weeks/months now, one MDB did 'not' have an empty constructor, while the
other MDB had empty constructor.
2. I don't @Override the onMessage(...)
Below is one of my MDBs, and they both are pretty much defined this way.
@MessageDriven
public class EmailMessageDrivenBean implements MessageListener {
private final Boolean debug = true;
private final Logger logger = LoggerFactory.getLogger(getClass());
@Inject
private ApplicationScopeBean applicationScopeBean;
/*
* 2013-03-19 DO NOT USE @EJB AddEmailRequest; use @Inject, since NO
DEADLOCK
* ONLY USE @EJB after testing, and if there are NO DEADLOCK
*/
@EJB
private AddEmailRequest addEmailRequestBean;
public EmailMessageDrivenBean() {
/*
* since MDB is pooled, do NOT use to initialize values!!!
*/
}
public void onMessage(Message message) {
On Tue, Apr 23, 2013 at 1:08 PM, TomeeUser <pa...@gmail.com> wrote:
>
> I see all messages are send to right queue ( in activeMQ webconsole ) but
> MessageListner is not being invoked... I put log statements nothing appears
> in log...and same client and app works just fine in JBoss...
>
> I would really hate to switch back to JBoss as love Tomee for its
> simplicity.
>
> Below are the logs:
>
>
>
> 20130423 11:43:03 INFO (HostConfig)
> org.apache.catalina.startup.HostConfig [deployWAR]:Deploying web
> application
> archive C:\AppServers\tomee\webapps\TomEEApp.war
> 20130423 11:43:03 INFO (root)
> org.apache.tomee.catalina.TomcatWebAppBuilder
> [init]:------------------------- localhost -> /TomEEApp
> 20130423 11:43:03 INFO (root) org.apache.openejb.util.JarExtractor
> [extract]:Extracting jar: C:\AppServers\tomee\webapps\TomEEApp.war
> 20130423 11:43:03 INFO (root) org.apache.openejb.util.JarExtractor
> [extract]:Extracted path: C:\AppServers\tomee\webapps\TomEEApp
> 20130423 11:43:03 INFO (root)
>
> org.apache.openejb.config.ConfigurationFactory[configureApplication]:Configuring
> enterprise application: C:\AppServers\tomee\webapps\TomEEApp
> 20130423 11:43:04 INFO (root)
> org.apache.openejb.config.InitEjbDeployments [deploy]:Auto-deploying ejb
> CalculatorBean: EjbDeployment(deployment-id=CalculatorBean)
> 20130423 11:43:04 INFO (root)
> org.apache.openejb.config.InitEjbDeployments [deploy]:Auto-deploying ejb
> CachedInfoMessageHandlerBean:
> EjbDeployment(deployment-id=CachedInfoMessageHandlerBean)
> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
> [resolveDestinationLinks]:Auto-configuring a message driven bean
> CachedInfoMessageHandlerBean destination CachedInfoMessageHandlerBean to be
> destinationType javax.jms.Queue
> 20130423 11:43:04 INFO (root)
>
> org.apache.openejb.config.ConfigurationFactory[configureService]:Configuring
> Service(id=Default JMS Connection Factory, type=Resource,
> provider-id=Default JMS Connection Factory)
> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
> [logAutoCreateResource]:Auto-creating a Resource with id 'Default JMS
> Connection Factory'of type 'javax.jms.ConnectionFactory for
> 'CalculatorBean'.
> 20130423 11:43:04 INFO (root)
>
> org.apache.openejb.config.ConfigurationFactory[configureService]:Configuring
> Service(id=Default JMS Resource Adapter, type=Resource, provider-id=Default
> JMS Resource Adapter)
> 20130423 11:43:04 INFO (root)
>
> org.apache.openejb.config.ConfigurationFactory[configureService]:Configuring
> Service(id=Default Unmanaged JDBC Database, type=Resource,
> provider-id=Default Unmanaged JDBC Database)
> 20130423 11:43:04 INFO (root)
> org.apache.openejb.assembler.classic.Assembler[createRecipe]:Creating
> Resource(id=Default Unmanaged JDBC Database)
> 20130423 11:43:04 INFO (root)
> org.apache.openejb.assembler.classic.Assembler[createRecipe]:Creating
> Resource(id=Default JMS Resource Adapter)
> 20130423 11:43:04 INFO (root)
> org.apache.openejb.resource.activemq.ActiveMQ5Factory
> [createBroker]:ActiveMQ5Factory creating broker
> 20130423 11:43:04 INFO (root)
> org.apache.openejb.resource.activemq.ActiveMQ5Factory [createBroker]:Using
> ActiveMQ startup timeout of 10000ms
> 20130423 11:43:04 INFO (root)
> org.apache.openejb.resource.activemq.ActiveMQ5Factory$1 [run]:Starting
> ActiveMQ BrokerService
> 20130423 11:43:04 INFO (BrokerService)
> org.apache.activemq.broker.BrokerService [doStartPersistenceAdapter]:Using
> Persistence Adapter: MemoryPersistenceAdapter
> 20130423 11:43:04 INFO (BrokerService)
> org.apache.activemq.broker.BrokerService [doStartBroker]:Apache ActiveMQ
> 5.7.0 (localhost, ID:CND1222QY1-4861-1366731730439-0:2) is starting
> 20130423 11:43:04 INFO (TransportServerThreadSupport)
> org.apache.activemq.transport.TransportServerThreadSupport
> [doStart]:Listening for connections at: tcp://localhost:61616
> 20130423 11:43:04 INFO (TransportConnector)
> org.apache.activemq.broker.TransportConnector [start]:Connector
> tcp://localhost:61616 Started
> 20130423 11:43:04 INFO (BrokerService)
> org.apache.activemq.broker.BrokerService [doStartBroker]:Apache ActiveMQ
> 5.7.0 (localhost, ID:CND1222QY1-4861-1366731730439-0:2) started
> 20130423 11:43:04 INFO (BrokerService)
> org.apache.activemq.broker.BrokerService [doStartBroker]:For help or more
> information please see: http://activemq.apache.org
> 20130423 11:43:04 INFO (root)
> org.apache.openejb.resource.activemq.ActiveMQ5Factory$1 [run]:Starting
> ActiveMQ checkpoint
> 20130423 11:43:04 INFO (root)
> org.apache.openejb.resource.activemq.ActiveMQ5Factory
> [createBroker]:ActiveMQ broker started
> 20130423 11:43:04 INFO (root)
> org.apache.openejb.assembler.classic.Assembler[createRecipe]:Creating
> Resource(id=Default JMS Connection Factory)
> 20130423 11:43:04 INFO (root)
> org.apache.openejb.assembler.classic.Assembler[createResource]:Creating
> ConnectionManager for Resource(id=Default JMS Connection Factory)
> 20130423 11:43:04 INFO (GenericConnectionManager)
>
> org.apache.geronimo.connector.outbound.GenericConnectionManager$InterceptorsImpl
> [<init>]:No runtime TransactionSupport
> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
> [processResourceRef]:Auto-linking resource-ref
>
> 'java:comp/env/test.ejbs.TomEE.beans.CachedInfoMessageHandlerBean/connectionFactory'
> in bean CalculatorBean to Resource(id=Default JMS Connection Factory)
> 20130423 11:43:04 INFO (root)
>
> org.apache.openejb.config.ConfigurationFactory[configureService]:Configuring
> Service(id=AnswerQueue, type=Resource, provider-id=Default Queue)
> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
> [logAutoCreateResource]:Auto-creating a Resource with id 'AnswerQueue' of
> type 'javax.jms.Queue for 'CalculatorBean'.
> 20130423 11:43:04 INFO (root)
> org.apache.openejb.assembler.classic.Assembler[createRecipe]:Creating
> Resource(id=AnswerQueue)
> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
> [processResourceEnvRef]:Auto-linking resource-env-ref
> 'java:comp/env/AnswerQueue' in bean CalculatorBean to
> Resource(id=AnswerQueue)
> 20130423 11:43:04 INFO (root)
>
> org.apache.openejb.config.ConfigurationFactory[configureService]:Configuring
> Service(id=Default MDB Container, type=Container, provider-id=Default MDB
> Container)
> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
> [createContainer]:Auto-creating a container for bean
> CachedInfoMessageHandlerBean: Container(type=MESSAGE, id=Default MDB
> Container)
> 20130423 11:43:04 INFO (root)
> org.apache.openejb.assembler.classic.Assembler[createRecipe]:Creating
> Container(id=Default MDB Container)
> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
> [processResourceRef]:Auto-linking resource-ref
>
> 'java:comp/env/test.ejbs.TomEE.beans.CachedInfoMessageHandlerBean/connectionFactory'
> in bean CachedInfoMessageHandlerBean to Resource(id=Default JMS Connection
> Factory)
> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
> [processResourceEnvRef]:Auto-linking resource-env-ref
> 'java:comp/env/AnswerQueue' in bean CachedInfoMessageHandlerBean to
> Resource(id=AnswerQueue)
> 20130423 11:43:04 INFO (root)
>
> org.apache.openejb.config.ConfigurationFactory[configureService]:Configuring
> Service(id=CachedInfoMessageHandlerBean, type=Resource, provider-id=Default
> Queue)
> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
> [logAutoCreateResource]:Auto-creating a Resource with id
> 'CachedInfoMessageHandlerBean' of type 'javax.jms.Queue for
> 'CachedInfoMessageHandlerBean'.
> 20130423 11:43:04 INFO (root)
> org.apache.openejb.assembler.classic.Assembler[createRecipe]:Creating
> Resource(id=CachedInfoMessageHandlerBean)
> 20130423 11:43:04 INFO (root) org.apache.openejb.config.AppInfoBuilder
> [build]:Enterprise application "C:\AppServers\tomee\webapps\TomEEApp"
> loaded.
> 20130423 11:43:04 INFO (root)
>
> org.apache.openejb.assembler.classic.Assembler[createApplication]:Assembling
> app: C:\AppServers\tomee\webapps\TomEEApp
> 20130423 11:43:04 INFO (root)
> org.apache.openejb.assembler.classic.JndiBuilder
> [bind]:Jndi(name=CalculatorBeanLocalBean) -->
> Ejb(deployment-id=CalculatorBean)
> 20130423 11:43:04 INFO (root)
> org.apache.openejb.assembler.classic.JndiBuilder
>
> [bind]:Jndi(name=global/TomEEApp/CalculatorBean!test.ejbs.TomEE.beans.CalculatorBean)
> --> Ejb(deployment-id=CalculatorBean)
> 20130423 11:43:04 INFO (root)
> org.apache.openejb.assembler.classic.JndiBuilder
> [bind]:Jndi(name=CalculatorBeanRemote) -->
> Ejb(deployment-id=CalculatorBean)
> 20130423 11:43:04 INFO (root)
> org.apache.openejb.assembler.classic.JndiBuilder
>
> [bind]:Jndi(name=global/TomEEApp/CalculatorBean!test.ejbs.TomEE.headers.CalculatorRemote)
> --> Ejb(deployment-id=CalculatorBean)
> 20130423 11:43:04 INFO (root)
> org.apache.openejb.assembler.classic.JndiBuilder
>
> [bind]:Jndi(name=global/TomEEApp/CalculatorBean!test.ejbs.TomEE.headers.CalculatorLocal)
> --> Ejb(deployment-id=CalculatorBean)
> 20130423 11:43:04 INFO (root)
> org.apache.openejb.assembler.classic.JndiBuilder
> [bind]:Jndi(name=global/TomEEApp/CalculatorBean) -->
> Ejb(deployment-id=CalculatorBean)
> 20130423 11:43:04 INFO (root)
> org.apache.openejb.assembler.classic.JndiBuilder
> [bind]:Jndi(name=CachedInfoMessageHandlerBean) -->
> Ejb(deployment-id=CachedInfoMessageHandlerBean)
> 20130423 11:43:04 INFO (root) org.apache.openejb.cdi.CdiBuilder
> [initSingleton]:Existing thread singleton service in SystemInstance():
> org.apache.openejb.cdi.ThreadSingletonServiceImpl@15c97a420130423 11:43:04
> INFO (root) org.apache.openejb.cdi.OpenEJBLifecycle
> [startApplication]:OpenWebBeans Container is starting...
> 20130423 11:43:04 INFO (PluginLoader)
> org.apache.webbeans.plugins.PluginLoader [startUp]:Adding
> OpenWebBeansPlugin
> : [CdiPlugin]
> 20130423 11:43:04 INFO (PluginLoader)
> org.apache.webbeans.plugins.PluginLoader [startUp]:Adding
> OpenWebBeansPlugin
> : [OpenWebBeansJsfPlugin]
> 20130423 11:43:04 INFO (root) org.apache.openejb.cdi.BeansDeployer
> [validateInjectionPoints]:All injection points are validated successfully.
> 20130423 11:43:04 INFO (root) org.apache.openejb.cdi.OpenEJBLifecycle
> [startApplication]:OpenWebBeans Container has started, it took 16 ms.
> 20130423 11:43:04 INFO (root)
> org.apache.openejb.assembler.classic.Assembler[startEjbs]:Created
> Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean,
> container=Default
> Stateless Container)
> 20130423 11:43:04 INFO (ActiveMQEndpointWorker)
> org.apache.activemq.ra.ActiveMQEndpointWorker [start]:Starting20130423
> 11:43:04 INFO (root)
> org.apache.openejb.assembler.classic.Assembler[startEjbs]:Created
> Ejb(deployment-id=CachedInfoMessageHandlerBean,
> ejb-name=CachedInfoMessageHandlerBean, container=Default MDB Container)
> 20130423 11:43:04 INFO (WorkerContext)
> org.apache.geronimo.connector.work.WorkerContext [run]:Removing
> non-required
> WorkContextHandler with no context:
> org.apache.geronimo.connector.work.TransactionContextHandler@7ed6f6
> 20130423 11:43:04 INFO (WorkerContext)
> org.apache.geronimo.connector.work.WorkerContext [run]:Removing
> non-required
> WorkContextHandler with no context:
> org.apache.openejb.core.security.SecurityContextHandler@14949e620130423
> 11:43:04 INFO (root)
> org.apache.openejb.assembler.classic.Assembler[startEjbs]:Started
> Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean,
> container=Default
> Stateless Container)
> 20130423 11:43:04 INFO (WorkerContext)
> org.apache.geronimo.connector.work.WorkerContext [run]:Removing
> non-required
> WorkContextHandler with no context:
> org.apache.geronimo.connector.work.HintsContextHandler@1c88d9c
> 20130423 11:43:04 INFO (root)
> org.apache.openejb.assembler.classic.Assembler[startEjbs]:Started
> Ejb(deployment-id=CachedInfoMessageHandlerBean,
> ejb-name=CachedInfoMessageHandlerBean, container=Default MDB Container)
> 20130423 11:43:04 INFO (ActiveMQEndpointWorker)
> org.apache.activemq.ra.ActiveMQEndpointWorker$1 [run]:Establishing
> connection to broker [vm://localhost?waitForStart=20000&async=true]
> 20130423 11:43:04 INFO (root)
> org.apache.tomee.catalina.TomcatWebAppBuilder [deployWebApps]:using context
> file C:\AppServers\tomee\webapps\TomEEApp\META-INF\context.xml
> 20130423 11:43:04 INFO (root)
> org.apache.openejb.assembler.classic.Assembler[createApplication]:Deployed
> Application(path=C:\AppServers\tomee\webapps\TomEEApp)
> 20130423 11:43:04 INFO (TransportConnector)
> org.apache.activemq.broker.TransportConnector [start]:Connector
> vm://localhost Started
> 20130423 11:43:04 INFO (ActiveMQEndpointWorker)
> org.apache.activemq.ra.ActiveMQEndpointWorker$1 [run]:Successfully
> established connection to broker
> [vm://localhost?waitForStart=20000&async=true]
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662407.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
Re: Can not connect to Message Bean from remote client : Null
pointer
Posted by TomeeUser <pa...@gmail.com>.
I see all messages are send to right queue ( in activeMQ webconsole ) but
MessageListner is not being invoked... I put log statements nothing appears
in log...and same client and app works just fine in JBoss...
I would really hate to switch back to JBoss as love Tomee for its
simplicity.
Below are the logs:
20130423 11:43:03 INFO (HostConfig)
org.apache.catalina.startup.HostConfig [deployWAR]:Deploying web application
archive C:\AppServers\tomee\webapps\TomEEApp.war
20130423 11:43:03 INFO (root)
org.apache.tomee.catalina.TomcatWebAppBuilder
[init]:------------------------- localhost -> /TomEEApp
20130423 11:43:03 INFO (root) org.apache.openejb.util.JarExtractor
[extract]:Extracting jar: C:\AppServers\tomee\webapps\TomEEApp.war
20130423 11:43:03 INFO (root) org.apache.openejb.util.JarExtractor
[extract]:Extracted path: C:\AppServers\tomee\webapps\TomEEApp
20130423 11:43:03 INFO (root)
org.apache.openejb.config.ConfigurationFactory[configureApplication]:Configuring
enterprise application: C:\AppServers\tomee\webapps\TomEEApp
20130423 11:43:04 INFO (root)
org.apache.openejb.config.InitEjbDeployments [deploy]:Auto-deploying ejb
CalculatorBean: EjbDeployment(deployment-id=CalculatorBean)
20130423 11:43:04 INFO (root)
org.apache.openejb.config.InitEjbDeployments [deploy]:Auto-deploying ejb
CachedInfoMessageHandlerBean:
EjbDeployment(deployment-id=CachedInfoMessageHandlerBean)
20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
[resolveDestinationLinks]:Auto-configuring a message driven bean
CachedInfoMessageHandlerBean destination CachedInfoMessageHandlerBean to be
destinationType javax.jms.Queue
20130423 11:43:04 INFO (root)
org.apache.openejb.config.ConfigurationFactory[configureService]:Configuring
Service(id=Default JMS Connection Factory, type=Resource,
provider-id=Default JMS Connection Factory)
20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
[logAutoCreateResource]:Auto-creating a Resource with id 'Default JMS
Connection Factory'of type 'javax.jms.ConnectionFactory for
'CalculatorBean'.
20130423 11:43:04 INFO (root)
org.apache.openejb.config.ConfigurationFactory[configureService]:Configuring
Service(id=Default JMS Resource Adapter, type=Resource, provider-id=Default
JMS Resource Adapter)
20130423 11:43:04 INFO (root)
org.apache.openejb.config.ConfigurationFactory[configureService]:Configuring
Service(id=Default Unmanaged JDBC Database, type=Resource,
provider-id=Default Unmanaged JDBC Database)
20130423 11:43:04 INFO (root)
org.apache.openejb.assembler.classic.Assembler[createRecipe]:Creating
Resource(id=Default Unmanaged JDBC Database)
20130423 11:43:04 INFO (root)
org.apache.openejb.assembler.classic.Assembler[createRecipe]:Creating
Resource(id=Default JMS Resource Adapter)
20130423 11:43:04 INFO (root)
org.apache.openejb.resource.activemq.ActiveMQ5Factory
[createBroker]:ActiveMQ5Factory creating broker
20130423 11:43:04 INFO (root)
org.apache.openejb.resource.activemq.ActiveMQ5Factory [createBroker]:Using
ActiveMQ startup timeout of 10000ms
20130423 11:43:04 INFO (root)
org.apache.openejb.resource.activemq.ActiveMQ5Factory$1 [run]:Starting
ActiveMQ BrokerService
20130423 11:43:04 INFO (BrokerService)
org.apache.activemq.broker.BrokerService [doStartPersistenceAdapter]:Using
Persistence Adapter: MemoryPersistenceAdapter
20130423 11:43:04 INFO (BrokerService)
org.apache.activemq.broker.BrokerService [doStartBroker]:Apache ActiveMQ
5.7.0 (localhost, ID:CND1222QY1-4861-1366731730439-0:2) is starting
20130423 11:43:04 INFO (TransportServerThreadSupport)
org.apache.activemq.transport.TransportServerThreadSupport
[doStart]:Listening for connections at: tcp://localhost:61616
20130423 11:43:04 INFO (TransportConnector)
org.apache.activemq.broker.TransportConnector [start]:Connector
tcp://localhost:61616 Started
20130423 11:43:04 INFO (BrokerService)
org.apache.activemq.broker.BrokerService [doStartBroker]:Apache ActiveMQ
5.7.0 (localhost, ID:CND1222QY1-4861-1366731730439-0:2) started
20130423 11:43:04 INFO (BrokerService)
org.apache.activemq.broker.BrokerService [doStartBroker]:For help or more
information please see: http://activemq.apache.org
20130423 11:43:04 INFO (root)
org.apache.openejb.resource.activemq.ActiveMQ5Factory$1 [run]:Starting
ActiveMQ checkpoint
20130423 11:43:04 INFO (root)
org.apache.openejb.resource.activemq.ActiveMQ5Factory
[createBroker]:ActiveMQ broker started
20130423 11:43:04 INFO (root)
org.apache.openejb.assembler.classic.Assembler[createRecipe]:Creating
Resource(id=Default JMS Connection Factory)
20130423 11:43:04 INFO (root)
org.apache.openejb.assembler.classic.Assembler[createResource]:Creating
ConnectionManager for Resource(id=Default JMS Connection Factory)
20130423 11:43:04 INFO (GenericConnectionManager)
org.apache.geronimo.connector.outbound.GenericConnectionManager$InterceptorsImpl
[<init>]:No runtime TransactionSupport
20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
[processResourceRef]:Auto-linking resource-ref
'java:comp/env/test.ejbs.TomEE.beans.CachedInfoMessageHandlerBean/connectionFactory'
in bean CalculatorBean to Resource(id=Default JMS Connection Factory)
20130423 11:43:04 INFO (root)
org.apache.openejb.config.ConfigurationFactory[configureService]:Configuring
Service(id=AnswerQueue, type=Resource, provider-id=Default Queue)
20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
[logAutoCreateResource]:Auto-creating a Resource with id 'AnswerQueue' of
type 'javax.jms.Queue for 'CalculatorBean'.
20130423 11:43:04 INFO (root)
org.apache.openejb.assembler.classic.Assembler[createRecipe]:Creating
Resource(id=AnswerQueue)
20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
[processResourceEnvRef]:Auto-linking resource-env-ref
'java:comp/env/AnswerQueue' in bean CalculatorBean to
Resource(id=AnswerQueue)
20130423 11:43:04 INFO (root)
org.apache.openejb.config.ConfigurationFactory[configureService]:Configuring
Service(id=Default MDB Container, type=Container, provider-id=Default MDB
Container)
20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
[createContainer]:Auto-creating a container for bean
CachedInfoMessageHandlerBean: Container(type=MESSAGE, id=Default MDB
Container)
20130423 11:43:04 INFO (root)
org.apache.openejb.assembler.classic.Assembler[createRecipe]:Creating
Container(id=Default MDB Container)
20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
[processResourceRef]:Auto-linking resource-ref
'java:comp/env/test.ejbs.TomEE.beans.CachedInfoMessageHandlerBean/connectionFactory'
in bean CachedInfoMessageHandlerBean to Resource(id=Default JMS Connection
Factory)
20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
[processResourceEnvRef]:Auto-linking resource-env-ref
'java:comp/env/AnswerQueue' in bean CachedInfoMessageHandlerBean to
Resource(id=AnswerQueue)
20130423 11:43:04 INFO (root)
org.apache.openejb.config.ConfigurationFactory[configureService]:Configuring
Service(id=CachedInfoMessageHandlerBean, type=Resource, provider-id=Default
Queue)
20130423 11:43:04 INFO (root) org.apache.openejb.config.AutoConfig
[logAutoCreateResource]:Auto-creating a Resource with id
'CachedInfoMessageHandlerBean' of type 'javax.jms.Queue for
'CachedInfoMessageHandlerBean'.
20130423 11:43:04 INFO (root)
org.apache.openejb.assembler.classic.Assembler[createRecipe]:Creating
Resource(id=CachedInfoMessageHandlerBean)
20130423 11:43:04 INFO (root) org.apache.openejb.config.AppInfoBuilder
[build]:Enterprise application "C:\AppServers\tomee\webapps\TomEEApp"
loaded.
20130423 11:43:04 INFO (root)
org.apache.openejb.assembler.classic.Assembler[createApplication]:Assembling
app: C:\AppServers\tomee\webapps\TomEEApp
20130423 11:43:04 INFO (root)
org.apache.openejb.assembler.classic.JndiBuilder
[bind]:Jndi(name=CalculatorBeanLocalBean) -->
Ejb(deployment-id=CalculatorBean)
20130423 11:43:04 INFO (root)
org.apache.openejb.assembler.classic.JndiBuilder
[bind]:Jndi(name=global/TomEEApp/CalculatorBean!test.ejbs.TomEE.beans.CalculatorBean)
--> Ejb(deployment-id=CalculatorBean)
20130423 11:43:04 INFO (root)
org.apache.openejb.assembler.classic.JndiBuilder
[bind]:Jndi(name=CalculatorBeanRemote) --> Ejb(deployment-id=CalculatorBean)
20130423 11:43:04 INFO (root)
org.apache.openejb.assembler.classic.JndiBuilder
[bind]:Jndi(name=global/TomEEApp/CalculatorBean!test.ejbs.TomEE.headers.CalculatorRemote)
--> Ejb(deployment-id=CalculatorBean)
20130423 11:43:04 INFO (root)
org.apache.openejb.assembler.classic.JndiBuilder
[bind]:Jndi(name=global/TomEEApp/CalculatorBean!test.ejbs.TomEE.headers.CalculatorLocal)
--> Ejb(deployment-id=CalculatorBean)
20130423 11:43:04 INFO (root)
org.apache.openejb.assembler.classic.JndiBuilder
[bind]:Jndi(name=global/TomEEApp/CalculatorBean) -->
Ejb(deployment-id=CalculatorBean)
20130423 11:43:04 INFO (root)
org.apache.openejb.assembler.classic.JndiBuilder
[bind]:Jndi(name=CachedInfoMessageHandlerBean) -->
Ejb(deployment-id=CachedInfoMessageHandlerBean)
20130423 11:43:04 INFO (root) org.apache.openejb.cdi.CdiBuilder
[initSingleton]:Existing thread singleton service in SystemInstance():
org.apache.openejb.cdi.ThreadSingletonServiceImpl@15c97a420130423 11:43:04
INFO (root) org.apache.openejb.cdi.OpenEJBLifecycle
[startApplication]:OpenWebBeans Container is starting...
20130423 11:43:04 INFO (PluginLoader)
org.apache.webbeans.plugins.PluginLoader [startUp]:Adding OpenWebBeansPlugin
: [CdiPlugin]
20130423 11:43:04 INFO (PluginLoader)
org.apache.webbeans.plugins.PluginLoader [startUp]:Adding OpenWebBeansPlugin
: [OpenWebBeansJsfPlugin]
20130423 11:43:04 INFO (root) org.apache.openejb.cdi.BeansDeployer
[validateInjectionPoints]:All injection points are validated successfully.
20130423 11:43:04 INFO (root) org.apache.openejb.cdi.OpenEJBLifecycle
[startApplication]:OpenWebBeans Container has started, it took 16 ms.
20130423 11:43:04 INFO (root)
org.apache.openejb.assembler.classic.Assembler[startEjbs]:Created
Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean, container=Default
Stateless Container)
20130423 11:43:04 INFO (ActiveMQEndpointWorker)
org.apache.activemq.ra.ActiveMQEndpointWorker [start]:Starting20130423
11:43:04 INFO (root)
org.apache.openejb.assembler.classic.Assembler[startEjbs]:Created
Ejb(deployment-id=CachedInfoMessageHandlerBean,
ejb-name=CachedInfoMessageHandlerBean, container=Default MDB Container)
20130423 11:43:04 INFO (WorkerContext)
org.apache.geronimo.connector.work.WorkerContext [run]:Removing non-required
WorkContextHandler with no context:
org.apache.geronimo.connector.work.TransactionContextHandler@7ed6f6
20130423 11:43:04 INFO (WorkerContext)
org.apache.geronimo.connector.work.WorkerContext [run]:Removing non-required
WorkContextHandler with no context:
org.apache.openejb.core.security.SecurityContextHandler@14949e620130423
11:43:04 INFO (root)
org.apache.openejb.assembler.classic.Assembler[startEjbs]:Started
Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean, container=Default
Stateless Container)
20130423 11:43:04 INFO (WorkerContext)
org.apache.geronimo.connector.work.WorkerContext [run]:Removing non-required
WorkContextHandler with no context:
org.apache.geronimo.connector.work.HintsContextHandler@1c88d9c
20130423 11:43:04 INFO (root)
org.apache.openejb.assembler.classic.Assembler[startEjbs]:Started
Ejb(deployment-id=CachedInfoMessageHandlerBean,
ejb-name=CachedInfoMessageHandlerBean, container=Default MDB Container)
20130423 11:43:04 INFO (ActiveMQEndpointWorker)
org.apache.activemq.ra.ActiveMQEndpointWorker$1 [run]:Establishing
connection to broker [vm://localhost?waitForStart=20000&async=true]
20130423 11:43:04 INFO (root)
org.apache.tomee.catalina.TomcatWebAppBuilder [deployWebApps]:using context
file C:\AppServers\tomee\webapps\TomEEApp\META-INF\context.xml
20130423 11:43:04 INFO (root)
org.apache.openejb.assembler.classic.Assembler[createApplication]:Deployed
Application(path=C:\AppServers\tomee\webapps\TomEEApp)
20130423 11:43:04 INFO (TransportConnector)
org.apache.activemq.broker.TransportConnector [start]:Connector
vm://localhost Started
20130423 11:43:04 INFO (ActiveMQEndpointWorker)
org.apache.activemq.ra.ActiveMQEndpointWorker$1 [run]:Successfully
established connection to broker
[vm://localhost?waitForStart=20000&async=true]
--
View this message in context: http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662407.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Can not connect to Message Bean from remote client : Null pointer
Posted by Romain Manni-Bucau <rm...@gmail.com>.
here we are i think
Auto-linking resource-env-ref
'java:test/ejb/AnswerQueue' in bean CachedInfoMessageHandlerBean to
Resource(id=AnswerQueue)
AnswerQueue is not test/ejb/AnswerQueue
*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*
2013/4/23 TomeeUser <pa...@gmail.com>
> No I did not find that. I could find Auto-linking
>
>
> 20130423 10:17:46 INFO (root) org.apache.openejb.config.AutoConfig
> [processResourceRef]:Auto-linking resource-ref
>
> 'java:comp/env/test.ejbs.TomEE.beans.CachedInfoMessageHandlerBean/connectionFactory'
> in bean CalculatorBean to Resource(id=MyJmsConnectionFactory)
> 20130423 10:17:46 INFO (root) org.apache.openejb.config.AutoConfig
> [processResourceEnvRef]:Auto-linking resource-env-ref
> 'java:test/ejb/AnswerQueue' in bean CachedInfoMessageHandlerBean to
> Resource(id=AnswerQueue)
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662395.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
Re: Can not connect to Message Bean from remote client : Null
pointer
Posted by TomeeUser <pa...@gmail.com>.
No I did not find that. I could find Auto-linking
20130423 10:17:46 INFO (root) org.apache.openejb.config.AutoConfig
[processResourceRef]:Auto-linking resource-ref
'java:comp/env/test.ejbs.TomEE.beans.CachedInfoMessageHandlerBean/connectionFactory'
in bean CalculatorBean to Resource(id=MyJmsConnectionFactory)
20130423 10:17:46 INFO (root) org.apache.openejb.config.AutoConfig
[processResourceEnvRef]:Auto-linking resource-env-ref
'java:test/ejb/AnswerQueue' in bean CachedInfoMessageHandlerBean to
Resource(id=AnswerQueue)
--
View this message in context: http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662395.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Can not connect to Message Bean from remote client : Null pointer
Posted by Romain Manni-Bucau <rm...@gmail.com>.
basically you can check you queues are the correct one looking for
Auto-adjusting lines in catalina*.log
if any of these lines exist and refer a queue you have a naming issue
(queue are created automatically and probably doesn't follow the name you
expect).
*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*
2013/4/22 TomeeUser <pa...@gmail.com>
> Not sure I understood the question.. but I put SOP to see log.
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662374.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
Re: Can not connect to Message Bean from remote client : Null
pointer
Posted by TomeeUser <pa...@gmail.com>.
Not sure I understood the question.. but I put SOP to see log.
--
View this message in context: http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662374.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Can not connect to Message Bean from remote client : Null pointer
Posted by Romain Manni-Bucau <rm...@gmail.com>.
In the logs do you have Auto-adjusting lines?
Le 22 avr. 2013 21:08, "TomeeUser" <pa...@gmail.com> a écrit :
> well my my question why the listener is not being called? what else should
> I
> do to access the queue ?
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662372.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
Re: Can not connect to Message Bean from remote client : Null
pointer
Posted by TomeeUser <pa...@gmail.com>.
well my my question why the listener is not being called? what else should I
do to access the queue ?
--
View this message in context: http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662372.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Can not connect to Message Bean from remote client : Null
pointer
Posted by TomeeUser <pa...@gmail.com>.
however my messagebean doesn't get invoked. I don't get any message in the
log. Is there anything I am missing ?
--
View this message in context: http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662370.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Can not connect to Message Bean from remote client : Null pointer
Posted by Romain Manni-Bucau <rm...@gmail.com>.
did exactly it with trunk and saw the queue size increasing (didnt get any
exception)
*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*
2013/4/21 TomeeUser <pa...@gmail.com>
> Hi Romain,
>
> I am sorry still it didn't work. I am providing another zip file, which has
> ant scripts to build and deploy app and another one to run
> jmstest/app -- server side code. ( web app )
> *<property name="tomee_home" value="c:/AppServers/tomee"/>
> =>needs to be changed according to tomee location in build.xml *
>
> *ant deploy => in order to deploy*
>
> jmstest/client -- client code
> *<property name="tomee_home" value="c:/AppServers/tomee"/>
> => needs to be changed according to tomee location in build.xml*
>
> *ant run => to execute *
>
> jmstest.zip <http://openejb.979440.n4.nabble.com/file/n4662346/jmstest.zip
> >
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662346.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
Re: Can not connect to Message Bean from remote client : Null
pointer
Posted by TomeeUser <pa...@gmail.com>.
Hi Romain,
I am sorry still it didn't work. I am providing another zip file, which has
ant scripts to build and deploy app and another one to run
jmstest/app -- server side code. ( web app )
*<property name="tomee_home" value="c:/AppServers/tomee"/>
=>needs to be changed according to tomee location in build.xml *
*ant deploy => in order to deploy*
jmstest/client -- client code
*<property name="tomee_home" value="c:/AppServers/tomee"/>
=> needs to be changed according to tomee location in build.xml*
*ant run => to execute *
jmstest.zip <http://openejb.979440.n4.nabble.com/file/n4662346/jmstest.zip>
--
View this message in context: http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662346.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Can not connect to Message Bean from remote client : Null pointer
Posted by Romain Manni-Bucau <rm...@gmail.com>.
well, netbeans projects are never buildable with ant so i can't build your
app ATM
that said, java:test/ejb/AnswerQueue is not defined i think, shouldn't it
be java:openejb/Resource/test/ejb/AnswerQueue?
*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*
2013/4/18 TomeeUser <pa...@gmail.com>
> Created a batch file to run the client:
> *mdbrun.cmd*
>
> @SET OCP=%CLASSPATH%
> @SET TOMEE_HOME=C:\AppServers\tomee
> @SET TOMEE_LIB=%TOMEE_HOME%\lib
> @SET CLIENT_JAR=C:\experiments\TomEEAppClient\dist\TomEEAppClient.jar
> @SET REMOTE_JAR=C:\experiments\TomEEApp\dist\TomEEAppRemote.jar
> @SET EJB_CLIENT_JAR=%TOMEE_LIB%\openejb-client-4.5.2.jar
> @SET JAVA_EE_JAR=%TOMEE_LIB%\javaee-api-6.0-5-tomcat.jar
> @SET
> SLF4J_JAR=%TOMEE_LIB%\slf4j-api-1.7.2.jar;%TOMEE_LIB%\slf4j-jdk14-1.7.2.jar
>
> @SET ACTIVE_MQ_JAR=%TOMEE_LIB%\activemq-core-5.7.0.jar
>
> @SET CLASSPATH=%CLASSPATH%;%REMOTE_JAR%;%EJB_CLIENT_JAR%;%JAVA_EE_JAR%;
> @SET CLASSPATH=%CLASSPATH%;%ACTIVE_MQ_JAR%;%SLF4J_JAR%
> @SET CLASSPATH=%CLASSPATH%;%CLIENT_JAR%
>
> java -cp %CLASSPATH% tomeeappclient.TomEEAppClient
>
> @SET CLASSPATH=%OCP%
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662336.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
Re: Can not connect to Message Bean from remote client : Null
pointer
Posted by TomeeUser <pa...@gmail.com>.
Created a batch file to run the client:
*mdbrun.cmd*
@SET OCP=%CLASSPATH%
@SET TOMEE_HOME=C:\AppServers\tomee
@SET TOMEE_LIB=%TOMEE_HOME%\lib
@SET CLIENT_JAR=C:\experiments\TomEEAppClient\dist\TomEEAppClient.jar
@SET REMOTE_JAR=C:\experiments\TomEEApp\dist\TomEEAppRemote.jar
@SET EJB_CLIENT_JAR=%TOMEE_LIB%\openejb-client-4.5.2.jar
@SET JAVA_EE_JAR=%TOMEE_LIB%\javaee-api-6.0-5-tomcat.jar
@SET
SLF4J_JAR=%TOMEE_LIB%\slf4j-api-1.7.2.jar;%TOMEE_LIB%\slf4j-jdk14-1.7.2.jar
@SET ACTIVE_MQ_JAR=%TOMEE_LIB%\activemq-core-5.7.0.jar
@SET CLASSPATH=%CLASSPATH%;%REMOTE_JAR%;%EJB_CLIENT_JAR%;%JAVA_EE_JAR%;
@SET CLASSPATH=%CLASSPATH%;%ACTIVE_MQ_JAR%;%SLF4J_JAR%
@SET CLASSPATH=%CLASSPATH%;%CLIENT_JAR%
java -cp %CLASSPATH% tomeeappclient.TomEEAppClient
@SET CLASSPATH=%OCP%
--
View this message in context: http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662336.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Can not connect to Message Bean from remote client : Null
pointer
Posted by TomeeUser <pa...@gmail.com>.
Hi Romain,
Here are the NB projects.
TomEEApp.zip
<http://openejb.979440.n4.nabble.com/file/n4662335/TomEEApp.zip>
TomEEAppClient.zip
<http://openejb.979440.n4.nabble.com/file/n4662335/TomEEAppClient.zip>
--
View this message in context: http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662335.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Can not connect to Message Bean from remote client : Null pointer
Posted by Romain Manni-Bucau <rm...@gmail.com>.
hmm,
can you package it to let it be run easily?
*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*
2013/4/18 TomeeUser <pa...@gmail.com>
> Hi Romain,
>
> Here is the sample code:
>
> *Resources configured in tomee.xml*
> <Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
> BrokerXmlConfig = broker:(tcp://localhost:61616)
> ServerUrl = tcp://localhost:61616
> </Resource>
>
> <Resource id="MyJmsConnectionFactory"
> type="javax.jms.ConnectionFactory"
> ResourceAdapter = MyJmsResourceAdapter
> </Resource>
>
> <Container id="MyJmsMdbContainer" ctype="MESSAGE">
> ResourceAdapter = MyJmsResourceAdapter
> </Container>
>
> <Resource id="test/ejb/AnswerQueue" type="javax.jms.Queue">
> Destination test/ejb/AnswerQueue
> </Resource>
>
> ////////////////////////////////////////////////////////////////////////////
>
>
> *CachedInfoMessageHandlerBean.java*
> package test.ejbs.TomEE.beans;
>
> import javax.jms.Connection;
> import javax.jms.ConnectionFactory;
> import javax.jms.DeliveryMode;
> import javax.jms.JMSException;
> import javax.jms.Message;
> import javax.jms.MessageListener;
> import javax.jms.MessageProducer;
> import javax.jms.Queue;
> import javax.jms.Session;
> import javax.jms.TextMessage;
>
>
> public class CachedInfoMessageHandlerBean implements MessageListener
> {
>
> private ConnectionFactory connectionFactory;
> private Queue answerQueue;
>
> @Override
> public void onMessage(Message message) {
> try {
>
> final TextMessage textMessage = (TextMessage) message;
> final String question = textMessage.getText();
>
> System.out.println("onMessage called");
>
> if ("Hello World!".equals(question))
> {
> respond("Hello, Test Case!");
> } else if ("How are you?".equals(question))
> {
> respond("I'm doing well.");
> } else if ("Still spinning?".equals(question))
> {
> respond("Once every day, as usual.");
> }
> } catch (JMSException e) {
> throw new IllegalStateException(e);
> }
> }
>
>
> private void respond(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(answerQueue);
> producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
>
> // Create a message
> TextMessage message = session.createTextMessage(text);
>
> // Tell the producer to send the message
> producer.send(message);
> } finally
> {
> // Clean up
> if (session != null)
> {
> session.close();
> }
> if (connection != null)
> {
> connection.close();
> }
> }
> }
> }
> // END
>
> *ejb-jar.xml*
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <ejb-jar xmlns = "http://java.sun.com/xml/ns/javaee"
> version = "3.0"
> xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation = "http://java.sun.com/xml/ns/javaee
> http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
> <enterprise-beans>
> <session>
> <ejb-name>CalculatorBean</ejb-name>
>
> <business-local>test.ejbs.TomEE.headers.CalculatorLocal</business-local>
>
> <business-remote>test.ejbs.TomEE.headers.CalculatorRemote</business-remote>
> <ejb-class>test.ejbs.TomEE.beans.CalculatorBean</ejb-class>
> <session-type>Stateless</session-type>
> <transaction-type>Container</transaction-type>
> </session>
> <message-driven>
>
> <ejb-name>CachedInfoMessageHandlerBean</ejb-name>
>
> <ejb-class>test.ejbs.TomEE.beans.CachedInfoMessageHandlerBean</ejb-class>
> <messaging-type>javax.jms.MessageListener</messaging-type>
> <message-destination-type>javax.jms.Queue</message-destination-type>
> <activation-config>
> <activation-config-property>
>
>
> <activation-config-property-name>destination</activation-config-property-name>
>
>
> <activation-config-property-value>CachedInfoMessageHandlerBean</activation-config-property-value>
> </activation-config-property>
> <activation-config-property>
>
>
> <activation-config-property-name>destinationType</activation-config-property-name>
>
>
> <activation-config-property-value>javax.jms.Queue</activation-config-property-value>
> </activation-config-property>
> <activation-config-property>
>
>
> <activation-config-property-name>acknowledgeMode</activation-config-property-name>
>
>
> <activation-config-property-value>Auto-acknowledge</activation-config-property-value>
> </activation-config-property>
> <activation-config-property>
>
>
> <activation-config-property-name>messageSelector</activation-config-property-name>
>
>
> <activation-config-property-value>state=1</activation-config-property-value>
> </activation-config-property>
> </activation-config>
>
> <resource-ref>
>
>
> <res-ref-name>java:comp/env/test.ejbs.TomEE.beans.CachedInfoMessageHandlerBean/connectionFactory</res-ref-name>
> <res-type>javax.jms.ConnectionFactory</res-type>
> <injection-target>
>
>
> <injection-target-class>test.ejbs.TomEE.beans.CachedInfoMessageHandlerBean</injection-target-class>
> <injection-target-name>connectionFactory</injection-target-name>
> </injection-target>
> </resource-ref>
>
> <resource-env-ref>
>
> <resource-env-ref-name>java:test/ejb/AnswerQueue</resource-env-ref-name>
> <resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
> <mapped-name>AnswerQueue</mapped-name>
> <injection-target>
>
>
> <injection-target-class>test.ejbs.TomEE.beans.CachedInfoMessageHandlerBean</injection-target-class>
> <injection-target-name>answerQueue</injection-target-name>
> </injection-target>
> </resource-env-ref>
>
> </message-driven>
> </enterprise-beans>
> </ejb-jar>
>
> *// TomEEAppClient.java*
> package tomeeappclient;
>
> import java.util.Properties;
> import javax.jms.Connection;
> import javax.jms.ConnectionFactory;
> import javax.jms.JMSException;
> import javax.jms.MessageProducer;
> import javax.jms.Queue;
> import javax.jms.Session;
> import javax.jms.TextMessage;
> import javax.naming.InitialContext;
>
> public class TomEEAppClient
> {
>
> // @Resource(mappedName = "AnswerQueue")
> private Queue queue;
>
> // @Resource(mappedName = "MyJmsConnectionFactory")
> private ConnectionFactory connectionFactory;
>
> static
> {
> System.out.println("Loading System properties");
> System.setProperty("MyJmsConnectionFactory",
>
> "connectionfactory:org.apache.activemq.ActiveMQConnectionFactory:tcp://localhost:61616");
> // System.setProperty("java:test/ejb/AnswerQueue",
> "queue:org.apache.activemq.command.ActiveMQQueue:LISTENER");
> }
> public static void main(String[] args) throws Exception
> {
> TomEEAppClient client = new TomEEAppClient();
> client.process();
> }
> private void process() throws Exception
> {
> 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/tomee/ejb");
> InitialContext ctx = new InitialContext(p);
>
> String factory = "java:MyJmsConnectionFactory";
> javax.jms.ConnectionFactory cf = (ConnectionFactory)
> ctx.lookup(factory);
> Connection connection = null;
>
> try
> {
> connection = cf.createConnection();
> queue = (Queue)ctx.lookup("java:test/ejb/AnswerQueue");
> connection.start();
> Session session =
> connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
> MessageProducer messageProducer = session.createProducer(queue);
>
> TextMessage msg = session.createTextMessage();
> msg.setText("Hello World!");
> msg.setStringProperty("name", "TomEERemoteClient");
>
> messageProducer.send(msg);
>
> } catch (JMSException e)
> {
> throw new RuntimeException(e);
> } finally
> {
> try
> {
> if (connection != null)
> {
> connection.close();
> }
> }catch (JMSException e) { }//ignore
> }
>
>
> }
>
>
> }
> //END
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662332.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
Re: Can not connect to Message Bean from remote client : Null
pointer
Posted by TomeeUser <pa...@gmail.com>.
Hi Romain,
Here is the sample code:
*Resources configured in tomee.xml*
<Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
BrokerXmlConfig = broker:(tcp://localhost:61616)
ServerUrl = tcp://localhost:61616
</Resource>
<Resource id="MyJmsConnectionFactory"
type="javax.jms.ConnectionFactory"
ResourceAdapter = MyJmsResourceAdapter
</Resource>
<Container id="MyJmsMdbContainer" ctype="MESSAGE">
ResourceAdapter = MyJmsResourceAdapter
</Container>
<Resource id="test/ejb/AnswerQueue" type="javax.jms.Queue">
Destination test/ejb/AnswerQueue
</Resource>
////////////////////////////////////////////////////////////////////////////
*CachedInfoMessageHandlerBean.java*
package test.ejbs.TomEE.beans;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.DeliveryMode;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
public class CachedInfoMessageHandlerBean implements MessageListener
{
private ConnectionFactory connectionFactory;
private Queue answerQueue;
@Override
public void onMessage(Message message) {
try {
final TextMessage textMessage = (TextMessage) message;
final String question = textMessage.getText();
System.out.println("onMessage called");
if ("Hello World!".equals(question))
{
respond("Hello, Test Case!");
} else if ("How are you?".equals(question))
{
respond("I'm doing well.");
} else if ("Still spinning?".equals(question))
{
respond("Once every day, as usual.");
}
} catch (JMSException e) {
throw new IllegalStateException(e);
}
}
private void respond(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(answerQueue);
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
// Create a message
TextMessage message = session.createTextMessage(text);
// Tell the producer to send the message
producer.send(message);
} finally
{
// Clean up
if (session != null)
{
session.close();
}
if (connection != null)
{
connection.close();
}
}
}
}
// END
*ejb-jar.xml*
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns = "http://java.sun.com/xml/ns/javaee"
version = "3.0"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
<enterprise-beans>
<session>
<ejb-name>CalculatorBean</ejb-name>
<business-local>test.ejbs.TomEE.headers.CalculatorLocal</business-local>
<business-remote>test.ejbs.TomEE.headers.CalculatorRemote</business-remote>
<ejb-class>test.ejbs.TomEE.beans.CalculatorBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
<message-driven>
<ejb-name>CachedInfoMessageHandlerBean</ejb-name>
<ejb-class>test.ejbs.TomEE.beans.CachedInfoMessageHandlerBean</ejb-class>
<messaging-type>javax.jms.MessageListener</messaging-type>
<message-destination-type>javax.jms.Queue</message-destination-type>
<activation-config>
<activation-config-property>
<activation-config-property-name>destination</activation-config-property-name>
<activation-config-property-value>CachedInfoMessageHandlerBean</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>destinationType</activation-config-property-name>
<activation-config-property-value>javax.jms.Queue</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>acknowledgeMode</activation-config-property-name>
<activation-config-property-value>Auto-acknowledge</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>messageSelector</activation-config-property-name>
<activation-config-property-value>state=1</activation-config-property-value>
</activation-config-property>
</activation-config>
<resource-ref>
<res-ref-name>java:comp/env/test.ejbs.TomEE.beans.CachedInfoMessageHandlerBean/connectionFactory</res-ref-name>
<res-type>javax.jms.ConnectionFactory</res-type>
<injection-target>
<injection-target-class>test.ejbs.TomEE.beans.CachedInfoMessageHandlerBean</injection-target-class>
<injection-target-name>connectionFactory</injection-target-name>
</injection-target>
</resource-ref>
<resource-env-ref>
<resource-env-ref-name>java:test/ejb/AnswerQueue</resource-env-ref-name>
<resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
<mapped-name>AnswerQueue</mapped-name>
<injection-target>
<injection-target-class>test.ejbs.TomEE.beans.CachedInfoMessageHandlerBean</injection-target-class>
<injection-target-name>answerQueue</injection-target-name>
</injection-target>
</resource-env-ref>
</message-driven>
</enterprise-beans>
</ejb-jar>
*// TomEEAppClient.java*
package tomeeappclient;
import java.util.Properties;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.InitialContext;
public class TomEEAppClient
{
// @Resource(mappedName = "AnswerQueue")
private Queue queue;
// @Resource(mappedName = "MyJmsConnectionFactory")
private ConnectionFactory connectionFactory;
static
{
System.out.println("Loading System properties");
System.setProperty("MyJmsConnectionFactory",
"connectionfactory:org.apache.activemq.ActiveMQConnectionFactory:tcp://localhost:61616");
// System.setProperty("java:test/ejb/AnswerQueue",
"queue:org.apache.activemq.command.ActiveMQQueue:LISTENER");
}
public static void main(String[] args) throws Exception
{
TomEEAppClient client = new TomEEAppClient();
client.process();
}
private void process() throws Exception
{
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/tomee/ejb");
InitialContext ctx = new InitialContext(p);
String factory = "java:MyJmsConnectionFactory";
javax.jms.ConnectionFactory cf = (ConnectionFactory)
ctx.lookup(factory);
Connection connection = null;
try
{
connection = cf.createConnection();
queue = (Queue)ctx.lookup("java:test/ejb/AnswerQueue");
connection.start();
Session session =
connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
MessageProducer messageProducer = session.createProducer(queue);
TextMessage msg = session.createTextMessage();
msg.setText("Hello World!");
msg.setStringProperty("name", "TomEERemoteClient");
messageProducer.send(msg);
} catch (JMSException e)
{
throw new RuntimeException(e);
} finally
{
try
{
if (connection != null)
{
connection.close();
}
}catch (JMSException e) { }//ignore
}
}
}
//END
--
View this message in context: http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662332.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Can not connect to Message Bean from remote client : Null pointer
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hmm, no idea which conf takes AMQ? weird it uses the port tcp://
127.0.0.1:60058
any sample reproducing it?
Le 16 avr. 2013 01:38, "TomeeUser" <pa...@gmail.com> a écrit :
> Hi Romain,
>
> I moved little further.
>
> Now when I make connection client hangs and when I press CTRL-C I get
> following message at server
>
> 20130415 19:28:36 WARN (Transport)
> org.apache.activemq.broker.TransportConnection
> [serviceTransportException]:Transport Connection to: tcp://127.0.0.1:60058
> failed: java.net.SocketException: Connection reset
>
> java -cp
>
> C:\AppServers\tomee\lib\activemq-client-5.7.0.jar;C:\AppServers\tomee\lib\slf4j-api-1.7.2.jar;C:\AppServers\tomee\lib\slf4j-jdk14-1.7.2.jar;C:\experiments\TomEEAppClient\dist\TomEEAppClient.jar
> tomeeappclient.Client3
>
> Setting sys property
> Apr 15, 2013 7:27:33 PM org.apache.openejb.client.EventLogger log
> INFO:
> RemoteInitialContextCreated{providerUri=http://127.0.0.1:8080/tomee/ejb}
> 20
> Qname : LISTENER
> Terminate batch job (Y/N)? y
>
> Below is my client code:
>
> package tomeeappclient;
>
> import com.xerox.TomEE.headers.CalculatorRemote;
> import java.util.Properties;
> import javax.annotation.Resource;
> import javax.jms.Connection;
> import javax.jms.ConnectionFactory;
> import javax.jms.Destination;
> import javax.jms.JMSException;
> import javax.jms.MessageConsumer;
> import javax.jms.MessageProducer;
> import javax.jms.Queue;
> import javax.jms.Session;
> import javax.jms.TextMessage;
> import javax.naming.InitialContext;
>
>
> public class Client3
> {
> static
> {
> System.out.println("Setting sys property");
> System.setProperty("MyJmsConnectionFactory",
>
> "connectionfactory:org.apache.activemq.ActiveMQConnectionFactory:tcp://localhost:61616");
> System.setProperty("AnswerQueue",
> "queue:org.apache.activemq.command.ActiveMQQueue:LISTENER");
> }
> private ConnectionFactory connectionFactory;
> private Queue questionQueue;
> private Queue answerQueue;
> /**
> * @param args the command line arguments
> */
> public static void main(String[] args) throws Exception
> {
> Client3 client = new Client3();
> client.process();
> }
> private void process() throws Exception
> {
>
> 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/tomee/ejb");
> InitialContext ctx = new InitialContext(p);
>
> CalculatorRemote calc = (CalculatorRemote)
> ctx.lookup("CalculatorBeanRemote");
>
>
> System.out.println( calc.add(10, 10) );
>
> connectionFactory = (ConnectionFactory)
> ctx.lookup("java:MyJmsConnectionFactory");
>
> questionQueue = ( Queue ) ctx.lookup("java:AnswerQueue");
>
> System.out.println("Qname : "+ questionQueue.getQueueName());
>
> final Connection connection = connectionFactory.createConnection();
>
> Session session = connection.createSession(false,
> Session.AUTO_ACKNOWLEDGE);
> MessageProducer messageProducer =
> session.createProducer(questionQueue);
> TextMessage message = session.createTextMessage();
> message.setText("Hello World!");
> messageProducer.send(message);
>
> }
>
> private void sendText(String text, MessageProducer questions, Session
> session) throws JMSException
> {
> questions.send(session.createTextMessage(text));
> }
>
> private String receiveText(MessageConsumer answers) throws JMSException
> {
> return ((TextMessage) answers.receive(1000)).getText();
> }
>
> }
>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662289.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
Re: Can not connect to Message Bean from remote client : Null
pointer
Posted by TomeeUser <pa...@gmail.com>.
Hi Romain,
I moved little further.
Now when I make connection client hangs and when I press CTRL-C I get
following message at server
20130415 19:28:36 WARN (Transport)
org.apache.activemq.broker.TransportConnection
[serviceTransportException]:Transport Connection to: tcp://127.0.0.1:60058
failed: java.net.SocketException: Connection reset
java -cp
C:\AppServers\tomee\lib\activemq-client-5.7.0.jar;C:\AppServers\tomee\lib\slf4j-api-1.7.2.jar;C:\AppServers\tomee\lib\slf4j-jdk14-1.7.2.jar;C:\experiments\TomEEAppClient\dist\TomEEAppClient.jar
tomeeappclient.Client3
Setting sys property
Apr 15, 2013 7:27:33 PM org.apache.openejb.client.EventLogger log
INFO:
RemoteInitialContextCreated{providerUri=http://127.0.0.1:8080/tomee/ejb}
20
Qname : LISTENER
Terminate batch job (Y/N)? y
Below is my client code:
package tomeeappclient;
import com.xerox.TomEE.headers.CalculatorRemote;
import java.util.Properties;
import javax.annotation.Resource;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.InitialContext;
public class Client3
{
static
{
System.out.println("Setting sys property");
System.setProperty("MyJmsConnectionFactory",
"connectionfactory:org.apache.activemq.ActiveMQConnectionFactory:tcp://localhost:61616");
System.setProperty("AnswerQueue",
"queue:org.apache.activemq.command.ActiveMQQueue:LISTENER");
}
private ConnectionFactory connectionFactory;
private Queue questionQueue;
private Queue answerQueue;
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception
{
Client3 client = new Client3();
client.process();
}
private void process() throws Exception
{
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/tomee/ejb");
InitialContext ctx = new InitialContext(p);
CalculatorRemote calc = (CalculatorRemote)
ctx.lookup("CalculatorBeanRemote");
System.out.println( calc.add(10, 10) );
connectionFactory = (ConnectionFactory)
ctx.lookup("java:MyJmsConnectionFactory");
questionQueue = ( Queue ) ctx.lookup("java:AnswerQueue");
System.out.println("Qname : "+ questionQueue.getQueueName());
final Connection connection = connectionFactory.createConnection();
Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
MessageProducer messageProducer =
session.createProducer(questionQueue);
TextMessage message = session.createTextMessage();
message.setText("Hello World!");
messageProducer.send(message);
}
private void sendText(String text, MessageProducer questions, Session
session) throws JMSException
{
questions.send(session.createTextMessage(text));
}
private String receiveText(MessageConsumer answers) throws JMSException
{
return ((TextMessage) answers.receive(1000)).getText();
}
}
--
View this message in context: http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662289.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Can not connect to Message Bean from remote client : Null pointer
Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
Interesting. thanks Romain.
On Sun, Apr 14, 2013 at 3:30 PM, Romain Manni-Bucau
<rm...@gmail.com>wrote:
> basically
>
> https://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/client-resource-lookup-preview/
> does
> more or less it
>
> https://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/client-resource-lookup-preview/src/test/java/org/superbiz/client/SenderTest.java
>
> *Romain Manni-Bucau*
> *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> *Blog: **http://rmannibucau.wordpress.com/*<
> http://rmannibucau.wordpress.com/>
> *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> *Github: https://github.com/rmannibucau*
>
>
>
> 2013/4/14 Howard W. Smith, Jr. <sm...@gmail.com>
>
> > Shan, can you share your final code and config, when you have it done. I
> > may want to send msgs to least one remote server. Thanks.
> > On Apr 14, 2013 12:24 PM, "TomeeUser" <pa...@gmail.com> wrote:
> >
> > Hi Romain,
> >
> > Thanks for your help. I got it resolved. One more question how connect to
> > multiple servers? My client needs to send messes to series of servers.
> >
> > Regards,
> > -Shan
> >
> >
> >
> > --
> > View this message in context:
> >
> >
> http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662240.html
> > Sent from the OpenEJB User mailing list archive at Nabble.com.
> >
>
Re: Can not connect to Message Bean from remote client : Null pointer
Posted by Romain Manni-Bucau <rm...@gmail.com>.
basically
https://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/client-resource-lookup-preview/
does
more or less it
https://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/client-resource-lookup-preview/src/test/java/org/superbiz/client/SenderTest.java
*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*
2013/4/14 Howard W. Smith, Jr. <sm...@gmail.com>
> Shan, can you share your final code and config, when you have it done. I
> may want to send msgs to least one remote server. Thanks.
> On Apr 14, 2013 12:24 PM, "TomeeUser" <pa...@gmail.com> wrote:
>
> Hi Romain,
>
> Thanks for your help. I got it resolved. One more question how connect to
> multiple servers? My client needs to send messes to series of servers.
>
> Regards,
> -Shan
>
>
>
> --
> View this message in context:
>
> http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662240.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
Re: Can not connect to Message Bean from remote client : Null pointer
Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
Shan, can you share your final code and config, when you have it done. I
may want to send msgs to least one remote server. Thanks.
On Apr 14, 2013 12:24 PM, "TomeeUser" <pa...@gmail.com> wrote:
Hi Romain,
Thanks for your help. I got it resolved. One more question how connect to
multiple servers? My client needs to send messes to series of servers.
Regards,
-Shan
--
View this message in context:
http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662240.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Can not connect to Message Bean from remote client : Null
pointer
Posted by TomeeUser <pa...@gmail.com>.
Hi Romain,
Thanks for your help. I got it resolved. One more question how connect to
multiple servers? My client needs to send messes to series of servers.
Regards,
-Shan
--
View this message in context: http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662240.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Can not connect to Message Bean from remote client : Null
pointer
Posted by TomeeUser <pa...@gmail.com>.
Hi Romain,
Not sure I understood correctly. I changed the scheme to IIRC but still get
the following error:
Resource/javax.jms.ConnectionFactory=activemq:IIRC:MyJmsConnectionFactory:org.apache.activemq.ActiveMQConnectionFactory:tcp://localhost:61616
---------------------------------------------------------------------------------
Getting the OpenEJB InitialContext
----------------------------------
Apr 14, 2013 11:04:08 AM org.apache.openejb.client.EventLogger log
INFO:
RemoteInitialContextCreated{providerUri=http://localhost:8080/tomee/ejb}
{java.naming.factory.initial=org.apache.openejb.client.RemoteInitialContextFactory,
java.naming.provider.url=http://localhost:8080/tomee/ejb}
----------------------------------
Looking up MyJmsConnectionFactory
----------------------------------
*javax.naming.NamingException: Unknown JNDI name prefix
'openejb/remote/iirc:'
at
org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:130)*
at
org.apache.openejb.server.ejbd.JndiRequestHandler.doLookup(JndiRequestHandler.java:214)
at
org.apache.openejb.server.ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java:147)
at
org.apache.openejb.server.ejbd.EjbDaemon.processJndiRequest(EjbDaemon.java:271)
at org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:194)
at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:81)
at
org.apache.openejb.server.httpd.ServerServlet.service(ServerServlet.java:56)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:45)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
ConnectionFactory: null
----------------------------------
Listing all Context Entries
----------------------------------
-> . : java.lang.String
-> openejb : javax.naming.Context
-> -> UserBusinessRemote :
org.apache.openejb.core.ivm.naming.BusinessRemoteReference
-> -> DeployerBusinessRemote :
org.apache.openejb.core.ivm.naming.BusinessRemoteReference
-> -> ConfigurationInfoBusinessRemote :
org.apache.openejb.core.ivm.naming.BusinessRemoteReference
-> CachedInfoMessageHandlerBean :
org.apache.openejb.core.ivm.naming.IntraVmJndiReference
-> MEJB : org.apache.openejb.core.ivm.naming.ObjectReference
-> CalculatorBeanRemote :
org.apache.openejb.core.ivm.naming.BusinessRemoteReference
---------------------------------------------------------------------------------
---------------------------------------------------------------------------------
Getting the ActiveMQ InitialContext
----------------------------------
{java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory,
java.naming.provider.url=http://localhost:61616}
----------------------------------
Looking up MyJmsConnectionFactory
----------------------------------
*javax.naming.NamingException: scheme iirc not recognized*
at
org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:221)
at javax.naming.InitialContext.lookup(Unknown Source)
at
tomeeappclient.TomEEAppClient.lookupConnectionFactory(TomEEAppClient.java:88)
at tomeeappclient.TomEEAppClient.testActiveMqJNDI(TomEEAppClient.java:41)
at tomeeappclient.TomEEAppClient.main(TomEEAppClient.java:29)
ConnectionFactory: null
----------------------------------
Listing all Context Entries
----------------------------------
-> dynamicTopics : org.apache.activemq.jndi.ActiveMQInitialContextFactory$2
-> TopicConnectionFactory : org.apache.activemq.ActiveMQConnectionFactory
-> ConnectionFactory : org.apache.activemq.ActiveMQConnectionFactory
-> XAConnectionFactory : org.apache.activemq.ActiveMQXAConnectionFactory
-> dynamicQueues : org.apache.activemq.jndi.ActiveMQInitialContextFactory$1
-> QueueConnectionFactory : org.apache.activemq.ActiveMQConnectionFactory
---------------------------------------------------------------------------------
--
View this message in context: http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662236.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Can not connect to Message Bean from remote client : Null pointer
Posted by Romain Manni-Bucau <rm...@gmail.com>.
scheme should be activemq IIRC
Le 14 avr. 2013 02:40, "TomeeUser" <pa...@gmail.com> a écrit :
> Hi Romain,
>
> I tried to follow the steps mentioned in the thread but still I am getting
> exceptions: I am using tomee 1.5.2
> Any help would be greatly appreciated.
> -Shan
>
> java
>
> -DResource/javax.jms.ConnectionFactory=MyJmsConnectionFactory:org.apache.activemq.ActiveMQConnectionFactory:tcp://localhost:61616
> -cp
>
> C:\AppServers\tomee\lib\activemq-core-5.7.0.jar;C:\AppServers\tomee\lib\slf4j-api-1.7.2.jar;C:\AppServers\tomee\lib\slf4j-jdk14-1.7.2.jar;C:\experiments\TomEEAppClient\dist\TomEEAppClient.jar
> tomeeappclient.TomEEAppClient
>
> Resource/javax.jms.ConnectionFactory=MyJmsConnectionFactory:org.apache.activemq.ActiveMQConnectionFactory:tcp://localhost:61616
>
> ---------------------------------------------------------------------------------
> Getting the OpenEJB InitialContext
> ----------------------------------
> Apr 13, 2013 8:28:14 PM org.apache.openejb.client.EventLogger log
> INFO:
> RemoteInitialContextCreated{providerUri=http://localhost:8080/tomee/ejb}
>
> {java.naming.factory.initial=org.apache.openejb.client.RemoteInitialContextFactory,
> java.naming.provider.url=http://localhost:8080/tomee/ejb}
>
> ----------------------------------
> Looking up MyJmsConnectionFactory
> ----------------------------------
> *java.lang.UnsupportedOperationException: Unsupported Naming URI scheme
> 'MyJmsConnectionFactory'*
> at
> org.apache.openejb.client.JNDIContext.parseEntry(JNDIContext.java:327)
> at
> org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:270)
> at javax.naming.InitialContext.lookup(Unknown Source)
> at
>
> tomeeappclient.TomEEAppClient.lookupConnectionFactory(TomEEAppClient.java:88)
> at
> tomeeappclient.TomEEAppClient.testOpenEjbJNDI(TomEEAppClient.java:59)
> at tomeeappclient.TomEEAppClient.main(TomEEAppClient.java:27)
> ConnectionFactory: null
>
> ----------------------------------
> Listing all Context Entries
> ----------------------------------
> -> . : java.lang.String
> -> openejb : javax.naming.Context
> -> -> UserBusinessRemote :
> org.apache.openejb.core.ivm.naming.BusinessRemoteReference
> -> -> DeployerBusinessRemote :
> org.apache.openejb.core.ivm.naming.BusinessRemoteReference
> -> -> ConfigurationInfoBusinessRemote :
> org.apache.openejb.core.ivm.naming.BusinessRemoteReference
> -> CachedInfoMessageHandlerBean :
> org.apache.openejb.core.ivm.naming.IntraVmJndiReference
> -> MEJB : org.apache.openejb.core.ivm.naming.ObjectReference
> -> CalculatorBeanRemote :
> org.apache.openejb.core.ivm.naming.BusinessRemoteReference
>
> ---------------------------------------------------------------------------------
>
>
> ---------------------------------------------------------------------------------
> Getting the ActiveMQ InitialContext
> ----------------------------------
>
> {java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory,
> java.naming.provider.url=http://localhost:61616}
>
> ----------------------------------
> Looking up MyJmsConnectionFactory
> ----------------------------------
> *javax.naming.NameNotFoundException: MyJmsConnectionFactory*
> at
> org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:235)
> at javax.naming.InitialContext.lookup(Unknown Source)
> at
>
> tomeeappclient.TomEEAppClient.lookupConnectionFactory(TomEEAppClient.java:88)
> at
> tomeeappclient.TomEEAppClient.testActiveMqJNDI(TomEEAppClient.java:41)
> at tomeeappclient.TomEEAppClient.main(TomEEAppClient.java:29)
> ConnectionFactory: null
>
> ----------------------------------
> Listing all Context Entries
> ----------------------------------
> -> dynamicTopics : org.apache.activemq.jndi.ActiveMQInitialContextFactory$2
> -> TopicConnectionFactory : org.apache.activemq.ActiveMQConnectionFactory
> -> ConnectionFactory : org.apache.activemq.ActiveMQConnectionFactory
> -> XAConnectionFactory : org.apache.activemq.ActiveMQXAConnectionFactory
> -> dynamicQueues : org.apache.activemq.jndi.ActiveMQInitialContextFactory$1
> -> QueueConnectionFactory : org.apache.activemq.ActiveMQConnectionFactory
>
> ---------------------------------------------------------------------------------
>
> *Resource defined in tomee.xml*
> <Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
> BrokerXmlConfig = broker:(tcp://localhost:61616)
> ServerUrl = tcp://localhost:61616
> </Resource>
>
> <Resource id="MyJmsConnectionFactory"
> type="javax.jms.ConnectionFactory">
> ResourceAdapter = MyJmsResourceAdapter
> </Resource>
>
> <Container id="MyJmsMdbContainer" ctype="MESSAGE">
> ResourceAdapter = MyJmsResourceAdapter
> </Container>
>
> <Resource id="AnswerQueue" type="javax.jms.Queue" />
>
> *Message Bean:*
>
> import javax.annotation.Resource;
> import javax.ejb.MessageDriven;
> import javax.jms.Connection;
> import javax.jms.ConnectionFactory;
> import javax.jms.DeliveryMode;
> import javax.jms.JMSException;
> import javax.jms.Message;
> import javax.jms.MessageListener;
> import javax.jms.MessageProducer;
> import javax.jms.Queue;
> import javax.jms.Session;
> import javax.jms.TextMessage;
>
>
> @MessageDriven
> public class CachedInfoMessageHandlerBean implements MessageListener
> {
> @Resource(name = "MyJmsConnectionFactory", type =
> ConnectionFactory.class)
> // @Resource
> private ConnectionFactory connectionFactory;
>
> @Resource(name = "AnswerQueue")
> private Queue answerQueue;
>
> @Override
> public void onMessage(Message message) {
> try {
>
> final TextMessage textMessage = (TextMessage) message;
> final String question = textMessage.getText();
>
> if ("Hello World!".equals(question))
> {
> respond("Hello, Test Case!");
> } else if ("How are you?".equals(question))
> {
> respond("I'm doing well.");
> } else if ("Still spinning?".equals(question))
> {
> respond("Once every day, as usual.");
> }
> } catch (JMSException e) {
> throw new IllegalStateException(e);
> }
> }
>
> private void respond(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(answerQueue);
> producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
>
> // Create a message
> TextMessage message = session.createTextMessage(text);
>
> // Tell the producer to send the message
> producer.send(message);
> } finally
> {
> // Clean up
> if (session != null)
> {
> session.close();
> }
> if (connection != null)
> {
> connection.close();
> }
> }
> }
> }
>
> *Client Code :*
>
> import java.util.Hashtable;
> import javax.jms.ConnectionFactory;
> import javax.naming.Context;
> import javax.naming.InitialContext;
> import javax.naming.NameClassPair;
> import javax.naming.NameNotFoundException;
> import javax.naming.NamingEnumeration;
> import javax.naming.NamingException;
> import javax.naming.NotContextException;
>
> /**
> *
> *
> */
> public class TomEEAppClient
> {
> /**
> * @param args
> * @throws NamingException
> */
> public static void main(String[] args) {
>
> System.out.println("Resource/javax.jms.ConnectionFactory="
> +
> System.getProperty("Resource/javax.jms.ConnectionFactory"));
>
> testOpenEjbJNDI();
>
> testActiveMqJNDI();
> }
>
> private static void testActiveMqJNDI() {
> InitialContext context;
> ConnectionFactory cf;
>
>
> System.out.println("---------------------------------------------------------------------------------");
> System.out.println("Getting the ActiveMQ InitialContext");
> System.out.println("----------------------------------");
>
> context = getActiveMQInitialContext();
>
> lookupConnectionFactory(context);
>
> listContextEntries(context, "");
>
>
>
> System.out.println("---------------------------------------------------------------------------------");
> System.out.println();
> }
>
> private static void testOpenEjbJNDI() {
> InitialContext context;
> ConnectionFactory cf;
>
>
>
> System.out.println("---------------------------------------------------------------------------------");
> System.out.println("Getting the OpenEJB InitialContext");
> System.out.println("----------------------------------");
>
> context = getOpenEJBInitialContext();
>
> lookupConnectionFactory(context);
>
> listContextEntries(context, "");
>
>
>
> System.out.println("---------------------------------------------------------------------------------");
> System.out.println();
> }
>
> private static InitialContext getInitialContext(Hashtable<String,
> String>
> ctxProps) {
> InitialContext ctx = null;
> try {
> ctx = new InitialContext(ctxProps);
> System.out.println(ctx.getEnvironment());
> } catch (NamingException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> return ctx;
> }
>
> private static void lookupConnectionFactory(InitialContext
> context) {
>
> ConnectionFactory cf = null;
> try {
> System.out.println();
>
> System.out.println("----------------------------------");
> System.out.println("Looking up
> MyJmsConnectionFactory ");
>
> System.out.println("----------------------------------");
> String factory = "MyJmsConnectionFactory";
> cf = (ConnectionFactory)context.lookup(factory);
> } catch (NamingException e)
> {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }catch( Exception ex)
> {
> ex.printStackTrace();
> }
> System.out.println("ConnectionFactory: " + cf);
> }
>
> private static InitialContext getOpenEJBInitialContext() {
>
> Hashtable<String, String> ctxProps = new Hashtable<String,
> String>(4);
> ctxProps.put("java.naming.factory.initial",
> "org.apache.openejb.client.RemoteInitialContextFactory");
> ctxProps.put("java.naming.provider.url",
> "http://localhost:8080/tomee/ejb");
> // ctxProps.put("java.naming.security.principal", "tomee");
> // ctxProps.put("java.naming.security.credentials",
> "tomee");
>
> return getInitialContext(ctxProps);
> }
>
> private static InitialContext getActiveMQInitialContext() {
>
> Hashtable<String, String> ctxProps = new Hashtable<String,
> String>(2);
> ctxProps.put("java.naming.factory.initial",
> "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
> ctxProps.put("java.naming.provider.url", "
> http://localhost:61616");
>
> return getInitialContext(ctxProps);
> }
>
> private static int contextCount = 0;
>
> private static void listContextEntries(Context ctx, String
> namedContext) {
> if (0 == contextCount) {
> System.out.println();
>
> System.out.println("----------------------------------");
> System.out.println("Listing all Context Entries");
>
> System.out.println("----------------------------------");
> }
> NamingEnumeration<NameClassPair> list;
> try {
> list = ctx.list(namedContext);
>
> if (null != list) {
> while (list.hasMore()) {
> final NameClassPair pair =
> list.next();
> final String name = pair.getName();
> final String className =
> pair.getClassName();
>
> for(int count = 0; count <=
> contextCount; count++) {
> System.out.print("-> ");
> }
>
> System.out.println(name + " : " +
> className);
> contextCount++;
> if(contextCount > 1) {
> listContextEntries(ctx,
> namedContext + '/' + name);
> } else {
> listContextEntries(ctx,
> name);
> }
> contextCount--;
> }
> }
> } catch (NameNotFoundException e) {
> // not a valid context...
> e.printStackTrace(System.out);
> } catch (NotContextException e) {
> // not a valid context...
> } catch (NamingException e) {
> e.printStackTrace(System.out);
> }
>
> }
> }
>
>
>
>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662220.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
Re: Can not connect to Message Bean from remote client : Null
pointer
Posted by TomeeUser <pa...@gmail.com>.
Hi Romain,
I tried to follow the steps mentioned in the thread but still I am getting
exceptions: I am using tomee 1.5.2
Any help would be greatly appreciated.
-Shan
java
-DResource/javax.jms.ConnectionFactory=MyJmsConnectionFactory:org.apache.activemq.ActiveMQConnectionFactory:tcp://localhost:61616
-cp
C:\AppServers\tomee\lib\activemq-core-5.7.0.jar;C:\AppServers\tomee\lib\slf4j-api-1.7.2.jar;C:\AppServers\tomee\lib\slf4j-jdk14-1.7.2.jar;C:\experiments\TomEEAppClient\dist\TomEEAppClient.jar
tomeeappclient.TomEEAppClient
Resource/javax.jms.ConnectionFactory=MyJmsConnectionFactory:org.apache.activemq.ActiveMQConnectionFactory:tcp://localhost:61616
---------------------------------------------------------------------------------
Getting the OpenEJB InitialContext
----------------------------------
Apr 13, 2013 8:28:14 PM org.apache.openejb.client.EventLogger log
INFO:
RemoteInitialContextCreated{providerUri=http://localhost:8080/tomee/ejb}
{java.naming.factory.initial=org.apache.openejb.client.RemoteInitialContextFactory,
java.naming.provider.url=http://localhost:8080/tomee/ejb}
----------------------------------
Looking up MyJmsConnectionFactory
----------------------------------
*java.lang.UnsupportedOperationException: Unsupported Naming URI scheme
'MyJmsConnectionFactory'*
at org.apache.openejb.client.JNDIContext.parseEntry(JNDIContext.java:327)
at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:270)
at javax.naming.InitialContext.lookup(Unknown Source)
at
tomeeappclient.TomEEAppClient.lookupConnectionFactory(TomEEAppClient.java:88)
at tomeeappclient.TomEEAppClient.testOpenEjbJNDI(TomEEAppClient.java:59)
at tomeeappclient.TomEEAppClient.main(TomEEAppClient.java:27)
ConnectionFactory: null
----------------------------------
Listing all Context Entries
----------------------------------
-> . : java.lang.String
-> openejb : javax.naming.Context
-> -> UserBusinessRemote :
org.apache.openejb.core.ivm.naming.BusinessRemoteReference
-> -> DeployerBusinessRemote :
org.apache.openejb.core.ivm.naming.BusinessRemoteReference
-> -> ConfigurationInfoBusinessRemote :
org.apache.openejb.core.ivm.naming.BusinessRemoteReference
-> CachedInfoMessageHandlerBean :
org.apache.openejb.core.ivm.naming.IntraVmJndiReference
-> MEJB : org.apache.openejb.core.ivm.naming.ObjectReference
-> CalculatorBeanRemote :
org.apache.openejb.core.ivm.naming.BusinessRemoteReference
---------------------------------------------------------------------------------
---------------------------------------------------------------------------------
Getting the ActiveMQ InitialContext
----------------------------------
{java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory,
java.naming.provider.url=http://localhost:61616}
----------------------------------
Looking up MyJmsConnectionFactory
----------------------------------
*javax.naming.NameNotFoundException: MyJmsConnectionFactory*
at
org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:235)
at javax.naming.InitialContext.lookup(Unknown Source)
at
tomeeappclient.TomEEAppClient.lookupConnectionFactory(TomEEAppClient.java:88)
at tomeeappclient.TomEEAppClient.testActiveMqJNDI(TomEEAppClient.java:41)
at tomeeappclient.TomEEAppClient.main(TomEEAppClient.java:29)
ConnectionFactory: null
----------------------------------
Listing all Context Entries
----------------------------------
-> dynamicTopics : org.apache.activemq.jndi.ActiveMQInitialContextFactory$2
-> TopicConnectionFactory : org.apache.activemq.ActiveMQConnectionFactory
-> ConnectionFactory : org.apache.activemq.ActiveMQConnectionFactory
-> XAConnectionFactory : org.apache.activemq.ActiveMQXAConnectionFactory
-> dynamicQueues : org.apache.activemq.jndi.ActiveMQInitialContextFactory$1
-> QueueConnectionFactory : org.apache.activemq.ActiveMQConnectionFactory
---------------------------------------------------------------------------------
*Resource defined in tomee.xml*
<Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
BrokerXmlConfig = broker:(tcp://localhost:61616)
ServerUrl = tcp://localhost:61616
</Resource>
<Resource id="MyJmsConnectionFactory" type="javax.jms.ConnectionFactory">
ResourceAdapter = MyJmsResourceAdapter
</Resource>
<Container id="MyJmsMdbContainer" ctype="MESSAGE">
ResourceAdapter = MyJmsResourceAdapter
</Container>
<Resource id="AnswerQueue" type="javax.jms.Queue" />
*Message Bean:*
import javax.annotation.Resource;
import javax.ejb.MessageDriven;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.DeliveryMode;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
@MessageDriven
public class CachedInfoMessageHandlerBean implements MessageListener
{
@Resource(name = "MyJmsConnectionFactory", type =
ConnectionFactory.class)
// @Resource
private ConnectionFactory connectionFactory;
@Resource(name = "AnswerQueue")
private Queue answerQueue;
@Override
public void onMessage(Message message) {
try {
final TextMessage textMessage = (TextMessage) message;
final String question = textMessage.getText();
if ("Hello World!".equals(question))
{
respond("Hello, Test Case!");
} else if ("How are you?".equals(question))
{
respond("I'm doing well.");
} else if ("Still spinning?".equals(question))
{
respond("Once every day, as usual.");
}
} catch (JMSException e) {
throw new IllegalStateException(e);
}
}
private void respond(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(answerQueue);
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
// Create a message
TextMessage message = session.createTextMessage(text);
// Tell the producer to send the message
producer.send(message);
} finally
{
// Clean up
if (session != null)
{
session.close();
}
if (connection != null)
{
connection.close();
}
}
}
}
*Client Code :*
import java.util.Hashtable;
import javax.jms.ConnectionFactory;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NameClassPair;
import javax.naming.NameNotFoundException;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.NotContextException;
/**
*
*
*/
public class TomEEAppClient
{
/**
* @param args
* @throws NamingException
*/
public static void main(String[] args) {
System.out.println("Resource/javax.jms.ConnectionFactory=" +
System.getProperty("Resource/javax.jms.ConnectionFactory"));
testOpenEjbJNDI();
testActiveMqJNDI();
}
private static void testActiveMqJNDI() {
InitialContext context;
ConnectionFactory cf;
System.out.println("---------------------------------------------------------------------------------");
System.out.println("Getting the ActiveMQ InitialContext");
System.out.println("----------------------------------");
context = getActiveMQInitialContext();
lookupConnectionFactory(context);
listContextEntries(context, "");
System.out.println("---------------------------------------------------------------------------------");
System.out.println();
}
private static void testOpenEjbJNDI() {
InitialContext context;
ConnectionFactory cf;
System.out.println("---------------------------------------------------------------------------------");
System.out.println("Getting the OpenEJB InitialContext");
System.out.println("----------------------------------");
context = getOpenEJBInitialContext();
lookupConnectionFactory(context);
listContextEntries(context, "");
System.out.println("---------------------------------------------------------------------------------");
System.out.println();
}
private static InitialContext getInitialContext(Hashtable<String, String>
ctxProps) {
InitialContext ctx = null;
try {
ctx = new InitialContext(ctxProps);
System.out.println(ctx.getEnvironment());
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return ctx;
}
private static void lookupConnectionFactory(InitialContext context) {
ConnectionFactory cf = null;
try {
System.out.println();
System.out.println("----------------------------------");
System.out.println("Looking up MyJmsConnectionFactory ");
System.out.println("----------------------------------");
String factory = "MyJmsConnectionFactory";
cf = (ConnectionFactory)context.lookup(factory);
} catch (NamingException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}catch( Exception ex)
{
ex.printStackTrace();
}
System.out.println("ConnectionFactory: " + cf);
}
private static InitialContext getOpenEJBInitialContext() {
Hashtable<String, String> ctxProps = new Hashtable<String, String>(4);
ctxProps.put("java.naming.factory.initial",
"org.apache.openejb.client.RemoteInitialContextFactory");
ctxProps.put("java.naming.provider.url",
"http://localhost:8080/tomee/ejb");
// ctxProps.put("java.naming.security.principal", "tomee");
// ctxProps.put("java.naming.security.credentials", "tomee");
return getInitialContext(ctxProps);
}
private static InitialContext getActiveMQInitialContext() {
Hashtable<String, String> ctxProps = new Hashtable<String, String>(2);
ctxProps.put("java.naming.factory.initial",
"org.apache.activemq.jndi.ActiveMQInitialContextFactory");
ctxProps.put("java.naming.provider.url", "http://localhost:61616");
return getInitialContext(ctxProps);
}
private static int contextCount = 0;
private static void listContextEntries(Context ctx, String namedContext) {
if (0 == contextCount) {
System.out.println();
System.out.println("----------------------------------");
System.out.println("Listing all Context Entries");
System.out.println("----------------------------------");
}
NamingEnumeration<NameClassPair> list;
try {
list = ctx.list(namedContext);
if (null != list) {
while (list.hasMore()) {
final NameClassPair pair = list.next();
final String name = pair.getName();
final String className = pair.getClassName();
for(int count = 0; count <= contextCount; count++) {
System.out.print("-> ");
}
System.out.println(name + " : " + className);
contextCount++;
if(contextCount > 1) {
listContextEntries(ctx, namedContext + '/' + name);
} else {
listContextEntries(ctx, name);
}
contextCount--;
}
}
} catch (NameNotFoundException e) {
// not a valid context...
e.printStackTrace(System.out);
} catch (NotContextException e) {
// not a valid context...
} catch (NamingException e) {
e.printStackTrace(System.out);
}
}
}
--
View this message in context: http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662220.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Can not connect to Message Bean from remote client : Null pointer
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Was thinking to
http://openejb.979440.n4.nabble.com/Remote-JNDI-access-to-JMS-resources-td4656767.html
Le 13 avr. 2013 15:15, "TomeeUser" <pa...@gmail.com> a écrit :
> Hi Romain,
>
> Thanks for reply. Can you please help me in setting properties ? I am
> really
> stuck.
>
> Regards,
> Shan
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662215.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
Re: Can not connect to Message Bean from remote client : Null
pointer
Posted by TomeeUser <pa...@gmail.com>.
Hi Romain,
Thanks for reply. Can you please help me in setting properties ? I am really
stuck.
Regards,
Shan
--
View this message in context: http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203p4662215.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Can not connect to Message Bean from remote client : Null pointer
Posted by Romain Manni-Bucau <rm...@gmail.com>.
This kind of client stuff needs config (resource config through system prop
basically), think there are some other threads on the list dealing with it.
Le 13 avr. 2013 02:01, "TomeeUser" <pa...@gmail.com> a écrit :
> I created a simple message bean from example and tried to connect it from
> remote. but getting error not able to connect. Getting Null pointer. Below
> is the code: Please help
> /*
> * To change this template, choose Tools | Templates
> * and open the template in the editor.
> */
> package com.xerox.TomEE.beans;
>
> import javax.annotation.Resource;
> import javax.ejb.MessageDriven;
> import javax.jms.Connection;
> import javax.jms.ConnectionFactory;
> import javax.jms.DeliveryMode;
> import javax.jms.JMSException;
> import javax.jms.Message;
> import javax.jms.MessageListener;
> import javax.jms.MessageProducer;
> import javax.jms.Queue;
> import javax.jms.Session;
> import javax.jms.TextMessage;
>
> /**
> *
> *
> */
> @MessageDriven
> public class CachedInfoMessageHandlerBean implements MessageListener
> {
> //@Resource
> @Resource(name = "CachedInfoMessageHandlerBeanFactory", type =
> ConnectionFactory.class)
> private ConnectionFactory connectionFactory;
>
> @Resource(name = "AnswerQueue")
> private Queue answerQueue;
>
> @Override
> public void onMessage(Message message) {
> try {
>
> final TextMessage textMessage = (TextMessage) message;
> final String question = textMessage.getText();
>
> if ("Hello World!".equals(question))
> {
> respond("Hello, Test Case!");
> } else if ("How are you?".equals(question))
> {
> respond("I'm doing well.");
> } else if ("Still spinning?".equals(question))
> {
> respond("Once every day, as usual.");
> }
> } catch (JMSException e) {
> throw new IllegalStateException(e);
> }
> }
>
> private void respond(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(answerQueue);
> producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
>
> // Create a message
> TextMessage message = session.createTextMessage(text);
>
> // Tell the producer to send the message
> producer.send(message);
> } finally
> {
> // Clean up
> if (session != null)
> {
> session.close();
> }
> if (connection != null)
> {
> connection.close();
> }
> }
> }
> }
>
> Client code :
> /*
> * To change this template, choose Tools | Templates
> * and open the template in the editor.
> */
> package tomeeappclient;
>
> import com.xerox.TomEE.headers.*;
> import java.util.Properties;
> import javax.annotation.Resource;
> import javax.jms.Connection;
> import javax.jms.ConnectionFactory;
> import javax.jms.JMSException;
> import javax.jms.MessageConsumer;
> import javax.jms.MessageProducer;
> import javax.jms.Queue;
> import javax.jms.Session;
> import javax.jms.TextMessage;
> import javax.naming.Context;
> import javax.naming.InitialContext;
>
> /**
> *
> *
> */
> public class TomEEAppClient
> {
> // @Resource
> // @Resource(name = "jms/CachedInfoMessageHandlerBeanFactory", type =
> ConnectionFactory.class)
>
> @Resource
> private ConnectionFactory connectionFactory;
>
> @Resource(name = "CachedInfoMessageHandlerBeanFactory")
> private Queue questionQueue;
>
> @Resource(name = "AnswerQueue")
> private Queue answerQueue;
> /**
> * @param args the command line arguments
> */
> public static void main(String[] args) throws Exception
> {
> TomEEAppClient client = new TomEEAppClient();
> client.process();
> }
> private void process() throws Exception
> {
> // TODO code application logic here
> 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/tomee/ejb");
> //p.put(Context.PROVIDER_URL, "ejbd://127.0.0.1:61616");
> InitialContext ctx = new InitialContext(p);
>
> CalculatorRemote calc = (CalculatorRemote)
> ctx.lookup("CalculatorBeanRemote");
>
>
> System.out.println( calc.add(10, 10) );
> // System.out.println( calc.divide(4, 2) );
>
> // String factory = "remote:CachedInfoMessageHandlerBeanFactory";
> // javax.jms.ConnectionFactory cf = (ConnectionFactory)
> ctx.lookup(factory);
> // final Connection connection = cf.createConnection();
>
>
> final Connection connection = connectionFactory.createConnection();
>
> connection.start();
>
> final Session session = connection.createSession(false,
> Session.AUTO_ACKNOWLEDGE);
> final MessageProducer questions =
> session.createProducer(questionQueue);
> final MessageConsumer answers =
> session.createConsumer(answerQueue);
>
> sendText("Hello World!", questions, session);
>
> // assertEquals("Hello, Test Case!", receiveText(answers));
> String answer = receiveText(answers);
> System.out.println("Answer received : " + answer);
>
>
> }
>
> private void sendText(String text, MessageProducer questions, Session
> session) throws JMSException {
>
> questions.send(session.createTextMessage(text));
> }
>
> private String receiveText(MessageConsumer answers) throws JMSException
> {
>
> return ((TextMessage) answers.receive(1000)).getText();
> }
> }
>
> Error :
>
> C:\AppServers\tomee\webapps>java -jar
> "C:\experiments\TomEEAppClient\dist\TomEEAppClient.jar"
> Apr 12, 2013 5:27:59 PM org.apache.openejb.client.EventLogger log
> INFO:
> RemoteInitialContextCreated{providerUri=http://127.0.0.1:8080/tomee/ejb}
> 20
> Exception in thread "main" java.lang.NullPointerException
> at tomeeappclient.TomEEAppClient.process(TomEEAppClient.java:66)
> at tomeeappclient.TomEEAppClient.main(TomEEAppClient.java:44)
>
>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Can-not-connect-to-Message-Bean-from-remote-client-Null-pointer-tp4662203.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>