This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Tomcat and the fly likes binding tomcat to my application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "binding tomcat to my application" Watch "binding tomcat to my application" New topic
Author

binding tomcat to my application

S bitz
Ranch Hand

Joined: Jan 20, 2006
Posts: 80
Hi,
I developed an application and now i want to create a package so that the package holds a TOMCAT(with its bin, conf,webapps,etc folders) directory, a JAVA directory(that has all bin,lib,jre etc folders in it.) and a myapp.bat file. So when user executes the bat file, the tomcat server would be started irrespective of whether he has installed TOMCAT on his system or not also Java. The bat file that i have written is this :



but this doesn't seem to work. Does anyone have some idea on how this can be done.I hope i am clear in explaining my objective.

Thanks in advance,
bitz.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41586
    
  54
Welcome to JavaRanch.

"net start" would only work if the server was installed as an NT service, and it sounds like that is precisely what you want to avoid. You need to use the startup and/or catalina scripts that come Tomcat.

An easier way may be to embed Tomcat in your application; see this article for details on how to do that.


Ping & DNS - my free Android networking tools app
S bitz
Ranch Hand

Joined: Jan 20, 2006
Posts: 80
Thanks for the reply.
Bitz
S bitz
Ranch Hand

Joined: Jan 20, 2006
Posts: 80
Hi,
I tried using the code, but there are some packages i wasn't able to find in my tomcat directory. I am using Tomcat-5.5.12. I am as good as a newbie, so please help me out!!

These are the packages that are i don't find the jar files of:

import org.apache.catalina.Connector;

import org.apache.catalina.Deployer;

import org.apache.catalina.logger.SystemOutLogger;

What actually i'm trying to do is that for a user who doesnt have tomcat or jdk (both will be in the zipped file)installed on his system, he just has to unzip my application folder click on a batch file and type the url in the browser and he should be able to do it.
Thanks in advance.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41586
    
  54
Installing the JDK seems a much bigger problem than installing Tomcat, because that requires running an installer (unless you want to muck around with registry entries and the like yourself), but I'll leave that aside for the moment.

I'm not sure about TC 5.5, but for TC 5.0 the server jar files are all in TOMCAT_HOME/server/lib.
S bitz
Ranch Hand

Joined: Jan 20, 2006
Posts: 80
Hi Ulf,
Actually i have tried to add all the jar files available in the tomcat/server/lib and when i use this line of code


i get this error :

reference to createConnector is ambiguous, both method createConnector(java.net.InetAddress,int,boolean) in org.apache.catalina.startup.Embedded and method createConnector(java.lang.String,int,boolean) in org.apache.catalina.startup.Embedded match

and when i try to create a Deployer object it says,

cannot find symbol
symbol : Deployer

I've tried googling the first error but i get nothing.
Can you help me solve this problem?

Thanks in advance.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41586
    
  54
I'm not familiar enough with the embedded version to say if it is OK to pass null as the first parameter, but to disambiguate, use something like
S bitz
Ranch Hand

Joined: Jan 20, 2006
Posts: 80
Thanks Ulf,
That error is gone, but now its not able to find the class!!
Really sorry to keep bothering you!! But i'm also going thru the API and i'm seriously not able to find the solution. I dunno what i am missing.

Thanks,
Bitz.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41586
    
  54
its not able to find the class

Which class is that? Please post the full error message/stack trace, and a bit of code that shows where the problem occurs.
S bitz
Ranch Hand

Joined: Jan 20, 2006
Posts: 80
Hi Ulf,
The errormessage is this :

Compiling 1 source file to D:\My Projects\HackersBank_V1_production_team\Project1\build\web\WEB-INF\classes
D:\My Projects\HackersBank_V1_production_team\Project1\src\java\EmbeddedTomcat.java:79: cannot find symbol
symbol : class Connector
location: class EmbeddedTomcat
Connector connector = embedded.createConnector(null, 8080, false);
D:\My Projects\HackersBank_V1_production_team\Project1\src\java\EmbeddedTomcat.java:79: reference to createConnector is ambiguous, both method createConnector(java.net.InetAddress,int,boolean) in org.apache.catalina.startup.Embedded and method createConnector(java.lang.String,int,boolean) in org.apache.catalina.startup.Embedded match
Connector connector = embedded.createConnector(null, 8080, false);
D:\My Projects\HackersBank_V1_production_team\Project1\src\java\EmbeddedTomcat.java:117: cannot find symbol
symbol : class Deployer
location: class EmbeddedTomcat
Deployer deployer = (Deployer)host;
D:\My Projects\HackersBank_V1_production_team\Project1\src\java\EmbeddedTomcat.java:117: cannot find symbol
symbol : class Deployer
location: class EmbeddedTomcat
Deployer deployer = (Deployer)host;
4 errors
D:\My Projects\HackersBank_V1_production_team\Project1\nbproject\build-impl.xml:258: The following error occurred while executing this line:
D:\My Projects\HackersBank_V1_production_team\Project1\nbproject\build-impl.xml:122: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 12 seconds)


The code is this :


Thanks for taking interest.
S bitz
Ranch Hand

Joined: Jan 20, 2006
Posts: 80
Lemme mention one thing,
Even if i un-comment the import org.apache.catalina.Connector and
import org.apache.catalina.Deployer;

i'm getting the same error.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41586
    
  54
It's strange that it would complain about not finding Deployer and Connector, because those are in the same jar file (catalina.jar) as Container (at least in TC 5.0).

Also, it looks like the disambiguation isn't working; try this:
Connector connector = embedded.createConnector((String) null, 8080, false);
S bitz
Ranch Hand

Joined: Jan 20, 2006
Posts: 80
Hi Ulf,
I was able to catch one mistake that i was making,and that was in my import statement,
instead of using this statement,

import org.apache.catalina.connector.Connector;
in Tomcat 5.5.12, i was using

import org.apache.catalina.Connector;

and that was wrong. But then once this was solved i wasn't able to find the Deployer class in the jar files.
Anyways, when i'm importing the jar files of Tomcat 5.0, and everything seems to be working fine.

Thanks for your time and help.
Bitz.
S bitz
Ranch Hand

Joined: Jan 20, 2006
Posts: 80
Hi Ulf,
That did not work out with tomcat 5.5.12 but its working perfectly fine with tomcat 5.0.30.

Thanks,
Bitz
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: binding tomcat to my application