• 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

binding tomcat to my application

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
S bitz
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply.
Bitz
 
S bitz
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ulf,
That did not work out with tomcat 5.5.12 but its working perfectly fine with tomcat 5.0.30.

Thanks,
Bitz
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic