• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Running an applet in Wicket 1.3.5

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I've been reading these forums for awhile now, and finally came across an issue that I couldn't find an answer to here, so I figured I might as well ask. I'm trying to add an applet to a Wicket HTML template, but every time I load the page while the webapp is running, the applet fails to load and throws a ClassNotFoundException. Here's the code that's failing :

I thought by placing the applet jar inside of src/main/webapp would be the proper way to get it working. So I did that, compiled it, and deployed it to my Tomcat servlet container. Sure enough, the jar was sitting next to the WEB-INF directory inside of Tomcat/webapps/<MY APP>/. But when I load the page in my browser, it fails. I've tried putting the extracted classes inside of there, and putting the jar in pretty much every directory I can think of. Nothing works. When I load a static html page with the same code (from a directory where the jar is sitting) then it works fine. I'm pretty confused as to what the problem is here...anybody have an idea?

Thanks for reading.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the URL of the page containing the applet? The jar file location is assumed to be relative to that URL. For example, if the URL is

http://localhost:8080/myApp/wicket/AppletPage

then the jar file would need to be in Tomcat/webapps/myApp/wicket.

You might also want to check Tomcat's access logs; it would show at which URLs the browser tries to find the jar file. (You may have to enable the access log in conf/server.xml.)
 
mark lar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As of right now, my URL to access the applet page is:

http://localhost:8080/<web app name>/app/

This is because of the way my web.xml is setup:



However, there is no 'app' folder inside of Tomcat/webapps/<web app name> directory. Moreover, I can't seem to directly access a class from the URL, something like
http://localhost:8080/<web app name>/app/<path to class>
always results in a 404. What do you think?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In that case you need to use a CODEBASE attribute in your applet tag - it allows you to use a different directory for your applet resources (like classes and jar files) than the document directory: http://java.sun.com/j2se/1.4.2/docs/guide/misc/applet.html
 
mark lar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does the codebase attribute need to be a URL that can directly access the jar? So something like

codebase="http://localhost:8080/<jar name>.jar" ?

Or do I need to extract all of the individual classes from the jar and make them URL accessible? In the past, when I used a plain old apache server that brought up HTML with PHP in it, then each file inside of my /var/www/html/<app name> directory was accessible through the URL. How exactly do you go about that in Tomcat?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Codebase points to a directory, not a file. In that directory can be loose class files, but it's much more convenient to put your jar file there that you specify in the archive attribute.

All files you put inside your webapps/myApp directory should be accessible through an URL (as long as they aren't in webapps/myApp/WEB-INF, of course).
 
mark lar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So if I have a jar sitting inside of Tomcat/webapps/myapp, I should be able to type in

http://localhost:8080/<My App>/<jar name>.jar

And not get a 404? If that's not working, is there some Tomcat configuration that needs to take place?

Btw, thanks a lot for reading / answering my questions.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that should work. Maybe the file has permissions set that prevent it from being served?
 
mark lar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've got it working! I ended up having to set codebase="http://localhost:8080/<App name>" and the applet now loads! Thanks for all of your help. This won't be an issue when it's deployed to a live server will it?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That depends on what you mean by "issue" ... if the applet is on a page that is mapped to "/app/" (or something similar) like in this example, then yes, you need the codebase attribute.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic