You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Abhishek Agrawal <aa...@vt.edu> on 2002/06/10 18:30:08 UTC

exception in fibonacci Example

I am trying to run the fibonacci Example at the following link :
http://www.onjava.com/pub/a/onjava/2002/06/05/axis.html?page=2

The only change i have made is that  I have added a line 
MessageContext.getCurrentContext() in the FibonacciImpl.java

fibonacciImpl.java: 

package fibonacci;
import org.apache.axis.*;

public class FibonacciImpl {
        public int calculateFibonacci( int num ) {
                if (num <= 0) return 0;
                if (num == 1) return 1;
                int previous1 = 1, previous2 = 0, fib = 0;

->>>              MessageContext n = 		       
org.apache.axis.MessageContext.getCurrentContext();

                for (int i=2; i <= num; i++) {
                        // the fib is the answer of the previous two answers
                        fib = previous1 + previous2;

                        // reset the previous values
                        previous2 = previous1;
                        previous1 = fib;
                }

                return fib;
        }

        public int[] calculateFibonacciRange(int start, int stop) {
                int[] results = new int[stop + 1];

                for (int x=start; x <= stop; x++) {
                        results[x] = this.calculateFibonacci( x );
                }
                return results;
        }
}

I am getting the following exception :
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at 
org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:134)
        at 
org.apache.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:875)
        at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1528)
        at org.apache.crimson.parser.Parser2.content(Parser2.java:1779)
        at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1507)
        at org.apache.crimson.parser.Parser2.content(Parser2.java:1779)
        at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1507)
        at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:500)
        at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
        at 
org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442)
        at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
        at 
org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:202)
        at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:428)
        at org.apache.axis.client.Call.invoke(Call.java:1919)
        at org.apache.axis.client.Call.invoke(Call.java:1690)
        at org.apache.axis.client.Call.invoke(Call.java:1608)
        at org.apache.axis.client.Call.invoke(Call.java:1169)
        at 
fibonacci.ws.FibonacciSoapBindingStub.calculateFibonacci(FibonacciSoapBindingStub.java:118)
        at fibonacci.FibonacciTester.main(FibonacciTester.java:14)

this is a very simple thing and it should work properly. I wonder why it is 
not working. I have set the classpath properly and i was also able to run 
some webservices. Problems occur only when i start using "MessageContext" in 
my code. 

Can anyone help me, as am stuck with this problem for a long time now.

Thanks,
Abhishek