Hi! I really need assistance from You; can You help me understand how to set
up connection factory in JBoss-2.2.1?:
I'm trying to get a simple Message Bean to work on JBoss-2.2.1. JDK1.3 is
used.
My client fails when it tries to lookup the connection factory; What must I
do to get the client to recieve a connection factory? Must the XML
config-files be updated with connection factory parameters?
----------------------------------------------------------------------------
-----
The message bean is like the simple "HelloWorld MDB" in the JBoss
documentation. The bean is OK deployed with this ejb-jar.xml:
<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise
JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
<ejb-jar>
<enterprise-beans>
<message-driven>
<ejb-name>MDB</ejb-name>
<ejb-class>test.bean.MDB</ejb-class>
<message-selector></message-selector>
<transaction-type>Container</transaction-type>
<message-driven-destination>
<destination-type>javax.jms.Topic</destination-type>
<subscription-durability>NonDurable</subscription-durability>
</message-driven-destination>
</message-driven>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>MDB</ejb-name>
<method-name>onMessage</method-name>
<method-params>
<method-param>javax.jms.Message</method-param>
</method-params>
</method>
<trans-attribute>Supports</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
----------------------------------------------------------------------------
-----
The Message Bean is deployed with this jboss.xml:
<?xml version="1.0" encoding="Cp1252"?>
<jboss>
<enterprise-beans>
<message-driven>
<ejb-name>MDB</ejb-name>
<configuration-name>Standard Message Driven
Bean</configuration-name>
<destination-jndi-name>topic/testTopic</destination-jndi-name>
</message-driven>
</enterprise-beans>
</jboss>
----------------------------------------------------------------------------
-----
I have this client that tries to send stuff to the message bean:
import javax.naming.*;
import javax.jms.*;
public class Main {
public static void main(String arg[]) {
try {
// Get access to JNDI
Context context = new InitialContext();
// Lookup the managed connection factory for a topic
TopicConnectionFactory topicFactory =
(TopicConnectionFactory)context.lookup("TOPIC_FACTORY"); //HOW DO I
REGISTER THIS CONNECTION FACTORY?
//Create a connection to the JMS provider
TopicConnection topicConnection =
topicFactory.createTopicConnection();
// Creat a topic session
TopicSession session = topicConnection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
// Lookup the destination you want to publish to
Topic topic = (Topic)context.lookup("topic/testTopic");
System.out.println("Topic set...");
// Create a publisher
TopicPublisher pub = session.createPublisher(topic);
// Create a message
TextMessage message = session.createTextMessage();
message.setText("Hello World!");
// Publish the message
pub.publish(topic, message);
// Close the stuff
session.close();
topicConnection.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
----------------------------------------------------------------------------
-----
Sets this CLASSPATH before running the client:
set
CLASSPATH=D:\JBoss-2.2.1\client\ejb.jar;D:\JBoss-2.2.1\client\ejb.jar;D:\JBo
ss-2.2.1\client\jnp-client.jar;D:\JBoss-2.2.1\client\jta-spec1_0_1.jar;D:\JB
oss-2.2.1\client\jbossmq-client.jar;.;D:\JBoss-2.2.1\lib\ext\jms.jar;
When the Main-client is run this ERROR appears:
javax.naming.NoInitialContextException: Need to specify class name in
environment or system property
, or as an applet parameter, or in an application resource file:
java.naming.factory.initial
at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:646)
at
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246)
at
javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:283)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at Main.main(Main.java:31)
----------------------------------------------------------------------------
-----
Best regards from
_________________
Cecilie Aulesjord
Developer
Locus AS
Leif Weldingsvei 6-8
P.O.Box 2087
N- 3202 Sandefjord
Norway
http://www.locus.no/
E-mail: [EMAIL PROTECTED]
Phone: +47 33 48 42 00
Direct: +47 33 48 42 15
Fax: +47 33 48 42 01
Mobile: +47 47 62 32 15
_________________
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user