facebook

Attaching source for debugging [Closed]

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #202713 Reply

    etornick
    Member

    I have a null ptr exception somewhere in my tomcat 5 when I run my project. I know the problem does not have to do with MyEclipse but I am having some issues with attaching source for debugging.

    Here is the problem. I can attach source to a jar file by following the directions in the help.

    But in this case, there are 2 things I dont understand. I don’t have a single tomcat 5 jar file in the build path. I actually don’t know how this is being resolved. Perhaps the myeclipse integration with tomcat5 does this for me behind the scenes.. (it would be nice to know what is going on here)

    But anyway I downloaded the src.zip file for tomcat and I dont know how to attach this so I can step thru the code to figure out why tomcat is throwing the exception.

    Also when you have src spread out in nested subdirectories all over the zip file (like in tomcat) how do you specify the path to the src.

    Thanks,
    Ed

    #202715 Reply

    Riyad Kalla
    Member

    Hey Ed,
    If you downloaded Tomcat’s source, then when you unzip it you should see 5 top level directories. The one you want to attach to are:

    
    jakarta-servletapi-5/jsr152/src/share
    

    for JSP code and

    
    jakarta-servletapi-5/jsr154/src/share
    

    for servlet code. I have to uncompress this into a “src/” directory under my Tomcat install as I don’t know how to reference a dir inside of a JAR in a URL.

    Once you’ve done this, select the JAR in your build path (probably jsp-api.jar and servlet-api.jar from Tomcat 5) and attach a source folder to them. You should be good to go.

    As far as MyEclipse resolving things for you, I don’t know how you are able to compile Servlet classes without the servlet-api.jar in your build path, atleast I can’t. What kinds of files are you working on?

    #202720 Reply

    etornick
    Member

    Riyad:

    When I look at the project properties/build path I don’t see a jsp-api.jar or servlet-api.jar.

    I am not working on anything difficult. I created a web project with the myeclipse, added struts capabilities and am working on some nested tags code.

    Perhaps it is finding tomcat because on my machines environment variables I have (win2k) , there is a definition for CLASSPATH which has one entry for jakarta-tomcat5.0.18/common/lib

    Perhaps I should remove this and just have it set by myeclipse???

    Should I do this and then explicitly add servlet-api.jar and jsp-api.jar? Then attach the source as you described.

    Thanks,
    Ed

    #202728 Reply

    Riyad Kalla
    Member

    Ed,
    Its usually a good idea (IMO) to not have a classpath env variable. I set it on a application per application basis. But the reason you probably don’t need/hvae these in your path is because you are working exclusively with struts and all the necessary classes are in struts.jar. So for runtime you need the servlet and jsp APIs, which Tomcat provides. But for compilation you only need the struts classes and taglibs (all of which MyEclipse provides for you).

    So now I need to ask you what it is you want to step into while you are debugging. The only servlet in Struts is the root ActionServlet that acts like a traffic cop. If you want to trace into it or any other Struts files (ActionForm, Action, etc.) you will need to get the source for Struts and attach it to the struts.jar file.

    If you plan to develop some servlets and want to trace into them, then yes add servlet-api.jar and attach source to it as I’ve posted above. As it stands now since you are able to build/run your project, it seems you are in a totally Struts environment, so maybe all you need/want is the struts source to attach?

    #202732 Reply

    etornick
    Member

    I removed the classpath variable as you suggested.

    As for what I am doing…

    Everything is working fine except I wanted to use a library of nested tags from a site called http://www.keyboardmonkey.com/index.jsp

    There is an excellent nested tag library that I wanted to use with my project.

    When I try any of the demos it has an exception.

    ==============================================
    exception

    org.apache.jasper.JasperException: Null attribute name
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

    root cause

    java.lang.NullPointerException: Null attribute name
    org.apache.jasper.runtime.PageContextImpl.findAttribute(PageContextImpl.java:495)
    org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:874)
    org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:934)
    org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:286)
    org.apache.struts.taglib.nested.bean.NestedWriteTag.doStartTag(NestedWriteTag.java:93)
    org.apache.jsp.MonkeyStruts_jsp._jspx_meth_nested_write_0(MonkeyStruts_jsp.java:593)
    org.apache.jsp.MonkeyStruts_jsp._jspService(MonkeyStruts_jsp.java:170)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)

    ============================================

    So I tried everything i could think of to see why there was a null pointer. I thought I could use MyEclipse to debug this to have some idea of what is wrong.

    Perhaps it is something as simple as a bad property file in the demo code. This seems to be a problem with j2ee development in general, sometimes you get an exception in some deeply nested code in a library you are using and the message gives you no idea what is wrong

    I found out exactly where the exception occurs but now I seem to have a problem attaching source to the code.

    For example I a now stepping thru the threads and if there is no source available, I find the java class that is being used , locate the jar file in the library (in this case it is in tomcat 5), and I put the jar file in my build path and then attach the source there. (Project -properties – build path)

    So I thought now I was going to make progress and step into the line that is throwing the exception (somewhere in tomcat) and see what is going on.

    The only problem now is that even after I put the jar in the build path and attach the source when I step into the code Myeclipse says “no source found”

    For example I wanted to step into StandardHostValve.class, so I located the jar that had this and added it to the build path, then I located the directory in tomcat source that had the .java file and attached that source directory.

    But when I reach the code, it still says the source is not found.

    Do you know why this is happening?

    Thanks,
    Ed

    #202736 Reply

    Riyad Kalla
    Member

    Ed,
    This could certainly be happening if you are attaching the source incorrectly… so for example say you have the JAR (of classes) that looks like this:

    
    /org
      /apache
        /struts
          StandardHostValue.class
    

    and lets say you want to step into StandardHostValue… if you then scour through the src you uncompressed on your hard drive, and find it in the corresponding directory:

    
    /org
      /apache
        /struts
          StandardHostValue.java
    

    and then select the “struts” directory to attach to, this won’t work as you need to attach the source folder, directory or otherwise at the same root level of the JAR you are attaching it to. So in this case, to get resolution to work, you need to attach to you Struts.jar, the directory that contained the root level “org” source directory.

    So lets say your actual directory structure looked like this for the source:

    
    /tomcat5
      /src
        /org
          /apache
            /struts
              StandardHostValue.java
    

    If you select you struts.jar and want to attach source to it, you will have to navigate to the /tomcat/src directory and attach THAT (not the /org) directory to the JAR. Once you have done this, you should be able to step correctly into the struts source code.

    If this is what you did and you are still having problems, then let me know which JAR file the StandardHostValue is in, and I’ll try and reproduce the problem on my end.

    Also please note that your original stack trace above with the NPE actuall was occuring in a jasper package and not either of the servlet-api or jsp-api packages. So if you were trying to step down to figure out what was null, you will have to mount the jasper jar and attach to it the source code for the jasper compiler.

    #202743 Reply

    etornick
    Member

    Riyad:

    Thanks again. You were absolutely right. I was not attaching the source properly.

    Looks like I am now able to into the code where this exception is coming from.

    ED

    #202744 Reply

    Riyad Kalla
    Member

    Hey glad to hear it. Happy debugging.

Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: Attaching source for debugging [Closed]

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