• 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

Applet not shown in Eclipse internal browser.

 
Ranch Hand
Posts: 65
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I entered some example software as a Tomcat 7 Dynamic Web Project into Eclipse.
It consists of an applet, a servlet and an index.html file which starts the app.

When I deploy the app by exporting a .war file and starting Tomcat 7 manually outside
of Eclipse I can successfully start the app by entering http://localhost:8080/app/index.html
The applet is correctly shown in my browser.

In Eclipse I have installed the Sysdeo Tomcat Launcher Plugin.

When I run the index.html file "As Server" the browser window opens with the same address
as above BUT : the screen remains blank ( no error message ).

Have I to set the codebase in the <applet>-tag in the index.html file to a certain value ?
This is my only idea I have about the problem. I tried until now unsuccessfully several values
for codebase.

My directory/file structure under the app directory is :
WebContent
--META-INF
--WEB-INF
----classes ( this is the build path)
----web.xml
--Applet.class
--index.html

I tried as codebase : . , WebContent , WebContent/WEB-INF/classes - no result !
I also put the applet.class directly under the app directory and put codebase=".." - no change !
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Post the complete APPLET tag; I understand that's part of index.html?

Note that NOTHING that's inside of WEB-INF will ever be served to a client; that includes class files.

You should also check the Java Console for error messages.
 
Wolfgang Tintemann
Ranch Hand
Posts: 65
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is my index.html content :

 
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
Remove the codebase attribute; it's unnecessary.

Where is the file EchoApplet.class relative to the HTML file?
 
Wolfgang Tintemann
Ranch Hand
Posts: 65
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also without the codebase it doesn't work. This was the original state of index.html.

Sorry, I simply named the applet EchoApplet.class as applet.class in my diagram.
I put the EchoApplet.class in the WebContent directory. Same with index.html.

I am surprised that it works when I deploy via the .war file.
 
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The sysdeo plugin runs Tomcat according to the exact same configuration that Tomcat would run stand-alone. That's why I prefer it to the WTP "Run In Server" Tomcat option.

Without doing anything as mundane as actually reading the documentation, I'd presume that codeBase should be optional in the case where the applet class is located in the WAR root. However, do you actually have to explicitly put the ".class" suffix on the "code" attribute of the applet tag? In other words, it is really looking for a file named "Applet.class.class"?

The other possibility is that Tomcat itself is playing games with you. Depending on how you've configured the project, Tomcat may be working from a copy of the WAR stored in the TOMCAT_HOME/webapps directory. In that case, if you update a copy of the WAR in your project (for example, adding the applet class file), but fail to update the exploded WAR in TOMCAT_HOME/webapps, you'll fail because the applet classfile isn't where Tomcat can serve it. Also remember, that an exploded war is use in preference to a "real" (zipped) WAR file, even when the WAR file is newer than the exploded WAR.

 
Wolfgang Tintemann
Ranch Hand
Posts: 65
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I get a depression !

I removed the .class from the code name - no result !

I had already removed the .war file from the Tomcat webapps dir and also
deleted the exploded .war directory of my app to have a clean environment.
Doesn't help !

Something is queer with my Tomcat installation in Eclipse... For instance, I also
get error pages when I call http://localhost:8080/ or http://localhost:8080/manager.
When I start Tomcat 7 manually all works well in my external browser.

The question is : where is the applet searched from the <applet> tag in index.html ?
 
Tim Holloway
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Wolfgang Tintemann wrote:
The question is : where is the applet searched from the <applet> tag in index.html ?



It isn't searched. It's downloaded. The base URL of the download is the webapp (WAR) root.

So one easy way to see if the webapp itself is OK is to download "http://localhost:8080/mywebapp/Applet.class". If you get a "404" response, your WAR isn't set up properly (or Tomcat doesn't have file read access rights for the applet class). Otherwise, the problem is in your applet tag.

BTW, I trust you have installed the latest sysdeo plugin, since that's required to support Tomcat 7.
 
Wolfgang Tintemann
Ranch Hand
Posts: 65
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:
So one easy way to see if the webapp itself is OK is to download "http://localhost:8080/mywebapp/Applet.class". If you get a "404" response, your WAR isn't set up properly (or Tomcat doesn't have file read access rights for the applet class). Otherwise, the problem is in your applet tag.

BTW, I trust you have installed the latest sysdeo plugin, since that's required to support Tomcat 7.



I get the "404" reponse. I don't understand what means that "the WAR isn't set up properly". Some error in the dir structure under WebContent ?
Also I don't know what/how to get Tomcat access rights under Windows 7. I work as a user with restricted access rights but gave me full rights
on the applet class file.

The plugin I took from http://www.eclipsetotale.com/.

BTW: I made a small Java Project ( NOT Dynamic Web Project ) and there I get the page http://localhost:8080 also shown in Eclipse.
 
Tim Holloway
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dynamic Web Project is designed to work with WTP, and I'm not totally sure that it wouldn't have issues with non-WTP development. I don't use it myself.

eclipsetotale is the authoritative place for sysdeo plugins. But they have several versions there, so the main thing I wanted to confirm is that the one you're using was explicitly designated as functioning with Tomcat7. They only added Tomcat 7 support recently, and I, for one, haven't updated (yet!).

Chances are very low that you have a file access rights problem, since other parts of the webapp would also not serve up. But I included that possibility for completeness' sake. When running sysdeo, you're normally running Tomcat under the same user id as you're developing under and therefore should have no problem. Running a Tomcat Windows System service, however, might be a different matter!

Failing access rights problems, failure to retrieve the class via direct URL request does in fact mean that the directory structure of the WAR is somehow wrong. You should verify the context name that the WAR is deployed under (I used "mywebapp" as an example) and you should verify that all the upper/lower case items are properly capitalized, since that's a problem in Windows, where filenames are case-insensitive to the OS, but not to Java. If you're sufficiently desperate, you can configure an access log Valve in Tomcat that will record all URLs coming in to it.

 
Wolfgang Tintemann
Ranch Hand
Posts: 65
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I will later check/reinstall the sysdeo plugin.

I have now things changed a little bit. I right-clicked on the project name ( echoAppletServlet ) and chose Properties.
Under Web Project Settings the Context root is correct : echoAppletServlet.
But under Targeted Runtimes there was the old Tomcat 6 checked and I repaired this.

Now : if I enter http://localhost:8080/echoAppletServlet/index.html I get an "404" error page - formerly I only had
a blank page... Also http://localhost:8080 now works !

Tim Holloway wrote:
If you're sufficiently desperate, you can configure an access log Valve in Tomcat that will record all URLs coming in to it.



Can you tell me the details how to configure an "access log Valve" in Tomcat ?
 
Tim Holloway
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I see your problem.

Like I said, I don't do "web projects". Partly because I despise WTP, partly because there's no way to "upgrade" to Web Project in Eclipse on a legacy webapp. So I'm not 100% certain here. However, I'm at least 75% certain that the Project Properties context name is neither used nor even seen by the sysdeo plugin - it's only used by WTP.

For a Tomcat server to deploy a webapp(s) for executing in the sysdeo/Eclipse environment, they must be deployed in exactly the same way you would for running Tomcat stand-alone. Meaning:

