JBOSS 下部署MDB???

06-07-12 ningjiao
在JBOSS 下部署MDB,当JBOSS服务器已启动,而且把已经打包好jar文件部署到deploy的时候,服务器中出现:

Info:Class not found on "connect.logBean":No ClassLoaders

for:connect.logBean

这倒是什么原因呢

banq
2006-07-15 08:40
MDB是EJB一种,另外,需要配置容器和JNDI

ningjiao
2006-07-17 16:07
但是,我在部署无状态会话Bean时,只要把打包好的jar文件,放在deploy下,在运行客户端就可以看到所要输出的字符串了

bang大哥,请帮我看一下是哪里错了,先谢了

这是logBean:

package log;

import javax.ejb.*;

import javax.jms.*;

public class logBean implements MessageDrivenBean, MessageListener {

protected MessageDrivenContext ctx;

public void setMessageDrivenContext(MessageDrivenContext ctx) {

this.ctx = ctx;

}

public void ejbCreate() {

System.err.println("ejbCreate()");

}

public void onMessage(Message msg) {

TextMessage tm = (TextMessage) msg;

try {

String text = tm.getText();

System.err.println("Received new message : " + text);

}

catch(JMSException e) {

e.printStackTrace();

}

}

public void ejbRemove() {

System.err.println("ejbRemove()");

}

}

这是一客户端:

package log;

import javax.naming.*;

import javax.jms.*;

import java.util.*;

public class logClient {

public static void main (String[] args) throws Exception {

Properties props =new Properties();

props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");

props.put(Context.PROVIDER_URL,"192.168.0.163:1099");

Context iniCtx = new InitialContext( props);

Object tmp = iniCtx.lookup("jms/TopicConnectionFactory");

TopicConnectionFactory factory = (TopicConnectionFactory) tmp;

TopicConnection connection = factory.createTopicConnection();

TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);

Topic topic = (Topic) iniCtx.lookup("jms/Topic");

TopicPublisher publisher = session.createPublisher(topic);

TextMessage msg = session.createTextMessage();

msg.setText("This is a test message.");

publisher.publish(msg);

System.out.println ("Message published to jms/Topic. Please check application server's console to see the response from MDB.");

}

}

还有ejb-jar.xml

<?xml version="1.0" encoding="UTF-8" ?>

<!-- Copyright 2004 Sun Microsystems, Inc. All rights reserved.

SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.

-->

<ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee" version="2.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">

<display-name>log</display-name>

<enterprise-beans>

<message-driven>

<ejb-name>log</ejb-name>

<ejb-class>log.logBean</ejb-class>

<messaging-type>javax.jms.MessageListener</messaging-type>

<transaction-type>Bean</transaction-type>

<message-destination-type>javax.jms.Topic</message-destination-type>

<message-destination-link>PhysicalTopic</message-destination-link>

</message-driven>

</enterprise-beans>

<assembly-descriptor>

<message-destination>

<message-destination-name>PhysicalTopic</message-destination-name>

</message-destination>

</assembly-descriptor>

</ejb-jar>

这是jboss.xml

<?xml version="1.0" encoding="ISO-8859-1" ?>

<jboss>

<enterprise-beans>

<session>

<ejb-name>log</ejb-name>

<jndi-name>log</jndi-name>

<message-driven>

<configuration-name>Standard Message Driven Bean</configuration-name>

<destination-jndi-name>jms/Topic</destination-jndi-name>

</message-driven>

</session>

<secure>true</secure>

</enterprise-beans>

<resource-managers />

</jboss>

我觉得没有什么问题呀,但jboss总是no ClassLoaders found for:log.logBean

ningjiao
2006-07-17 16:08
但是,我在部署无状态会话Bean时,只要把打包好的jar文件,放在deploy下,在运行客户端就可以看到所要输出的字符串了

bang大哥,请帮我看一下是哪里错了,先谢了

这是logBean:

package log;

import javax.ejb.*;

import javax.jms.*;

public class logBean implements MessageDrivenBean, MessageListener {

protected MessageDrivenContext ctx;

public void setMessageDrivenContext(MessageDrivenContext ctx) {

this.ctx = ctx;

}

public void ejbCreate() {

System.err.println("ejbCreate()");

}

public void onMessage(Message msg) {

TextMessage tm = (TextMessage) msg;

try {

String text = tm.getText();

System.err.println("Received new message : " + text);

}

catch(JMSException e) {

e.printStackTrace();

}

}

public void ejbRemove() {

System.err.println("ejbRemove()");

}

}

这是一客户端:

package log;

import javax.naming.*;

import javax.jms.*;

import java.util.*;

public class logClient {

public static void main (String[] args) throws Exception {

Properties props =new Properties();

props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");

props.put(Context.PROVIDER_URL,"192.168.0.163:1099");

Context iniCtx = new InitialContext( props);

Object tmp = iniCtx.lookup("jms/TopicConnectionFactory");

TopicConnectionFactory factory = (TopicConnectionFactory) tmp;

TopicConnection connection = factory.createTopicConnection();

TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);

Topic topic = (Topic) iniCtx.lookup("jms/Topic");

TopicPublisher publisher = session.createPublisher(topic);

TextMessage msg = session.createTextMessage();

msg.setText("This is a test message.");

publisher.publish(msg);

System.out.println ("Message published to jms/Topic. Please check application server's console to see the response from MDB.");

}

}

还有ejb-jar.xml

<?xml version="1.0" encoding="UTF-8" ?>

<!-- Copyright 2004 Sun Microsystems, Inc. All rights reserved.

SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.

-->

<ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee" version="2.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">

<display-name>log</display-name>

<enterprise-beans>

<message-driven>

<ejb-name>log</ejb-name>

<ejb-class>log.logBean</ejb-class>

<messaging-type>javax.jms.MessageListener</messaging-type>

<transaction-type>Bean</transaction-type>

<message-destination-type>javax.jms.Topic</message-destination-type>

<message-destination-link>PhysicalTopic</message-destination-link>

</message-driven>

</enterprise-beans>

<assembly-descriptor>

<message-destination>

<message-destination-name>PhysicalTopic</message-destination-name>

</message-destination>

</assembly-descriptor>

</ejb-jar>

这是jboss.xml

<?xml version="1.0" encoding="ISO-8859-1" ?>

<jboss>

<enterprise-beans>

<session>

<ejb-name>log</ejb-name>

<jndi-name>log</jndi-name>

<message-driven>

<configuration-name>Standard Message Driven Bean</configuration-name>

<destination-jndi-name>jms/Topic</destination-jndi-name>

</message-driven>

</session>

<secure>true</secure>

</enterprise-beans>

<resource-managers />

</jboss>

我觉得没有什么问题呀,但jboss总是no ClassLoaders found for:log.logBean

猜你喜欢