0
votes

I have created a MDB bean and deployed in glassfish 4 and application got deployed successfully, but i am trying to put message in the queue using a standalone client. And i am getting this error.

**java.lang.NullPointerException at com.sun.enterprise.naming.impl.SerialContext.getORB(SerialContext.java:347) javax.naming.NamingException: Lookup failed for 'jms/myQueue' in SerialContext[myEnv={java.naming.provider.url=iiop://localhost:3700, java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEnv={java.naming.provider.url=iiop://localhost:3700, java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is java.lang.NullPointerException]]

Caused by: javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEnv={java.naming.provider.url=iiop://localhost:3700, java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is java.lang.NullPointerException]**

MDB class code is::

    package test;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

@MessageDriven(activationConfig = {
    @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "jms/myQueue")
    ,
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
    ,
        @ActivationConfigProperty(propertyName = "connectionFactoryLookup", propertyValue = "jms/myConnectionFactory")
})
public class testMDB1 implements MessageListener {

    public testMDB1() {
    }

    @Override
    public void onMessage(Message message) {
        if (message instanceof TextMessage) {
            TextMessage t = (TextMessage) message;
            try {
                System.out.println("ye le " + t.getText());
            } catch (JMSException ex) {
                Logger.getLogger(TestMDB.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

}

and the client file is

package test;
import java.util.Properties;
import javax.jms.ConnectionFactory;
import javax.jms.JMSContext;
import javax.jms.JMSProducer;
import javax.jms.Queue;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class TestClient {

    public static void main(String[] args) {

        try {

            final Properties env = new Properties();
            env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
            env.put(Context.URL_PKG_PREFIXES, "com.sun.enterprise.naming");
            env.put(Context.PROVIDER_URL, "iiop://localhost:3700");
            Context remoteContext = new InitialContext(env);
            System.out.println("remote context" + remoteContext.getEnvironment());
            Queue queue = (Queue) remoteContext.lookup("jms/myQueue");
            JMSContext jmsContext = ((ConnectionFactory) remoteContext.lookup("jms/myConnectionFactory")).createContext();
            JMSProducer producer = jmsContext.createProducer();
            producer.send(queue, "hello ");
            System.out.println("1. Sent TextMessage to the Queue");

        } catch (NamingException e) {
            e.printStackTrace();
        }
    }
}

I have added gf-client.jar,orb-iiop.jar and appserv-rt.jar but nothing is solving my problem.

1

1 Answers

1
votes

I came to know that glassfish 4.1 is having this bug where local client cant connect to the MDB. I tried the same with two ejb projects and it is working just fine.