2 Replies Latest reply on May 11, 2012 1:04 PM by rahatjaan

    How to connect to JBOSS AS7

    asdmonster

      I had try to develop a simple JMS program wich connect a JBOSS AS7 server ,which two were on the same machine:localhost.

       

      I start JBOSS using

      standalone

      I patch some entry into the default standalone.xml,the additional info is

       

      <extension module="org.jboss.as.messaging"/>

       

      <subsystem xmlns="urn:jboss:domain:messaging:1.0">

                  <persistence-enabled>

                      false

                  </persistence-enabled>

                  <journal-type>

                      NIO

                  </journal-type>

                  <journal-file-size>

                      102400

                  </journal-file-size>

                  <acceptors>

                      <netty-acceptor name="netty" socket-binding="messaging"/>

                      <netty-acceptor name="netty-throughput" socket-binding="messaging-throughput">

                          <param key="batch-delay" value="50"/>

                          <param key="direct-deliver" value="false"/>

                      </netty-acceptor>

                      <acceptor name="stomp-acceptor">

                          <factory-class>

                              org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory

                          </factory-class>

                          <param key="protocol" value="stomp"/>

                          <param key="port" value="61613"/>

                      </acceptor>

                      <in-vm-acceptor name="in-vm" server-id="0"/>

                  </acceptors>

                  <address-settings>

                      <address-setting match="#">

                          <dead-letter-address>

                              jms.queue.DLQ

                          </dead-letter-address>

                          <expiry-address>

                              jms.queue.ExpiryQueue

                          </expiry-address>

                          <redelivery-delay>

                              0

                          </redelivery-delay>

                          <max-size-bytes>

                              10485760

                          </max-size-bytes>

                          <message-counter-history-day-limit>

                              10

                          </message-counter-history-day-limit>

                          <address-full-policy>

                              BLOCK

                          </address-full-policy>

                      </address-setting>

                  </address-settings>

                  <connectors>

                      <netty-connector name="netty" socket-binding="messaging"/>

                      <netty-connector name="netty-throughput" socket-binding="messaging-throughput">

                          <param key="batch-delay" value="50"/>

                      </netty-connector>

                      <in-vm-connector name="in-vm" server-id="0"/>

                  </connectors>

                  <security-settings>

                      <security-setting match="#">

                          <permission type="send" roles="guest"/>

                          <permission type="consume" roles="guest"/>

                          <permission type="createNonDurableQueue" roles="guest"/>

                          <permission type="deleteNonDurableQueue" roles="guest"/>

                      </security-setting>

                  </security-settings>

                  <jms-connection-factories>

                      <connection-factory name="InVmConnectionFactory">

                          <connectors>

                              <connector-ref connector-name="in-vm"/>

                          </connectors>

                          <entries>

                              <entry name="java:/ConnectionFactory"/>

                          </entries>

                      </connection-factory>

                      <connection-factory name="RemoteConnectionFactory">

                          <connectors>

                              <connector-ref connector-name="netty"/>

                          </connectors>

                          <entries>

                              <entry name="RemoteConnectionFactory"/>

                          </entries>

                      </connection-factory>

                      <pooled-connection-factory name="hornetq-ra">

                          <connectors>

                              <connector-ref connector-name="in-vm"/>

                          </connectors>

                          <entries>

                              <entry name="java:/JmsXA"/>

                          </entries>

                          <transaction mode="xa"/>

                      </pooled-connection-factory>

                  </jms-connection-factories>

                  <jms-destinations>

                      <jms-queue name="testQueue">

                          <entry name="queue/test"/>

                      </jms-queue>

                      <jms-queue name="myqueue2">

                          <entry name="jms/queye/queue2"/>

                      </jms-queue>

                      <jms-topic name="testTopic">

                          <entry name="topic/test"/>

                      </jms-topic>

                      <jms-topic name="mytopic1">

                          <entry name="jms/topic/topic1"/>

                      </jms-topic>

                  </jms-destinations>

              </subsystem>

            

      <socket-binding name="messaging" port="5445"/>

      <socket-binding name="messaging-throughput" port="5455"/>

            Actually,the additional entries were all compy from some official document .

            Follow someone`s advice,i edit the standalone.conf,append:

           

      JAVA_OPTS="$JAVA_OPTS -b 0.0.0.0

            By now,the server is ok:successfully startup and run well.

          

            But,i cann`t connect to it through my jms application,the fragment of code is:

           

      p = new Properties();    

      p.setProperty( Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");

      p.setProperty( Context.PROVIDER_URL, "jnp://localhost:5445");

      p.setProperty( Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");

       

      context = new InitialContext( p);

      QueueConnectionFactory qfac = (QueueConnectionFactory)context.lookup("java:/ConnectionFactory");

      que = (Queue)context.lookup("jms/queye/queue2");

                  javax.jms.QueueConnection  qconn = qfac.createQueueConnection();

                  javax.jms.QueueSession qsession = qconn.createQueueSession( false, Session.AUTO_ACKNOWLEDGE);

                  TextMessage msg = qsession.createTextMessage();

                  msg.setText("Hello,word!,this is one");

                  javax.jms.QueueSender sender = qsession.createSender( que);

                  qconn.start();

                  sender.send( msg);

                  qconn.stop();

                  qsession.close();

                  qconn.close();

       

       

           the  error msg is:

         

      javax.naming.CommunicationException: Could not obtain connection to any of these urls: jnp://localhost:5445 and discovery failed with error: javax.naming.CommunicationException: IP_ADD_MEMBERSHIP failed (out of hardware filters?) [Root exception is java.net.SocketException: IP_ADD_MEMBERSHIP failed (out of hardware filters?)] [Root exception is javax.naming.CommunicationException: Failed to retrieve stub from server localhost/127.0.0.1:5445 [Root exception is java.io.EOFException]]

          at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1763)

          at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:693)

          at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)

          at javax.naming.InitialContext.lookup(InitialContext.java:392)

          at net.asd.java.test.jws.myhello.JmsCreator.sendToQue(JmsCreator.java:34)

          at net.asd.java.test.jws.myhello.JmsCreator.main(JmsCreator.java:58)

      Caused by: javax.naming.CommunicationException: Failed to retrieve stub from server localhost/127.0.0.1:5445 [Root exception is java.io.EOFException]

          at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:327)

          at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1734)

          ... 5 more

      Caused by: java.io.EOFException

          at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2280)

          at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2749)

          at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:779)

          at java.io.ObjectInputStream.<init>(ObjectInputStream.java:279)

          at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:312)

          ... 6 more

           

            I had try do this

           

      telnet  localhost  5445

           It runs well that verified the localhost:5445 is open ready.

         

           What`s wrong with them?How can i do to correct my code?Are there someone so kindly to help me or give me some tip?

           Any advice are appreciated. thx.