RE: mod_jk problem related to multiple hosts on Apache and Tomcat

2009-10-08 Thread Maciej Zabielski
Well Andre, you are right, but when I started reading what is the easiest way 
to 
make Tomcat available on port 80 (under Centos 5.3) the most common answer was: 
use Apache HTTPD.

Other solutions looked even more complicated as:
1 - Ports below 1024 are available only to root user, and I wanted to run 
Tomcat under default Tomcat user
2 - I have removed aliases and exclusions from host configurations and left 
parts relevant to my question, so not everything will be served by Tomcat.
3 - The applications that I'm using have multiple endpoints defined (more than 
10 I believe) in different configuration files, and as far as I know it might 
be the case that not all of them are configurable. Because of that I still need 
localhost:8080 to serve the same application. This is going to be solved in 
some future releases of Alfresco so it is going to be possible to set main 
endpoint as just one configuration value.
4 - I can still use Apache HTTPD to host other applications on that server, 
that are PHP based. (I know you can make PHP work on Tomcat somehow, but I 
believe it is recommended or advised to run PHP on Apache HTTPD if possible?) 
 

Regards,
Maciej

-Original Message-
From: André Warnier [mailto:a...@ice-sa.com] 
Sent: Thursday, October 08, 2009 2:14 AM
To: Tomcat Users List
Subject: Re: mod_jk problem related to multiple hosts on Apache and Tomcat

One real question is why you are bothering with an Apache httpd in 
front, since unless I saw this wrong, you are proxying absolutely 
everything to Tomcat, in both virtual hosts.
JkMount /* etc..

Why not just turn off Apache, and have Tomcat listen on port 80 ?
You would save yourself some complication and some overhead.


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Default character encoding for ServletRequest

2009-10-08 Thread Halm Reusser

Christopher Schultz wrote:


On that page is a POST form. When I evaluate the posted data, they are NOT
utf-8 encoded.


/Most/ clients will act the way you expect, yet, there is no requirement
for them to do so. What client is this, by the way?


Firefox 3.5.3, IE7, Safari 4.0.3


See the W3C document for the form element, specifically the
accept-charset attribute:
http://www.w3.org/TR/html401/interact/forms.html#adef-accept-charset

Read the part about UNKNOWN and how clients MAY interpret this as use
the current page encoding. This is RFC 'MAY' which basically means
it's a recommendation, but not at all required.

If you configure your form like this, the client is essentially required
to use your specified encoding if it expects the server to behave correctly:

form action=... method=POST accept-charset=UTF-8
...
/form

Give that a try and see what happens.


Does neither work. But thanks.

-Halm

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Cannot set remote address in valve (Tomcat 5.5)

2009-10-08 Thread Cyrille Le Clerc
   Hello Elli,

   I am afraid there may be a flaw in the algorythm looking for the
first IP  of the coma delimited x-forwarded-for header without
ensuring that this first IP has been set by a trusted proxy and not by
the requester ( getFirstIP(xforwardedForHeaderValue) ). Such spoofing
can easily be achieved with tools like Firefox add-ons Modify Headers
(1) and X-Forwarded-For Spoofer (2) .

   The forthcoming version of Apache Httpd will offer a secure
mechanism to handle X-Forwarded-For with a module called mod_remoteip
(3). It relies on the concept of trusted proxies which IP address can
be 'swallowed'. The first IP of the list that is not a trusted proxy
is seen as the real remote ip. mod_remoteip would not have been
tricked by such x-forwarded-for header spoofing.

   Here are two java ports of mod_remoteip to handle X-Forwarded-For
at the Tomcat level with a valve and at the WAR level with a servlet
filter : RemoteIpValve (4) and XForwardedFilter (5). In addition to
handle X-Forwarded-For, they also integrate X-Forwarded-Proto (ssl).
These java ports integrate the same trusted proxies concept to prevent
spoofing.

   Cyrille
--
Cyrille Le Clerc
clecl...@xebia.fr cyri...@cyrilleleclerc.com
http://blog.xebia.fr


(1) https://addons.mozilla.org/en-US/firefox/addon/967
(2) https://addons.mozilla.org/en-US/firefox/addon/5948
(3) http://httpd.apache.org/docs/trunk/mod/mod_remoteip.html
(4) http://code.google.com/p/xebia-france/wiki/RemoteIpValve
(5) http://code.google.com/p/xebia-france/wiki/XForwardedFilter


On Mon, Oct 5, 2009 at 11:19 PM, Elli Albek e...@sustainlane.com wrote:

 Hi,

 We can add the header to the custom valves, but then in addition we have to
 change a few log file configurations, create a servlet filter and maybe
 something else I cant think of now. Basically doing the same thing a few
 times and keeping track of all the places that depend on the header. Ideally
 this would all be corrected once in the beginning of the request processing
 pipeline, so log file configuration, other valves and the war files will
 remain unchanged.



 Attached a Valve that does that. This is the minimum code necessary, so it
 should not have any significant performance impact.

 Feel free to use as is, not guaranteed to work, no expressed on implied
 warranties, not FDIC insured and may loose value.



 To configure Tomcat add to server.xml:



 Service name=Catalina

      Connector port=8080 .../

      Engine defaultHost=localhost name=Catalina

            !-- This should precede all other configuration in the engine
 --

            Valve className=org.apache.catalina.connector.RemoteIPValve/



 Java class/jar should be placed in /server/lib or /server/classes



 E







 package org.apache.catalina.connector;



 import java.io.IOException;

 import java.util.regex.Matcher;

 import java.util.regex.Pattern;



 import javax.servlet.ServletException;



 import org.apache.catalina.connector.Request;

 import org.apache.catalina.connector.Response;

 import org.apache.catalina.valves.ValveBase;



 /**

  * A valve that extracts the remote IP of the client from an HTTP header
 field

  * passed by the proxy, and set it in the request as the original client IP.

  * This valve should be the first valve in the engine, so log valves (and

  * others) will see the real client IP without requiring the same code
 again.

  *

  * @author Elli Albek, www.sustainlane.com

  */

 public class RemoteIPValve extends ValveBase {



      private static final Pattern ipExpr =
 Pattern.compile(^[\\da-fA-F]+(\\.[\\da-fA-F]+)+);



      private String forwardedForHeader = X-Forwarded-For;



      public void invoke(Request request, Response response) throws
 IOException, ServletException {



            String header = request.getHeader(forwardedForHeader);

            String forwardedIP = getFirstIP(header);

            if (forwardedIP != null)

                  request.remoteAddr = forwardedIP;



            next.invoke(request, response);

      }



      /**

       * Return the first IP address in a string that may contain an IP list

       */

      static final String getFirstIP(String header) {

            if (header == null)

                  return null;

            Matcher m = ipExpr.matcher(header);

            if (m.find()) {

                  return m.group();

            }

            return null;

      }



      public void setForwardedForHeader(String forwardedForHeader) {

            this.forwardedForHeader = forwardedForHeader;

      }



      public String getInfo() {

            return RemoteIPValve;

      }

 }


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: JNI problem

2009-10-08 Thread Mohamedin
Here is one function that always crash. The portion of the code that couse 
the crash in my opinion is the if which has malloc. I noticed it crash 
whenever it is called with the same srcFile and dstFile


