Results 1 to 8 of 8
  1. #1
    shall is offline Senior Member
    Join Date
    Apr 2012
    Posts
    199
    Rep Power
    0

    Default Debugging Dynamic Web App in Eclipse

    Hello,

    I was able to successfully access an example java application on a Tomcat v7 web server.

    Now, I want to be able to the same thing for an application that I created (called PuzzleApp).

    I initially tried to do so by updating the jnlp file and replacing the jar file with my PuzzleApp application. When I try to access the file using firefox, Webstart starts up, but then vanishes after a short while with no exception dialog box being displayed.

    I need to debug what's going on between the Tomcat server and my application, but I don't know how to set up that debug environment in Eclipse.

    Could some please point me in the right direction.

    Thanks,
    Stephen
    Last edited by shall; 06-21-2012 at 08:38 PM.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,039
    Rep Power
    20

    Default Re: Debugging Dynamic Web App in Eclipse

    I doubt you can, since the app isn't starting up.
    Does your app have any logging in it?
    What happens when you try and start your app from the command line (I'm assuming it's a jar)?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    shall is offline Senior Member
    Join Date
    Apr 2012
    Posts
    199
    Rep Power
    0

    Default Re: Debugging Dynamic Web App in Eclipse

    Thanks for the reply.

    It runs fine in Netbeans, but, just now when ran it from the command line the following exception occurs: Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: URI is not hierarchical

    The following code is at that line:
    Java Code:
    doc = docBuilder.parse(new File(bookXmlURI));
    bookXmlURI as a string is (as run in Netbeans):
    file:/C:/Users/earth/Documents/NetBeansProjects/PuzzleApp/build/classes/puzzleapp/PuzzlePieces/PuzzlePiecesInfo.xml

    The absolute path may be a problem for the jar file.

    How do I correct the problem?

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,039
    Rep Power
    20

    Default Re: Debugging Dynamic Web App in Eclipse

    You cannot access files in a jar file using the normal file system methods, as it is not a file system.
    You need to access them using the <class>.getResource() or getResourceAsStream() methods.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    shall is offline Senior Member
    Join Date
    Apr 2012
    Posts
    199
    Rep Power
    0

    Default Re: Debugging Dynamic Web App in Eclipse

    Actually, I did use getResource. Here's some more of the code:

    Java Code:
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder;
    
    docBuilder = docBuilderFactory.newDocumentBuilder();
    
    URL bookXmlURL = this.getClass().getResource(resourceName);
    
    URI bookXmlURI = bookXmlURL.toURI();
    
    doc = docBuilder.parse(new File(bookXmlURI));

  6. #6
    shall is offline Senior Member
    Join Date
    Apr 2012
    Posts
    199
    Rep Power
    0

    Default Re: Debugging Dynamic Web App in Eclipse

    Yahoooooo! (and I don't mean the website).

    Thanks a lot. you pointed me in the right direction.

    I replaced that big block of code above with the following:
    InputStream is = getClass().getResourceAsStream(resourceName);
    doc = docBuilder.parse(is);

    After that modification, webstart was able to run the puzzleapp.

    Running Jar files just do not act the same way as running class files.

    Stephen
    Last edited by shall; 06-21-2012 at 10:23 PM.

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,039
    Rep Power
    20

    Default Re: Debugging Dynamic Web App in Eclipse

    Yep, it was because you were taking the URI for the resource (which points to a thing in the jar file) and then hand that to a File, which will look for it on the file system.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  8. #8
    shall is offline Senior Member
    Join Date
    Apr 2012
    Posts
    199
    Rep Power
    0

    Default Re: Debugging Dynamic Web App in Eclipse

    Thanks for the explanation.

Similar Threads

  1. Eclipse Debugging Help
    By kuttam in forum Eclipse
    Replies: 5
    Last Post: 12-02-2011, 09:28 AM
  2. Debugging with Eclipse 3.4.0
    By edcaru in forum New To Java
    Replies: 2
    Last Post: 11-07-2008, 06:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •