aspose file tools*
The moose likes Applets and the fly likes Deploying Applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Deploying Applet" Watch "Deploying Applet" New topic
Author

Deploying Applet

Lance Manion
Greenhorn

Joined: May 16, 2011
Posts: 12
I have been mulling over this problem for a whole day and I'm unable to find any documentation or posts that help.

I have in folder C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\sample
index.html
Ship.jar
ship.gif

In index.html


ship.gif displays fine, but ship.jar gives me this error:


When I execute the html page from file:///C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%207.0/webapps/sample/index.html, it works fine, but when I use tomcat, http://localhost:8080/sample/, it fails.

Is this an issue with tomcat 7?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41526
    
  53
The first thing to do is to pay attention to tiny details; the error message says "class Ship.ShipGame.class not found". Well, the class is definitely not called "Ship.ShipGame.class"; I'm prepared to guess it's called "Ship.ShipGame". So the value of the "code" attribute is not correct: it takes a class name, not a file name.

That's probably not the source of the problem, though, especially as it works locally. Make sure that the permission on the jar file are set to allow download (in other words, public access). You could also check Tomcat's access logs in order to see which files the JVM is trying to download; that may contain a clue. If your Tomcat does not write access logs you need to enable that in the server.xml file.


Ping & DNS - my free Android networking tools app
Lance Manion
Greenhorn

Joined: May 16, 2011
Posts: 12
I have written the html applet code in every way I could think of, packed and unpacked in a jar. This is a jar I have used in the past, I even have it posted on a public server with the exact same html code.

If there are no tomcat settings or paths to worry about then it seems my only option is to try another version of tomcat.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

No, the chance that your configuration is wrong is about 99.9999% and the chance that there's a bug in Tomcat is about 0.0001%.

You'll notice that you've provided a relative URL (archive="Ship.jar") in your applet tag. That URL is relative to the URL of the page it's embedded in, and I don't recall you ever mentioning what the URL of that page is. Let's start from there.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41526
    
  53
Are you saying you have made sure that the permissions are set to allow public access, and that there is precisely nothing unusual in the Tomcat access logs?
Lance Manion
Greenhorn

Joined: May 16, 2011
Posts: 12
Lance Manion wrote:I have in folder C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\sample
index.html
Ship.jar
ship.gif

In index.html



The URL of my Tomcat server is http://localhost:8080/sample/ (index.html)

Ship.ShipGame.class is in the jar, Ship/ShipGame.class.

I am able to download the jar from http://localhost:8080/sample/Ship.jar, are there any other permissions I should check? I'll take a look at the access logs tomorrow.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16014
    
  20

Welcome to the JavaRanch, Lance.

You've got a lot to learn yet. Your package name violates standards on capitalization and unless I'm just doing my normal early-morning hallucinating, you've given a jar file name the file suffix ".class".

None of those offenses would necessarily cause your attempt to run a servlet to outright fail, but they do undercut your position when you assert that it's Tomcat's fault. And if you're using IDEs or other software development tools, those tools may not operate as desired when you're not adhering to the standards.


Customer surveys are for companies who didn't pay proper attention to begin with.
Lance Manion
Greenhorn

Joined: May 16, 2011
Posts: 12
I think I found the issue. Whenever I download Ship.jar, it is 12kb, but the current one in webapps/sample is 1,418kb.

If I'm manually putting files in to sample, how do I get tomcat to update this?

I'm starting the server with bin/tomcat7.exe, would this cause any problems?
Lance Manion
Greenhorn

Joined: May 16, 2011
Posts: 12
I renamed the package, removed the file extension, reinstalled tomcat. Access logs don't say much, just a bunch of GETS.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16014
    
  20

I think I was doing the early-morning hallucination or something, since I can plainly see you named your applet jar "Ship.jar" in the latest page. But never mind.

Your file sizes are close enough that I think the discrepancy is more likely in how the various apps do their byte-counting than actually having a problem with the downloaded jar.

I think you're close enough. However, I'm out of practice on applets, most of the people in this forum probably are too. So I'm moving this thread to the Applets Forum, since there doesn't seem to be anything really Tomcat-specific to discuss now.
Wolfgang Tintemann
Ranch Hand

Joined: Sep 11, 2010
Posts: 65

You say you enter : http://localhost:8080/sample/

Do you do this in Eclipse or in the stand-alone browser ?


Time isn't Money, Money is Time.
The man who works looses his time ( spanish proverb )
Lance Manion
Greenhorn

Joined: May 16, 2011
Posts: 12
I do not use any IDE.
Wolfgang Tintemann
Ranch Hand

Joined: Sep 11, 2010
Posts: 65

Is your application deployed correctly.
I will say : do you see it if you enter http://localhost:8080/manager ?

How does your WEB-INF folder look like ?
Lance Manion
Greenhorn

Joined: May 16, 2011
Posts: 12
From the manager I can see my webpage, but I don't see any references to the applet.

In WEB-INF I have
classes/
lib/
web.xml

classes and lib are empty.

In the folder with the html page I have a gif and the jar. From my understanding tomcat will pass the jar just as it would the gif. This is why I don't understand why the gif file displays without error while the applet will not load.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41526
    
  53
Lance Manion wrote:Access logs don't say much, just a bunch of GETS.

Do you see one or more GETs for the applet jar file? Do they go to the correct path? Do they result in 200 result codes?

Also, are there any error messages in the Java Console?
Lance Manion
Greenhorn

Joined: May 16, 2011
Posts: 12
The get looks fine.
0:0:0:0:0:0:0:1 - - [25/May/2011:15:08:03 -0400] "GET /sample/Ship.jar HTTP/1.1" 200 1451641

This is the error from the console



The jar works fine from explorer and on a public server I use. I have no idea why Tomcat won't run it locally.
Wolfgang Tintemann
Ranch Hand

Joined: Sep 11, 2010
Posts: 65

I think it is not correct that the classes folder is empty.
There I think has to be a folder Ship in it and the
class file therein.
Ui, I just see that there might be a spelling error:
Ship or ship, what is right?
Lance Manion
Greenhorn

Joined: May 16, 2011
Posts: 12
Ship is the jar
ship is the package name
It all seems kind of irrelevant to me since it works perfectly fine elsewhere.

The jar file needs to be in the same folder as the html page since it is an applet. I believe servlets go into the WEB-INF folder. I expect the tomcat server to display an html page exactly like I would find on the internet. It displays images fine, but for some reason it is doing something with the jar's.

The only thing I can even think of is that tomcat is forcing my computer to use a 32bit jvm while my browser expects 64b. However, this doesn't really make any sense and I don't know how to change tomcat's jvm anyway.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Your browser successfully requests the jar file, we have confirmed that. But when it gets to your browser, something is wrong with it (as far as the Java plugin is concerned anyway). So type the URL of the jar file into your browser's address bar and download it to your computer. Then inspect the downloaded file and see whether it's okay (and whether it's identical to the version in your web app in Tomcat).
Lance Manion
Greenhorn

Joined: May 16, 2011
Posts: 12
Yes, it downloads fine. I downloaded it from sample/Ship.jar. Then I replaced webapps/sample/Ship.jar with it. It runs fine in the explorer, but not on localhost.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

I'm still not clear what "from explorer" and "locally" mean. If they mean that other computers can successfully load the applet but your computer can't, then it would appear that your computer (specifically the Java plugin) is at fault. But you seem to be describing the problem relative to where Tomcat is located, which I find very confusing.
Wolfgang Tintemann
Ranch Hand

Joined: Sep 11, 2010
Posts: 65

I still think in the applet tag you should
say ship instead of Ship in the class name.
Lance Manion
Greenhorn

Joined: May 16, 2011
Posts: 12
By explorer I mean double clicking the .html file and displaying it with my web browser. The URL is file:///C:/Program%20Files/Apache%20Software%20Fou...07.0/webapps/sample/index.html

By local I mean using tomcat where the URL is http://localhost:8080/sample/

It works fine everywhere except on the tomcat server, localhost
Wolfgang Tintemann
Ranch Hand

Joined: Sep 11, 2010
Posts: 65

I still do not understand how you deployed your
sample webapp if fhe classes folder is empty.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41526
    
  53
I still do not understand how you deployed your sample webapp if fhe classes folder is empty.

A web app does not need to contain servlets or JSPs to be considered a web app; just static content is fine.
Wolfgang Tintemann
Ranch Hand

Joined: Sep 11, 2010
Posts: 65

Still this is unclear :

load: class ship.ShipGame not found.
java.lang.ClassNotFoundException: ship.ShipGame

And above you show the same message with Ship instead of ship.
Did you you do some changes ?

I have a similar app ( but without package ) and it works in
Opera and Firefox. BUT : not with IE9 !!!
Could this be the problem ?
Lance Manion
Greenhorn

Joined: May 16, 2011
Posts: 12
Yes, I had changed the name of the package to conform with java standards as someone suggested.

tbh, I'm not really interested in fixing this problem anymore unless someone with a similar experience already has a solution. We've gone through all the appropriate trouble shooting and I like to think that I kept my process as simple as possible. I think the problem is some obscure configuration error between windows 7, tomcat, java, and whatever else involved.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Deploying Applet