Configure Tomcat Logging Programmatically

2013-12-09 Thread Matthew Westwood-Hill
I am running Tomcat programmatically (embedded) and I wanted to configure
its logging so I can track inbound request.



I start Tomcat as follows:



tomcat = new Tomcat();

tomcat.setBaseDir(DEFAULT_BASE_DIR);

tomcat.getService().addConnector(defaultConnector);

tomcat.setConnector(defaultConnector);

tomcat.init();

tomcat.start();



How do I go about configuring the logging?



Cheers,

Matt


Setting unloadDelay within embedded Tomcat

2013-12-09 Thread Matthew Westwood-Hill
I am running Tomcat embedded via something like the following code:



tomcat = new Tomcat();

tomcat.setBaseDir(DEFAULT_BASE_DIR);

tomcat.getService().addConnector(defaultConnector);

tomcat.setConnector(defaultConnector);

tomcat.init();

tomcat.start();



How do I go about setting the *unloadDelay* property programmatically in
the above example?



Cheers,

Matthew


Configuring Embedded Tomcat for SSL

2013-10-31 Thread Matthew Westwood-Hill
Tomcat version: 7.0.47

OS: Windows 7 (x64)

JDK: 1.7



I am attempting to start an embedded instance of Tomcat, which is
configured for SSL only, on port 443.  The code I am using is as follows:



   *public* *static* *void* *main*(String[] args)
*throws*UnknownHostException, LifecycleException, ServletException {

  Tomcat tomcat = *new* Tomcat();



  tomcat.setBaseDir("D:\\Temp");

  tomcat.addWebapp("/sslapp", "D:\\");



  Connector connector = *new* Connector();

  connector.setPort(443);

  connector.setScheme("https");

  connector.setSecure(*true*);



  connector.setAttribute("address", "127.0.0.1");

  connector.setAttribute("SSLEnabled", *true*);



  connector.setAttribute("bindOnInit", *true*);



  connector.setAttribute("keystoreFile",
"...\\EngineInstance.keystore");

  connector.setAttribute("keystorePass", "password");

  connector.setAttribute("clientAuth", "false");

  connector.setAttribute("sslProtocol", "TLS");

  connector.setAttribute("keyAlias", "test");

  connector.setAttribute("keyPass", "password");



  tomcat.setConnector(connector);

  tomcat.init();

 tomcat.start();

  tomcat.getServer().await();



   }



When I run the above, I receive the following output:



Nov 01, 2013 10:08:07 AM org.apache.catalina.core.StandardService
startInternal

INFO: Starting service Tomcat

Nov 01, 2013 10:08:07 AM org.apache.catalina.core.StandardEngine
startInternal

INFO: Starting Servlet Engine: Apache Tomcat/7.0.47

Nov 01, 2013 10:08:07 AM org.apache.catalina.startup.ContextConfig
getDefaultWebXmlFragment

INFO: No global web.xml found



It does not look like the connector I created is actually being started.
 When I try browsing to the above port using Chrome/IE all it does not
connect.



I thought I was following the correct process base don information I
located on Google, however, it would appear I am still doing something
incorrect.



I have confirmed the existence of the private key in the keystore (using
Keystore Explorer), so all that is fine.

Please, any help would be greatly appreciated.



Cheers,

Matthew



*Matthew Westwood-Hill **

*