int reduce_quality(const char * srcFile, const char * dstFile, int maxSize){

struct stat info;

stat(srcFile, info);


if (info.st_size = maxSize){//it is already small enough!! so just copy it

return copy_file(srcFile, dstFile);

}


char * tmpFile = NULL;

if (strcmp(srcFile, dstFile)==0){

tmpFile = (char *) malloc(sizeof(srcFile)+1);

strcpy(tmpFile, srcFile);

strcat(tmpFile,_);

copy_file(srcFile, tmpFile);

srcFile = tmpFile;

}


int quality = DEFAULT_QUALITY;

long targetSize;

long lastTargetSize = 0;

int ret = False;

do {

ret = reduce_quality_to(srcFile, dstFile, quality);

if (ret == False) break;


stat(dstFile, info);

targetSize = info.st_size;


if (targetSize == lastTargetSize) {

ret = reduce_quality_to(srcFile, dstFile, quality + DECREASE_QUALITY_LEVEL);

break;

}

lastTargetSize = targetSize;

quality -= DECREASE_QUALITY_LEVEL;

} while (quality  0  targetSize  maxSize);

if (quality == 0)

fprintf(stderr,Couldn't reach desired size %d for %s\n, maxSize, dstFile);


if(tmpFile!=NULL){

remove(tmpFile);

free(tmpFile);

}

return ret;

}


JNIEXPORT jboolean JNICALL 
Java_com_vehicle_netapp_backend_objects_photo_PhotoOperations_reduceQuality


(JNIEnv * env, jobject jobj, jstring src, jstring dst, jint maxSize){

jboolean iscopy;

const char *srcFile = (*env)-GetStringUTFChars(env, src, iscopy);

const char *dstFile = (*env)-GetStringUTFChars(env, dst, iscopy);

int ret = reduce_quality(srcFile, dstFile, maxSize);

(*env)-ReleaseStringUTFChars(env, src, srcFile);

(*env)-ReleaseStringUTFChars(env, dst, dstFile);

return ret;

}


Thanks,
Mohamedin
- Original Message - 
From: Christopher Schultz ch...@christopherschultz.net

To: Tomcat Users List users@tomcat.apache.org
Sent: Wednesday, October 07, 2009 8:39 PM
Subject: Re: JNI problem



-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Mohamedin,

On 10/7/2009 10:40 AM, Mohamedin wrote:

Dear all,

I am trying to use a JNI library written by me that uses
GraphicsMagick wand. It is working fine as a stand alone java
application but when I tried to use it in tomcat it give me this error
and tomcat crashed.


Technically speaking, the JVM has crashed, not Tomcat.


I am running on:

AMD64
Tomcat 6.0.20
CATALINA_OPTS = 
-server -Xms512m -Xmx2048m -Djava.library.path=/usr/lib/apache-tomcat-6.0.20/shared/lib/:/usr/local/lib/


Please help

*** glibc detected *** /usr/bin/java: malloc(): memory corruption: 
0x7f5614455720 ***

=== Backtrace: =
/lib/libc.so.6[0x7f56b0cc7948]
/lib/libc.so.6[0x7f56b0cca17c]
/lib/libc.so.6(__libc_malloc+0x98)[0x7f56b0ccba78]
/usr/lib/apache-tomcat-6.0.20/shared/lib/libPhotoOperations.so(NewMagickWand+0x13)[0x7f561b7068de]
/usr/lib/apache-tomcat-6.0.20/shared/lib/libPhotoOperations.so(reduce_quality_to+0x26)[0x7f561b6f71f6]
/usr/lib/apache-tomcat-6.0.20/shared/lib/libPhotoOperations.so(reduce_quality+0x88)[0x7f561b6f74e8]
/usr/lib/apache-tomcat-6.0.20/shared/lib/libPhotoOperations.so(Java_com_vehicle_netapp_backend_objects_photo_PhotoOperations_reduceQuality+0x68)[0x7f561b6f7688]
[0x7f56a95ca542]


Since your code is definitely involved, here (the stack trace above
shows 4 layers of your code before glibc is involved), I suspect your
code is to blame for this problem.

Tomcat does not use any native code directly (except for tcnative if you
are using that). Are you using tcnative? If so, disable it and re-try to
convince yourself that this is not a Tomcat problem. I'm not saying it
is definitely /not/ a Tomcat problem, but chances are that it's your
code at fault.

My experience with native code from Java is that when memory corruption
is found in one instance but not another and the code is the same, then
there is probably some bug in your code that is sensitive to re-location
of your code within memory. That is, you are making assumptions about
your environment that are not valid when running from within a JVM (or
they work sometimes, but not other times because more code gets loaded
when running under an app server).

How much of your JNI code are you willing to post? Typically, one
develops a native library that has nothing to do with Java, and then
writes a Java wrapper around that code which is little more than the
plumbing necessary to convert data between Java-style objects, arrays,
etc. and C-style data structures. Have you done that? If so, go ahead
and post the JNI-specific layer.

If not, I think you're playing with fire by writing a native library
that does a great deal of Java interaction.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrM4EcACgkQ9CaO5/Lv0PBregCgumcWoLGOm+fOjvV4S79ZHt1P
y10AoKqWpMNgMMYKKubd9H+jQPKjIHS2
=rfQZ
-END PGP SIGNATURE-


Re: Should I use mod_jk or mod_proxy_ajp for my Apache2 to Tomcat5 connector on AIX ?

2009-10-08 Thread Tobias Crefeld
Am Thu, 24 Sep 2009 10:54:56 -0500
schrieb Strickland, Lawrence P lawrence-strickl...@uiowa.edu:

 I am having some problems building mod_jk on AIX and I see the same
 functionality is supported in mod_proxy_ajp.
 Does anyone have some good reason why I should use one over the other?

Using mod_proxy_ajp we got problems with larger http-1.0-POST's: The
connector is truncating the POST before receiving its size. 
FOR US this is a serious issue and we found no other workaround than
changing to mod_proxy (http) to wrap port 80 to port 8080 (Tomcat's
coyote-interface) which has other limitations (out.flush; hiding
source IP-addresses).

Beside this mod_proxy_ajp runs pretty well and is more simple to setup
than mod_jk and for most applications it works fine. 
We are still testing mod_jk, so I cannot say if there are other
arguments against mod_jk. Unfortunately CentOS' default-installation of
Apache2 has no support for mod_jk, so we have to update manually. I
estimate it's the same for AIX.

We're running Tomcat-6 but I don't think that this makes any difference
concerning your question.


RU,
 Tobias.

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: JNI problem

2009-10-08 Thread Konstantin Kolinko
2009/10/8 Mohamedin mohame...@easy-dialog.info:
 Here is one function that always crash. The portion of the code that couse
 the crash in my opinion is the if which has malloc. I noticed it crash
 whenever it is called with the same srcFile and dstFile

 int reduce_quality(const char * srcFile, const char * dstFile, int maxSize){

 ...
 tmpFile = (char *) malloc(sizeof(srcFile)+1);

You meant string length there?   sizeof(pointer) is - what is the size
of pointers on your OS?  8 bytes?

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: JNI problem

2009-10-08 Thread Mohamedin

Thanks a lot

I have fixed this bug (Long time without coding in C). But still the error. 
Then I removed all malloc from the code. Still crashing


Examples of stack traces:

Stack: [0x7fff8c015000,0x7fff8c215000),  sp=0x7fff8c212b58, 
free space=2038k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native 
code)


[error occurred during error reporting, step 120, id 0xb]

Stack: [0x41e03000,0x41f04000),  sp=0x41f02970, 
free space=1022k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native 
code)

