File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Applets and the fly likes class not found exception in applet servlet communication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "class not found exception in applet servlet communication" Watch "class not found exception in applet servlet communication" New topic
Author

class not found exception in applet servlet communication

Nanditha Parripati
Greenhorn

Joined: Jul 20, 2009
Posts: 12
Hi Guys,

I am trying to create applet servlet communication program. I have created an applet which has the connetion to the servlet(through getConnection() method).And i have sendObject and receive Objects methods in it. I have created an servlet with doPost method in which i write my business logic.i created a html in which i gave my applet classname in codebase attribute. I am trying to run this program in the browser. It shows applet failed and when i open the browser console it shows class not found exception(applet class).

Can any one help me in this issues.

Thanks,
Nanditha.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41865
    
  63
Welcome to JavaRanch.

What does your applet tag look like? Also post the full error message. Are all required classes in the same directory as the HTML page?


Ping & DNS - my free Android networking tools app
Nanditha Parripati
Greenhorn

Joined: Jul 20, 2009
Posts: 12



This is my code where i am trying to execute from the browser.

in the browser i have given as http://localhost:8080/appletservlet/pipeline.html

in this url appletservlet is my project name.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41865
    
  63
Is the file PipelineApplet.class in the "appletservlet" directory?
Nanditha Parripati
Greenhorn

Joined: Jul 20, 2009
Posts: 12
yes pipelineApplet.class is in appletservlet directory.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41865
    
  63
Can you download the class file manually by typing http://localhost:8080/appletservlet/PipelineApplet.class in the browser?

Can you see the class file being accessed in the server log files? If so, does it result in a 200 or 404 response code?
Maki Jav
Ranch Hand

Joined: May 09, 2002
Posts: 435
Hi,

I compiled everything and run it in Tomcat , I got this in the java console:


Curses! Foiled again: java.io.FileNotFoundException: http://localhost:8080/appletservlet/PipelineServlet

Applet is loading perfectly, but the URL is not being found...


In older Tomcat, your applet could access the Servlet like this:

http://localhost:8080/appletservlet/servlet/PipelineServlet


but now make web.xml file placed in WEB-INF folder like:



<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>


<servlet>
<servlet-name>PipelineServlet</servlet-name>
<servlet-class>PipelineServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>PipelineServlet</servlet-name>
<url-pattern>/PipelineServlet</url-pattern>
</servlet-mapping>



</web-app>



And your applet is now accessing the servlet.

the output on Applet and tomcat comand prompt, once you press button is:


s--->!noooooopS zes kciT ehT

pressing again gives:


s--->The Tick sez Spoooooon!

...and you can continue as long as you want.



Morale of the story:


>>>Set your paths, fellas!


Thanks,

Maki Jav



Help gets you when you need it!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41865
    
  63
Instead of hard-coding the servlet URL in the applet code I'd make that a param tag inside of the applet tag (see http://java.sun.com/docs/books/tutorial/deployment/applet/html.html for details). That way you don't need to change any code in case the URL changes; just the HTML file.
Maki Jav
Ranch Hand

Joined: May 09, 2002
Posts: 435
Agreed Ulf


Maki Jav
Nanditha Parripati
Greenhorn

Joined: Jul 20, 2009
Posts: 12
hi,

i had given the path in web.xml as how you had given then too i am facing the same problem class not found exception. and i am running this project using eclipse ide


still not solved.
Maki Jav
Ranch Hand

Joined: May 09, 2002
Posts: 435
When using Eclipse IDE, you use it's built-in servlet class generator. go to NEW--> other --> type servlet and choose...

If you have had simply made this web application with your "own hands", it would have been much easier for you.

I wrote it all using notepad

I am attaching all the source and compiled classes in a zip file.

Place them in tomcat webapps folder and run tomcat manually.

If don't know how? Tell me where you jdk is installed.
I will send you batch file for starting tomcat. Or if you are using linux, tell me that too.

Your code is running perfectly.



Mak Jav
Nanditha Parripati
Greenhorn

Joined: Jul 20, 2009
Posts: 12
Hi,

Tanks a lot for helping me. I am not using linux. jdk is installed in c drive program files. i know how to start the tomcat. as you said in the previous discussion you had attached all the files in zip folder but i didn't see any attached files. please send me those and do me a favor.

Thanks,
Nanditha.
Maki Jav
Ranch Hand

Joined: May 09, 2002
Posts: 435
I did not see it myself

Trying again




No it does not attach files here. I will upload on my host place. Download it from here


Thanks,

Maki Jav
Nanditha Parripati
Greenhorn

Joined: Jul 20, 2009
Posts: 12
Hi,

Thanks a lot for your help. The application is working fine now. thanks thanks thanks a lot.

Regards,
Nanditha.
Maki Jav
Ranch Hand

Joined: May 09, 2002
Posts: 435
ok I sent you a pm too...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: class not found exception in applet servlet communication