2014-01-06 115 views
1
在jboss.After

我已經成功地配置JMS隊列配置我有下面的JBoss控制檯消息這樣如何解決此錯誤?

[org.jboss.bootstrap.impl.base.server.AbstractServer] JBossAS [6.0.0.Final "Neo"] Started in 1m:2s:271ms 
[org.hornetq.ra.inflow.HornetQActivation] Attempting to reconnect org.hornetq.ra.inflow.HornetQActivationSpec([email protected] destination=queue/MyQueue destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=null maxSession=15) 
INFO [org.hornetq.ra.inflow.HornetQActivation] Reconnected with HornetQ 

後,我已經運行樣本客戶機程序使用以下代碼來發送消息到隊列

import javax.jms.JMSException; 
import javax.jms.ObjectMessage; 
import javax.jms.Queue; 
import javax.jms.QueueConnection; 
import javax.jms.QueueConnectionFactory; 
import javax.jms.QueueSender; 
import javax.jms.QueueSession; 
import javax.jms.TextMessage; 
import javax.naming.Context; 
import javax.naming.NamingException; 
import com.theopentutorials.mdb.to.Employee; 
import com.theopentutorials.utility.ClientUtility; 

    public class QueueSenderDemo{ 
     private static final String QUEUE_LOOKUP = "queue/MyQueue"; 
     private static final String CONNECTION_FACTORY = "ConnectionFactory"; 

     public static void main(String[] args) { 
      sendMessageToQueue(); 
      sendObjectMessageToQueue(); 
     } 

     public static void sendMessageToQueue() { 
      try { 
       Context context = ClientUtility.getInitialContextForClient(); 
       QueueConnectionFactory factory = (QueueConnectionFactory) context 
         .lookup(CONNECTION_FACTORY); 
       QueueConnection connection = factory.createQueueConnection(); 
       QueueSession session = connection.createQueueSession(false, 
         QueueSession.AUTO_ACKNOWLEDGE); 
       Queue queue = (Queue) context.lookup(QUEUE_LOOKUP); 

       QueueSender sender = session.createSender(queue); 
       TextMessage message = session.createTextMessage(); 
       message.setText("Welcome to EJB3"); 
       sender.send(message); 
       session.close(); 
      } catch (NamingException e) { 
       e.printStackTrace(); 
      } catch (JMSException e) { 
       e.printStackTrace(); 
      } 
     } 

     public static void sendObjectMessageToQueue() { 
      try { 
       Context context = ClientUtility.getInitialContextForClient(); 
       QueueConnectionFactory factory = (QueueConnectionFactory) context 
         .lookup(CONNECTION_FACTORY); 
       QueueConnection connection = factory.createQueueConnection(); 
       QueueSession session = connection.createQueueSession(false, 
         QueueSession.AUTO_ACKNOWLEDGE); 
       Queue queue = (Queue) context.lookup(QUEUE_LOOKUP); 

       QueueSender sender = session.createSender(queue); 
       ObjectMessage message = session.createObjectMessage(); 
       Employee emp = new Employee(); 
       emp.setDesignation("Developer"); 
       emp.setSalary(25000); 
       emp.setName("ABC"); 
       emp.setId(1); 
       message.setObject(emp); 
       sender.send(message); 
       session.close(); 
      } catch (Exception e) { 
       e.printStackTrace(); 
      } /*catch (JMSException e) { 
       e.printStackTrace(); 
      }*/ 
     } 
    } 

最後我有以下錯誤消息

javax.naming.NamingException: Could not dereference object [Root exception is java.io.InvalidClassException: org.hornetq.core.client.impl.ClientSessionFactoryImpl; org.hornetq.core.client.impl.ClientSessionFactoryImpl; class invalid for deserialization] 
    at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1135) 
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:690) 
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572) 
    at javax.naming.InitialContext.lookup(InitialContext.java:392) 
    at com.theopentutorials.client.QueueSenderDemo.sendMessageToQueue(QueueSenderDemo.java:33) 
    at com.theopentutorials.client.QueueSenderDemo.main(QueueSenderDemo.java:25) 
Caused by: java.io.InvalidClassException: org.hornetq.core.client.impl.ClientSessionFactoryImpl; org.hornetq.core.client.impl.ClientSessionFactoryImpl; class invalid for deserialization 
    at java.io.ObjectStreamClass.checkDeserialize(ObjectStreamClass.java:713) 
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732) 
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328) 
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946) 
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870) 
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752) 
    at java.io.Objpackage com.theopentutorials.client;ectInputStream.readObject0(ObjectInputStream.java:1328) 
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350) 
    at org.hornetq.jms.referenceable.SerializableObjectRefAddr.deserialize(SerializableObjectRefAddr.java:79) 
    at org.hornetq.jms.referenceable.ConnectionFactoryObjectFactory.getObjectInstance(ConnectionFactoryObjectFactory.java:43) 
    at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304) 
    at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1110) 
    at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1127) 
    ... 5 more 
Caused by: java.io.InvalidClassException: org.hornetq.core.client.impl.ClientSessionFactoryImpl; class invalid for deserialization 
    at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:587) 
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1582) 
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495) 
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731) 
    ... 16 more 
javax.naming.NamingException: Could not dereference object [Root exception is java.io.InvalidClassException: org.hornetq.core.client.impl.ClientSessionFactoryImpl; org.hornetq.core.client.impl.ClientSessionFactoryImpl; class invalid for deserialization] 
    at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1135) 
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:690) 
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572) 
    at javax.naming.InitialContext.lookup(InitialContext.java:392) 
    at com.theopentutorials.client.QueueSenderDemo.sendObjectMessageToQueue(QueueSenderDemo.java:55) 
    at com.theopentutorials.client.QueueSenderDemo.main(QueueSenderDemo.java:26) 
Caused by: java.io.InvalidClassException: org.hornetq.core.client.impl.ClientSessionFactoryImpl; org.hornetq.core.client.impl.ClientSessionFactoryImpl; class invalid for deserialization 
    at java.io.ObjectStreamClass.checkDeserialize(ObjectStreamClass.java:713) 
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732) 
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328) 
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946) 
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870) 
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752) 
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328) 
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350) 
    at org.hornetq.jms.referenceable.SerializableObjectRefAddr.deserialize(SerializableObjectRefAddr.java:79) 
    at org.hornetq.jms.referenceable.ConnectionFactoryObjectFactory.getObjectInstance(ConnectionFactoryObjectFactory.java:43) 
    at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304) 
    at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1110) 
    at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1127) 
    ... 5 more 
Caused by: java.io.InvalidClassException: org.hornetq.core.client.impl.ClientSessionFactoryImpl; class invalid for deserialization 
    at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:587) 
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1582) 
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495) 
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731) 
    ... 16 more 

我已經包含下面的類路徑012 jar文件jbossall-client.jar,hornetq-bootsrap.jar,hotnetq-jms.jar,hornetq-logging.jar,netty.jar,hornetq-common-client.jar,hornetq-jboss-as-integration.jar,jboss- as-hornetq-int.jar,hornetq-core.jar

請幫幫我。我已經在過去兩天嘗試過了。

+0

No.not that.tried使用jboss的示例jms應用程序 – Ami

回答

0

最後我已經解決了這個error.I已經使用JBoss的6.x.So它在的JBoss/common/lib下 folder.I已包含在類路徑不同的JAR文件自身HornetQ的配置和相應的jar文件。 因此,要麼使用任何一個jar文件。它應該解決以上錯誤。