aspose file tools*
The moose likes Servlets and the fly likes java.io.FileNotFoundException: http://localhost:8080/MyServlets/MyServlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "java.io.FileNotFoundException: http://localhost:8080/MyServlets/MyServlet" Watch "java.io.FileNotFoundException: http://localhost:8080/MyServlets/MyServlet" New topic
Author

java.io.FileNotFoundException: http://localhost:8080/MyServlets/MyServlet

James Gadbury
Greenhorn

Joined: Mar 20, 2009
Posts: 24
Hi everyone,

I have been experiencing problems with my applet / servlet / DB system for some days now (I even had it working at one point, but managed to mess it up again...!). I would be very grateful if someone could help to get my little project back on track - it's driving me insane at present! For those that saw my previous thread, after a lot of confusion and experimentation, I decided to start new applet and servlet projects, to try to tidy up the code, use packages (as advised here - I'm using 'jpg1980') and generally start a-fresh... but now, I have different errors. Despite having done a lot of research (and experimentation with) WAR project structure, web.xml structure, classpaths, servlet tutorials etc., I cannot seem to resolve these problems. I'm hoping someone can help me get my software project functioning again.

So, the error:

java.io.FileNotFoundException: http://localhost:8080/GTDBServlets/TunesListServlet
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at jpg1980.HomeJPanel.displayTunes(HomeJPanel.java:163)
at jpg1980.HomeJPanel.refreshListButtonActionPerformed(HomeJPanel.java:186)
at jpg1980.HomeJPanel.access$1(HomeJPanel.java:184)
at jpg1980.HomeJPanel$2.actionPerformed(HomeJPanel.java:96)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


I am using XAMPP 1.7 (includes Apache, MySQL 5 and Tomcat 6) on Windows XP (SP3). The servlet project is placed here: C:\Program Files\XAMPP\htdocs\GTDBServlets. htdocs is the right location for the servlet project directory as I have had my system (as well as demo Sevlets) up and running using this location).

So, to clarify: TuneListServlet is the name of my servlet class in the project (directory) called GTDBServlets, GTDBAppletMain is the name of my applet class in the project (directory) GTDBApplet and jpg1980 is the package name for the applet and servlet code.

Applet Code:
GTDBAppletMain - http://java.pastebin.ca/1368047 - the Applet code
HomeJPanel - http://java.pastebin.ca/1368049 - 'home page' (main) GUI

Servlet Code:
TuneSimple - http://pastebin.ca/1368052 - the serialized object passed between Servlet and Applet
TunesListServlet - http://pastebin.ca/1368054 - the Servlet code
TunesListAccessor - http://pastebin.ca/1368056 - helps out with the SQL connection / query

Other files
web.xml - http://pastebin.ca/1368057
Applet .classpth - http://pastebin.ca/1368061
Servlet .classpath - http://pastebin.ca/1368060

Whilst debugging, it is suggested the problem is at the following line (line 70 of the GTDBAppletMain code, see here http://java.pastebin.ca/1368047):



I have consulted the Tomcat logs (in C:\Program Files\XAMPP\Tomcat\logs), but there is nothing recent (i.e. a debug my code, run through until it crashes but the most recent log was an hour before).

Please could someone kindly help me get this up and running? Thanks for your time. Regards,

James
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Crossposted: http://forums.sun.com/thread.jspa?threadID=5375282&tstart=0
Please don't do that: http://faq.javaranch.com/java/BeForthrightWhenCrossPostingToOtherSites
James Gadbury
Greenhorn

Joined: Mar 20, 2009
Posts: 24
Sorry, I didn't mean to cause offence - I won't do it again. Needless to say, I was intending to add any resolution found to both posts for any others in my same position to refer to.
James Gadbury
Greenhorn

Joined: Mar 20, 2009
Posts: 24
I have resolved the problem - it seems so simple now!

It was the web.xml file... took so long to find because I had read some documentation and I was convinced it was right.

Before (incorrect):



After (correct):




So, it was the URL-pattern. I was obviously mistaken; before, I thought the url-pattern had to be the project name, not the class name.

The bizarre thing is, the change took effect when I changed the web.xml file in my project within Eclipse (the Eclipse workspace is on a different disk partition to my web server...(?!). When I changed the web.xml file for the project on the webserver, under ..XAMPP\htdocs\GTDBServlets\WEB-INF, it made no effect. Does anyone know why?

I will update the other post I made on Sun's forums with a link to this post.
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 605

James Gadbury wrote:

The bizarre thing is, the change took effect when I changed the web.xml file in my project within Eclipse (the Eclipse workspace is on a different disk partition to my web server...(?!). When I changed the web.xml file for the project on the webserver, under ..XAMPP\htdocs\GTDBServlets\WEB-INF, it made no effect. Does anyone know why?

I will update the other post I made on Sun's forums with a link to this post.


You need to re-look at how you have deployed your application. Are you using an integrated eclipse workbench and do you run the application from within it?

If you are staring the web server separately then changing under ..XAMPP\htdocs\GTDBServlets\WEB-INF should have an effect!

Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
James Gadbury
Greenhorn

Joined: Mar 20, 2009
Posts: 24
Thanks Sam - just to confirm that I am using a Tomcat plugin (by sysdeo v3.2.1, here: http://www.eclipsetotale.com/tomcatPlugin.html).

It has taken me a little while to get settled with applet / servlet development in Eclipse using the Tomcat plugin, but (dare I tempt fate?) things are going well now. I think the variety of error messages that a newbie can receive initially can be bewildering, but I am starting to learn what a few of them mean now and I have a 'feel for it'

Thanks to you and everyone else helping out on these forums.
 
 
subject: java.io.FileNotFoundException: http://localhost:8080/MyServlets/MyServlet