Problems running the example from your doc

Help
Juergen P
2004-11-10
2013-03-22
  • Juergen P
    Juergen P
    2004-11-10

    Hello,

    I have some problems running your simple example.
    Building MOM4J seems to work, I'm also able to administer it.

    But when I try to run the following program (your example), the lookup-method is producing a lot of exceptions. Please help.

    I'm using JDK1.4.1 and I have downloaded all products that were mentioned in your documentation.

    Program code:
    package jmstest;
    import javax.jms.*;
    import javax.naming.*;
    import java.util.*;
    import org.mom4j.jndi.*;

    public class QueueReceiverTest {

        public QueueReceiverTest() {
        }
       
        public static void main (String argv[])
        {
        Properties p = new Properties();
            p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.mom4j.jndi.InitialCtxFactory");
            p.setProperty(Context.PROVIDER_URL, "xcp://localhost:8001");
            try {
                Context ctx = new InitialContext(p);
                QueueConnectionFactory qcf =
                    (QueueConnectionFactory)ctx.lookup("QueueConnectionFactory");
                Queue queue = (Queue)ctx.lookup("testQueue");

    ================================
    Stacktrace:
    package jmstest;
    import javax.jms.*;
    import javax.naming.*;
    import java.util.*;
    import org.mom4j.jndi.*;

    public class QueueReceiverTest {

        public QueueReceiverTest() {
        }
       
        public static void main (String argv[])
        {
        Properties p = new Properties();
            p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.mom4j.jndi.InitialCtxFactory");
            p.setProperty(Context.PROVIDER_URL, "xcp://localhost:8001");
            try {
                Context ctx = new InitialContext(p);
                QueueConnectionFactory qcf =
                    (QueueConnectionFactory)ctx.lookup("QueueConnectionFactory");
                Queue queue = (Queue)ctx.lookup("testQueue");

     
    • Juergen P
      Juergen P
      2004-11-10

      Sorry, here comes the stacktrace:

      java.io.StreamCorruptedException: invalid stream header
              at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:737)
              at java.io.ObjectInputStream.<init>(ObjectInputStream.java:253)
              at org.mom4j.xcp.util.Serializer.string2Object(Serializer.java:45)
              at org.mom4j.jndi.XcpBindingHandler.endElement(XcpBindingHandler.java:68)
              at org.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1403)
              at org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator.java:1550)
              at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1149)
              at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
              at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
              at org.mom4j.xcp.XcpSender.recieveData(XcpSender.java:134)
              at org.mom4j.xcp.XcpSender.send(XcpSender.java:84)
              at org.mom4j.jndi.ContextImpl.lookup(ContextImpl.java:262)
              at org.mom4j.jndi.ContextImpl.lookup(ContextImpl.java:250)
              at javax.naming.InitialContext.lookup(InitialContext.java:347)
              at jmstest.QueueReceiverTest.main(QueueReceiverTest.java:25)
      java.lang.IllegalStateException: invalid stream header
              at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1111)
              at org.mom4j.xcp.XcpSender.recieveData(XcpSender.java:134)
              at org.mom4j.xcp.XcpSender.send(XcpSender.java:84)
              at org.mom4j.jndi.ContextImpl.lookup(ContextImpl.java:262)
              at org.mom4j.jndi.ContextImpl.lookup(ContextImpl.java:250)
              at javax.naming.InitialContext.lookup(InitialContext.java:347)
              at jmstest.QueueReceiverTest.main(QueueReceiverTest.java:25)
      java.io.IOException: invalid stream header
              at org.mom4j.xcp.XcpSender.recieveData(XcpSender.java:145)
              at org.mom4j.xcp.XcpSender.send(XcpSender.java:84)
              at org.mom4j.jndi.ContextImpl.lookup(ContextImpl.java:262)
              at org.mom4j.jndi.ContextImpl.lookup(ContextImpl.java:250)
              at javax.naming.InitialContext.lookup(InitialContext.java:347)
              at jmstest.QueueReceiverTest.main(QueueReceiverTest.java:25)
      javax.naming.NamingException: invalid stream header
              at org.mom4j.jndi.ContextImpl.lookup(ContextImpl.java:265)
              at org.mom4j.jndi.ContextImpl.lookup(ContextImpl.java:250)
              at javax.naming.InitialContext.lookup(InitialContext.java:347)
              at jmstest.QueueReceiverTest.main(QueueReceiverTest.java:25)