Win a copy of Microservices in Action this week in the Web Services forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

class not found exception in applet servlet communication  RSS feed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 42974
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Nanditha Parripati
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



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
Rancher
Posts: 42974
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the file PipelineApplet.class in the "appletservlet" directory?
 
Nanditha Parripati
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes pipelineApplet.class is in appletservlet directory.
 
Ulf Dittmer
Rancher
Posts: 42974
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 473
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


 
Ulf Dittmer
Rancher
Posts: 42974
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 473
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Agreed Ulf


Maki Jav
 
Nanditha Parripati
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 473
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 473
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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

Regards,
Nanditha.
 
Maki Jav
Ranch Hand
Posts: 473
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok I sent you a pm too...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!