开发者

Exception null while trying to set the value jms/Topic

i'm on this problem since a very long time and I really can't understand where the problem come, maybe you can help me.开发者_JAVA百科

I'm creating a J2EE web application using JMS topics for async messages. The problem is that when retrieving my Topic with a lookup on the InitialContext, my topic is always set as null and this exceptions is thrown :

    ATTENTION: RAR7096: Exception null while trying to set the value jms/Topic on property Name 
GRAVE: enterprise_naming.serialctx_communication_exception
GRAVE: com.sun.appserv.connectors.internal.api.PoolingException
        at com.sun.enterprise.resource.beans.AdministeredObjectResource.createAdministeredObject(AdministeredObjectResource.java:199)
        at com.sun.enterprise.resource.naming.AdministeredObjectFactory.getObjectInstance(AdministeredObjectFactory.java:128)
        at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
        at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:472)
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:437)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at org.apache.jsp.index_jsp.jspInit(index_jsp.java from :36)
        at org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:90)
        at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:208)
        at org.apache.jasper.servlet.JspServletWrapper.getDependants(JspServletWrapper.java:317)
        at org.apache.jasper.compiler.Compiler.isOutDated(Compiler.java:615)
        at org.apache.jasper.compiler.Compiler.isOutDated(Compiler.java:483)
        at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:618)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:483)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:373)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
        at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
        at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
        at java.lang.Thread.run(Thread.java:680)
Caused by: java.security.PrivilegedActionException: com.sun.appserv.connectors.internal.api.ConnectorRuntimeException
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.enterprise.resource.beans.AdministeredObjectResource.createAdministeredObject(AdministeredObjectResource.java:176)
        ... 41 more
Caused by: com.sun.appserv.connectors.internal.api.ConnectorRuntimeException
        at com.sun.enterprise.connectors.util.SetMethodAction.handleException(SetMethodAction.java:140)
        at com.sun.enterprise.connectors.util.SetMethodAction.run(SetMethodAction.java:126)
        ... 43 more
Caused by: java.lang.reflect.InvocationTargetException
        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.connectors.util.SetMethodAction.run(SetMethodAction.java:99)
        ... 43 more
Caused by: java.lang.IllegalArgumentException: MQ:Topic:Invalid Topic Name - jms/Topic
        at com.sun.messaging.Topic.setName(Topic.java:90)
        ... 48 more

Here is my code, the problematic line is "topic = (Topic) ic.lookup("jms/Topic");"

<%!
@Resource(mappedName = "jms/ConnectionFactory")
ConnectionFactory connectionFactory;
@Resource(mappedName = "jms/Topic")
Topic topic;
Connection connection = null;
Session jmsSession = null;
MessageProducer messageProducer = null;

public void jspInit() {
    try {
        InitialContext ic = new InitialContext();
        connectionFactory = (ConnectionFactory) ic.lookup("jms/ConnectionFactory");
        topic = (Topic) ic.lookup("jms/Topic");
        connection = connectionFactory.createConnection();
        jmsSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        messageProducer = jmsSession.createProducer(topic);
        connection.start();
    } catch (Exception e) {
        System.out.println("Couldn't create nsl : " + e.getMessage());
    }
}

I hope you can help me to figure out what is wrong in this file !

Thanks !

EDIT : Server ressources

Exception null while trying to set the value jms/Topic


Don't use slash character in physical destination, "jms/Topic" is erroneous for Glassfish.

ATTENTION:
RAR7096:
Exception null while trying to set the value jms/Topic on property Name

The "Name" property referred here is the "Physical Destination Name". Glassfish has strict naming convention for that field. In the screenshot, that is "Nom de la destination physique". Try updating it to "jmsTopic" and see how it turns out.

PS: I know this is an old question, but someone else may run into this. Hope it helps.

Link to similar problem: https://developer.jboss.org/thread/205474


Several things:

  • you inject the Connectionfactory and the Topic, and then you also try to look them up. I see you use a Glassfish server, which is at least JEE5, so lookups should not be needed. Now, if the injections don't get picked up, that might be related to my second point.
  • why on earth do you do all of this in a JSP? That kind of code should go (at least) into a servlet.

I can guarantee you that @Resource injections in servlets get picked up correctly, drop that Initialcontext stuff. And move your code to a servlet :-)

Other thing: you might want to check in the server if the Factory and the Topic exist... If they don't you can either create them manually, or add them to your project for creation on deployment, although personally I don't like the latter.

In Glassfish 2 at least the JMS resources are listed and defined in the server console via Resources, JMS resources, Destination resources.

EDIT: check out this article, it mentions exactly the same error, and in that case it was linked to an entry in sun-ejb-jar.xml - the place where project-defined resources live. Might be a good idea to check your sun-ejb-jar.xml deployment descriptor

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