V  [libjvm.so+0x318849]
V  [libjvm.so+0x62b60c]
V  [libjvm.so+0x62dc30]
V  [libjvm.so+0x5fa803]
V  [libjvm.so+0x5cf95d]
V  [libjvm.so+0x66a6fd]
V  [libjvm.so+0x66a0fa]
V  [libjvm.so+0x56b5e5]

Stack: [0x41dbd000,0x41ebe000),  sp=0x41ebc4b0, 
free space=1021k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native 
code)

V  [libjvm.so+0x2e6215]
V  [libjvm.so+0x3856d3]
V  [libjvm.so+0x317b47]
V  [libjvm.so+0x317db0]
V  [libjvm.so+0x62b466]
V  [libjvm.so+0x62d97b]
V  [libjvm.so+0x320ce2]
V  [libjvm.so+0x2e4860]
V  [libjvm.so+0x320782]
V  [libjvm.so+0x2adefd]
V  [libjvm.so+0x3209be]
V  [libjvm.so+0x66ae56]
V  [libjvm.so+0x66abda]
V  [libjvm.so+0x66a2f6]
V  [libjvm.so+0x66a56b]
V  [libjvm.so+0x66a0fa]
V  [libjvm.so+0x56b5e5]

VM_Operation (0x411747b0): generation collection for allocation, 
mode: safepoint, requested by thread 0x7fb2705448a0


Please help.

And here is the whole code:
#include jni.h

#include sys/types.h

#include sys/ipc.h

#include sys/shm.h

#include sys/mman.h

#include sys/stat.h

#include fcntl.h

#include unistd.h

#include stdlib.h

#include stdio.h

#include string.h

#include wand/magick_wand.h


#define False 0

#define True 1

#define DEFAULT_QUALITY 75

#define DECREASE_QUALITY_LEVEL 5


#define ThrowAPIException(wand) \

{ \

description=MagickGetException(wand,severity); \

(void) fprintf(stderr,%s %s %d %.1024s\n,GetMagickModule(),description); \

DestroyMagickWand(wand); \

free(description); \

}


int reduce_quality_to(const char * srcFile, const char * dstFile, int 
quality){


char *description;

ExceptionType severity;

MagickWand *magick_wand;

unsigned int status;


magick_wand = NewMagickWand();


status = MagickReadImage(magick_wand, srcFile);

if (status == False) {

ThrowAPIException(magick_wand);

return False;

}

MagickSetCompressionQuality(magick_wand, quality);

status=MagickWriteImages(magick_wand, dstFile,True);

if (status == False){

ThrowAPIException(magick_wand);

return False;

}

DestroyMagickWand(magick_wand);

return True;

}


JNIEXPORT jboolean JNICALL 
Java_com_vehicle_netapp_backend_objects_photo_PhotoOperations_reduceQualityTo


(JNIEnv * env, jobject jobj, jstring src, jstring dst, jint quality){

jboolean iscopy;

const char *srcFile = (*env)-GetStringUTFChars(env, src, iscopy);

const char *dstFile = (*env)-GetStringUTFChars(env, dst, iscopy);

int ret = reduce_quality_to(srcFile, dstFile, quality);

(*env)-ReleaseStringUTFChars(env, src, srcFile);

(*env)-ReleaseStringUTFChars(env, dst, dstFile);

return ret;

}


int copy_file(const char * src, const char * dst){

int inF, ouF;

char buff[1024*1024];

int bytes;


if (strcmp(src, dst)==0) return False;


if((inF = open(src, O_RDONLY)) == -1) {

perror(open);

return False;

}


if((ouF = open(dst, O_WRONLY | O_CREAT)) == -1) {

perror(open);

return False;

}


while((bytes = read(inF, buff, sizeof(buff)))  0)

write(ouF, buff, bytes);


close(inF);

close(ouF);

return True;

}


int reduce_quality(const char * srcFile, const char * dstFile, int maxSize){

struct stat info;

stat(srcFile, info);


if (info.st_size = maxSize){//it is already small enough!! so just copy it

return copy_file(srcFile, dstFile);

}


int quality = DEFAULT_QUALITY;

long targetSize;

long lastTargetSize = 0;

int ret = False;

do {

ret = reduce_quality_to(srcFile, dstFile, quality);

if (ret == False) break;


stat(dstFile, info);

targetSize = info.st_size;


if (targetSize == lastTargetSize) {

ret = reduce_quality_to(srcFile, dstFile, quality + DECREASE_QUALITY_LEVEL);

break;

}

lastTargetSize = targetSize;

quality -= DECREASE_QUALITY_LEVEL;

} while (quality  0  targetSize  maxSize);

if (quality == 0)

fprintf(stderr,Couldn't reach desired size %d for %s\n, maxSize, dstFile);


return ret;

}


JNIEXPORT jboolean JNICALL 
Java_com_vehicle_netapp_backend_objects_photo_PhotoOperations_reduceQuality


(JNIEnv * env, jobject jobj, jstring src, jstring dst, jint maxSize){

jboolean iscopy;

const char *srcFile = (*env)-GetStringUTFChars(env, src, iscopy);

const char *dstFile = (*env)-GetStringUTFChars(env, dst, iscopy);

int ret = reduce_quality(srcFile, dstFile, maxSize);

(*env)-ReleaseStringUTFChars(env, src, srcFile);

(*env)-ReleaseStringUTFChars(env, dst, dstFile);

return ret;

}


int resize(const char * srcFile, const char * dstFile, int width, int 
height, int quality){



Re: ssl_error_internal_error_alert in firefox only, dependent on jdk version (tomcat 5.5.26)

2009-10-08 Thread Konstantin Kolinko
Does this issue depend on Firefox version? (which version you are
using?) Is it reproducible on different client PCs running the same
Firefox version? Maybe different Firefox settings? Is TLS protocol
enabled in Firefox (usually it is)?

From description, this issue is not dependent on your application. Can
you reproduce it with default applications that Tomcat comes with, on
latest Tomcat 5.5.28 or 6.0.20, even if you cannot run your
application on that versions?

Is it reproducible with self-signed certificates? Is it reproducible
on other operating systems?

The set of ciphers in JDK 1.5 and JDK 1.6 might be different. That is,
the browser and the server might not agree on what cipher to use.
(though why there is the internal_error alert ?)

Best regards,
Konstantin Kolinko

2009/10/2 Nada O'Neal nco2...@columbia.edu:
 Hey everyone -

 I'm stuck on Tomcat 5.5.26 to support a specific application. This is a
 Solaris 9 server with no Apache - tomcat is handling its own webserving.
 We're hoping to upgrade the JDK. I can use JDK-1.5.0_21 successfully. When I
 start tomcat with JDK-1.6.0_16, I get one specific issue...

 Firefox, but not Safari or IE, will report on https connections:

        Secure Connection Error
        An error occurred during a connection to mysite.com:8443.
        Peer reports it experienced an internal error.
        (Error code: ssl_error_internal_error_alert)

 Weirdly, there is no error in any error log when this happens.

 I think this might be a configuration error on my part. Here's our SSL conf
 stanza:

                Connector port=8443 maxHttpHeaderSize=8192
               maxThreads=150 minSpareThreads=25 maxSpareThreads=75
               enableLookups=false disableUploadTimeout=true
               acceptCount=100 scheme=https secure=true
               clientAuth=false sslProtocol=TLS
                keystoreFile=/path/to/my/keystore
                keystorePass=somePass /

 ... I notice that in other people's configs, they have a specific reference
 to a TrustStore. I have the CA certs imported into the keystore, though, and
 I'm using this config on other servers, with other versions of tomcat, other
 versions of the JDK, etc. (However, those are all linux servers.) I'm
 especially suspicious about this possibility because lately there have been
 other Firefox https bugs (like the Flash uploader bug) that ultimately have
 to do with verifying the certificate authority. Adding in a truststore
 doesn't seem to help, but maybe i r doin it wrong.

 Thanks for any references or wild speculation you can provide.

 - Nada

 (p.s. if you're curious about the Flash uploader bug, see e.g.:
 http://bugs.adobe.com/jira/browse/FP-201
 http://bugs.adobe.com/jira/browse/FP-226
 https://bugs.adobe.com/jira/browse/SDK-13196
 http://swfupload.org/forum/generaldiscussion/347 )

 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: JNI problem

2009-10-08 Thread Konstantin Kolinko
2009/10/8 Mohamedin mohame...@easy-dialog.info:
 Thanks a lot

 I have fixed this bug (Long time without coding in C). But still the error.
 Then I removed all malloc from the code. Still crashing

You are using free(..). Thus you need to have malloc()s somewhere.

Also,
(void) fprintf(stderr,%s %s %d %.1024s\n,GetMagickModule(),description);
you have 4 substitutions, but only 2 arguments for them.

You really should review/debug your C code, and it likely has nothing
to do with Tomcat.

Best regards,
Konstantin Kolinko

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: JspServlet Issue

2009-10-08 Thread Konstantin Kolinko
2009/10/7 Mercy techme...@gmail.com:
 Hi Mark,

        I just want to compile the pages what i need, not all. Actually,the
 most pages ware compiled by ANT,thus, our application does not set the
 development parameter is true.

        What's more , I did not re-invent the wheel rather than I re-use the
 JspServlet and its correlative classes.

        Thank you for your time.


What part of your application does not work for you when you have
development=false? What are your requirements?

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: JspServlet Issue

2009-10-08 Thread Mercy


Hi Kolinko,

	In order to implement requirement is that our application can't set  
development=true and needs to compile little of pages without restart need.
If I use the JspServlet , it compiles JSP Pages and loads them class and  
works fine, but If use my compiler to compile and load, the JspServlet  
can't find the class.
I debuged it and found that JapserLoader can't find it,so I suspect that  
it's a problem about class loader.


Thank you for your response.

Kind regards,
Mercy



Mercy wrote:

Hi Mark,
 Thank you for your response, actually, I has found a way to fulfill
my requirement that it can compile the JSP pages when development
parameter is false.
My question is that why my compiler using JspServletWrapper has been
compiled some class files of Jsp file, the JasperLoader can't find
them,at the same time,
The other pages that were compiled by JspServlet in first time could be
found by JapserLoader.
 The exception told me that org/apache/jsp/_1_jsp class can't be
found,but it still exists and its modified time is latest.
 Is it a bug of JapserLoader or URLClassLoader?




On Thu, 08 Oct 2009 19:07:14 +0800, Konstantin Kolinko  
knst.koli...@gmail.com wrote:



What part of your application does not work for you when you have
development=false? What are your requirements?



--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Application gets started twice

2009-10-08 Thread Maciej Zabielski
Hi, 
I couldn't find anything related to my configuration problem.
I have Alfresco application installed under webapps/alfresco. The host looks 
like this:

Host name=localhost debug=0 appBase=webapps unpackWARs=true 
autoDeploy=false  xmlValidation=false xmlNamespaceAware=false
   Context path= docBase=/var/lib/tomcat5/webapps/alfresco/   
   Aliasalfresco.mydomain.com/Alias
/Host

When I look at the application log, or catalina.out I can see, that the 
application is started twice.
(there are two application started entries)
That happens for each restart of Tomcat...

(alias is used for my Apache HTTPD connection, I use Tomcat5, Centos 5.3)

Thanks for your great support!
Mike

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: JspServlet Issue

2009-10-08 Thread Konstantin Kolinko
2009/10/8 Mercy techme...@gmail.com:

 Hi Kolinko,

        In order to implement requirement is that our application can't set
 development=true and needs to compile little of pages without restart need.

Even if development=false, it compiles new pages.

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Application gets started twice

2009-10-08 Thread Mikolaj Rydzewski

Maciej Zabielski wrote:

I have Alfresco application installed under webapps/alfresco. The host looks 
like this:

Host name=localhost debug=0 appBase=webapps unpackWARs=true autoDeploy=false  
xmlValidation=false xmlNamespaceAware=false
   Context path= docBase=/var/lib/tomcat5/webapps/alfresco/ 
   Aliasalfresco.mydomain.com/Alias
/Host

When I look at the application log, or catalina.out I can see, that the 
application is started twice.
  

Application is started twice because:

  1. Tomcat starts all webapps located within webapps directory
  2. Tomcat starts all webapps specified by Context elements

Remove Context entry and restart tomcat. It's so easy :-)
If you - for any reason - need Context element, move webapp to folder 
different than webapps and update docBase.


--
Mikolaj Rydzewski m...@ceti.pl


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Application gets started twice

2009-10-08 Thread Mark Thomas
Maciej Zabielski wrote:
 Hi, 
 I couldn't find anything related to my configuration problem.
 I have Alfresco application installed under webapps/alfresco. The host looks 
 like this:
 
 Host name=localhost debug=0 appBase=webapps unpackWARs=true 
 autoDeploy=false  xmlValidation=false xmlNamespaceAware=false
Context path= docBase=/var/lib/tomcat5/webapps/alfresco/ 
Aliasalfresco.mydomain.com/Alias
 /Host

deployOnStartup is deploying the affresco dir as /alfresco when Tomcat starts.
Set deployOnStartup to false or delete the above context element and rename
/var/lib/tomcat5/webapps/alfresco to /var/lib/tomcat5/webapps/ROOT

Mark


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: JspServlet Issue

2009-10-08 Thread Mercy

Hi,

	Yes, it just does on the first time request,I need to compile the page  
when I need.


Kind regards,
Mercy

On Thu, 08 Oct 2009 20:00:50 +0800, Konstantin Kolinko  
knst.koli...@gmail.com wrote:



2009/10/8 Mercy techme...@gmail.com:


Hi Kolinko,

   In order to implement requirement is that our application can't  
set
development=true and needs to compile little of pages without restart  
need.


Even if development=false, it compiles new pages.

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org




--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: JspServlet Issue

2009-10-08 Thread Mark Thomas
Mercy wrote:
 Hi,
 
 Yes, it just does on the first time request,I need to compile the
 page when I need.

What is wrong with the process described in JSP.11.4.2?

Mark

 
 Kind regards,
 Mercy
 
 On Thu, 08 Oct 2009 20:00:50 +0800, Konstantin Kolinko
 knst.koli...@gmail.com wrote:
 
 2009/10/8 Mercy techme...@gmail.com:

 Hi Kolinko,

In order to implement requirement is that our application
 can't set
 development=true and needs to compile little of pages without restart
 need.

 Even if development=false, it compiles new pages.

 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org

 
 


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: how to integrate tomcat with IDE tools like eclipse,Netbeans?

2009-10-08 Thread srinivas2828

oops thats great working fine and have one  more and how can i use ant to
build this project to work with tomcat and eclipse

Mercy Ma wrote:
 
 Hi,
 
 At first , you need to create a web project , and the add it into 
 tomcat server.
 
 Later, you create a new jsp page, select it and click right button, 
 the pop-up menu dispears, select Run As - Run on Server, the server is 
 Ok when that page is present. :-)
 

 Kind regards,
 Mercy
 
 srinivas2828 wrote:
 Oh..thats Great and can you tell me how can i see the server status
 success
 or not and can i see the default success page in eclipse and is it
 possibe?
 or ele browser?dont mind for this question and I am newbie to this kind
 of
 configurations...
 O

 Mercy Ma wrote:
   
 Hi,
 You could add the src.zip under JDK folder instead of JRE,please take a 
  
 look at the attached image file.

 Kind regards,
 Mercy


 On Wed, 07 Oct 2009 17:34:18 +0800, srinivas2828
 srinivas2...@gmail.com  
 wrote:

 
 I really appriciate your help but got one more problem,please find  
 attached
 copy of image
 http://www.nabble.com/file/p25783409/Screenshot.png Screenshot.png

 Konstantin Kolinko wrote:
   
 2009/10/7 srinivas2828 srinivas2...@gmail.com:
 
 Hi Deepa
 I integrated tomcat with eclipse(I downloaded Eclipse-Galelio) then i  
 got
 and I am facing one problem that when I start Tomcat server it came  
 with
 one
 error message which says Starting Tomcatv6.0 Server at localhost has
 encoutered a problem, Port 80 required by Tomcat v6.0 server at  
 localhost
 already in use. the server may already running in another process, or
 a
 system process may be using  the port,To start this server you will  
 need
 to
 stop  the other process or change the port number(s)

 any idea

   
 As it says, you will need to stop the other process or change the
 port number(s)

 Either change the numbers by editing server.xml (that is inside the
 Servers project), or using the GUI, e.g. as is described here (found
 thanks to Google):

 http://techteam.wordpress.com/2009/02/13/changing-the-tomcat-port-settings-in-eclipse/

 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org



 
 -- 
 Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org

 

   
 
 
 

-- 
View this message in context: 
http://www.nabble.com/how-to-integrate-tomcat-with-IDE-tools-like-eclipse%2CNetbeans--tp25764753p25802960.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



RE: mod_jk problem related to multiple hosts on Apache and Tomcat

2009-10-08 Thread Caldarale, Charles R
 From: Maciej Zabielski [mailto:m...@tessel.pl]
 Subject: RE: mod_jk problem related to multiple hosts on Apache and
 Tomcat
 
 when I started reading what is the easiest way to make Tomcat 
 available on port 80 (under Centos 5.3) the most common
 answer was: use Apache HTTPD.

Probably written by someone very familiar with httpd and unfamiliar with 
Tomcat.  Using Tomcat standalone on port 80 without root privileges is actually 
much easier and less overhead, as described here:
http://tomcat.apache.org/tomcat-6.0-doc/setup.html#Unix%20daemon

 1 - Ports below 1024 are available only to root user, and I wanted to
 run Tomcat under default Tomcat user

See above.  You can also use iptables to do port forwarding.

 Because of that I still need localhost:8080 to serve the same
 application.

All you need for that is two Connector elements, one for port 80, one for 
8080.

 4 - I can still use Apache HTTPD to host other applications on that
 server, that are PHP based.

Now you have a real reason for keeping httpd in the mix.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Tomcat Repsonse question...

2009-10-08 Thread Tony Anecito
Hi Christopher,

I tried to change JBoss to run on port 80 and seems not to work so I will leave 
a message on JBoss forumabout how that can be accomplished since there have 
been others having the same issue with 5.1.

I did run a profiler and found out the response time for the ajp connection was 
6-7millisecond for the snapshot I took. So bypassing that by using JBoss http 
directly (without Apache Web Server) seems a valuable test to see if I can meet 
my goal.

Best Regards,
-Tony

--- On Wed, 10/7/09, Christopher Schultz ch...@christopherschultz.net wrote:

 From: Christopher Schultz ch...@christopherschultz.net
 Subject: Re: Tomcat Repsonse question...
 To: Tomcat Users List users@tomcat.apache.org
 Date: Wednesday, October 7, 2009, 3:14 PM
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 Tony,
 
 On 10/6/2009 1:32 PM, Tony Anecito wrote:
  I am running JBoss and Apache on the same box so not
 sure if the 
  TCP/IP stack is bypassed in that case.
 
 It's not bypassed, but it skips a lot of steps and does
 sneaky things
 like sharing send and receive buffers to dramatically
 reduce the
 overhead when communicating with localhost (at least,
 decent *NIX TCP/IP
 stacks do this... not sure about any others).
 
  What I am trying to do is find out where my
 bottlenecks are.
 
 Tomcat itself is unlikely to be a bottleneck, except where
 Connectors
 are concerned. There are several reasons why the
 connector/threads could
 be a problem for you:
 
 1. Your webapp is not responding quickly enough, resulting
 in a pileup
 of requests. This is obviously not really Tomcat's fault.
 
 2. You have lots of keepalive requests, and the client
 takes a long time
 to send secondary requests. In this case, consider using
 the NIO
 connector which doesn't allocate a request processing
 thread until a
 request has actually been made.
 
 3. You don't have enough request processing threads
 configured, and you
 are simply experiencing more traffic than you expected. In
 this case,
 your webapp is performing as expected (i.e. well) but you
 aren't getting
 the throughput you expect because you are simply limited by
 your
 available thread count.
 
 If you could explain what you are observing, we might be
 able to steer
 you toward a particular course of action.
 
  In my code I instrument the response time for my web
 service and I
  am below 1msec and if visualvm is right more like
 20microseconds 
  response time for the method exposed for my web
 service.
 
 That sounds reasonable, especially if you aren't hitting a
 database or
 you already have some data cached.
 
  At my Thick client over the lan I am seeing 3-5msec
 response time
  using JBoss 4.2.2.
 
 So, instrumenting the client gives you 3-5msec for an
 observed overhead
 of 2-4msec? Are you using SSL or anything like that? Still
 localhost?
 
  So trying to go from tier to tier to see how fast the
 tiers are and
  if there is anything else I can tune. I just updated
 to JBoss 5.1.0
  and am seeing 1msec slower or 4-5msec but have not
 tuned it yet
  except for jvm settings.
 
 Hmm...
 
  I am using ajp for the connector. I plan to upgrade my
 Apache web 
  server soon to the latest version hoping for
 performance improvement 
  for the ajp connector.
 
 If performance is what you're after, ditch httpd and go
 straight to
 Tomcat. Do you have a requirement to use httpd our front?
 
 - -chris
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.9 (MingW32)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
 
 iEYEARECAAYFAkrNBKgACgkQ9CaO5/Lv0PDfgwCgvgKOLHRAl5+JpS7+aqsFytJN
 C+gAnRRnxwliEkVBzYy73l7gpvT3+V0z
 =axGy
 -END PGP SIGNATURE-
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org
 
 


  

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: java.lang.OutOfMemoryError: Java heap space

2009-10-08 Thread Joe Hansen
 Yup, it looks like you have more of your application objects taking up
 memory than the tickets you were worried about.

So True! We are right now designing and developing our next generation
of websites and this experience will surely come handy. I will now
think twice before I store anything in the session and will make sure
I remove no longer used objects from the HTTP Session.

 You can couple session-object expiration with lazy instantiation/fetch for a 
 solution
 that can keep your sessions lightweight yet allow insanely long session
 timeouts.

Chris, can you please elaborate what you mean by coupling
session-object expiration with lazy fetch?

 Is it an absolute requirement that these objects be stored in the
 session at all? If so, then maybe the caching strategy can be tweaked a
 bit to allow both requirements to peacefully coexist.

The code is 3 years old and it does not use a caching strategy at all.
However, I am planning to use ehcache when we developer our future
websites.

 There are even techniques that will allow your session objects to expire
 when memory gets tight (which is super cool IMO).

I did not know that something like that existed. Thanks for letting me
know, Chris!

Thanks for telling me about SoftReference, Charles. Looks like
SoftReference existed since JDK 1.2 and I never knew about it! Is the
use of SoftReference popular?

Thanks guys!
Joe

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: New Sample Question...

2009-10-08 Thread Tony Anecito
Hi Jiri,

Thanks for the link it clears up better what you and Thomas are saying. You 
both have been extreemly helpful. What you and Thomas need to understand is the 
typical developer will not ask the questions that I do. To me a profiler and 
static code analysis tools are as important as a IDE for productivity and 
assuring quality.

I did run visualvm on two other windows PC's (Windows Xp Sp2 and Windows 2000 
prof sp4) and did not get the error that I got for the instrumentation profiler 
(the sampler did not generate any errors).

Thanks for your time I am trying to get different functional groups interested 
in using visualvm as we upgrade to jdk 1.6.0_7 and above so they get the 
visualvm profiler.

I am just trying to do what noone else has done and get a system response time 
via lan under 1 millisecond with inexpensive hardware and open source software 
(Tomcat/JBoss) and need a way to find bottlenecks using a tool that can measure 
down to millisecond or below. I am/was at 3-4 milliseconds measure at the 
client using JAX-WS and just last night figured out where my remaining 
bottleneck (using visualvm and help from the Tomcat group) might be to achieve 
my goals.

Just imagine the size of a data center if vendors/developers could create 
solutions that responded under a microsecond (I have code that used to be under 
1 nanosecond but now around 5 microsends with 3 tier caching). Depending upon 
the network technology you could serve up whole countries with that type of 
capability using open source like Tomcat no less! Just need the 200Gbps 
networks the universities have here in the US :-)

Best Regards,
-Tony



  

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



RE: java.lang.OutOfMemoryError: Java heap space

2009-10-08 Thread Caldarale, Charles R
 From: Joe Hansen [mailto:joe.hansen...@gmail.com]
 Subject: Re: java.lang.OutOfMemoryError: Java heap space
 
 Is the use of SoftReference popular?

You'll find it as the underlying mechanism of many cache managers, since it 
automatically adapts reasonably well to whatever the execution environment 
happens to be.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: java.lang.OutOfMemoryError: Java heap space

2009-10-08 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Joe,

On 10/8/2009 12:12 PM, Joe Hansen wrote:
 I will now think twice before I store anything in the session and
 will make sure I remove no longer used objects from the HTTP
 Session.

It's always a good goal to limit your session size, but it's not always
foolproof because users don't always do the things you expect. For
instance, if you have a process your user goes through, and you store a
big object (or set of objects) in the session during that process, and
the user does not finish the process, you still need to clean-up after that.

 You can couple session-object expiration with lazy 
 instantiation/fetch for a solution that can keep your sessions
 lightweight yet allow insanely long session timeouts.
 
 Chris, can you please elaborate what you mean by coupling
 session-object expiration with lazy fetch?

So, lazy instantiation (or initialization) is a design pattern where you
only create objects when you are actually going to use them, as opposed
to creating everything you /might/ need just in case it's necessary.
Lazy fetch is just a term I used to describe grabbing your Foto
objects only when actually needed (rather than speculatively loading them).

This concept is illustrated easily in a few lines of code:

// This would be speculative instantiation
Vector v = new Vector(1000); // Just in case

...

if(something) {
   // use the Vector object
}

// This would be lazy instantiation
Vector v = null;

if(something) {
  if(null == v)
v = new Vector();

  // use the Vector object
}

It sounds simple, and it is. The same concept can be applied when
fetching large objects from the database and possibly storing them in
the session. You can use the session as a poor-mans cache something like
this:

// You probably already do this kind of thing in your code:
Foto foto = (Foto)session.getAttribute(myFotoObject);

// But now, you can plan for the case where the object either
// was never there, or has disappeared because it has been
// removed to save memory:

if(null == foto) {
  foto = fotoManager.fetch(whatever);

  session.setAttribute(myFotoObject, foto);
}

Using this technique, you can get the benefit of session caching that
is tolerant of disappearing objects due to the lazy-fetching technique
I describe. See below for how to hook it up to cache-flushing schemes.

 Is it an absolute requirement that these objects be stored in the
 session at all? If so, then maybe the caching strategy can be tweaked a
 bit to allow both requirements to peacefully coexist.
 
 The code is 3 years old and it does not use a caching strategy at all.
 However, I am planning to use ehcache when we developer our future
 websites.

3 years is not a ripe old age for code. Our best code is the stuff that
has lasted for 3 or more years without having to be rewritten. ;)

If ehcache is your thing, go for it. There are other possibilities, too.

 There are even techniques that will allow your session objects to expire
 when memory gets tight (which is super cool IMO).

One way to retrofit your web application is to use SoftReferences to
store objects within your session attributes. You can either re-write
all your code to deal with SoftReferences (see examples below), or you
can get tricky and write a simple wrapper around your request/session
objects to do the magic for you.

I'll show you how such tricks could be implemented.

Let's say that you always use the prefix foto for all Foto objects in
the session. You could use this technique with all session objects, but
it really only makes sense with the big ones. Here's the plan:

1. Alter your code that deals with Foto objects stored in the session to
tolerate the objects apparently disappearing from the session without
notice. That is, always check for null and re-fetch from the database or
wherever you get your Foto data.

