Re: Java Mail Inside Tomcat

2008-03-15 Thread jamieb

Hi Sameer

Thanks for the pointer. As it happened, I managed to get StartTLS to work
inside Tomcat, although I am still not sure why there is a difference in
behaviour when the below application is run standalone vs inside Tomcat. In
advance, please forgive the extended explanation but I am acutely aware that
this may information may help someone else in the event they come across the
same problem.

What I discovered was (what seems like) a limitation in the Java mail API:

o I was attempting to use a DummySSLFactory to skip certificate
authentication
o Java mail only allows you to specify one socketFactoryClass i.e.
mail.imap.socketFactory.class
o When you are using StartTLS, Java mail should be using two socketFactory
classes (one for the first plaintext connection and then another for the
subsequent secure connection)
o Javamail does not provide a way to set two different socket factory
classes
o  setting the default ssl socket factory using the SSL libraries directly
had no effect inside Tomcat

In the end, I ended up editing the Java mail source code and changing
com.sun.mail.util.SocketFetcher 

the Java mail source code to accept: mail.imap.startTLS.socketFactory.class. 
 
public static Socket startTLS(Socket socket, Properties props,
String prefix) throws IOException {

props.getProperty(prefix + .startTLS.socketFactory.class, null);

}

That way, I could now specify:

mail.imap.socketFactory.class and mail.imap.startTLS.socketFactory.class so
that different Socket factories would be called depending on whether a
plaintext or encrypted connection is being negotiated as part of the
StartTLS protocol extension.

At this point, I am wondering whether I am missing something about the use
of the StartTLS functionality or this is a genuine issue in the java mail
API.

Thanks for the time taken to investigate this problem. I really appreciate
it!

Regards,

Jamie





