Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help running a standalone Java 6 program which is packaged in a war file and deployed in Tomcat 7

 
James Dekker
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The issue is that when I run it via Eclipse Juno by clicking on it and "Run as Java Application" it works,
but it needs to be to run in a Linux shell script or at least from the Linux shell.

I need it to append all the jar files from $CATALINA_HOME/webapps/myapp/WEB-INF/lib to my classpath.

Here's my code:



When I cd into $CATALINA_HOME/webapps/myapp/WEB-INF/classes/com/myapp/client issue the following command:



I receive this exception:


When I go to my home dir (/home/devuser) and type this in, it still doesn't work:


Thank you for taking the time to read this... Would appreciate it if someone could assist me.
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James Dekker wrote:

When I cd into $CATALINA_HOME/webapps/myapp/WEB-INF/classes/com/myapp/client issue the following command:



Your class is in the package com.myapp.client. The base of this package ($CATALINA_HOME/webapps/myapps/WEB-INF/classes) should be in your classpath, but it is not. You need to add it and call the class by its fully qualified name (com.myapp.client.ClientApp) so Java knows how to locate it - not with the class-only name (ClientApp) - because that looks like the class should be in the default (unnamed) package.



Same problem with the classpath - the base folder for the package is not in the classpath. But this time you are trying to tell Java that the fully qualified name for the class is "$CATALINA_HOME.webapps.myapp.WEB-INF.classes.com.myapp.ClientApp" (except that the environmental variable $CATALINA_HOME is expanded). You have to add the base folder to your classpath AND give the correct fully qualified name of the class you want to run.


And are you sure this application will run on its own? Apps packed in WARs and run through Tomcat are usually webapps and can't be run from the command line like that.
 
James Dekker
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Steve,

Yes, I was able to get it working by doing this:



Thanks for your great input / feedback!

James
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic