Debugging extended HttpServlets

I had created a Servlet which extends HttpServlet. This Servlet I use as baseClass for all servlets in my project
But JDeveloper3.0 can debug only Servlets which are directly extended by HttpServlet. on every other extended Servlet the "Run/Debug"-Context menu didn't appear
please help

I am in a similar situation as the first poster. I downloaded JDeveloper 3.1 for exactly this reason. It does not work - the Run/Debug context menu does not appear on servlets which don't directly inherit from HttpServlet.

Similar Messages

  • Servlet which extends HttpServlet

    I had created a Servlet which extends HttpServlet. This Servlet I use as baseClass for all servlets in my project But JDeveloper 3.1 can debug only Servlets which are directly extended by HttpServlet. on every other extended Servlet the "Run/Debug"-Context menu didn't appear
    does 3.1.1.2 fix this problem?

    This is a bug in JDev 3.1.x. It is being fixed in JDeveloper 3.2
    raghu

  • Errormessage using extending HttpServlet

    I'm having a class that extends HttpServlet. When I'm making a RequestDispatcherobject I get the following errormessage:
    java.lang.IllegalStateException: ServletConfig has not been initialized
    at javax.servlet.GenericServlet.getServletContext(GenericServlet.java:185)
    public class RegUserController extends HttpServlet {
    public void init( ServletConfig config )
    throws ServletException {
    // call superclass's init method for initialization
    super.init( config );
    Does anyone know what I'm doing wrong?

    I'm making a RequestDispatcherobject in class
    RegUserController. What do you write inside the init
    method? Nothing more that you have.
    Is your custom servlet registered in web.xml via <servlet>...</servlet> and <servlet-mapping>...</servlet-mapping> components?
    Has your Servlet been generated, called, and initiated from within normal Servlet activity? Meaning, did you call
    RegUserController controller = new RegUserController();
    Or did you let the servlet container do all the instantiation for you and you just get to this point when a request is made to it?

  • Problem in debug a servlet

    hello all,
    i am using eclipse 3.2 and tomcat 5.0.28
    i made a servlet class ServletFetchingDataFromDatabase.java in this package ( given below )
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ServletDataBaseConnection\src\servlet
    and corresponding this java file .... its class file situated in this package ( given below )
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ServletDataBaseConnection\build\classes\servlet
    because of my java file in servlet package , i wrote this file ( given below )
    package servlet;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class ServletFetchingDataFromDatabase extends HttpServlet {
    private static final long serialVersionUID = 8572240412874905464L;
         String url = "jdbc:mysql://localhost/mokshadatabase";
         String user = "root";
         String password = "password";
         String jdbcDriver = "com.mysql.jdbc.Driver";
    public void doGet(HttpServletRequest request , HttpServletResponse response) throws ServletException , IOException{
              String query = null;
              response.setContentType("text/html");
              PrintWriter pw = response.getWriter();
              pw.println("<html>");          
              pw.println("<body>");
              pw.println("<form>");
              pw.println("Servlet DataBase Connection<br>");
              pw.println("Patient Master Table <br><br>");
              try{
                  Class.forName(jdbcDriver).newInstance();
                  Connection conn = DriverManager.getConnection(url, user, password);
                  query = "SELECT * FROM mhis_m_patientmaster";
                  PreparedStatement stmt = conn.prepareStatement(query);
                  stmt.executeQuery();
                  ResultSet rs = stmt.getResultSet();
                  pw.println("<table border = 1>");
                  pw.println("<tr>");
                  pw.println("<td>patient_Id</td>");
                  pw.println("<td>patient_Registration_Date</td>");
                  pw.println("<td>patient_Registration_Time</td>");
                  pw.println("<td>patient_First_Name</td>");
                  pw.println("<td>patient_Last_Name</td>");
                  pw.println("</tr>");
                  while(rs.next()){
                              pw.println("<tr>");
                       if("".equalsIgnoreCase(rs.getString(1))){
                            pw.println("<td>Null</td>");
                       }else{
                            pw.println("<td>" + rs.getString(1) + "</td>");
                       if("".equalsIgnoreCase(rs.getString(2))){
                            pw.println("<td>Null</td>");
                       }else{
                            pw.println("<td>" + rs.getString(2) + "</td>");
                       pw.println("</tr>");
                  pw.println("</table>");
             }catch(IllegalAccessException e){
                   pw.println("Error is : " + e.getMessage() + "<br>");
                   pw.println("Error is IllegalAccessException<br>");
              }catch (ClassNotFoundException e) {
                   pw.println("Error is : " + e.getMessage() + "<br>");
                   pw.println("Error is ClassNotFoundException<br>");
              }catch(InstantiationException e){
                   pw.println("Error is : " + e.getMessage() + "<br>");
                   pw.println("Error is InstantiationException<br>");
              }catch(SQLException e){
                   pw.println("Error is : " + e.getMessage() + "<br>");
                   pw.println("Error is SQLException<br>");
              pw.println("</form>");
              pw.println("</body>");          
              pw.println("</html>");
    }and web.xml .. i wrote
    <!--    ServletFetchingDataFromDatabase.java (In side servlet package )    -->
        <servlet>
            <servlet-name>servlet\ServletFetchingDataFromDatabase</servlet-name>
            <servlet-class>servlet.ServletFetchingDataFromDatabase</servlet-class>
        </servlet>
        <servlet-mapping>
            <servlet-name>servlet\ServletFetchingDataFromDatabase</servlet-name>
            <url-pattern>/servlet/ServletFetchingDataFromDatabase.do</url-pattern>
        </servlet-mapping>now when i debug it then it gives error like that...
    HTTP Status 404 - /ServletDataBaseConnection/servlet/servlet.ServletFetchingDataFromDatabase.do
    type Status report
    message /ServletDataBaseConnection/servlet/servlet.ServletFetchingDataFromDatabase.do
    description The requested resource (/ServletDataBaseConnection/servlet/servlet.ServletFetchingDataFromDatabase.do) is not available.main thing is that when i check it from web browser
    ( http://localhost:8080/ServletDataBaseConnection/servlet/ServletFetchingDataFromDatabase.do ) then it gives correct out put .. no problem is there..but when i check it by debug using break point ...then it gives this error....
    i thing this problem is related to web.xml ... but if this web.xml is wrong then why this web.xml gives write out put from when i checked it by browser...

    Hi ,
    I really dont understand why you are making such a complicated folder structure for servlet.
    May be i m wrong, but if you are using eclipse everything is straight forward.
    Just create dynamic web project create servlet into src & jsp into webcontent . Everything place in your
    workspace thats all. Just simply call your servlet thats it
    Please Revert Back
    Sachin Kokcha

  • Servlet Debugging

    I have an abstract servlet class extending HttpServlet; from that abstract class I have a few subclasses, but I cannot debug those subclasses within JDev, although they run fine on server? Is this a bug of JDev?
    I am using JDev 3.1.1.2

    This bug seems not to be fixed in JDev 3.2
    Currently I try to avoid to subclass from other than HttpServlet...
    It may be possible to create a additional startup servlet, which calls the other subclassed servlet, which is not recognized as a runable program
    I hope Oracle provides a bug fix in the near future. I am really dissapointed thas this known bug was not fixed in JDev.
    Klaus
    null

  • Debugging endless loops in Servlets

    Anyone got any neat tricks for this? My loop is in some service methods outside of the servlet class itself, so I don't have access to the servlet log. I suppose I'm going to have to put in icky print statements until I've isolated the problem but it's ugly, especially since the problem methods have been jarred.
    Could do with a way of forcing the thread to exception and generate backtrace.

    Do you have -- or your could you build in -- any way of passing a Logger object from your servlet to the object that contains the problem loop? If so, you can make use of the following classes in your debugging process:
    package com.shaunkalley.java.toolkit.servlet;
    import com.shaunkalley.java.toolkit.util.*;
    import java.util.logging.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    * <p>
    * An abstract <code>HttpServlet</code> implementation which ties the Servlet
    *   logging facilities to those of the J2SDK.  The <code>Logger</code> instance
    *   is created as an anonymous <code>Logger</code> instance.
    * </p>
    * @version $Id: LoggerHttpServlet.java,v 1.4 2002/06/20 06:09:11 shaun Exp $
    * @author <a href="mailto:[email protected]">Shaun Kalley</a>
    public abstract class LoggerHttpServlet extends HttpServlet {
        protected Logger logger;
        public void init(ServletConfig config) throws ServletException {
            super.init(config);
            logger = Logger.getAnonymousLogger();
            Utilities.removeAllHandlers(logger);
            logger.addHandler(new ServletHandler(this));
    package com.shaunkalley.java.toolkit.servlet;
    import java.util.logging.*;
    import javax.servlet.*;
    * <p>
    * A logging <code>Handler</code> that publishes to a servlet's logging
    *   facility.
    * </p>
    * @author <a href="mailto:[email protected]">Shaun Kalley</a>
    * @version $Id: ServletHandler.java,v 1.4 2002/07/02 16:20:40 shaun Exp $
    * @see java.util.logging.Handler
    public class ServletHandler extends Handler {
        private GenericServlet servlet;
         * <p>
         * Creates a <code>ServletHandler</code> from a servlet.
         * </p>
         * @param servlet the servlet to log to.
         * @throws NullPointerException if <code>servlet</code> is
         *   <code>null</code>.
        public ServletHandler(GenericServlet servlet) {
            if (servlet == null) {
                throw new NullPointerException("servlet is null");
            this.servlet = servlet;
         * <p>
         * This method publishes a <code>LogRecord</code> by passing the message and
         *   any <code>Throwable</code> associated with the <code>LogRecord</code>
         *   to the servlet's <code>log()</code> methods.
         * </p>
         * @param record description of the log event.
         * @see java.util.logging.Handler#publish(java.util.logging.LogRecord)
         * @see java.util.logging.LogRecord@getMessage()
         * @see java.util.logging.LogRecord@getThrown()
         * @see javax.servlet.GenericServlet#log(java.lang.String)
         * @see javax.servlet.GenericServlet#log(java.lang.String, java.lang.Throwable)
        public void publish(LogRecord record) {
            Throwable thrown = record.getThrown();
            if (thrown == null) {
                servlet.log(record.getMessage());
            } else {
                servlet.log(record.getMessage(), thrown);
         * <p>
         * This method does nothing.
         * </p>
         * @see java.util.logging.Handler#flush()
        public void flush() {
         * <p>
         * This method does nothing.  No <code>SecurityException</code> is thrown.
         * </p>
         * @see java.util.logging.Handler#close()
        public void close() throws SecurityException {
    }Hope this helps...
    Shaun

  • Httpservlet doPost() problem

    Hi everyone,
    I'm having trouble with httpServlet. I can't seem to make a doPost() happen.
    Here's my problem:
    Everytime I click on the submit button on the html whether it is the "submit post" or "submit get". The text that appears on the console is "doGet". I never get a "doPost". I tried overriding the service method (which I commented out right now), to see what the method type of the request is and it is always GET even if I submitted using post.
    Is there something wrong with my code? Or am I not just understanding how doPost() works correctly. I'm really stumped, I don't know what else to do.Any help would be appreciated.
    here is my simple html form:
    <html><head><title>tester</title></head>
    <form name="input" action=http://localhost:8080/testSevlet method="get">
    Username:
    <input type="text" name="user">
    <input type="submit" value="Submit get">
    </form>
    <form name="input" action=http://localhost:8080/testSevlet method="post">
    Username:
    <input type="text" name="user">
    <input type="submit" value="Submit post">
    </form>
    Here's my processing servlet
    import javax.servlet.ServletContext;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.*;
    public class testServlet extends HttpServlet
    public testServlet)
    super();
    public void init() throws ServletException
    super.init();
    public void destroy()
    super.destroy();
    public void service(HttpServletRequest req, HttpServletResponse res)
    throws ServletException,IOException
    System.out.println(req.getMethod());
    public void doGet(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    System.out.println("doGet");
    public void doPost(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    System.out.println("doPost");
    }

    I'm having a similar problem with POST and HttpServlet in Tomcat 5.0.25 and JDK 1.5.0_06-b05
    The problem appears to be performing a POST to an HttpServlet before performing a GET.
    Using a very simple form test.html:
    <html>
    <body>
    <form method="post" action="http://localhost/test" name="request">
    <textarea rows="10" cols="60" name="textarea">
    some sample text
    </textarea>
    <input type="submit" name="submit" value="Ok">
    </form>
    </body>
    </html>--------------------
    If I load this form from Tomcat as http://localhost/test/test.html and click the Ok button, my test HttpServlet works fine, and outputs the following debug info:
    req.getRequestURL: http://localhost/test/
    req.getContentLength: 30
    req.getContentType: application/x-www-form-urlencoded
    req.getMethod: POST
    req.getProtocol: HTTP/1.1
    Request.Headers
    accept=image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
    referer=http://localhost/test/test.html
    accept-language=en-us
    content-type=application/x-www-form-urlencoded
    accept-encoding=gzip, deflate
    user-agent=Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
    host=localhost
    content-length=30
    connection=Keep-Alive
    cache-control=no-cache
    Request.Parameters
    xml=some sample text
    submit=Ok--------------------------------
    However, if I load the same html file into the browser from the filesystem (e.g., C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\test\test.html) and click OK, I get the following output:
    req.getRequestURL: http://localhost/test/
    req.getContentLength: -1
    req.getContentType: null
    req.getMethod: GET
    req.getProtocol: HTTP/1.1
    Request.Headers
    accept=image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
    accept-language=en-us
    accept-encoding=gzip, deflate
    user-agent=Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
    host=localhost
    connection=Keep-Alive
    cache-control=no-cache
    Request.Parameters--------------------------------------
    Highlighting the differences:
    In the first case -- when the form is POSTed after GETting the form through Tomcat, things are correct:
    * the method is POST
    * the content-length and content-type are set appropriately
    * the request parameters (from req.getParameter()) are correct
    However, when the form is POSTed after being opened from the filesystem, HttpServlet has done some strange things:
    * the method has changed to GET
    * the content-length has changed to -1, and the content-type isn't set
    * the content-length and content-type HTTP headers are gone
    * there are no request parameters
    In both cases, I've verified that the browser is outputting the same HTTP (with the exception of the referer header, which is missing if the form was opened from the filesystem):
    POST / HTTP/1.1
    Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
    Accept-Language: en-us
    Content-Type: application/x-www-form-urlencoded
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
    Host: localhost:8002
    Content-Length: 41
    Connection: Keep-Alive
    Cache-Control: no-cache
    textarea=some+sample+text%0D%0A&submit=Ok
    Why is HttpServlet responding differently to effectively the same HTTP? The only difference is the Referer header -- I don't see why that should matter....
    Any help here would be much appreciated!
    Thanks,
    Gerald

  • R12 Custom Servlet Debugging

    Hello Gurus,
    I am a novice w.r.t. Java.
    We are on EBS R12.1.3.
    I have written a custom servlet that will generate BI Publisher output.
    Basically the servlet will then be used within Oracle Apps forms to generate the BI Publisher output.
    The servlet works fine locally using JDeveloper.
    I have now deployed the servlet in R12 server.
    When I try to execute the servlet in a browser, it hangs and does not show output. Probably there is some exception somewhere.
    Where is the exception logged?
    How can I debug the servlet? If I write System.out.println, then what location will it write on the R12 server?
    Regards,
    Jay

    http://www.google.com/search?q="public class"+"extends httpservlet"

  • Debugging Servlet

    Is it possible to debug a servlet which extends a class which extends "HttpServlet"? In our project, JDeveloper always want to run the class which extends "HttpServlet" directly and not the class which is based on this class.

    Currently it is a bug in JDeveloper 3.1.x. We will be fixing it.
    raghu

  • HttpServlet implements Runnable thread issue

    Hi,
    I have a servlet that implements Runnable. In web.xml I have set this servlet to load-on-start=1. In the init method of the servlet I have a thread that starts and basically runs forever. Now I am facing some issues and am not able to figure out what exactly is going on. I see exceptions in the log file and then my servlet stops. I have catch block all over but somehow whenever some exception occurs my Thread just stops and the servlet stops too I have to manually invoke the servlet so the Thread to start over again. Here is a code snippet. Now if any error occurs in insert() method somehow Thread just stops even though I am catching an exception. This servlet is not called from anywhere it just loads as soon as the app is deployed and then the thread keeps running and in my insert method I am reading some files and inserting into the database. How can stop the thread from being stopping and where at the top level I can add catch block to exactly print the error even though I am catching all the exceptions in the code itself. How can I keep my thread alive even after any exceptions.
    public class InsertData extends HttpServlet implements Runnable {
        Thread thread;
        public void init(ServletConfig config) throws ServletException {
            super.init(config);
            thread = new Thread(this);
            thread.setPriority(Thread.MIN_PRIORITY);
            thread.start();
        public void run() {      
            while (true) {                     
               insert();
               try {
                thread.sleep(10000);
              catch (InterruptedException ignored) { ; }
        private insert()
         try{
         catch(Exception exception)
        }Thanks

    Hi,
    After more debugging it turned out all the exceptions are handled correctly but some how after some time the thread just stops running in the servlet and even after invoking the servlet manually it doesn't start. Now asThread may take arround couple of minutes to finish but I am starting a new run every 1 minute which may lead to several Threads running a one particular time and as the time goes on thread increase also. So wondering if there's any limit on number of Threads to run at one particular time or is the Application Server removing any of these as in the code I don't see anything and no errors in the logs either.
    Is there a way to find out if a servlet is loaded. As in the Application Server control I do see a servlet loaded but I don't see any of the Thread running that calls the insert method.
    Also is it a good idea to have a Thread start in the init method that runs forever. Any other approach I can take. Writing a windows service or a cron job can be one but it's not in the scope. Other option I though of was using JMS and thru MDB I manually invoke the servlet and so I don't have to use Threads.
    Is there any other approach I can have by using servlet itself. Basically I want to call my servlet every lets say 30 minutes automatically.
    Thanks

  • NoClassDefFoundError extending class in separate JAR

    I have a class Foo which gets called from my servlet (extends HttpServlet) class. Both Foo and the servlet class are located in WEB-INF/classes and are deployed as part of the war file. Class Foo extends class Bar, which is a different .jar file located in the /WEB-INF/lib directory of the webapp. When I attempt to create an instance of Foo, I get the following exception:
    java.lang.NoClassDefFoundError: /general/client/common/beans/Bar
         at java.lang.ClassLoader.defineClass1(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
         at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
         at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1267)
         at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
         at server.DBServlet.createFoo(DBServlet.java:236)
         at server.DBServlet.processInput(DBServlet.java:333)
         at server.DBServlet.doGet(DBServlet.java:154)
         at server.DBServlet.doPost(DBServlet.java:205)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
         at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:419)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
         at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)
         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
         at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
         at java.lang.Thread.run(Thread.java:595)
    I'm running this on Windows, and found if I added the classpath the the jar file where the Bar class is located, that it worked fine. But my expectation is that the jar file should have been found because it is in the /WEB-INF/lib dir. There is a line the Tomcat docs that says:
    "Last, any JAR containing servlet API classes will be ignored by the classloader. All other class loaders in Tomcat 5 follow the usual delegation pattern."
    So maybe I need to do something special to load the Bar class, or there's something strange about the way the classes and jars are being loaded that I don't fully understand. I was able to instantiate the Bar class directly from w/in my servlet class, I just can't create an instance of the Foo class that is in /WEB-INF/classes along with the servlet class. So I'm not convinced that the Bar class or associated jar file isn't being loaded.
    I don't want to have to set the classpath explicitly, so I'm looking for advice on why I'm getting this exception and how best to dynamically load the classes I need.
    Thanks.
    ab.

    Thanks for hanging in there so far. Here's the specifics if you want to try to re-create this.
    I have a webapp, which contains the class DBServlet:
    package com.hm.dhca.server;
    public class DBServlet extends HttpServlet
    // Stuff
         public void processInput()
              Foo foo = new Foo();
    The webapp also contains the class Foo:
    package com.hm.dhca.common;
    import com.general.client.common.beans.Bar;
    public class Foo extends Bar
         public Foo()
              super();
              System.out.println("Foo");
    Both of the classes are located in webapps\DHCA\WEB-INF\classes...
    The Bar class is in a separate jar called HMJCommon.jar in the webapps\DHCA\WEB-INF\lib dir.
    Class Bar looks like this:
    package com.general.client.common.beans;
    public class Bar
         public Bar()
              System.out.println("Bar");
    DBServlet creates an instance of Foo as:      
    Foo foo = new Foo();
    Which throws the Exception:
    java.lang.NoClassDefFoundError: com/general/client/common/beans/Bar
         at java.lang.ClassLoader.defineClass1(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
         at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
         at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1267)
         at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
         at com.hm.dhca.server.DBServlet.processInput(DBServlet.java:236)
         at com.hm.dhca.server.DBServlet.doGet(DBServlet.java:154)
         at com.hm.dhca.server.DBServlet.doPost(DBServlet.java:205)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
         at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:419)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
         at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)
         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
         at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
         at java.lang.Thread.run(Thread.java:595)
    Clues:
    1. All three classes exist in the locations specified above - I have checked this manually.
    2. Within DBServlet, I can create an instance of Bar. But I cannot create an instance of Foo without the exception.
    3. If I move the Foo class from package com.hm.dhca.common to package com.hm.dhca.server (same package as DBSerlvet), everything works fine.
    4. If I modify Tomcat's classpath to include the HMJCommon.jar, it works fine (as previously discussed).
    Theory:
    I have a vague theory that what is happening is that two different webappclassloaders are loading the Foo and Bar classes, for whatever reason. As a result, they can't see each other, because neither is up the hierarchy tree from the other.
    This does not explain how I can instantiate Bar from DBServlet, but not Foo.
    Hope this helps. I think I've corrected previous mistake w/ removing too much from package naming. I'm resorting to the workaround in clue #3 for the moment. But it's not the correct solution, and it's showing that I don't really understand what's going on here.

  • Need a help about init action in HttpServlet

    I provided a new class MServlet which extends HttpServlet.
    I want to use the Mservlet class for my all servlets. My Mservlet must do some thiggs.
    For example i have a class:
    public class ListNews extends MServlet
    So now i need some things would be done automaticaly. For example
    response.setContentType("text/html;charset=windows-1257"); must be setted
    that i do nor need to write this line in all servlets?
    How i can do it?
    If i am using public void init method in servlet and put there the string
    response.setContentType("text/html;charset=windows-1257");
    This does not work
    Thanks

    Just a minor switch with the previous post...
    Use the MServlet to implement the doGet and doPost methods, make them final so that the subclasses can override them.
    Provide a 'responseSetup' method that sets things that you want.
    Provide your own 'doGetWork and doPostWork methods that the subclass overrides with its own stuff:
    public MServlet extends HttpServlet {
      public final void doGet(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
          responseSetup(response);
          doGetWork(request, response);
      public final void doPost(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
          responseSetup(response);
          doPostWork(request, response);
      //Default implementation does the same as HttpServlet.doGet()
      public void doGetWork(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
          super.doGet(request,response);
      //Default implementation does the same as HttpServlet.doPost()
      public void doPostWork(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
          super.doPost(request,response);
      //Do your init stuff here
      private void responseSetup(HttpServletResponse response) {
          response.setContenType("text/html;charset=windows-1257");
    }Then subclasses would use doGetWork and doPostWork like notmal HttpServlet subclasses would use doGet and doPost...

  • Hi, How to debug

    Can anyone, help or guide me how to use /h, and proceed with debug
    is there any notes?
    thanks

    HI
    First test your code with '/h' type in command window which shall take you to debug or by putting break points with F8. You test your program from code and then go to se30 performance analysis transaction and there you can know what are the drawbacks. Then go to SLIN transaction and do extended syntax check or from code in menu options where you have debugging -> extended check and the program id ready without error.
    As mentioned above after doing syntax check and extended syntax check you have to create a TEST PLAN. You have  to  test all possible Postive & Negative test cases.
    Test for division by zero if it involves calculation or code accordingly.
    Try to test for field overflows. If it involves sap script or smart forms  try to  print  outputs which have single page and also multiple page and which does not have any output at all.
    Test by leaving all parameters in selection screen blank.
    Test by  entering  wrong  values in selection screen and display a pop-up if the user enters wrong selection screen values.
    You can also do ABAP trace and SQL trace to make sure that your program is efficient.
    Debugging code/program.
    As mentioned above type /h in command line and try to execute the program. Another way is to set break-point at the function module or the required line and do single step execute or execute.  Once you finished debugging, you can select Delete to clear all the break points.
    Third option in certain  cases is to  check for sy-subrc <> 0  and proceed from there by  making it 0 by updating the sy-subrc in the debug editor  and  see how the program  behaves if the value is what  you enterd in the debug screen. For certain case  try to use WATCH POINT feature in debug  editor.

  • How solve  import javax.servlet.http.HttpServlet err import javax.servlet.

    Hi
    I am trying to compile one servlet code using commancd prompt and i get
    package javax.servlet.http does not exist import javax.servlet.http.HttpServlet;
    error for following code
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    public class SampleServlet extends HttpServlet
    public void saveToSession(HttpServletRequest request)
         String testparam = request.getParameter("testparam");
         request.getSession().setAttribute("testAttribute", testparam);
    please help me

    Try giving servlet..jar path in the class path variable

  • Extending Abstract Classes & Program Entry Point

    I have the following classes:
    CopServlet - which extends PercServlet
    PercServlet - abstract class which extends HttpServlet
    HttpServlet is the base class. I'm using Visual Age with a web.xml file that points to CopSerlet as the controller servlet. So my question is... When CopServlet gets called, where is my program entry point? My CopServlet class does NOT have a main method.

    When CopServlet gets loaded, its init() method is called. And when it is called via an HTTP request, either its doGet() or its doPost() method is called, depending on whether it was a GET or a POST request. That's how servlets work. The business about abstract classes is irrelevant to that.

Maybe you are looking for

  • Send Existing Sales Orders to another system

    hi experts!! I have a requirement to move all existing sales orders from one system to another. Please provide some hints on usage of IDOC_OUTPUT_ORDERS 1. we have to file NAST mandatory fields only or what else we need to code for complete generatio

  • Receiver determination step - Send context

    Hi Experts, I have understood from SAP library and others threads that send context in the receiver determination step is used to send value for the conditions we have added in ther receiver determination and fetch only receivers those satisfy the cr

  • How can I save transparency/inner glow effects when exporting to jpg?

    I'm very new to InDesign. I increased the noise levels in inner glow in 'Effects' to create a textured look to my document (I wanted a paper texture and found this method on Google) but when I exported to pdf or jpg, I realized that my transparency e

  • Why is the iPad so slow on the net?

    Internet (and phone etc) all on cable with nominal download speed of 60Mb (reduces a bit when going to computer via router). Have added wireless access point (rated 300Mb) so I can connect the iPad (bought last Friday). Connections all fine, but the

  • SPAD - Spool Server - Set Command Id.

    Dear Experts. I set up a printer. This printer spool write spool orders in the operating system. Orders are generated spool in background jobs running various programs. Example: zjob     Step 1 rsusr100n     Step 2 rsusr003     Step 3 resauselect1 So