2. SoftReference objects will be used to store your actual Foto objects
in the session.

3. Write a Filter which wraps the HttpServletRequest object to return a
wrapped HttpSession object which will handle the SoftReferences
mentioned in #2 (got all that?)

It's easier than it sounds. Let's assume #1 is already done. Here's how
to write the filter (which implements both #2 and #2 above):

public class SoftReferenceFilter
  implements Filter
{
  public void doFilter(ServletRequest request, ServletResponse response,
   FilterChain chain)
throws ServletException, IOException
  {
if(request instanceof HttpServletRequest)
  request
= new SoftReferenceRequestWrapper((HttpServletRequest)request);

chain.doFilter(request, response);
  }

  public static class SoftReferenceRequestWrapper
extends HttpServletRequestWrapper
  {
public SoftReferenceRequestWrapper(HttpServletRequest request)
{
  super(request);
}

// Override
public HttpSession getSession()
{
  HttpSession session = super.getSession();

  if(null != session)

Re: java.lang.OutOfMemoryError: Java heap space

2009-10-08 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

All,

A correction to my code:

On 10/8/2009 4:22 PM, Christopher Schultz wrote:
 public class SoftReferenceFilter
   implements Filter
 {

This class needs two additional methods:

  public void init(FilterChain chain) { }
  public void destroy() { }

 // Here's where the magic happens
 public Object getAttribute(String key)
 {
   Object o = super.getAttribute(key); // Get the stored object

This should be:

Object o = _base.getAttribute(key);

 public Object setAttribute(String key, Object value)
 {
   // Wrap the value in a SoftReference if appropriate
   if(key.startsWith(foto)  null != value)
 value = new SoftReference(value);
 
   super.setAttribute(key, value);

This should be:

_base.setAttribute(key, value);

Not too bad for code typed directly into an email message.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrOTIwACgkQ9CaO5/Lv0PAgoACgoAZOVSzVhSOwD893/qC/YtZ/
57MAnApZ064qpwt15QzMuEswaU3KFxMY
=nno+
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: java.lang.OutOfMemoryError: Java heap space

2009-10-08 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

All,

Another correction to the code:

On 10/8/2009 4:22 PM, Christopher Schultz wrote:
   public static class SoftReferenceSessionWrapper
 implements HttpSession
   {

Remember to implement getValue and putValue to call getAttribute and
setAttribute. ;)

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrOTdUACgkQ9CaO5/Lv0PCIDwCgt+kyda0PTi+LoqQvQhGb2yHC
HKMAoL/uMesdmV1Ubrco5Hyx8F9x0IKF
=53/Y
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: [OT] JNI problem

2009-10-08 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Konstantin,

On 10/8/2009 4:37 AM, Konstantin Kolinko wrote:
 2009/10/8 Mohamedin mohame...@easy-dialog.info:
 Here is one function that always crash. The portion of the code that couse
 the crash in my opinion is the if which has malloc. I noticed it crash
 whenever it is called with the same srcFile and dstFile

 int reduce_quality(const char * srcFile, const char * dstFile, int maxSize){

 ...
 tmpFile = (char *) malloc(sizeof(srcFile)+1);
 
 You meant string length there?

I saw the same thing at first glance, but then I looked-up the sizeof()
operator and it seems that sizeof /can/ return the number of bytes in an
array in C99
(http://en.wikipedia.org/wiki/Sizeof#Using_sizeof_with_arrays), but that
might only work with statically-declared arrays, and that's not the
case, here. I can see why confusion might have occurred, especially with
someone with little C experience. :(

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrOcAcACgkQ9CaO5/Lv0PBPGgCgsu1cwLehuq9fvUp5+iVMgnbm
9EwAnAsD5IZTFw08QYfLuK81qvTSS/OS
=RgTy
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



RE: [OT] JNI problem

2009-10-08 Thread Caldarale, Charles R
 From: Christopher Schultz [mailto:ch...@christopherschultz.net]
 Subject: Re: [OT] JNI problem
 
 I saw the same thing at first glance, but then I looked-up the sizeof()
 operator and it seems that sizeof /can/ return the number of bytes in
 an array in C99

Minor correction: the operator is sizeof, not sizeof() - it is not a function.  
The parentheses one often sees with sizeof are either unnecessary (when used 
around a variable name) or a *cast* operator, when used with a type.  The 
sizeof operator always returns the number of bytes occupied by the type of the 
operand, which is the declared size, not any associated dynamically allocated 
size.  For example:

char array[6];
char * ptr;
struct string {
  int len;
  char body[];
};
struct string sptr = malloc(sizeof (struct string) + 8);

sizeof array returns 6
sizeof ptr returns 4 or 8, depending on platform
sizeof (struct string) returns 4 (usually; sometimes 8) - the length of the int
sizeof sptr returns 4 or 8, depending on platform
sizeof *sptr returns the same as sizeof (struct string)

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.




Re: JNI problem

2009-10-08 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Mohamedin,

On 10/8/2009 5:42 AM, Mohamedin wrote:
 I have fixed this bug (Long time without coding in C). But still the
 error.

You didn't look for all uses of sizeof:

 while((bytes = read(inF, buff, sizeof(buff)))  0)

I think you meant this:

while((bytes = read(inF, buff, 1024))  0)  // use any window size

Also, as Konstantin points out, you have a free in there somewhere, so
you ought to have a malloc, too. The API documentation for
MagickGetException does not seem to indicate that the returned object
needs to be freed.

It looks like you have memory leaks everywhere. For instance:

 int resize(const char * srcFile, const char * dstFile, int width, int
 height, int quality){
 
 char *description;
 ExceptionType severity;
 MagickWand *magick_wand;
 unsigned int status;
 
 magick_wand = NewMagickWand();
 
 status = MagickReadImage(magick_wand, srcFile);
 
 if (status == False) {
 
 ThrowAPIException(magick_wand);
 
 return False;
 }

What about the magick_wand variable? Shouldn't you free that guy?

 MagickResizeImage(magick_wand,width,height,LanczosFilter,1.0);
 
 MagickSetCompressionQuality(magick_wand, quality);
 
 status=MagickWriteImages(magick_wand, dstFile,True);
 
 if (status == False){
 
 ThrowAPIException(magick_wand);
 
 return False;
 }

What about freeing the memory allocated by MagickReadImage, here? You
ought to call this method before every 'return' from your function:

 DestroyMagickWand(magick_wand);

I would highly recommend that you have some with some more C experience
read-through your code. It's clear that your code is untrustworthy when
it comes to memory being managed by the JVM, and you can really ruin the
JVM's day, as you have seen.

 int resize_with_limits(const char * srcFile, const char * dstFile, int
 maxDim, int maxSize){

This function has the same problems as above.

 int crop(const char * srcFile, const char * dstFile, int widthRatio, int
 heightRatio){

Same here.

 int compose(const char * composeImgFile, const char * imageFile, int
 position, int width, int height, int shiftDirection, int shiftAmount){

Guess what? This one is correct!

 status = MagickReadImage(composite_wand, composeImgFile);
 
 if (status == False) {
 
 ThrowAPIException(composite_wand);
 
 DestroyMagickWand(magick_wand);
 
 return False;
 
 }

The above code is the way to do things.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrOdLcACgkQ9CaO5/Lv0PD3tgCgjmH9/+G+9FIyhwJiApknBWQ2
wbgAnjmuh9Fb8xuAMIsQAUNU9Xm40HYz
=dbmW
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Default character encoding for ServletRequest

2009-10-08 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Halm,

On 10/8/2009 3:20 AM, Halm Reusser wrote:
 Christopher Schultz wrote:
 
 Give [accept-charset] a try and see what happens.
 
 Does neither work. But thanks.

:(

Does the client send a Content-Type header including a charset if you
explicitly set it in this way? If not, what character set does it appear
to use when sending data to the server? If you specify UTF-8 but the
client sends ISO-8859-2 or whatever, then you should report a bug
against the client.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrOdaUACgkQ9CaO5/Lv0PA4+ACfRBmZLLR2SrpMVgASluYtIQcW
xHIAnigU6am7IEI3ON6oZiOGJoGSY0IB
=VsEn
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Cannot set remote address in valve (Tomcat 5.5)

2009-10-08 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Cyrille,

On 10/8/2009 4:03 AM, Cyrille Le Clerc wrote:
I am afraid there may be a flaw in the algorythm looking for the
 first IP  of the coma delimited x-forwarded-for header without
 ensuring that this first IP has been set by a trusted proxy and not by
 the requester ( getFirstIP(xforwardedForHeaderValue) ). Such spoofing
 can easily be achieved with tools like Firefox add-ons Modify Headers
 (1) and X-Forwarded-For Spoofer (2) .

This is a good point that you've raised, here: it's a lot easier to
spoof an HTTP header than it is to spoof a source IP address in an IP
packet.

The forthcoming version of Apache Httpd will offer a secure
 mechanism to handle X-Forwarded-For with a module called mod_remoteip
 (3). It relies on the concept of trusted proxies which IP address can
 be 'swallowed'. The first IP of the list that is not a trusted proxy
 is seen as the real remote ip. mod_remoteip would not have been
 tricked by such x-forwarded-for header spoofing.

Uh huh? That seems counter-intuitive to trust the first untrusted IP
address you find. I'll read about mod_remoteip and see what it's all about.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrOdn0ACgkQ9CaO5/Lv0PBJtACggGynXG9+5aTVIntOzJ3rB4Ie
ZZ4AoLTmXelgtQEC6+udWuCSyQsqQnTc
=cYNl
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: [OT] JNI problem

2009-10-08 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Chuck,

On 10/8/2009 7:24 PM, Caldarale, Charles R wrote:
 char array[6];

...

 sizeof array returns 6

This is what I was describing. The Wikipedia article states (I don't
have my KR book in front of me... besides, it wouldn't cover this case,
anyway) that C99 allows /dynamic/ size determination:


sizeof is generally a compile-time operation, although in C99 it can be
used at run-time to find the size of a variable length array.


Oddly, this statement is contradicted without qualification immediately
below:


Since argv is a pointer to an array rather than an array itself,
sizeof(argv) is equivalent to sizeof(char **) — that is, the size of the
pointer type of argv. It will not be the size of the array to which argv
points (which consists of a series of char* pointers).


 sizeof (struct string) returns 4 (usually; sometimes 8) - the length of the 
 int

Wouldn't this yield (not return :) sizeof(int) + sizeof(char*)?

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrOd7sACgkQ9CaO5/Lv0PCE2QCfX9y5QoZX8bhd1+Z24e5wmLTq
8eQAoJ4MxvuEiCC/Y7EF/3kTUsT012PP
=ngEg
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Apache Version

2009-10-08 Thread desertdenizen

I've never before installed Tomcat. I compiled and installed Apache 2.0.63
earlier today and have a further requirement to install Tomcat. Is there a
particular Tomcat version that works best with that version of Apache? Thank
you, everyone!
-- 
View this message in context: 
http://www.nabble.com/Apache-Version-tp25813491p25813491.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Apache Version

2009-10-08 Thread Jordan Michaels
The version of Tomcat won't really matter, because Apache communicates 
with Tomcat through a connector, or as a proxy. If you use the connector 
method, just make sure you use the Apache 2.0 connector and you should 
be all set!


Warm regards,
Jordan Michaels
Vivio Technologies
http://www.viviotech.net/
Open BlueDragon Steering Committee
Adobe Solution Provider


desertdenizen wrote:

I've never before installed Tomcat. I compiled and installed Apache 2.0.63
earlier today and have a further requirement to install Tomcat. Is there a
particular Tomcat version that works best with that version of Apache? Thank
you, everyone!


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



RE: [OT] JNI problem

2009-10-08 Thread Caldarale, Charles R
 From: Christopher Schultz [mailto:ch...@christopherschultz.net]
 Subject: Re: [OT] JNI problem
 
 C99 allows /dynamic/ size determination:

Sounds like a flaw in the article; it can't possibly be true, since there is no 
standard-defined API to discover the size of a malloc'd item; sizeof is 
*always* a compile-time operation.  The only situation where it is not a 
compile-time /constant/ is if the size of the array of interest is dependent on 
the value of a function parameter:

int func(int val) {
  char arr[val + 6];
  return sizeof arr; /* returns val + 6 */
}

This is not really dynamic allocation.

  sizeof (struct string) returns 4 (usually; sometimes 8) - 
  the length of the int
 
 Wouldn't this yield (not return :) sizeof(int) + sizeof(char*)?

(Yield is definitely better terminology than return.)  The struct I had was 
incorrect (it wouldn't compile); it should have been:

struct string {
  int len;
  char body[0];
};

Since the struct includes a zero-element char array, not a char pointer, the 
resultant value is 4 + 0.  The struct is expected to be malloc'd for an 
appropriate length, but the sizeof would always return the same value, being 
unaware of the allocated size of the structure.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.



RE: Apache Version

2009-10-08 Thread Caldarale, Charles R
 From: desertdenizen [mailto:erik.sch...@gmail.com]
 Subject: Apache Version
 
 Is there a particular Tomcat version that works best with that 
 version of Apache?

No, but it's always recommended to use the latest (6.0.20, today), since that 
will have the most recent security fixes and will be the best performing 
version.  However, some 3rd-party webapps may have a dependency on a particular 
Tomcat version.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Support for Java 1.6 with Tomcat 5.5.x

2009-10-08 Thread Steve Wade
I know this configuration works and that Apache states Tomcat 5.5.x support for 
Java 1.5 and above, but I cannot find a statement for support of Java 1.6 with 
Tomcat 5.5.x. Anyone know where this support is documented?


  

RE: InvocationTargetException results OutOfMemory issue ascodecache is full in tomcat 5.5

2009-10-08 Thread subrahmanyam

Hi Chuck,
We have increased the codecache for the workaround, found the root casue of
this issue is in drool 4.0.7 which we have recenlty integrated in our
application. For a permanent fix we will post in jboss drool forum .
-- 
View this message in context: 
http://www.nabble.com/InvocationTargetException-results-OutOfMemory-issue-as-codecache-is-full-in-tomcat-5.5-tp25745877p25815858.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org