activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gerdes, Mike" <Mike.Ger...@airbus.com>
Subject AW: jaas
Date Fri, 24 Mar 2006 14:04:12 GMT

Ok I have managed to reproduce the problem on another fresh installed ServiceMix installation
as well as with a fresh installed activemq. My AMQ config file looks like this:

<beans xmlns="http://activemq.org/config/1.0">
	<broker useJmx="false" persistent="false" brokerName="Poller">

		<plugins>
		      <jaasAuthenticationPlugin configuration="activemq-domain" />
	      	<authorizationPlugin>
				<map>
					<authorizationMap>
            				<authorizationEntries>
              					<authorizationEntry queue=">" read="admins" write="admins" admin="admins"
/>
              					<authorizationEntry topic=">" read="admins" write="admins" admin="admins"
/>
            				</authorizationEntries>
          				</authorizationMap>
	        		</map>
      		</authorizationPlugin>
 	   	</plugins>

    		<transportConnectors>
       		<transportConnector name="pollertransport" uri="ssl://localhost:61616?trace=true"
discoveryUri="multicast://default"/>
    		</transportConnectors>
   
		<networkConnectors>
			<networkConnector name="pollernetwork" uri="multicast://default"/>
		</networkConnectors>
	</broker>
</beans>

And I use a Jms message sender to produce messages. The error does not happen everytime I
use the jms sender, but everytime I use SM.

The error is produced in this file:

MessageConsumer advisoryConsumer=broadcastSession.createConsumer(advisoryTopic);

Is there some error in my code or is there an error in the AMQ code?

Now the whole message-sender code I hope it is just my error.




/*
 * Created on 23.02.2006
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package test.jmstopic.sender;
import java.util.Date;

import javax.jms.Connection;
import javax.jms.DeliveryMode;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.Topic;
import javax.jms.TopicConnection;
import javax.jms.TopicSession;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.advisory.AdvisorySupport;
import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.command.ActiveMQTopic;

import test.jmstopic.Constants;

/**
 * @author TH89V6
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class MessageSender {

	MessageProducer producer;

	Connection connection;
	Session session;
    private String broadcastDestinationName = "org.apache.servicemix.JMSFlow";

	public MessageSender(String destTopic) {
    	System.setProperty("javax.net.ssl.trustStore", new String(Constants.TRUSTSTORE1));
    	System.setProperty("javax.net.ssl.trustStorePassword", new String(Constants.TRUSTSTORE1PASS));
		ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(Constants.TRANSPORT+"://"+Constants.HOST+":"+Constants.PORT);
		
		ActiveMQTopic pubTopic = new ActiveMQTopic(destTopic);
        try {
        	System.out.println("Connecting to JMS server.");
        	connection = factory.createConnection("admin", "admin");
        	connection.setClientID("client2");
        	session = connection.createSession(false, TopicSession.AUTO_ACKNOWLEDGE);
        	producer = session.createProducer(pubTopic);
        }
        catch (JMSException e) {
        	System.out.println(e);
        }
	}

	public void start(int count) {
		try {
        	connection.start();
            System.out.println("Start Sending Messages");
            System.out.println(new Date());
            Message m = createTextMessage(1000);
            m = createTextMessage();
            for (int i=0; i<count; i++) {
            	producer.send(m);
            }
            System.out.println(new Date()); 
            System.out.println("Stop Sending Messages");
           
           
            Session broadcastSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            Topic broadcastTopic = broadcastSession.createTopic(broadcastDestinationName);
            MessageProducer topicProducer = broadcastSession.createProducer(broadcastTopic);
            topicProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
		MessageConsumer broadcastConsumer = broadcastSession.createConsumer(broadcastTopic, null,
true);
            broadcastConsumer.setMessageListener(null);
 		Topic advisoryTopic=AdvisorySupport.getConsumerAdvisoryTopic((ActiveMQDestination) broadcastTopic);

		System.out.println("Error comes next");
		System.in.read();
           
		MessageConsumer advisoryConsumer=broadcastSession.createConsumer(advisoryTopic);
           
            System.out.println("After error");
           
            advisoryConsumer.setMessageListener(null);
           
           
           
        }
		catch (Exception e) {
			System.out.println(e);
		}
	}
	
	public void close() {
		try {	producer.close();
				System.out.println("Producer closed"); }
		catch (Exception e) { System.out.println(e); }
		try { 	session.close();
				System.out.println("Session closed"); }
		catch (Exception e) { System.out.println(e); }
		try {	connection.close();
				System.out.println("Connection closed"); }
		catch (Exception e) { System.out.println(e); }
	}


	public Message createTextMessage(int bodysize) throws JMSException{
		int bsize = bodysize - 19;
	    if (bsize < 0) {
	    	bsize = 0;
	    }
	    if (bsize > 10000) {
	    	bsize = 10000;
	    }
	    String body ="<message>";
	    for (int i = 0; i<bsize; i++) {
	    	body += "X";
	    }
	    body += "</message>";
	    return session.createTextMessage(body);
    }	
	public Message createTextMessage() throws JMSException{
	    String body ="<message>";
	    body += "<from>test@localhost</from>";
	    body += "<to>test@localhost</to>";
	    body += "<subject>subject</subject>";
	    body += "<text>text</text>";	   
	    body += "</message>";
	    return session.createTextMessage(body);
    }	
   
}

-----Ursprüngliche Nachricht-----
Von: Gerdes, Mike
Gesendet: Freitag, 24. März 2006 11:14
An: activemq-users@geronimo.apache.org
Betreff: AW: jaas




ok forget my last email, that was jsut because I changed the order of the <plugin> and
the <transportConnector> and the <networkConnector>. If the <plugin> tag
is behind the connectors then it is possible to connect to the Broker without any JAAS authentication.

So the error is still present and preventing me from using JAAS

-----Ursprüngliche Nachricht-----
Von: Gerdes, Mike

Gesendet: Freitag, 24. März 2006 11:00
An: activemq-users@geronimo.apache.org
Betreff: AW: jaas




I think I found the solution myself, I used activemq-core and activemq-ra and activemq-jaas.
When I use the complete activemq jar file I don't get the error anymore.

-----Ursprüngliche Nachricht-----
Von: Gerdes, Mike

Gesendet: Freitag, 24. März 2006 10:39
An: activemq-users@geronimo.apache.org
Betreff: jaas




hi,

have somebody else encountered this strange error when using jaas?
Everything else seems to work fine and I get no username or password errors, just this classcastexception.
I am using ActiveMQ-4.0-SNAPSHOT togather with activemq-jaas-4.0-SNAPSHOT, but I also get
the error with activemq-jaas-4.0-M3


Exception in thread "ActiveMQ Task" java.lang.ClassCastException: org.apache.act
ivemq.security.AuthorizationBroker$1
        at org.apache.activemq.openwire.v1.ConsumerInfoMarshaller.tightMarshal1(
ConsumerInfoMarshaller.java:116)
        at org.apache.activemq.openwire.OpenWireFormat.tightMarshalNestedObject1
(OpenWireFormat.java:378)
        at org.apache.activemq.openwire.v1.BaseDataStreamMarshaller.tightMarshal
NestedObject1(BaseDataStreamMarshaller.java:120)
        at org.apache.activemq.openwire.v1.MessageMarshaller.tightMarshal1(Messa
geMarshaller.java:123)
        at org.apache.activemq.openwire.v1.ActiveMQMessageMarshaller.tightMarsha
l1(ActiveMQMessageMarshaller.java:75)
        at org.apache.activemq.openwire.OpenWireFormat.tightMarshalNestedObject1
(OpenWireFormat.java:378)
        at org.apache.activemq.openwire.v1.BaseDataStreamMarshaller.tightMarshal
NestedObject1(BaseDataStreamMarshaller.java:120)
        at org.apache.activemq.openwire.v1.MessageDispatchMarshaller.tightMarsha
l1(MessageDispatchMarshaller.java:86)
        at org.apache.activemq.openwire.OpenWireFormat.marshal(OpenWireFormat.ja
va:148)
        at org.activeio.command.AsyncChannelToAsyncCommandChannel.writeCommand(A
syncChannelToAsyncCommandChannel.java:41)
        at org.apache.activemq.transport.activeio.ActiveIOTransport.oneway(Activ
eIOTransport.java:95)
        at org.apache.activemq.transport.TransportLogger.oneway(TransportLogger.
java:51)
        at org.apache.activemq.transport.InactivityMonitor.oneway(InactivityMoni
tor.java:141)
        at org.apache.activemq.transport.TransportFilter.oneway(TransportFilter.
java:86)
        at org.apache.activemq.transport.WireFormatNegotiator.oneway(WireFormatN
egotiator.java:77)
        at org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.ja
va:44)
        at org.apache.activemq.transport.ResponseCorrelator.oneway(ResponseCorre
lator.java:55)
        at org.apache.activemq.broker.TransportConnection.dispatch(TransportConn
ection.java:211)
        at org.apache.activemq.broker.AbstractConnection.processDispatch(Abstrac
tConnection.java:568)
        at org.apache.activemq.broker.AbstractConnection.iterate(AbstractConnect
ion.java:584)
        at org.apache.activemq.thread.SimpleTaskRunner.runTask(SimpleTaskRunner.
java:110)
        at org.apache.activemq.thread.SimpleTaskRunner.access$100(SimpleTaskRunn
er.java:25)
        at org.apache.activemq.thread.SimpleTaskRunner$1.run(SimpleTaskRunner.ja
va:43)
        at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Wor
ker.runTask(ThreadPoolExecutor.java:650)
        at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Wor
ker.run(ThreadPoolExecutor.java:675)
        at java.lang.Thread.run(Thread.java:595)

This mail has originated outside your organization, either from an external partner or the
Global Internet. Keep this in mind if you answer this message.



This mail has originated outside your organization,
either from an external partner or the Global Internet.
Keep this in mind if you answer this message.

This mail has originated outside your organization, either from an external partner or the
Global Internet. Keep this in mind if you answer this message.



This mail has originated outside your organization,
either from an external partner or the Global Internet.
Keep this in mind if you answer this message.

This mail has originated outside your organization, either from an external partner or the
Global Internet. Keep this in mind if you answer this message.



This mail has originated outside your organization,
either from an external partner or the Global Internet.
Keep this in mind if you answer this message.

This mail has originated outside your organization, either from an external partner or the
Global Internet. Keep this in mind if you answer this message.

Mime
View raw message