jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruce Scharlau <schar...@csd.abdn.ac.uk>
Subject port out of range error
Date Thu, 23 Jan 2003 13:46:31 GMT
Hi,

I'm trying to get cactus working with jboss+tomcat using Ant, and am almost 
their with it.
The <runservertests> task is called, which deploys my war for startTarget, 
and then gives me an error when it runs my servlet test under the 
'cactus-tests' target.
I tried swapping out the commons-HttpClient jar with a new one from Gump, 
but that didn't help.
A search on this list archive reported someone else getting this error last 
month, but no solution came up.

So I'm looking for suggestions.
I'm not sure if the 'port out of range:-1' means that some input was 
expected, although the servlet doesn't take parameters, or whether it does 
mean that my port number was wrong.
I'm using this set up, and haven't specified the cactus.properties 
anywhere, and it all seems to work ok.

  <runservertests 
testURL="http://localhost:8080/firstAntApp/ServletRedirector?Cactus_Service=RUN_TEST"
                                  startTarget="deploy-war"
                                  stopTarget= "undeploy-war"
                      testTarget="cactus-tests"/>
    </target>

The error, my very basic servlet and its test are below.
All I'm looking to do is get the basics working now, and then I can make it 
all more robust.

cheers,

Bruce

Dr. Bruce Scharlau
Dept. of Computing Science
University of Aberdeen
Aberdeen AB24 3UE
01224 272193
http://www.csd.abdn.ac.uk/~bscharla
mailto:scharlau@csd.abdn.ac.uk


The error it gives is this taken from the console:

cactus-tests:
[runservertests] log4j:WARN No appenders could be found for logger 
(org.apache.cactus.util.JUnitVersionHelper).
[runservertests] log4j:WARN Please initialize the log4j system properly.
     [junit] Running uk.ac.abdn.csd.mtp.ant.web.TestfirstAntServlet
     [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0.611 sec
     [junit] Testsuite: uk.ac.abdn.csd.mtp.ant.web.TestfirstAntServlet
     [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0.611 sec

     [junit] Testcase: testReadServletOutputStream took 0.601 sec
     [junit]     Caused an ERROR
     [junit] port out of range:-1
     [junit] java.lang.IllegalArgumentException: port out of range:-1
     [junit]     at 
java.net.InetSocketAddress.<init>(InetSocketAddress.java:103)
     [junit]     at java.net.Socket.<init>(Socket.java:119)
     [junit]     at 
org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:309)
     [junit]     at 
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:314)
     [junit]     at 
org.apache.cactus.client.HttpClientConnectionHelper.dispatch24_connect(HttpClientConnectionHelper.java;org/apache/cactus/util/log/LogAspect.java(1k):163)
     [junit]     at 
org.apache.cactus.client.HttpClientConnectionHelper.around24_connect(HttpClientConnectionHelper.java;org/apache/cactus/util/log/LogAspect.java(1k):1218)
     [junit]     at 
org.apache.cactus.client.HttpClientConnectionHelper.connect(HttpClientConnectionHelper.java;org/apache/cactus/util/log/LogAspect.java(1k):105)
     [junit]     at 
org.apache.cactus.client.AbstractHttpClient.callRunTest(AbstractHttpClient.java;org/apache/cactus/util/log/LogAspect.java(1k):186)
     [junit]     at 
org.apache.cactus.client.AbstractHttpClient.dispatch2_doTest(AbstractHttpClient.java;org/apache/cactus/util/log/LogAspect.java(1k):109)
     [junit]     at 
org.apache.cactus.client.AbstractHttpClient.around2_doTest(AbstractHttpClient.java;org/apache/cactus/util/log/LogAspect.java(1k):1218)
     [junit]     at 
org.apache.cactus.client.AbstractHttpClient.doTest(AbstractHttpClient.java;org/apache/cactus/util/log/LogAspect.java(1k):104)
     [junit]     at 
org.apache.cactus.AbstractWebTestCase.runGenericTest(AbstractWebTestCase.java:260)
     [junit]     at 
org.apache.cactus.ServletTestCase.runTest(ServletTestCase.java:133)
     [junit]     at 
org.apache.cactus.AbstractTestCase.runBare(AbstractTestCase.java:195)
     [junit]     at 
org.apache.cactus.ant.RunServerTestsTask.callTests(Unknown Source)
     [junit]     at 
org.apache.cactus.ant.RunServerTestsTask.execute(Unknown Source)

     [junit] Testcase: testReadServletOutputStream

BUILD FAILED

The servlet:
package uk.ac.abdn.csd.mtp.ant.web;

import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

/**
  *
  * @web.servlet
  *      display-name="firstAntServlet"
  *      load-on-startup="1"
  *      name="firstAntServlet"
  *
  *
  */

public class firstAntServlet extends HttpServlet {

         public void init() throws ServletException {

         }

         public void doGet(HttpServletRequest req, HttpServletResponse res)
                         throws ServletException, IOException {

                 StringBuffer buf = new StringBuffer(1024);

                 res.setContentType("text/html");
                 PrintWriter out = res.getWriter();

                 // set the statement of greeting

                 buf.append("Hello there from your fist servlet!");

                 // output the html results
                 out.println("<html><head><title>First Ant 
App</title></head>");
                 out.println("<body background=\"#000000\"><h1 align 
=\"center\">First Ant App</h1>");
                 out.println("<div align=\"center\"><table border=\"0\" 
bgcolor=\"#cccc99\"><tr><td>");

                 out.println(buf);
                 out.println("</td></tr></table>");
                 out.println("</body></html>");
         }
}

The testServlet

package uk.ac.abdn.csd.mtp.ant.web;

import org.apache.cactus.ServletTestCase;
import org.apache.cactus.WebResponse;
import java.io.IOException;

import javax.servlet.ServletException;

public class TestfirstAntServlet extends ServletTestCase {

         /**
          * Constructor for TestfirstAntServlet.
          */
         public TestfirstAntServlet(String theName) {
                 super(theName);
         }

             /**
      * Verify that we can assert the servlet output stream.
      */
     public void testReadServletOutputStream() throws IOException, 
ServletException
     {
         firstAntServlet servlet = new firstAntServlet();
         servlet.doGet(request, response);
     }

     /**
      * Verify that we can assert the servlet output stream.
      *
      * @param theResponse the response from the server side.
      */
     public void endReadServletOutputStream(WebResponse theResponse)
         throws IOException
     {
         String expected = "<html><head><title>First Ant App</title></head>";
         String result = theResponse.getText();
         assertEquals(expected, result);
     }

}





Mime
View raw message