• 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

Only some apps in web.xml run

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have eight web apps in the same WEB-INF/classes/ folder. They are all listed in the web.xml file. When I start Tomcat 6, only some of the apps run. I am able to run the other apps, but to do so, I have to recompile them and then restart Tomcat. Am I doing something incorrectly?
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Wehrstein wrote:I have eight web apps in the same WEB-INF/classes/ folder.


No, you don't. Each folder with a WEB-INF subfolder defines one web app (context). If you've got them all mixed up in the same folder, you have one web app, not eight.

Am I doing something incorrectly?


Yes. See above. Each web app should be completely separate form the others.
 
Rob Wehrstein
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Each web app should be completely separate form the others.



I think what I mean is that I have multiple servlets in one folder. I see lots of example web.xml files online and these have multiple servlet mappings, which would essentially
mean multiple servlets.

To rephrase:

I have eight servlets in the same WEB-INF/classes/ folder. They are all listed in the web.xml file. When I start Tomcat 6, only some of the servlets run. I am able to run the other servlets, but to do so, I have to recompile them and then restart Tomcat. Am I doing something incorrectly?
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The short answer is Yes. But you already knew there was a problem, so let's move on to solving it. So far all you said was that the servlets "didn't run". What are the symptoms of not running? Tell us about error messages, response codes, whatever you saw.
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, yes, That's different.

Have you worked through the list of troubleshooting steps in the ServletsFaq?
 
Rob Wehrstein
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:The short answer is Yes. But you already knew there was a problem, so let's move on to solving it. So far all you said was that the servlets "didn't run". What are the symptoms of not running? Tell us about error messages, response codes, whatever you saw.



I can point my web browser at the URL. The browser appears to load an empty web page that has no page source. I looked in the tomcat logs, but did not see anything that looked problematic.
 
Saloon Keeper
Posts: 27808
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 didn't get a Tomcat 404 error page, the servlets ran. They just didn't return anything.

Use your browser's View Page Source option to see if they literally returned nothing or if they returned non-displayable content.
 
Rob Wehrstein
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:If you didn't get a Tomcat 404 error page, the servlets ran. They just didn't return anything.

Use your browser's View Page Source option to see if they literally returned nothing or if they returned non-displayable content.



There was no error message. I clicked "View Page Source" and the page source is empty.
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Empty or incomplete responses are almost always a sign of an exception. Have you checked the logs?
 
Tim Holloway
Saloon Keeper
Posts: 27808
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
Then the servlets in question returned nothing.

"Nothing" comes in several flavors. If you have a sophisticated client-side debugger such as Firefly, you can examine the details of the response stream and see if you got completely nothing or nothing but HTTP headers with no body. Plus you will see the HTTP response code.

Aside from that, you describe your server like you think Tomcat is something you can just throw stuff at and it gets served up. Tomcat is a J2EE server and requires webapps to be packaged in WAR format, either as an actual WAR file or as an exploded (unzipped) war residing in a directory directly underneath the TOMCAT_HOME/webapps directory (assuming default configuration).
 
Rob Wehrstein
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error goes away when the start up script is called from a specific directory. This directory contains an html file that the is read at run time by the servlet.
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That likely means you are using too general a path to the HTML file, which depends upon the very iffy concept of "current directory". Bad move.
 
Tim Holloway
Saloon Keeper
Posts: 27808
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
To be more explict, in J2EE, you should not rely on a "current directory" or on stdin, stdout or stderr (System.in, System.out, System.err). Although the JVM inherits all of the preceeding from its general environment, a J2EE server makes little or no attempt to make them reliable. Other mechanisms more suitable for the web environment exists within J2EE.

In particular, the "current directory" can be randomly zapped to any place at any time with no notice whatsoever and that includes while you are in the middle of a method execution.

The best way to locate a resource in J2EE is either to use one of the ServletRequest getResource methods if the resource is within the WAR or to use a locator mechanism such as JNDI if the resource is external to the WAR. There's a method that will return the filesystem location of a resource as well, but that returns null if the WAR hasn't been exploded. And it's bad practice for a webapp to assume that the WAR was exploded, since that's determined solely by how the WAR was deployed, not by the system environment or program logic.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic