Title: RE: Error instantiating servlet!!!!

 

hi

 

Here is my sample servlet. It is exactly what is there in the sample code in how_to_ejb.

I m stuck in it for last 2 days.

 

Hoping for a reply,

Maniranjan Kumar

 

 

 

 

package com.cpb.InternalWS.ejb.positions;

 

import org.apache.cactus.*;
import junit.framework.*;
import java.util.Properties;
import javax.servlet.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import com.cpb.InternalWS.dvo.positions.PositionBySecurityVO;
import com.cpb.InternalWS.dvo.positions.PositionBySecurityRO;
import com.cpb.InternalWS.dvo.positions.ResultVO;
import com.cpb.util.VitiWebLog4j;
import com.cpb.util.VitiWebConstants;
import java.util.List;
import com.cpb.util.VitiWebLookupProperties;
import com.cpb.util.Lookup;

 

public class EmptyServletTestCase1 extends ServletTestCase
{
 private InvstPositionDetailsSession invstPositionDetailsSession; 
 private PositionBySecurityRO positionBySecurityRO;
 private PositionBySecurityVO positionBySecurityVO;
    private ResultVO resultVO;
 private String searchText = null;
    private List resultList = null;

 


    public EmptyServletTestCase1(String name) throws Exception
    {
        super(name);
       
    }

 

    protected void setUp()
    {
        VitiWebLog4j.debuglog("Entering EmptyServletTestCase1.java :: setUp() : ", VitiWebConstants.LOGTYPE_DEBUG);

 

  try
        {
      Context ctx = new InitialContext();
         InvstPositionDetailsSessionHome home = (InvstPositionDetailsSessionHome)
             PortableRemoteObject.narrow(ctx.lookup("InvstPositionsDetailsJndiName"),
          InvstPositionDetailsSessionHome.class);
         this.invstPositionDetailsSession = home.create();
         VitiWebLog4j.debuglog("Exiting EmptyServletTestCase1.java :: setUp() : ", VitiWebConstants.LOGTYPE_DEBUG);
        }
        catch(Exception e)
        {
         VitiWebLog4j.debuglog("Exiting EmptyServletTestCase1.java :: setUp() : Exception Occured In Getting EJB Handler : ", VitiWebConstants.LOGTYPE_DEBUG);
        }

 

    }

 

    protected void tearDown()
    {
        VitiWebLog4j.debuglog("Entering EmptyServletTestCase1.java :: tearDown() : ", VitiWebConstants.LOGTYPE_DEBUG);  
  invstPositionDetailsSession = null;
  searchText = null;
        resultList = null;
        VitiWebLog4j.debuglog("Exiting EmptyServletTestCase1.java :: tearDown() : ", VitiWebConstants.LOGTYPE_DEBUG);
    }

 


    public void testGetPositionBySecurity() throws Exception
    {
        VitiWebLog4j.debuglog("Entering EmptyServletTestCase1.java :: testGetPositionBySecurity : ", VitiWebConstants.LOGTYPE_DEBUG);
     positionBySecurityVO = (PositionBySecurityVO)invstPositionDetailsSession.getPositionBySecurity(positionBySecurityRO);

 

  VitiWebLog4j.debuglog("In EmptyServletTestCase1.java :: testGetPositionBySecurity : ", VitiWebConstants.LOGTYPE_DEBUG);

 

        if(positionBySecurityVO != null)
        {
   searchText = positionBySecurityVO.getSearchText();
   resultList = positionBySecurityVO.getResultList();
        }

 

  VitiWebLog4j.debuglog("In TestInvstPositionDAO.java :: Before assertEquals", VitiWebConstants.LOGTYPE_DEBUG);
  assertEquals("INFY", searchText);
        assertEquals(1,resultList.size());
        assertEquals("211000115",((ResultVO)resultList.get(0)).getCusip());

 

     VitiWebLog4j.debuglog("Exiting EmptyServletTestCase1.java :: testGetPositionBySecurity : ", VitiWebConstants.LOGTYPE_DEBUG);

 

    }

 

}

 

 

 


 

 -----Original Message-----
From: Vincent Massol [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 22, 2002 4:45 PM
To: 'Cactus Users List'
Subject: RE: Error instantiating servlet!!!!

Hi,

It seems your EmptyServletTestCase1 class is a servlet whereas it should not be. It is supposed to be a standard java class extending ServletTestCase.

Please check http://jakarta.apache.org/cactus/howto_testcase.html

You should also check http://jakarta.apache.org/cactus/how_it_works.html to understand how Cactus works (with WRT Redirectors, etc).

Cheers,
-Vincent

> -----Original Message-----
> From: Kumar_maniranjan [mailto:[EMAIL PROTECTED]]
> Sent: 22 July 2002 10:56
> To: [EMAIL PROTECTED]
> Subject: Error instantiating servlet!!!!
>
> hi,
> I m trying to write a servlet to test one EJB. This servlet contains
> only default constructor, setUp, tearDown and test method. Everything else
> is
> properly set, I assume so, cactus.properties file and JVM properties,
> but I m facing this  "Error instantiating servlet' error.
>
> Please get back to me if u have any clue regarding this ASAP.
>
> regards,
> Maniranjan Kumar
>
> PS : Below is console output of weblogic 6.1 sp2 and below that is log
> file content.
>
> CONSOLE
> ----------------
>
> <Jul 22, 2001 1:59:40 PM IST> <Error> <HTTP>
> <[WebAppServletContext(6535361,Citi
> webWar,/CitiwebWar)] Error instantiating servlet: "EmptyServletTestCase1"
> java.lang.InstantiationException: ****************.**.****..EmptyServletT
> estCase1
>         at java.lang.Class.newInstance0(Native Method)
>         at java.lang.Class.newInstance(Class.java:237)
>         at
> weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubIm
> pl.java:665)
>         at
> weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStub
> Impl.java:643)
>         at
> weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubI
> mpl.java:588)
>         at
> weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.
> java:368)
>         at
> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
> pl.java:242)
>         at
> weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:21)
>         at
> weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
> va:27)
>         at
> weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
> rvletContext.java:2464)
>         at
> weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
> pl.java:2039)
>         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
>         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
> >
> <Jul 22, 2001 1:59:40 PM IST> <Error> <HTTP>
> <[WebAppServletContext(6535361,Citi
> webWar,/CitiwebWar)] Servlet failed with ServletException
> javax.servlet.ServletException: Servlet class: '******.****.*****.*****
> .EmptyServletTestCase1' couldn't be instantiated
>         at
> weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubIm
> pl.java:676)
>         at
> weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStub
> Impl.java:643)
>         at
> weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubI
> mpl.java:588)
>         at
> weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.
> java:368)
>         at
> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
> pl.java:242)
>         at
> weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:21)
>         at
> weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
> va:27)
>         at
> weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
> rvletContext.java:2464)
>         at
> weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
> pl.java:2039)
>         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
>         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
> >
>
>
>
> CACTUS LOG FILE
> ----------------------------
> 2001-07-22 13:59:40,020 DEBUG applicationlogging - Exiting
> EmptyServletTestCase1.java :: CONSTRUCTOR :
> 2001-07-22 13:59:40,361 DEBUG
> ******.*****.**.**********.EmptyServletTestCase1 - >runGenericTest(...)
> 2001-07-22 13:59:40,361 DEBUG
> ******.*****.**.**********.EmptyServletTestCase1 - Test case =
> testGetPositionBySecurity
> 2001-07-22 13:59:40,371 DEBUG org.apache.cactus.client.AbstractHttpClient
> - >doTest(simulation URL = [null], automatic session = [true], cookies =
> [], headers = [], method = [POST], parameters =
> [[[ServletTestRedirector_TestClass] =
> [[******.*****.**.**********..EmptyServletTestCase1]]][[ServletTestRedirec
> tor_AutomaticSession] = [[true]]][[ServletTestRedirector_TestMethod] =
> [[testGetPositionBySecurity]]]])
> 2001-07-22 13:59:40,581 DEBUG org.apache.cactus.client.HttpClientHelper -
> >HttpClientHelper([http://localhost:7001/******War/EmptyServletTestCase1])
> 2001-07-22 13:59:40,581 DEBUG org.apache.cactus.client.HttpClientHelper -
> <HttpClientHelper
> 2001-07-22 13:59:40,591 DEBUG org.apache.cactus.client.HttpClientHelper -
> >connect(simulation URL = [null], automatic session = [true], cookies =
> [], headers = [], method = [POST], parameters =
> [[[ServletTestRedirector_TestClass] =
> [[com.cpb.InternalWS.ejb.positions.EmptyServletTestCase1]]][[ServletTestRe
> director_Service] =
> [[CALL_TEST]]][[ServletTestRedirector_AutomaticSession] =
> [[true]]][[ServletTestRedirector_TestMethod] =
> [[testGetPositionBySecurity]]]])
> 2001-07-22 13:59:40,591 DEBUG org.apache.cactus.client.HttpClientHelper -
> >addCookies(...)
> 2001-07-22 13:59:40,591 DEBUG org.apache.cactus.client.HttpClientHelper -
> <addCookies
> 2001-07-22 13:59:40,601 DEBUG org.apache.cactus.client.HttpClientHelper -
> <connect
> 2001-07-22 13:59:40,601 DEBUG
> org.apache.cactus.client.AutoReadHttpURLConnection - >getInputStream()
> 2001-07-22 13:59:40,601 DEBUG
> org.apache.cactus.client.AutoReadHttpURLConnection - Original connection =
> sun.net.www.protocol.http.HttpURLConnection:http://localhost:7001/CitiwebW
> ar/EmptyServletTestCase1
> 2001-07-22 13:59:40,631 DEBUG
> com.cpb.InternalWS.ejb.positions.EmptyServletTestCase1 - Exception in test
> java.io.IOException: Server returned HTTP response code: 500 for URL:
> http://localhost:7001/********War/EmptyServletTestCase1
>       at
> sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnecti
> on.java:562)
>       at
> org.apache.cactus.client.AutoReadHttpURLConnection.getInputStream(AutoRead
> HttpURLConnection.java:127)
>       at
> org.apache.cactus.client.AbstractHttpClient.doTest(AbstractHttpClient.java
> :136)
>       at
> org.apache.cactus.AbstractTestCase.runGenericTest(AbstractTestCase.java:42
> 2)
>       at
> org.apache.cactus.ServletTestCase.runTest(ServletTestCase.java:130)
>       at
> org.apache.cactus.AbstractTestCase.runBare(AbstractTestCase.java:371)
>       at junit.framework.TestResult$1.protect(TestResult.java:106)
>       at junit.framework.TestResult.runProtected(TestResult.java:124)
>       at junit.framework.TestResult.run(TestResult.java:109)
>       at junit.framework.TestCase.run(TestCase.java:131)
>       at junit.framework.TestSuite.runTest(TestSuite.java:173)
>       at junit.framework.TestSuite.run(TestSuite.java:168)
>       at
> com.togethersoft.testing.internal.testserver.plugin.junit.JUnitTestRunner.
> a([DashoPro-V2-050200])
>       at
> com.togethersoft.testing.internal.testserver.plugin.junit.JUnitTestRunner.
> a([DashoPro-V2-050200])
>       at
> com.togethersoft.testing.internal.testserver.plugin.junit.JUnitHttpTestRun
> ner.run([DashoPro-V2-050200])
>       at mtfwes.execute([DashoPro-V2-050200])
>       at mtfwer.execute([DashoPro-V2-050200])
>       at
> com.togethersoft.testing.internal.testserver.TestServerServlet.executeComm
> and([DashoPro-V2-050200])
>       at
> com.togethersoft.testing.internal.testserver.TestServerServlet.GetMethod([
> DashoPro-V2-050200])
>       at
> com.togethersoft.testing.internal.testserver.jetty.TsHandler.handleRequest
> ([DashoPro-V2-050200])
>       at
> com.togethersoft.testing.internal.testserver.jetty.TsHandler.handle([Dasho
> Pro-V2-050200])
>       at org.mortbay.http.HandlerContext.handle(HandlerContext.java:1047)
>       at org.mortbay.http.HandlerContext.handle(HandlerContext.java:1002)
>       at org.mortbay.http.HttpServer.service(HttpServer.java:774)
>       at org.mortbay.http.HttpConnection.service(HttpConnection.java:745)
>       at
> org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:918)
>       at org.mortbay.http.HttpConnection.handle(HttpConnection.java:760)
>       at
> org.mortbay.http.SocketListener.handleConnection(SocketListener.java:148)
>       at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:287)
>       at org.mortbay.util.ThreadPool$JobRunner.run(ThreadPool.java:775)
>       at java.lang.Thread.run(Thread.java:484)
>
>
> --
> To unsubscribe, e-mail:   <mailto:cactus-user-
> [EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:cactus-user-
> [EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


Reply via email to