activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james.strac...@gmail.com>
Subject Re: NullPointerException with RA on Glassfish
Date Tue, 20 Jun 2006 07:40:18 GMT
It looks like this exception...

Caused by: java.lang.NullPointerException
       at
org.apache.activemq.ra.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:88)

is caused by Glassfish calling

  ManagedConnectionFactory.createConnectionFactory(ConnectionManager manager)

by passing in a null ConnectionManager.

So it sounds like Glassfish is not creating a connection manager to
use. This is only required if UseInboundSessionEnabled is not set.

I've just updated SVN HEAD of ActiveMQ to throw a more descriptive
error message if the JCA container does not configure a
ConnectionManager.

On 6/20/06, rhavyn <cconrad@vasoftware.com> wrote:
>
> Hello,
>
> I'm trying to get ActiveMQ 4.0 working with Glassfish using the JCA 1.5 RA.
> I've deployed the RA and created a connection pool and queue.  Sending
> messages to a MDB works without a problem using a Stomp client (I haven't
> tried a JMS client yet), however when I try and respond I'm getting a NPE
> from within the createConnection call.  The code to the MDB is:
>
> import javax.annotation.Resource;
> import javax.ejb.ActivationConfigProperty;
> import javax.ejb.MessageDriven;
> import javax.ejb.MessageDrivenContext;
> import javax.jms.Connection;
> import javax.jms.ConnectionFactory;
> import javax.jms.Destination;
> import javax.jms.JMSException;
> import javax.jms.Message;
> import javax.jms.MessageListener;
> import javax.jms.Session;
> import javax.jms.TextMessage;
> import javax.jms.MessageProducer;
> import java.util.logging.Logger;
>
> @MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName =
> "destination",
>         propertyValue = "queue"), @ActivationConfigProperty(propertyName =
> "destinationType",
>         propertyValue = "javax.jms.Queue") })
> public class MDB implements MessageListener {
>     private static final Logger logger = Logger.getLogger("MDB");
>
>     @Resource
>     private MessageDrivenContext mdc;
>
>     @Resource(mappedName = "jms/ConnectionFactory")
>     private ConnectionFactory connectionFactory;
>
>     public void onMessage(Message message) {
>         Connection connection = null;
>         try {
>             if (message instanceof TextMessage) {
>                 TextMessage msg = (TextMessage) message;
>
>                 logger.info("Message received: " + msg.getText());
>
>                 connection = connectionFactory.createConnection();
>                 Session session = connection.createSession(false,
> Session.AUTO_ACKNOWLEDGE);
>                 Destination destination = msg.getJMSReplyTo();
>                 MessageProducer producer =
> session.createProducer(destination);
>                 TextMessage response = session.createTextMessage();
>                 response.setText("Hello " + msg.getText());
>                 producer.send(response);
>             }
>         } catch (JMSException e) {
>             logger.warning("Error retrieving message: " + e);
>             mdc.setRollbackOnly();
>         } finally {
>             if (connection != null) {
>                 try {
>                     connection.close();
>                 } catch (JMSException e) {
>                     logger.warning("Exception while closing connection: " +
> e);
>                 }
>             }
>         }
>     }
> }
>
> The log output is:
>
> [#|2006-06-19T17:14:58.179-0700|INFO|sun-appserver-pe9.1|MDB|_ThreadID=11;_ThreadName=p:
> thread-pool-1; w: 2;|Message received: FOO BAR BAZ BUM i|#]
>
> [#|2006-06-19T17:15:09.111-0700|INFO|sun-appserver-pe9.1|javax.enterprise.system.container.ejb.mdb|_ThreadID=11;_ThreadName=p:
> thread-pool-1; w: 2;mdb-1:MDB;javax.ejb.EJBException;|MDB00037: [mdb-1:MDB]:
> Message-driven bean invocation exception: [javax.ejb.EJBException]|#]
>
> [#|2006-06-19T17:15:09.159-0700|INFO|sun-appserver-pe9.1|javax.enterprise.system.container.ejb.mdb|_ThreadID=11;_ThreadName=p:
> thread-pool-1; w: 2;|javax.ejb.EJBException
> javax.ejb.EJBException
>         at
> com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:3730)
>         at
> com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3630)
>         at
> com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3431)
>         at
> com.sun.ejb.containers.MessageBeanContainer.afterMessageDeliveryInternal(MessageBeanContainer.java:1112)
>         at
> com.sun.ejb.containers.MessageBeanContainer.afterMessageDelivery(MessageBeanContainer.java:1083)
>         at
> com.sun.ejb.containers.MessageBeanListenerImpl.afterMessageDelivery(MessageBeanListenerImpl.java:66)
>         at
> com.sun.enterprise.connectors.inflow.MessageEndpointInvocationHandler.invoke(MessageEndpointInvocationHandler.java:126)
>         at $Proxy18.afterDelivery(Unknown Source)
>         at
> org.apache.activemq.ra.MessageEndpointProxy$MessageEndpointAlive.afterDelivery(MessageEndpointProxy.java:125)
>         at
> org.apache.activemq.ra.MessageEndpointProxy.afterDelivery(MessageEndpointProxy.java:64)
>         at
> org.apache.activemq.ra.ServerSessionImpl.afterDelivery(ServerSessionImpl.java:214)
>         at org.apache.activemq.ActiveMQSession.run(ActiveMQSession.java:751)
>         at
> org.apache.activemq.ra.ServerSessionImpl.run(ServerSessionImpl.java:163)
>         at
> com.sun.enterprise.connectors.work.OneWork.doWork(OneWork.java:63)
>         at
> com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:479)
> Caused by: java.lang.NullPointerException
>         at
> org.apache.activemq.ra.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:88)
>         at
> org.apache.activemq.ra.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:65)
>         at net.sourceforge.sfx.mdb.MDB.onMessage(MDB.java:42)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:585)
>         at
> com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1050)
>         at
> com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:165)
>         at
> com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2766)
>         at
> com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3847)
>         at
> com.sun.ejb.containers.MessageBeanContainer.deliverMessage(MessageBeanContainer.java:997)
>         at
> com.sun.ejb.containers.MessageBeanListenerImpl.deliverMessage(MessageBeanListenerImpl.java:61)
>         at
> com.sun.enterprise.connectors.inflow.MessageEndpointInvocationHandler.invoke(MessageEndpointInvocationHandler.java:166)
>         at $Proxy18.onMessage(Unknown Source)
>         at
> org.apache.activemq.ra.MessageEndpointProxy$MessageEndpointAlive.onMessage(MessageEndpointProxy.java:120)
>         at
> org.apache.activemq.ra.MessageEndpointProxy.onMessage(MessageEndpointProxy.java:60)
>         at org.apache.activemq.ActiveMQSession.run(ActiveMQSession.java:692)
>         ... 3 more
> |#]
>
> Any help would be greatly appreciated.
>
> Thanks so much,
> --Chris
>
> --
> View this message in context: http://www.nabble.com/NullPointerException-with-RA-on-Glassfish-t1814940.html#a4947362
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>


-- 

James
-------
http://radio.weblogs.com/0112098/

Mime
View raw message