facebook

Unable to debug doGet() and doPost() methods of servlet

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #296943 Reply

    LathaAdj
    Member

    i am developing a web application on Webshpere 6.1. I have configured the connector for webshpere in MyEclipse.

    When i am debugging, servlet debugging gets started fine. But after servlet init() method, application execution is getting stopped. I provided the application url in the MyEclipse Web browser and clicked on “Go to selected URL” button in debug Perspective. But break points in doPost() and doGet() method are never getting hit. Because of this issue i am not able to debug my application. Please let me know how to resolve this problem.

    #296950 Reply

    support-joy
    Member

    LathaAdj,

    Have you implemented protected void service()? Can you PM me your servlet?

    #296965 Reply

    LathaAdj
    Member

    Joy,
    Thanks for your prompt response.

    Here is the code for servlet

    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    package com.adjacent.app.workplaceex40;

    import java.io.*;

    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import java.io.FileInputStream;
    import org.apache.commons.fileupload.servlet.ServletFileUpload;
    import org.apache.log4j.Logger;
    import org.apache.log4j.Level;
    import org.w3c.dom.Document;

    /**
    * This servlet initializes configuration data, examines the current request,
    * and spawns the appropriate workflow object.
    *
    *
    *
    */
    public class Connector extends HttpServlet
    {
    Document _document = null;
    String _wcmApiConfig = null;
    Document _mimeType= null;
    String _viewerHost =null;
    String _viewerPort = null;
    String _uploadDirectory = null;
    String _viewerApplication = null;
    String _javaSecurityAuthLoginConfig = null;
    String _javaNamingFactoryInitial = null;
    String _javaNamingProviderUrl = null;
    String _ConfigUrl = null;
    String _SSLConfigUrl = null;
    String _filenetConnectionProviderUri = null;
    String _domainName = null;

    public void init(ServletConfig sc) throws ServletException
    {
    try
    {
    //Retrieve configuration parameters

    ServletContext context = sc.getServletContext();
    _viewerHost = sc.getInitParameter(“viewerHost”);
    _viewerPort = sc.getInitParameter(“viewerPort”);
    _uploadDirectory = sc.getInitParameter(“UploadDirectory”);
    _viewerApplication = sc.getInitParameter(“viewerApplication”);
    _javaSecurityAuthLoginConfig = sc.getInitParameter(“java.security.auth.login.config”);
    _javaNamingFactoryInitial = sc.getInitParameter(“java.naming.factory.initial”);
    _javaNamingProviderUrl = sc.getInitParameter(“java.naming.provider.url”);
    _ConfigUrl = sc.getInitParameter(“com.ibm.CORBA.ConfigURL”);
    _SSLConfigUrl = sc.getInitParameter(“com.ibm.SSL.ConfigURL”);

    _filenetConnectionProviderUri = sc.getInitParameter(“filenet.connection.provider.uri”);
    _domainName = sc.getInitParameter(“filenet.domain.name”);

    if (_uploadDirectory == null)
    _uploadDirectory = “.”;

    if (_wcmApiConfig == null)
    _wcmApiConfig = context.getRealPath(“/”) + “/” + sc.getInitParameter(“WcmApiConfig”);

    //set System.Property

    System.setProperty(“java.security.auth.login.config”, _javaSecurityAuthLoginConfig);
    System.setProperty(“java.naming.factory.initial”, _javaNamingFactoryInitial);
    System.setProperty(“java.naming.provider.url”, _javaNamingProviderUrl);
    System.setProperty(“com.ibm.CORBA.ConfigURL”, _ConfigUrl);
    System.setProperty(“com.ibm.SSL.ConfigURL”, _SSLConfigUrl);

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();

    if (_document == null)
    {
    String configXml = context.getRealPath(“/”) + “/” + sc.getInitParameter(“ConfigXml”);
    FileInputStream inputStream = new FileInputStream(configXml);
    _document = builder.parse(inputStream);
    }

    if (_mimeType == null)
    {
    String mimeTypePath = context.getRealPath(“/”) + “/” + sc.getInitParameter(“MimeTypeXml”);
    FileInputStream mimeTypeStream = new FileInputStream(mimeTypePath);
    _mimeType = builder.parse(mimeTypeStream);
    }
    super.init(sc);
    }
    catch(Exception e)
    {
    }
    }

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

    public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
    {
    Logger logger = Logger.getLogger(com.adjacent.app.workplaceex40.Connector.class);
    try
    {
    //boolean isUploadRequest=ServletFileUpload.isMultipartContent(req); // saves digging op=add out of the multipart…

    ServletContext context = getServletContext();

    //if ((isUploadRequest))// || ((req.getParameter(“op”) != null)))
    //{
    // DocumentWorkFlow docWorkFlow = new DocumentWorkFlow(context, _document, _wcmApiConfig, _uploadDirectory);
    // docWorkFlow.doWork(req, res);
    //}
    //else
    //{
    ConnectorWorkFlow conn = new ConnectorWorkFlow(context, _document, _mimeType, _wcmApiConfig,_viewerHost, _viewerPort, _viewerApplication, _filenetConnectionProviderUri, _domainName, _uploadDirectory);
    conn.doWork(req, res);
    //}
    }
    catch(Exception e)
    {
    if (logger.isEnabledFor(Level.ERROR)){logger.error(e);}
    }
    }

    }
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

    #297021 Reply

    support-joy
    Member

    Hey LathaAdj,

    Your servlet code looks good. Can you clarify if you are able to run your application in the normal run mode? And if the problem is only when trying to debug. MyEclipse comes with Sandbox Tomcat. Can you deploy your application on tomcat and see if you are able to deploy and run, next try the debug.
    Also, please copy and paste your installation detail. You can find it from MyEclipse > Installation Summary > Installation Detail.

    #297059 Reply

    LathaAdj
    Member

    Yes, i am able to run appln in run mode.

    Here is the Installation details
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    *** Date:
    Tuesday, March 31, 2009 9:44:42 PM PDT

    ** System properties:
    OS=Windows2003
    OS version=5.2
    Java version=1.5.0_17

    *** MyEclipse details:
    MyEclipse Enterprise Workbench
    Version: 6.6.0
    Build id: 6.6.0-20081015

    *** Eclipse details:
    Eclipse Platform

    Version: 3.3.2
    Build id: M20080221-1800

    Eclipse Platform

    Version: 3.3.3.r33x_r20080129-_19UEl7Ezk_gXF1kouft
    Build id: M20080221-1800

    Eclipse Java Development Tools

    Version: 3.3.2.r33x_r20080129-7o7jE7_EDhYDiyVEnjb1pFd7ZGD7
    Build id: M20080221-1800

    Eclipse Plug-in Development Environment

    Version: 3.3.3.r33x_r20080129-7N7M5DQVIA_6oJsEFkEL
    Build id: M20080221-1800

    Eclipse Graphical Editing Framework

    Version: 3.3.2.v20080129
    Build id: 20080221-1602

    Eclipse RCP

    Version: 3.3.3.r33x_r20080129-8y8eE9UEUWI6qujeED0xT7bc
    Build id: M20080221-1800

    Eclipse startup command=-os
    win32
    -ws
    win32
    -arch
    x86
    -showsplash
    E:\Eclipse\eclipse\\plugins\org.eclipse.platform_3.3.3.r33x_r20080129\splash.bmp
    -launcher
    E:\Eclipse\eclipse\eclipse.exe
    -name
    Eclipse
    –launcher.library
    E:\Eclipse\eclipse\plugins\org.eclipse.equinox.launcher.win32.win32.x86_1.0.3.R33x_v20080118\eclipse_1023.dll
    -startup
    E:\Eclipse\eclipse\plugins\org.eclipse.equinox.launcher_1.0.1.R33x_v20080118.jar
    -vm
    C:\Program Files\Java\jre1.5.0_17\bin\client\jvm.dll

    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

    I have couple of questions
    (1) In the debug view, suspended thread stack trace; following line is listed: “Source not found for ServletWrapper(ServletWrapper).init(ServletConfig) line: 220”. It does show doGet() method in the threads. Does it have any thing to do with not hiting break point in doGet() method.

    (2) What is the correct way of accessing servlet in debug perspective? Should i be using “Internal Web browser” or “MyEclipse Web Browser”?

    #297067 Reply

    support-joy
    Member

    LathaAdj,

    Thanks for the installation details. How are you deploying your application? As a WAR or EAR? Refer http://www.myeclipseide.com/documentation/quickstarts/websphere6/#eardeployment. Can you try by wrapping your web application around an EAR and deploy.

    1. It could be a possibility. Can you investigate this ->

    “Source not found for ServletWrapper(ServletWrapper).init(ServletConfig) line: 220”.

    What is it referring at line 220?
    2. It doesn’t matter what web browser you are using, be it internal(MyEclipse web browser) or external. If you are running your application in debug mode, once it hits the breakpoint, it will automatically direct you to the debugger. Also it depends on your configuration under Window > Preferences > General > Web Browser.

    #297068 Reply

    LathaAdj
    Member

    I deployed appln as EAR

    As you can see in my servlet code, there is no line 220 in it. Not sure what this message actually mean.

    I have tried using both web browsers but no luck.

    thanks,
    Latha

    #297074 Reply

    support-joy
    Member

    Latha,

    I don’t have websphere6.1 with me. I am able to run and debug servlet using tomcat/jboss. Can you check if you can run/debug your servlet using tomcat? I will try to get a dev team member assist you on this.

    Also line 220 could be referred in some other file. Can you double click on the stack trace and see, where this points to?

    #297076 Reply

    support-joy
    Member

    Latha,

    I have news for you. I have downloaded and configured Websphere 6.1 with MyEclipse and I am able to debug a servlet using MyEclipse. Please refer to the attached screenshot. The only difference is that I am using MyEclipse 7.1.1 and you are using MyEclipse 6.6. Try to download MyEclipse 7.1.1 and install in a separate location than your 6.6 and create a new workspace. See if you are able to debug.

    Attachments:
    You must be logged in to view attached files.
    #297116 Reply

    rmcvay
    Member

    @LathaAdj wrote:

    As you can see in my servlet code, there is no line 220 in it. Not sure what this message actually mean.

    I believe that is a reference to line 220 in ServletWrapper.java, not in your code.

    #297123 Reply

    LathaAdj
    Member

    Ray,
    Error is “Source not found for ServletWrapper(ServletWrapper).init(ServletConfig) line: 220”. Is it possible i am missing some jar file which contains this ServletWrapper class in it? FYI – I don’t have any compilation errors.
    thanks,
    Latha

    #297135 Reply

    support-joy
    Member

    Latha,

    Can you check if you have servletwrapper class in your application? Else download the relevant .jar file. You can use docjar.org to locate your jar file. I have one more question, when you run the application in the debug mode, does it invoke the debugger? If yes, add breakpoints in init method, I need you to keep pressing [F5] till you reach your breakpoint. Also I would recommend you to add System.out.println() statements in doGet() and doPost() and see, if you can see these in the console window.
    I have downloaded MyEclipse 6.6 and I am able to debug servlet. It hits the breakpoint just fine.
    Since this is a coding issue, I would recommend you to cross post your queries to Java servlet forums. You may get more help there.

    #297169 Reply

    rmcvay
    Member

    It would be a referenced dependency. The source would be in the J2EE sources, which are not included in ME or any other IDE AFAIK.

    #297181 Reply

    support-joy
    Member

    Ray, you are right, the source would be in a J2EE resource rather than ME.

    Thanks.

Viewing 14 posts - 1 through 14 (of 14 total)
Reply To: Unable to debug doGet() and doPost() methods of servlet

You must be logged in to post in the forum log in