开发者

OpenJMS: context creation fails with InvalideClassException

开发者 https://www.devze.com 2023-03-07 03:41 出处:网络
I am using OpenJMS with NetBeans 6.9.1. I have created a simple NetBeans Platform Application and a module inside it. I have started my openjms-0.7.7-beta using its startup.bat file. Now in the module

I am using OpenJMS with NetBeans 6.9.1. I have created a simple NetBeans Platform Application and a module inside it. I have started my openjms-0.7.7-beta using its startup.bat file. Now in the module the following code exec开发者_运维问答utes to start listening for messages on a topic.

      factoryName = "ConnectionFactory";
      String topicName = "topic1";
      String initialContext = "org.exolab.jms.jndi.InitialContextFactory";
      String providerURL = "tcp://localhost:3035/";

        Hashtable properties = new Hashtable();
        properties.put(Context.INITIAL_CONTEXT_FACTORY, initialContext);
        properties.put(Context.PROVIDER_URL, providerURL);
        context = new InitialContext(properties);
        factory = (ConnectionFactory) context.lookup(factoryName);
        dest = (Destination) context.lookup(topicName);
        connection = factory.createConnection();
        session = connection.createSession(false,  Session.AUTO_ACKNOWLEDGE);
        receiver = session.createConsumer(dest);
        receiver.setMessageListener(this);
        connection.start();

The code worked perfectly in a simple java application but in this configuration it fails on the line;

                    context = new InitialContext(properties);

Here is the Exeception

    javax.naming.CommunicationException: Failed to lookup JNDI provider for URL: tcp://localhost:3035/ [Root exception is java.rmi.UnmarshalException: Failed to unmarshal response; nested exception is: 
    java.io.InvalidClassException: org.exolab.jms.server.net.RemoteNamingProvider__Proxy; local class incompatible: stream classdesc serialVersionUID = 8042785765194780386, local class serialVersionUID = 3384686210958076383]
    at org.exolab.jms.jndi.InitialContextFactory.getInitialContext(InitialContextFactory.java:160)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
    at javax.naming.InitialContext.init(InitialContext.java:223)
    at javax.naming.InitialContext.<init>(InitialContext.java:197)

It appears to me that this client code sends an object of class "org.exolab.jms.server.net.RemoteNamingProvider__Proxy" to the openJMS server. The class is located in same JAR file used by both the code and openJMS server. For some strange reason, however, compiler the class is having different serial ID on the server side.

I searched the internet for clues. Serial ids of a class can be different if we use different compilers. I don't know if openJMS server is using a compiler other than my Java SE compiler installed on my computer. However, I am sure that NetBeans is using it (Java SE compiler) for this client code compilation.

Secondly, I can't explicitly assign serial id to the exception causing class becuase it is in openJMS library and not my own class.

Any help will be appreciated.

-Hadaytullah

0

精彩评论

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