Sameer Acharya wrote:
 
 Can you give the line number as to where the error is
 happening.
 I found this link on google search you can read thru
 the same it describes similar problems.
 We have not had problems using java mail under tomcat
 but we dont use imap.
 http://forum.java.sun.com/thread.jspa?threadID=761635messageID=4347363
 
 -Sameer
 
 --- jamieb [EMAIL PROTECTED] wrote:
 
 
 
 Hi there
 
 I have encountered a bizzare problem... I have a
 small peice of code that
 fetches emails from an IMAP server using TLS. This
 code works perfectly in a
 standalone application, however, when I copy and
 paste it over to a Tomcat
 application it does not work.  The code uses Java
 Mail 1.4.1 and Java Secure
 Sockets. 
 
 The following error is outputted when the code is
 run from within Tomcat:
 
 javax.mail.MessagingException: Unrecognized SSL
 message, plaintext
 connection?;
   nested exception is:
  javax.net.ssl.SSLException: Unrecognized SSL
 message, plaintext connection?
 
 NOTE: in case you are wondering: YES in both cases
 the server is connecting
 to the same port. 
 
 Now I have checked:
 - the same java mail version is used across
 applications
 - the same JRE (v1.6)
 - all input parameters are the same
 
 Any ideas on what might be causing this problem in
 the Tomcat environment? 
 
 package com.test.support;
 
 import java.io.*;
 import java.security.Security;
 import java.util.Properties;
 import javax.mail.*;
 import javax.mail.internet.*;
 import java.net.*;
 
 public class TestMailboxConnection {
 
  /**
   * @param args
   */
  
  private static final String DUMMY_SSL_FACTORY =
 com.test.support.DummySSLSocketFactory;
  
  public static void main(String[] args) {
 

 if (args.length3) {
  System.out.println(\n\nUtility to
 Detect Mail Server
 Connection Settings);
  System.out.println(Usage:
 TestMailboxConnection server
 username password port secure_port );
  return;
  }
  String server = args[0];
  String username = args[1];
  String password = args[2];
  
  String port = 143;
  String secureport = 993;
  
  if (args.length3) {
  port   = args[3];
  secureport   = args[4];
  }
  
  
  Properties props = new Properties();
  // Insecure Test
  testEcho(server,port);
  //testEcho(server,secureport);
  System.out.println(properties:+props);
  String protocol = imap;
  props.put(mail.+protocol+.port,port); 
  test(imap

 insecure,protocol,server,Integer.valueOf(port),username,password,props);
 
 props.put(mail.+protocol+.starttls.enable,
 Boolean.TRUE);
 

 

API call to reload Tomcat web application

2008-03-15 Thread jamieb

Hi there

I am busy implementing an auto update facility for a Tomcat web application.
As part of the auto update process, the auto update code needs to unpack the
changed class files and reload the Tomcat web application. 

I am aware that you can configure Tomcat to automatically reload the web
application when class files are changed. I've decided against the use of
this functionality for fear of unscheduled service disruption.

My question: Is recommended way for a web application to apply an update to
itself and restart itself? Is there an API call to reload the current Tomcat
web application from within that application? 

Much appreciate

Jamie


-- 
View this message in context: 
http://www.nabble.com/API-call-to-reload-Tomcat-web-application-tp16065357p16065357.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Trouble building jsvc

2008-03-15 Thread Rainer Jung

Hi Ethan,

jarrod schrieb:

which version of jsvc do you try to compile?


The one distributed with Tomcat 6.0.16. It's in tomcat/bin as jsvc.tar.gz.


OK, I checked and that one is identical to the one I tried 
(commons-daemon 1.0.1).





Which docs page are you referring to?


I mean the main Tomcat site...

http://tomcat.apache.org/tomcat-5.5-doc/setup.html

I also checked the file INSTALL.txt that's inside jsvc.tar.gz.

I tried generating the configure script using autoconf. And also I tried
what it said in INSTALL.txt:

sh support/buildconf.sh


You should *not* do that without special reason. Usually the configure 
file provided as is should be fine. I assume the config.log you posted 
came from the configure you recreated and that was the reason for the 
line numbers that differed from mine. Let's ignore this for the moment, 
since you get the same problem with the original configure.



Same result each time -- what I described.



So let's look at your config.log:


Thread model: posix
gcc version 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)


H prerelease ...


configure:2131: $? = 0configure:2138: gcc -V 5
gcc: '-V' option must have argument
configure:2141: $? = 1


The -V problem we should ignore. I get the same error, but apart from 
that configure works and make too. The -V thing is an ancient way of 
determining gcc version that does not work any more.



configure:2164: checking for C compiler default output file name
configure:2191: gccconftest.c  5
/usr/bin/ld: crt1.o: 
No such file: No such file or directory

collect2: ld returned 1 exit status
configure:2194: $? = 1
configure:2232: result: configure: failed program was:
| /* confdefs.h.  */
| #define PACKAGE_NAME 
| #define PACKAGE_TARNAME 
| #define PACKAGE_VERSION 
| #define PACKAGE_STRING 
| #define PACKAGE_BUGREPORT 
| /* end confdefs.h.  */
| 
| int

| main ()
| {
| 
|   ;

|   return 0;
| }
configure:2239: error: C compiler cannot create executables


Aha, here it breaks. So next I would try to compile this test program 
myself, to see, if the compiler really is not able to compile the 
snippet. If so, then something is wrong with your environment.


So create a new file with the contents

/* confdefs.h.  */
#define PACKAGE_NAME 
#define PACKAGE_TARNAME 
#define PACKAGE_VERSION 
#define PACKAGE_STRING 
#define PACKAGE_BUGREPORT 
/* end confdefs.h.  */

int
main ()
{

  ;
  return 0;
}

and try to compile it with gcc filename. See if you get a resulting 
binary a.out or an error during compile/link.


Regards,

Rainer


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: API call to reload Tomcat web application

2008-03-15 Thread Martin Gainty
Jamie-

yes there is a way if you register SimpletonAgent in the registry as a
Managed Bean
http://java.sun.com/developer/technicalArticles/J2SE/jmx.html

perhaps if you have a simple test webapp we could suggest a test harness?

Martin-
- Original Message -
From: jamieb [EMAIL PROTECTED]
To: users@tomcat.apache.org
Sent: Saturday, March 15, 2008 2:21 AM
Subject: API call to reload Tomcat web application



 Hi there

 I am busy implementing an auto update facility for a Tomcat web
application.
 As part of the auto update process, the auto update code needs to unpack
the
 changed class files and reload the Tomcat web application.

 I am aware that you can configure Tomcat to automatically reload the web
 application when class files are changed. I've decided against the use of
 this functionality for fear of unscheduled service disruption.

 My question: Is recommended way for a web application to apply an update
to
 itself and restart itself? Is there an API call to reload the current
Tomcat
 web application from within that application?

 Much appreciate

 Jamie


 --
 View this message in context:
http://www.nabble.com/API-call-to-reload-Tomcat-web-application-tp16065357p1
6065357.html
 Sent from the Tomcat - User mailing list archive at Nabble.com.


 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Trouble building jsvc

2008-03-15 Thread jarrod



Rainer Jung-3 wrote:
 
 Hi Ethan,
 
 jarrod schrieb:
 which version of jsvc do you try to compile?
 
 The one distributed with Tomcat 6.0.16. It's in tomcat/bin as
 jsvc.tar.gz.
 
 OK, I checked and that one is identical to the one I tried 
 (commons-daemon 1.0.1).
 
 
 Which docs page are you referring to?
 
 I mean the main Tomcat site...
 
 http://tomcat.apache.org/tomcat-5.5-doc/setup.html
 
 I also checked the file INSTALL.txt that's inside jsvc.tar.gz.
 
 I tried generating the configure script using autoconf. And also I tried
 what it said in INSTALL.txt:
 
 sh support/buildconf.sh
 
 You should *not* do that without special reason. Usually the configure 
 file provided as is should be fine. I assume the config.log you posted 
 came from the configure you recreated and that was the reason for the 
 line numbers that differed from mine. Let's ignore this for the moment, 
 since you get the same problem with the original configure.
 
 Same result each time -- what I described.
 
 
 So let's look at your config.log:
 
 Thread model: posix
 gcc version 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
 
 H prerelease ...
 
 configure:2131: $? = 0configure:2138: gcc -V 5
 gcc: '-V' option must have argument
 configure:2141: $? = 1
 
 The -V problem we should ignore. I get the same error, but apart from 
 that configure works and make too. The -V thing is an ancient way of 
 determining gcc version that does not work any more.
 
 configure:2164: checking for C compiler default output file name
 configure:2191: gccconftest.c  5
 /usr/bin/ld: crt1.o: 
 No such file: No such file or directory
 collect2: ld returned 1 exit status
 configure:2194: $? = 1
 configure:2232: result: configure: failed program was:
 | /* confdefs.h.  */
 | #define PACKAGE_NAME 
 | #define PACKAGE_TARNAME 
 | #define PACKAGE_VERSION 
 | #define PACKAGE_STRING 
 | #define PACKAGE_BUGREPORT 
 | /* end confdefs.h.  */
 | 
 | int
 | main ()
 | {
 | 
 |   ;
 |   return 0;
 | }
 configure:2239: error: C compiler cannot create executables
 
 Aha, here it breaks. So next I would try to compile this test program 
 myself, to see, if the compiler really is not able to compile the 
 snippet. If so, then something is wrong with your environment.
 
 So create a new file with the contents
 
 /* confdefs.h.  */
 #define PACKAGE_NAME 
 #define PACKAGE_TARNAME 
 #define PACKAGE_VERSION 
 #define PACKAGE_STRING 
 #define PACKAGE_BUGREPORT 
 /* end confdefs.h.  */
 
 int
 main ()
 {
 
;
return 0;
 }
 
 and try to compile it with gcc filename. See if you get a resulting 
 binary a.out or an error during compile/link.
 
 Regards,
 
 Rainer
 
 

Ranier, thanks a lot for the help. Now that it's Saturday, I don't have
access to that particular machine. I'll have to try your suggestion on
Monday.

In the meantime, I'm planning to set up a VPS machine this weekend, so once
I get that running and get to the point of installing Tomcat, I'll try
running make without running configure first, as you suggested.

Thanks,

Ethan

-

ebdb
http://aeondust.com
-- 
View this message in context: 
http://www.nabble.com/Trouble-building-jsvc-tp16055587p16072353.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: DelegatingCallableStatement.getInnermostDelegate() -- NoSuchMethodError

2008-03-15 Thread Phil Steitz
On Fri, Mar 14, 2008 at 5:03 PM, Jim Garrison [EMAIL PROTECTED] wrote:

  I'm getting a NoSuchMethodError on
  org.apache.commons.dbcp.DelegatingCallableStatement.getInnermostDelegate
  ().

  AFAICT DelegatingCallableStatement inherits ultimately from
  DelegatingStatement, which DOES have such a method. I've examined the
  commons-dbcp-1.2.1.jar file that's in the classpath, and the
  inheritance hierarchy looks OK and there IS a getInnermostDelegate()
  method on DelegatingStatement.


  Since this is running in BusinessObjects' Tomcat 5.0 server I thought
  there might be a classloader problem.  I printed out the classloaders
  at the point where the error happens, but the debugging output seems
  to indicate that everything should work -- but I still get the
  exception.  I can't really post an SSCCE as this is buried in a much
  larger system that runs only under Tomcat.

  Source Fragment
  ===

  import java.sql.*;
  import org.apache.commons.dbcp.DelegatingCallableStatement;
 .
 .
 .
  PreparedStatement stmt;
 .
 .
 .
  protected void executeStatement() throws SQLException
  {
   if ( TPMonitor.TYPE_ORACLE == TPMonitor.getInstance().getDBType() )
   {
 System.out.println(DBTYPE: ORA);
 System.out.println(stmt CLASS:  + stmt.getClass().getName());
 System.out.println(stmt LOADER:  +
  stmt.getClass().getClassLoader().toString());

 DelegatingCallableStatement dcs = (DelegatingCallableStatement)
  stmt;
 System.out.println(dcs CLASS:  + dcs.getClass().getName());
 System.out.println(dcs LOADER:  +
  dcs.getClass().getClassLoader().toString());

 Statement cs = dcs.getInnermostDelegate();


  The above statement throws the following exception:

  java.lang.NoSuchMethodError:
  org.apache.commons.dbcp.DelegatingCallableStatement.getInnermostDelegate
  ()Ljava/sql/CallableStatement;



  Debugging Output
  

  DBTYPE: ORA
  stmt CLASS: org.apache.commons.dbcp.DelegatingCallableStatement
  stmt LOADER: StandardClassLoader
   delegate: true
   repositories:
 file:C:\Program Files\Business Objects\Tomcat\common\classes\
 file:C:\Program Files\Business
  Objects\Tomcat\common\endorsed\xalan.jar
 file:C:\Program Files\Business
  Objects\Tomcat\common\endorsed\xercesImpl.jar
 file:C:\Program Files\Business
  Objects\Tomcat\common\endorsed\xml-apis.jar
 file:C:\Program Files\Business
  Objects\Tomcat\common\lib\ant-launcher.jar
 file:C:\Program Files\Business Objects\Tomcat\common\lib\ant.jar
 file:C:\Program Files\Business
  Objects\Tomcat\common\lib\commons-collections-2.1.1.jar
 file:C:\Program Files\Business
  Objects\Tomcat\common\lib\commons-dbcp-1.2.1.jar
 file:C:\Program Files\Business
  Objects\Tomcat\common\lib\commons-el.jar
 file:C:\Program Files\Business
  Objects\Tomcat\common\lib\commons-pool-1.2.jar
 file:C:\Program Files\Business
  Objects\Tomcat\common\lib\jasper-compiler.jar
 file:C:\Program Files\Business
  Objects\Tomcat\common\lib\jasper-runtime.jar
 file:C:\Program Files\Business Objects\Tomcat\common\lib\jsp-api.jar
 file:C:\Program Files\Business
  Objects\Tomcat\common\lib\naming-common.jar
 file:C:\Program Files\Business
  Objects\Tomcat\common\lib\naming-factory.jar
 file:C:\Program Files\Business
  Objects\Tomcat\common\lib\naming-java.jar
 file:C:\Program Files\Business
  Objects\Tomcat\common\lib\naming-resources.jar
 file:C:\Program Files\Business Objects\Tomcat\common\lib\ojdbc14.jar
 file:C:\Program Files\Business
  Objects\Tomcat\common\lib\servlet-api.jar
 file:C:\Program Files\Business Objects\Tomcat\common\lib\sqljdbc.jar
  -- Parent Classloader:
  [EMAIL PROTECTED]

  dcs CLASS: org.apache.commons.dbcp.DelegatingCallableStatement
  dcs LOADER: StandardClassLoader
   delegate: true
   repositories:
 file:C:\Program Files\Business Objects\Tomcat\common\classes\
 file:C:\Program Files\Business
  Objects\Tomcat\common\endorsed\xalan.jar
 file:C:\Program Files\Business
  Objects\Tomcat\common\endorsed\xercesImpl.jar
 file:C:\Program Files\Business
  Objects\Tomcat\common\endorsed\xml-apis.jar
 file:C:\Program Files\Business
  Objects\Tomcat\common\lib\ant-launcher.jar
 file:C:\Program Files\Business Objects\Tomcat\common\lib\ant.jar
 file:C:\Program Files\Business
  Objects\Tomcat\common\lib\commons-collections-2.1.1.jar
 file:C:\Program Files\Business
  Objects\Tomcat\common\lib\commons-dbcp-1.2.1.jar
 file:C:\Program Files\Business
  Objects\Tomcat\common\lib\commons-el.jar
 file:C:\Program Files\Business
  Objects\Tomcat\common\lib\commons-pool-1.2.jar
 file:C:\Program Files\Business
  Objects\Tomcat\common\lib\jasper-compiler.jar
 file:C:\Program Files\Business
  Objects\Tomcat\common\lib\jasper-runtime.jar
 file:C:\Program Files\Business Objects\Tomcat\common\lib\jsp-api.jar
 file:C:\Program Files\Business
  

Tomcat on Leopard

2008-03-15 Thread maxchoc

I'm trying to install Tomcat 6.0.16 on Leopard.  I'm following a tutorial on 
http://swetnam.wordpress.com/2007/12/15/installing-apache-tomcat-6-on-os-x/

I've gotten to the point of trying to start tomcat on my mac but when in the
Terminal, I get the following

sh-3.2# ./start_tomcat
./start_tomcat: line 1: {rtf1ansiansicpg1252cocoartf949cocoasubrtf270:
command not found
./start_tomcat: line 2: syntax error near unexpected token `}'
./start_tomcat: line 2: `{\fonttbl\f0\fswiss\fcharset0 Helvetica;}'

What am I missing?

Thanks

marlene

-- 
View this message in context: 
http://www.nabble.com/Tomcat-on-Leopard-tp16075179p16075179.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Tomcat on Leopard

2008-03-15 Thread Hassan Schroeder
On Sat, Mar 15, 2008 at 8:08 PM, maxchoc [EMAIL PROTECTED] wrote:

  I'm trying to install Tomcat 6.0.16 on Leopard.  I'm following a tutorial on
  http://swetnam.wordpress.com/2007/12/15/installing-apache-tomcat-6-on-os-x/

Not sure why you'd use that instead of the real docs, and there's
no reason I can imagine to write a startup script to call an existing
startup script, but whatever...  :-)

  I've gotten to the point of trying to start tomcat on my mac but when in the
  Terminal, I get the following

  sh-3.2# ./start_tomcat
  ./start_tomcat: line 1: {rtf1ansiansicpg1252cocoartf949cocoasubrtf270:
  command not found

Use a real text editor, or make sure you save your file as text, not
RTF or whatever the heck that is...

-- 
Hassan Schroeder  [EMAIL PROTECTED]

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Tomcat on Leopard

2008-03-15 Thread Alan Chaney
I'd guess that you copied the text in the tutorial using an editor which 
converted it to an RTF

(Rich Text Format). The text you show in your email  is rtf markup.

The startup_tomcat file is a shell script which is setting the following 
environment variables


JAVA_HOME   - where you have installed our java sdk
JRE_HOME - the java runtime
CATALINA_HOME - the location of your tomcat files

You can set these 'by hand' by typing the lines in at the command line. 
Its better to set them in the .bashrc file.


Hope that helps



maxchoc wrote:
I'm trying to install Tomcat 6.0.16 on Leopard.  I'm following a tutorial on 
http://swetnam.wordpress.com/2007/12/15/installing-apache-tomcat-6-on-os-x/


I've gotten to the point of trying to start tomcat on my mac but when in the
Terminal, I get the following

sh-3.2# ./start_tomcat
./start_tomcat: line 1: {rtf1ansiansicpg1252cocoartf949cocoasubrtf270:
command not found
./start_tomcat: line 2: syntax error near unexpected token `}'
./start_tomcat: line 2: `{\fonttbl\f0\fswiss\fcharset0 Helvetica;}'

What am I missing?

Thanks

marlene

  



-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]