Hi Keith,

Long post below...

I'm using VisualAge for Java 3.5.3, Cactus 1.1, and JUnit 3.7.  I was
getting the same SocketException that your test was throwing (see end of
post).  This is the configuration that got my tests to work in the WebSphere
Test Environment.  Some of the steps may be superfluous but this is what
worked for me.  I'm not sure what fixed the exception because I was doing a
lot of tweaking and following Andrew's steps from the previous post in this
thread.  {Cactus dir} refers to the directory where Cactus was extracted and
{VisualAge dir} refers to the VisualAge for Java install directory.

1. I created three projects: JUnit, Cactus, and Log4j.  Into JUnit, I
imported src.jar from the JUnit zip.  Into Cactus, I imported {Cactus
dir}\src\framework\servlet22 and {Cactus dir}\src\framework\share.  Into
Log4j, I imported log4j-core.jar from {Cactus dir}\lib.

2. Into the directory {VisualAge dir}\ide\project_resources\Cactus, I copied
cactus.properties, log_client.properties, and log_server.properties, which I
took from {Cactus dir}\sample\conf\test.

3. In the file {VisualAge dir}\ide\project_resources\IBM WebSphere Test
Environment\properties\default.servlet_engine, I added 
      
    <websphere-webgroup name="test">
       <description>Cactus Testing Web Application</description>
       <document-root>$approot$/web</document-root>
       <classpath>$approot$/servlets</classpath>
       <root-uri>/test</root-uri>
       <auto-reload enabled="true" polling-interval="3000"/>
       <shared-context>false</shared-context>
    </websphere-webgroup>

under the default_app webgroup.

4. I created a directory called test under {VisualAge
dir}\ide\project_resources\IBM WebSphere Test
Environment\hosts\default_host\.  In test, I created two subdirectories:
servlets and web.  

a. Into the servlets subdirectory, I copied the file default_app.webapp from
{VisualAge dir}\ide\project_resources\IBM WebSphere Test
Environment\hosts\default_host\default_app\servlets\ and renamed it
test.webapp.  I made these changes to the file:

i. Replaced value of the webapp/name element with 'test' and replaced the
value of webapp/description.

ii. Right below the webapp/error-page element, I added

   <servlet>
      <name>ServletRedirector</name>
      <description>Cactus Testing ServletRedirector</description>
      <code>org.apache.commons.cactus.server.ServletTestRedirector</code>
      <servlet-path>/ServletRedirector</servlet-path>
      <autostart>false</autostart>
   </servlet>

   <servlet>
      <name>JspRedirector</name>
      <description>Cactus Testing JspRedirector</description>
      <code>/test/web/redirector.jsp</code>
      <servlet-path>/JspRedirector</servlet-path>
      <autostart>false</autostart>
   </servlet>

iii. Removed the invoker servlet shown below

   <servlet>
      <name>invoker</name>
      <description>Auto-registration servlet</description>
      <code>com.ibm.servlet.engine.webapp.InvokerServlet</code>
      <servlet-path>/servlet/*</servlet-path>
      <autostart>true</autostart>
   </servlet>

iv. Changed the code element for the jsp servlet to
com.ibm.ivj.jsp.jasper.runtime.JspDebugServlet and the scratchdir
init-parameter value element to $server_root$/temp/JSP1_1/default_app.

b. Into the web subdirectory, I copied redirector.jsp from {Cactus
dir}\sample\web\test.

5. Back in VisualAge, I selected Window...Options from the menu.  Under the
Resources option for the workspace classpath, I added {VisualAge
dir}\ide\project_resources\JUnit\;{VisualAge
dir}\ide\project_resources\Cactus\;{VisualAge
dir}\ide\project_resources\Log4j\;

6. In the WebSphere Test Environment under Servlet Engine, I added Cactus,
JUnit, Log4j, and the project that contained the tests to the classpath.

With this configuration, you'll find cactus_client.log under {VisualAge
dir}\ide\project_resources\{project being tested} and cactus_server.log
under {VisualAge dir}\ide\tools\com-ibm-ivj-ui-webcontrolcenter when you run
your tests.

I had found that the ServletRedirector had not been called when the
SocketException was being thrown.  The exception originated in
ServletHttpClient.doTest() in the call to connection.getInputStream(), which
is supposed to force the calling of ServletRedirector.  In the
default.servlet_engine file, I  had the webgroup for the webapp that I was
testing mapped to a root-uri of "/", which is where the default_app webgroup
is mapped.  I was getting strange results when trying to run my webapp with
this mapping and the Cactus test mapping.  Once I changed the root-uri for
my webapp to something unique and had the Cactus test configuration as
above, everything worked.  I don't know if this mis-mapping was somehow
causing problems with the loading of ServletRedirector.

Hope this helps.

Todd

-----Original Message-----
From: Pierce, Keith [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 14, 2001 10:12 AM
To: '[EMAIL PROTECTED]'
Subject: RE: [cactus] Problem running under Visual Age for Java


        I followed Andrew's steps. The test still bombs at the same point --
statement connection.getInputStream(), in method ServletHttpClient.doTest()
-- but now throws exception

                java.net.SocketException: Unexpected end of file from server

        Any suggestions?

Keith Pierce
FedACH Support Services
Federal Reserve Bank of Minneapolis
612-204-6480

Reply via email to