ejb3+jboss5.0 发送JMS消息,我写的客户端报ClassNotFound

代码如下:
[code="java"]
public static void main(String[] args) throws NamingException, JMSException {
Properties properties = new Properties();
properties.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
properties.setProperty("java.naming.provider.url", "localhost:1099");
properties.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");
InitialContext context = new InitialContext(properties);
QueueConnectionFactory factory = (QueueConnectionFactory) context.lookup("ConnectionFactory");
QueueConnection queueConnection = factory.createQueueConnection();
QueueSession queueSession = queueConnection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);

    Queue destination = (Queue) context.lookup("queue/MDBQueue");
    MessageProducer messageProducer = queueSession.createProducer(destination);
    TextMessage message = queueSession.createTextMessage("Hello,this is a queue");
    messageProducer.send(message);

    queueSession.close();
    queueConnection.close();

}

[/code]

异常是这样的:
Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/aop/advice/ClassifiedBindingCollection
at org.jboss.aop.AspectManager.(AspectManager.java:138)
at org.jboss.aop.AspectManager$1.run(AspectManager.java:286)
at org.jboss.aop.AspectManager$1.run(AspectManager.java:274)
at java.security.AccessController.doPrivileged(Native Method)
at org.jboss.aop.AspectManager.initManager(AspectManager.java:272)
at org.jboss.aop.AspectManager.instance(AspectManager.java:251)
at org.jboss.aop.AspectManager.instance(AspectManager.java:240)
at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate.(ClientConnectionFactoryDelegate.java)
at sun.misc.Unsafe.ensureClassInitialized(Native Method)
at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
at java.lang.reflect.Field.getLong(Field.java:528)
at java.io.ObjectStreamClass.getDeclaredSUID(ObjectStreamClass.java:1614)
at java.io.ObjectStreamClass.access$700(ObjectStreamClass.java:52)
at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:425)
at java.security.AccessController.doPrivileged(Native Method)
at java.io.ObjectStreamClass.(ObjectStreamClass.java:413)
at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:310)
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:547)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at java.rmi.MarshalledObject.get(MarshalledObject.java:142)
at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:72)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:712)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:629)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.javaeye.jashawn.ejbtest.MdbQueueClient.main(MdbQueueClient.java:31)
Caused by: java.lang.ClassNotFoundException: org.jboss.aop.advice.ClassifiedBindingCollection
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 36 more

一开始是另一个与AOP有关的异常,我到JBOSS网站上把JBOSS-AOP也下了下来,把里面lib文件夹下的包都拷到我的客户端程序的lib里,于是那个异常就解决了,可是新的异常又出现了,我找遍了Jar包,只看到一个ClassifiedBindingAndPointcutCollection的类,就是没看到一个ClassifiedBindingCollection的类,大家帮忙看一下这个异常的问题是什么?

2个回答

的确是你的版本问题!但是不是你的版本太低,而是你使用的版本要比你项目需要的版本要高。
你下了最新的版本吧,
最新版本号为:JBoss AOP - Version 2.0.0.GA(为JBoss AOP - Version 2.0.0.CR20之后的版本名),

而正如你说的:这版本的只有ClassifiedBindingAndPointcutCollection类。
因为从“JBoss AOP - Version 2.0.0.CR18”开始,将ClassifiedBindingCollection类改名为:ClassifiedBindingAndPointcutCollection。

官方发布文档详细说明换名的原因:
[quote]Move pointcuts and pointcutInfos into ClassifiedBindingCollection, and rename to ClassifiedBindingAndPointcutCollection [/quote]

那你的可能就是版本不对吧

jboss-aop@2.0.0.CR15以上吧

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