|
From: <nic...@uk...> - 2005-11-08 11:31:22
|
I still prefer to use JSW with tomcat - we still occasionally have jvm
crashes - and JSW means our users never notice these.
FWIW, I have done a slightly tighter integration between JSW and tomcat.
The StartStopApp approach has the flaw that start/stop are somewhat
asynchronous (ie the StopApp exits before tomcat)
This has the disadvantage that doing a "restart" usually results in a new
instance of tomcat starting before the previous one has finished exiting -
then you get port conflicts etc.
The "tighter" integration is still very simple - and still uses tomcat's
Bootstrap class to start and stop it. (ie it doesnt get involved in tomcat
internals)
If ppl think its valuable, I am quite happy to contribute it. (I have
copied it below in any case)
-Nick
import java.lang.management.ManagementFactory;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.apache.catalina.startup.Bootstrap;
import org.tanukisoftware.wrapper.WrapperListener;
import org.tanukisoftware.wrapper.WrapperManager;
public class TomcatServiceWrapper implements WrapperListener {
private static final String DEFAULT_WRAPPER_MBEAN_NAME =
"wrapper:type=Java Service Wrapper Control";
private static final String WRAPPER_BEAN_NAME_KEY =
"wrapper.mbean.name";
public static final String TOMCAT_START = "startd";
public static final String TOMCAT_STOP = "stopd";
private static final int JDK15_NOT_FOUND_EXIT_CODE = 1;
public Integer start(String[] args) {
if (isNotJDK15()) {
WrapperManager.log(WrapperManager.WRAPPER_LOG_LEVEL_FATAL,
"-------------- !! TOMCAT FAILED TO START !! --------------\tJDK 1.5+ NOT
detected. JDK 1.5 or above is required");
WrapperManager.stop(JDK15_NOT_FOUND_EXIT_CODE);
}
if (WrapperManager.getJVMId() > 1) {
// we have restarted. Add hook here to run shell/bat command
}
registerServiceWrapperMbean();
Bootstrap.main(new String[]{TOMCAT_START});
WrapperManager.log(WrapperManager.WRAPPER_LOG_LEVEL_STATUS,
"--------------TOMCAT STARTED SUCCESSFULLY--------------");
return null;
}
public int stop(int exitCode) {
Bootstrap.main(new String[]{TOMCAT_STOP});
return exitCode;
}
public void controlEvent(int event) {
if (WrapperManager.isControlledByNativeWrapper()) {
// The Wrapper will take care of this event
WrapperManager.log(WrapperManager.WRAPPER_LOG_LEVEL_INFO,
"Control Event: to be handled by Native Wrapper");
}
else {
// We are not being controlled by the Wrapper, so handle the
event ourselves.
if ((event == WrapperManager.WRAPPER_CTRL_C_EVENT) ||
(event == WrapperManager.WRAPPER_CTRL_CLOSE_EVENT) ||
(event == WrapperManager.WRAPPER_CTRL_SHUTDOWN_EVENT)) {
WrapperManager.stop(0);
}
}
}
public static void main(String[] args) {
WrapperManager.start(new TomcatServiceWrapper(), args);
}
private boolean isNotJDK15() {
try {
Class.forName("java.lang.management.ManagementFactory");
return false;
}
catch (ClassNotFoundException ignore) {
return true;
}
}
private void registerServiceWrapperMbean() {
try {
System.out.println("JDK 1.5+ detected, registering Java Service
Wrapper MBean");
org.tanukisoftware.wrapper.jmx.WrapperManager managerBean = new
org.tanukisoftware.wrapper.jmx.WrapperManager();
ObjectName name = new ObjectName(getName());
MBeanServer server =
ManagementFactory.getPlatformMBeanServer();
server.registerMBean(managerBean, name);
}
catch (Exception e) {
System.err.println("Failed to register ServiceWrapper MBeans");
e.printStackTrace();
}
}
private String getName() {
String name = System.getProperty(WRAPPER_BEAN_NAME_KEY);
if (name == null) {
System.out.println("Property \"" + WRAPPER_BEAN_NAME_KEY + "\"
not set. Using default : \"" + DEFAULT_WRAPPER_MBEAN_NAME + "\"");
name = DEFAULT_WRAPPER_MBEAN_NAME;
}
return name.replaceAll("\"", "");
}
}
Internet
mai...@st...@lists.sourceforge.net - 08/11/2005 01:40
Please respond to wra...@li...
Sent by: wra...@li...
To: wrapper-user
cc:
Subject: Re: [Wrapper-user] tomcat 5.5
Thanks!
I only use the error detection and recovery features as I run the
containers on linux.
I was just wondering if the wrapper was necessary with the new tomcat
5.5 and its better memory management.
John Larsen
Storm's i Media, LLC.
Java | Pipe
.................:DISCLAIMER:.....................
This e-mail and the information it contains is confidential and is
intended only for the addressee(s) named above or in the case of an
incorrectly addressed e-mail message, the intended recipient. If you
have received this e-mail and you are not the intended recipient any
disclosure, distribution, copying or any other use of this information
is strictly prohibited. If you have received this e-mail in error,
please accept our apologies and please notify the sender by e-mailing
jo...@st.... Please then delete this e-mail and any attachment
from your system. The views and opinions expressed in this e-mail are
the author's own and may not reflect the views and opinions of Storm's
i Media, LLC.
Although this email, including any attachments, is believed to be free
of any virus, or other defect which might affect any computer or IT
systeminto which it is received and opened, it is the responsibility of
the recipient to ensure that it is virus free, and no responsibility is
accepted for any loss or damage arising in any way from its use.
On Nov 7, 2005, at 1:14 AM, Leif Mortenson wrote:
> John,
> It had been a while since I tried out the newer Tomcat versions so
> I gave it a try with
> the latest and greatest Tomcat 5.5.12. Following the directions on
> the Wrapper site,
> it worked perfectly. There were a couple differences in the actual
> configuration values
> as the new version appears to expect a couple more system properties.
> But the
> instructions lead the user to the correct config file.
>
> I went ahead and attached it to this mail.
>
> It looks like Tomcat 5.5 contains its own native binary capable of
> installing and
> running Tomcat as a service. If that is the only feature of the
> Wrapper that you are
> looking for then it should meet your needs. The Wrapper does go much
> farther
> however, particularly the error detection and recovery features.
>
> Cheers,
> Leif
>
> John Larsen wrote:
>
>> Hi - I know long time no post.
>>
>> Say does the wrapper work with tomcat 5.5 or does it even need it
>> since memory
>> managment appears to be much improved?
>>
>> Thanks!
>>
>> John
>>
>
> #********************************************************************
> # Wrapper Properties
> #********************************************************************
> # Java Application
> wrapper.java.command=%JAVA_HOME%/bin/java
>
> # Java Main class. This class must implement the WrapperListener
> interface
> # or guarantee that the WrapperManager class is initialized. Helper
> # classes are provided to do this for you. See the Integration
> section
> # of the documentation for details.
> wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperStartStopApp
>
> # Java Classpath (include wrapper.jar) Add class path elements as
> # needed starting from 1
> wrapper.java.classpath.1=../common/lib/wrapper.jar
> wrapper.java.classpath.2=%JAVA_HOME%/lib/tools.jar
> wrapper.java.classpath.3=../bin/bootstrap.jar
>
> # Java Library Path (location of Wrapper.DLL or libwrapper.so)
> wrapper.java.library.path.1=../common/lib
>
> # Java Additional Parameters
> wrapper.java.additional.1=-
> Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
> wrapper.java.additional.2=-Djava.util.logging.config.file=../conf/
> logging.properties
> wrapper.java.additional.3=-Djava.endorsed.dirs=../common/endorsed
> wrapper.java.additional.4=-Dcatalina.base=..
> wrapper.java.additional.5=-Dcatalina.home=..
> wrapper.java.additional.6=-Djava.io.tmpdir=../temp
>
> # Initial Java Heap Size (in MB)
> #wrapper.java.initmemory=3
>
> # Maximum Java Heap Size (in MB)
> #wrapper.java.maxmemory=64
>
> # Application parameters. Add parameters as needed starting from 1
> wrapper.app.parameter.1=org.apache.catalina.startup.Bootstrap
> wrapper.app.parameter.2=1
> wrapper.app.parameter.3=start
> wrapper.app.parameter.4=org.apache.catalina.startup.Bootstrap
> wrapper.app.parameter.5=true
> wrapper.app.parameter.6=1
> wrapper.app.parameter.7=stop
>
> #********************************************************************
> # Wrapper Logging Properties
> #********************************************************************
> # Format of output for the console. (See docs for formats)
> wrapper.console.format=PM
>
> # Log Level for console output. (See docs for log levels)
> wrapper.console.loglevel=INFO
>
> # Log file to use for wrapper output logging.
> wrapper.logfile=../logs/wrapper.log
>
> # Format of output for the log file. (See docs for formats)
> wrapper.logfile.format=LPTM
>
> # Log Level for log file output. (See docs for log levels)
> wrapper.logfile.loglevel=INFO
>
> # Maximum size that the log file will be allowed to grow to before
> # the log is rolled. Size is specified in bytes. The default value
> # of 0, disables log rolling. May abbreviate with the 'k' (kb) or
> # 'm' (mb) suffix. For example: 10m = 10 megabytes.
> wrapper.logfile.maxsize=0
>
> # Maximum number of rolled log files which will be allowed before old
> # files are deleted. The default value of 0 implies no limit.
> wrapper.logfile.maxfiles=0
>
> # Log Level for sys/event log output. (See docs for log levels)
> wrapper.syslog.loglevel=NONE
>
> #********************************************************************
> # Wrapper Windows Properties
> #********************************************************************
> # Title to use when running as a console
> wrapper.console.title=Tomcat
>
> #********************************************************************
> # Wrapper Windows NT/2000/XP Service Properties
> #********************************************************************
> # WARNING - Do not modify any of these properties when an application
> # using this configuration file has been installed as a service.
> # Please uninstall the service before modifying this section. The
> # service can then be reinstalled.
>
> # Name of the service
> wrapper.ntservice.name=Tomcat
>
> # Display name of the service
> wrapper.ntservice.displayname=Tomcat
>
> # Description of the service
> wrapper.ntservice.description=Tomcat
>
> # Service dependencies. Add dependencies as needed starting from 1
> wrapper.ntservice.dependency.1=
>
> # Mode in which the service is installed. AUTO_START or DEMAND_START
> wrapper.ntservice.starttype=AUTO_START
>
> # Allow the service to interact with the desktop.
> wrapper.ntservice.interactive=false
>
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server.
Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Wrapper-user mailing list
Wra...@li...
https://lists.sourceforge.net/lists/listinfo/wrapper-user
This message and any attachments (the "message") is
intended solely for the addressees and is confidential.
If you receive this message in error, please delete it and
immediately notify the sender. Any use not in accord with
its purpose, any dissemination or disclosure, either whole
or partial, is prohibited except formal approval. The internet
can not guarantee the integrity of this message.
BNP PARIBAS (and its subsidiaries) shall (will) not
therefore be liable for the message if modified.
**********************************************************************************************
BNP Paribas Private Bank London Branch is authorised
by CECEI & AMF and is regulated by the Financial Services
Authority for the conduct of its investment business in
the United Kingdom.
BNP Paribas Securities Services London Branch is authorised
by CECEI & AMF and is regulated by the Financial Services
Authority for the conduct of its investment business in
the United Kingdom.
BNP Paribas Fund Services UK Limited is authorised and
regulated by the Financial Services Authority
|