users@glassfish.java.net

ACC003: Couldn't establish a JMS Connection Factory

From: <glassfish_at_javadesktop.org>
Date: Wed, 10 Mar 2010 05:30:27 PST

Hi Forum members,

I came across the following error when trying to send a CUSTOMER object to a remote server using JMS (Glassfish v2r1) by following the example in <INSTALL>/javaeetutorial5/examples/jms/simple/producer:

10/03/2010 11:14:08 PM com.sun.enterprise.appclient.MainWithModuleSupport <init>
WARNING: ACC003: Application threw an exception.
java.lang.NullPointerException
        at client.CustomerproducerApplicationClient.sendJMSMessageToMyQueue(CustomerproducerApplicationClient.java:101)
        at client.CustomerproducerApplicationClient.addCustomers(CustomerproducerApplicationClient.java:633)
        at client.CustomerproducerApplicationClient.main(CustomerproducerApplicationClient.java:68)
        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:597)
        at com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:266)
        at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:449)
        at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
        at com.sun.enterprise.appclient.Main.main(Main.java:200)
Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:461)
        at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
        at com.sun.enterprise.appclient.Main.main(Main.java:200)
Caused by: java.lang.reflect.InvocationTargetException

Below are the snippets of client.CustomerproducerApplicationClient:

    @Resource(mappedName = "jms/customerQueueConnectionFactory")
    private static ConnectionFactory customerQueueConnectionFactory;
    @Resource(mappedName = "jms/customerQueue")
    private static Queue customerQueue;
    ......
     
    public Message createJMSMessageForjmsMyQueue(Session session, Object messageData) throws JMSException {
        ObjectMessage objectMessage = session.createObjectMessage();
        objectMessage.setObject((Customer)messageData);
        return objectMessage;
    }

    public void sendJMSMessageToMyQueue(Object messageData) throws JMSException {
        
line 101 connection = customerQueueConnectionFactory.createConnection();
            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            MessageProducer messageProducer = session.createProducer(customerQueue);
            messageProducer.send(createJMSMessageForjmsMyQueue(session, messageData));
    }

    .........

    Customer customer = new Customer();
    customer.setFirstname("Jack");
    .....
    sendJMSMessageToMyQueue(customer);

Some detail of defining the Connection Factory & Queue sun-resource.xml are as follows:

<resources>
  <admin-object-resource enabled="true" jndi-name="jms/customerQueue" object-type="user" res-adapter="jmsra" res-type="javax.jms.Queue">
    <description/>
    <property name="Name" value="customerQueue"/>
  </admin-object-resource>
  <connector-resource enabled="true" jndi-name="jms/customerQueueConnectionFactory" object-type="user" pool-name="jms/customerQueueConnectionFactory">
    <description/>
  </connector-resource>
  <connector-connection-pool associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-definition-name="javax.jms.ConnectionFactory" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="true" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="jms/customerQueueConnectionFactory" pool-resize-quantity="2" resource-adapter-name="jmsra" steady-pool-size="8" validate-atmost-once-period-in-seconds="0">
    <property name="AddressList" value="remoteserver"/>
  </connector-connection-pool>
</resources>

All resources & CustomerproducerApplicationClient have successfully deployed only to run into trouble at runtime.

Any suggestion would be greatly appreciated.

Thanks,

Jack
[Message sent by forum member 'htran_888' (htran_888_at_yahoo.com.au)]

http://forums.java.net/jive/thread.jspa?messageID=391034