1. You copy the WAR file to the TOMCAT_HOME/webapps directory (context name = WAR name, less ".war")
OR
2. You explode the WAR file to TOMCAT_HOME/webapps (context name same as the subdirectory name under webapps that the exploded WAR's contents live in)
OR
3. You do one of the following, but include a META-INF/context.xml in your WAR (context name defined in the context.xml)
OR
4. You create a file in context.xml format and copy it to TOMCAT_HOME/conf/Calatlina/localhost (context name is same as the filename, less ".xml").

I'm fairly sure that the sysdeo plugin won't do any of the above things automatically from a project's preferences, so it's questionable what actually deployed. Although your Eclipse console should display them on server startup.
 
Wolfgang Tintemann
Ranch Hand
Posts: 65
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:
1. You copy the WAR file to the TOMCAT_HOME/webapps directory (context name = WAR name, less ".war")



I now tried this as I already used the method in the past. I did it this way :
right-click on project name and choose export/WAR file. Then the .war file is
written into TOMCAT_HOME/webapps as expected.

Then I start Tomcat from the icon in the toolbar and get the following console message :
INFO: Deploying web application archive echoAppletServlet.war

I checked in webapps dir and found that also the .war file was exploded into a
echoAppletServlet dir. That seems fine to me.
BUT : now again only a blank page appears on http://localhost:8080/echoAppletServlet/index.html.
( I started the browser from the toolbar in the Web perspective and entered the URL manually )

I also tried to right-click on the index.html file under WebContent and chose Run As/Run on Server.
Again only a blank page appears on http://localhost:8080/echoAppletServlet/index.html.
BUT : what puzzles me is the console output of the starting Tomcat now ! It seems to be another one :
no deployment messages any more !!!

I want to tell you that I have in the Project Explorer frame a dir called Servers. I don't remember when
and by what it was created there. It contains a dir called Tomcat v7.0 Server at localhost-config with
conf files in it ( e.g. server.xml ) This server.xml file for instance is different from the one in the conf dir
in TOMCAT_HOME. There is added the following line ( not by me... ) :
<Context docBase="echoAppletServlet" path="/echoAppletServlet" reloadable="true" source="org.eclipse.jst.jee.server:echoAppletServlet"/>
Is this all correct ?

Let me add my app structure again :

 
Tim Holloway
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Run on Server" starts up the WTP webapp server. Looks like you're ending up with 2 different copies of Tomcat running at the same time. That ain't gonna work - at least if they're fighting for the same ports.

The "Server" directory is also created, used, and maintained by WTP for the benefit of the "Run on Server" command. It contains a crippled copy of the Tomcat server.xml file, among other things. No user-serviceable parts inside, as they say.
 
Tim Holloway
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Incidentally, can you list the directory of TOMCAT_HOME/webapps/echoAppletServlet? I don't trust the "Export as WAR" WTP function, either.
 
Wolfgang Tintemann
Ranch Hand
Posts: 65
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all I found in the web someone who had the same problem as I have :
click here to find the "solution"
Now I am again making tests with the codebase of the <applet> tag but the "solution" above doesn't work
(perhaps I don't understand it right)

What hampers me is when I change the <applet> tag in index.html and start the URL in the browser I always get
the old version of index.html ( I check this by looking at the source code in the browser ). Any hint how I get the
new version without restarting the whole eclipse program ???

I can list the webapps/echoAppletServlet dir nicely : this seems to work. There is the exact content as under WebContent.

Can I simply delete the Servers dir ??? Or shall I copy the conf files from TOMCAT_HOME therein ?
Normally I pay attention that I start/stop only one Tomcat : also I get a warning about port usage if I make an error. Thats fine.
 
Tim Holloway
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're using sysdeo, the Servers directory is never used. In fact, it's never even created unless you muck around with WTP. I don't have a Servers directory.

Sysdeo and WTP are 2 entirely different products that do almost the same thing except that IMHO, sysdeo does most of it MUCH better, although not as well integrated into the JEE menus.

When you click the "tomcat" icons (or select the Tomcat/Start Tomcat menu), that launches sysdeo Tomcat. When you menu-select "Run on Server", that launches WTP Tomcat. As I said before, running both at the same time usually doesn't work.

The WebContent folder generally should not be exactly like the WAR. It contains the static parts of your webapp. The actual WAR has to also include the generated parts of your webapp. That includes the WEB-INF/classes directory and its children. For example, WEB-INF/classes/EchoServlet.class.

Which is why I wanted to see what your actual TOMCAT_HOME/webapps/echoAppletServlet directory looked like.


 
Wolfgang Tintemann
Ranch Hand
Posts: 65
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your patient explanations. I start to understand some facts.

Here is the content of webapps/echoAppletServlet dir :

I added in between the classes dir because I tried to verify the above mentioned
"solution". I simply changed the build path dir to WebContent/classes.
Somehow it surprises me that the old classes dir under WEB-INF is still there even
though I was prompted by eclipse that I might have it deleted. Puzzling.
 
Tim Holloway
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can direct Eclipse to build classes into WebContent/WEB-INF/classes. However, I have learned to my sorrow that mixing generated and static files in the same directory tree of a project can result in considerable pain. Then again, WTP is also considerable pain. Maybe that's how they set up the Web Project configuration. I'm definitely not the expert on that!

Given what you've listed, and assuming that part of the pathname rolled out of the display, you should have a file named

C:\Program Files\Apache Software Foundation\tomcat-7.0.1\webapps\echoAppletServlet\classes\EchoApplet.class

So an applet tag that references "classes/EchoApplet" would be what you're looking for.

However, there's an additional complication here. You have an embedded class definition or something like that and it's causing an additional class (EchoApplet$1.class) to be created. If you just reference EchoApplet, only the EchoApplet.class file will be downloaded, and the applet will fail to run, throwing a ClassNotFoundException for EchoApplet$1.class. To get around that, you should put all the applet's classes in a jar file, and use the jar as your codebase, rather than using loose classes.
 
Wolfgang Tintemann
Ranch Hand
Posts: 65
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your hints.

Here is also a thread where someone proposes your solution with creating
a .jar file of the .class files :
solved by creating .jar file

Alas, I found no "easy" way to create a .jar archive from the invisible classes folder. Any way ?

BTW : the problem lies with the internal browser !
Under the Windows menu I selected as Web Browser the Internet Explorer and all works fine with codebase="classes"
in the <applet> tag.

For now I leave the discussion and go to bed.
 
Tim Holloway
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eclipse by itself is not suitable for building complex projects. Complex projects usually rely on external build tools such as Ant or Maven. Which is good practice anyway, since IDEs are more prone to "break" as new releases come out, but command-line builds are more stable. Plus you can do them on machines that don't run GUIs.

Your best bet here is to build the applet as a separate Eclipse project, "jar" up the applet, and copy the resulting jar into the webapp project.
 
Wolfgang Tintemann
Ranch Hand
Posts: 65
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:
Eclipse by itself is not suitable for building complex projects. Complex projects usually rely on external build tools such as Ant or Maven. Which is good practice anyway, since IDEs are more prone to "break" as new releases come out, but command-line builds are more stable. Plus you can do them on machines that don't run GUIs.



I only heard about Ant and Maven - don't know yet any details. What do you prefer ?

Tim Holloway wrote:
Your best bet here is to build the applet as a separate Eclipse project, "jar" up the applet, and copy the resulting jar into the webapp project.



IF the trick with the .jar file works I also think that is a good idea.

A question about the <applet> tag : where do I have to tell about the .jar file ? In archive="..." or codebase="..." ? Or both ?

Asap I will try whether the internal browser works with the .jar file trick. I will report again.
 
Tim Holloway
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I started with Ant, but these days I use Maven. I originally didn't like Maven because it forced me to organize my directories THEIR way and because it was "magic" - you didn't really know what it was going to do or even what you could validly ask it to do.

However, as my projects got more complex, my Ant build files got more complex relative to their Maven equivalents. And as I started using more and more external libraries, I liked the fact that Maven would not only automatically include them into my project, it would also automatically include their dependencies as well. Plus, if someone hands me a maven project, I know precisely where all the components are - the upside to having standardized directory organization.

I'm afraid I'm no longer on top of applets, so for details of how to code the tags, I'll have to refer you to the documentation. Don't forget, however, that we have a whole forum dedicated to questions and answers about applets!
 
Wolfgang Tintemann
Ranch Hand
Posts: 65
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The internal browser doesn't work with the .jar file trick.
I give up now - no more playing around with codebase...

I put the .jar file directly under WebContent and used archive="EchoApplet.jar" in the <applet> tag.

BUT : when I switch to IE - all works fine.

So I think I will not use Dynamic Web Projects any more and try it with Java Projects.

I thank you for your patient and unremitting help.
 
Wolfgang Tintemann
Ranch Hand
Posts: 65
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A final remark :

I added a text between the <applet> and </applet> tags in the index.html file
and now the internal browser shows the page with this text instead of the applet.

So the internal browser is not able to handle the applet tag - as far as I understand.
 
Rancher
Posts: 436
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are aware that the use of the applet tag is deprecated and may lead to browsers not displaying the applet?
 
Wolfgang Tintemann
Ranch Hand
Posts: 65
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Once I heard that also the <object> tag can be used for showing Java Applets.
I have only one source of information at this moment and there they gave an example
which I used as follows :

<applet code="EchoApplet" archive="EchoApplet.jar" width="500" height="200">
The browser can't show the applet.
</applet>

replaced by

<object classid="java:EchoApplet"
archive="EchoApplet.jar"
codetype="application/java-vm"
width="500" height="200">
</object>

But this doesn't work neither in the internal browser nor with IE(9).
The <applet> tag worked with IE(9).

NEWS : if I start Tomcat manually and enter index.html into the browser
the applet is shown also with this <object> tag. I am confused !

HOLLA ! Only Opera and Firefox show the <object> tag in this form !
 
Tim Holloway
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, when you run applets within Eclipse, I believe it's really running the Sun appletviewer program, which is a good way to launch applets quickly, but it isn't actually a webapp server, so most appserver functions are unavailable. I thought that the "classid" was supposed to be some long nasty UUID number, though.
 
Hauke Ingmar Schmidt
Rancher
Posts: 436
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. Running it in Eclipse's browser window shows an applet in the browser that is configured to be used there.

I have only one source of information at this moment



I don't know what your "one source" is but your embedding code does not look like the one in the documentation.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic