[jboss-user] [JBoss Messaging] - Exception by getting a reference to the ConnectionFactory

BjoernWilken do-not-reply at jboss.com
Wed Nov 29 09:51:54 EST 2006


Dear JBoss-Comunity!

The Problem:
I wrote a simple Message Driven Bean and want to send her a Message!
The client program, which should send the message gets always the following Exception:

javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: org.jboss.jms.client.JBossConnectionFactory (no security manager: RMI class loader disabled)]
	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:728)
	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
	at javax.naming.InitialContext.lookup(Unknown Source)
	at Client.main(Client.java:47)
Caused by: java.lang.ClassNotFoundException: org.jboss.jms.client.JBossConnectionFactory (no security manager: RMI class loader disabled)
	at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
	at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
	at java.rmi.server.RMIClassLoader$2.loadClass(Unknown Source)
	at java.rmi.server.RMIClassLoader.loadClass(Unknown Source)
	at sun.rmi.server.MarshalInputStream.resolveClass(Unknown Source)
	at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
	at java.io.ObjectInputStream.readClassDesc(Unknown Source)
	at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
	at java.io.ObjectInputStream.readObject0(Unknown Source)
	at java.io.ObjectInputStream.readObject(Unknown Source)
	at java.rmi.MarshalledObject.get(Unknown Source)
	at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:72)
	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:652)
	... 3 more

My configuration:
I use JBoss AS 4.0.4 and installed the JBoss Messaging plugin (Version 1.0.1 GA)

The Deployment:
The MDB is correct deployed by JBoss (i use a JAR file which contains the bean).

I tried a lof of things, but nothing helped:
- Tried to use a SecurityManager
- Tried to use an ear file with the following jboss-app.xml file:

<jboss-app>
<loader-repository>
  jboss.messaging:loader=ScopedLoaderRepository <loader-repository-config>java2ParentDelegation=false</loader-repository-config> 
  </loader-repository>
</jboss-app>

The Code for the Message Driven Bean looks like:
import javax.jms.Message;
  | import javax.ejb.ActivationConfigProperty;
  | import javax.ejb.MessageDriven;
  | import javax.annotation.*;
  | import javax.jms.*;
  | 
  | @MessageDriven(
  | 		activationConfig = {
  | 					@ActivationConfigProperty(propertyName  = "destinationType",
  | 											  propertyValue = "javax.jms.Topic"),
  | 					@ActivationConfigProperty(propertyName  = "destination",
  | 					        					propertyValue = "testTopic"),
  | 					@ActivationConfigProperty(propertyName  = "acknowledgeMode",
  | 											  propertyValue = "Auto-acknowledge")
  | 											  
  | 			   }
  | )
  | public class LogBean implements MessageListener 
  | {
  | 	/*
  | 	@Resource(mappedName="ConnectionFactory")
  | 	private ConnectionFactory connectionFactory;
  | 	*/
  | 	
  | 	public LogBean()
  | 	{
  | 		System.out.println("LogBean created ...");
  | 	}
  | 	
  | 	public void onMessage(Message msg) {
  | 		if (msg instanceof TextMessage)
  | 		{
  | 			TextMessage tm = (TextMessage)msg;
  | 			try
  | 			{
  | 				String text = tm.getText();
  | 				System.out.println("Received new message: " + text);
  | 				
  | 			}
  | 			catch (JMSException e)
  | 			{
  | 				e.printStackTrace();
  | 			}								
  | 		}
  | 	}
  | 
  | 	@PreDestroy
  | 	public void remove()
  | 	{
  | 		System.out.println("LogBean destroyed!");
  | 	}
  | }
  | 

The Code for the Client looks like:


  | import java.rmi.RMISecurityManager;
  | import java.util.Properties;
  | 
  | import javax.annotation.*;
  | import javax.jms.Topic;
  | import javax.jms.ConnectionFactory;
  | import javax.jms.Connection;
  | import javax.jms.MessageProducer;
  | import javax.jms.Session;
  | import javax.jms.TextMessage;
  | import javax.jms.JMSException;
  | import javax.jms.TopicConnectionFactory;
  | import javax.naming.Context;
  | import javax.naming.InitialContext;
  | 
  | public class Client 
  | {
  | 	@Resource(mappedName = "testTopic")
  | 	private static Topic topic;
  | 
  | 	public static void main(String args[])
  | 	{
  |         Connection connection = null;
  |         Session session = null;
  |         MessageProducer messageProducer = null;
  |         TextMessage message = null;
  |         final int NUM_MSGS = 3;
  |                
  |         try
  | 		{		
  |         	InitialContext ctx = new InitialContext();
  |         	if (ctx == null)
  |         	{
  |         		System.out.println("Kein gültiger Kontext!");
  |         		System.exit(1);
  |         	} else
  |         	{
  |         		System.out.println("Kontext gefunden (" + ctx.toString() + ")!");        		
  |         	}
  |         	TopicConnectionFactory factory = (TopicConnectionFactory)ctx.lookup("/ConnectionFactory");  
  |         	
  | 	        // Connection factory benutzen, um eine JMS Connection zu erzeugen
  | 			connection = factory.createConnection();
  | 			
  | 			// Connection benutzen, um eine Session zu erzeugen
  | 			session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
  | 			
  | 			// Sender für einen Topic erzeugen
  | 			messageProducer = session.createProducer(topic);
  | 			
  | 			// Nachricht, die gesendet werden soll erzeugen
  | 			message = session.createTextMessage();
  | 			
  |             for (int i = 0; i < NUM_MSGS; i++) 
  |             {
  |                 message.setText("This is message " + (i + 1));
  |                 System.out.println("Sending message: " + message.getText());
  |                 messageProducer.send(message);
  |             }
  | 		}
  | 		catch (Exception e)
  | 		{
  | 			e.printStackTrace();
  | 		}
  | 		finally 
  | 		{
  | 			if (connection != null)
  | 			{
  | 				try
  | 				{
  | 					connection.close();
  | 				}
  | 				catch (JMSException e)
  | 				{		
  | 				}
  | 			}
  | 		} // finally
  | 	} // main
  | } // class
  | 

Need urgent help, because i need this bean to work ahaed on my current project @work.

Thank you very much!

Best regards
Björn Wilken

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3989717#3989717

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3989717




More information about the jboss-user mailing list