Re: Custom Connector class

2015-12-12 Thread Roel Storms
Chris,

I believe that this is not entirely what I need. As far as I understand the
code it will detect if getInputStream or getReader has been called by the
servlet application. Depending on the usingReader boolean that was set as a
result, it will either use _inputReaderBuffer or _inputStreamBuffer to
fetch the body.

In my case I need to retrieve the body in advance and still allow the web
application to call either method, getInputStream, getReader, getParameter.
If I choose to call getInputStream in my Valve to retrieve the body then
the web application will be restricted to using getInputStream. If I choose
getReader then the web application will be restricted to using getReader.
If a web application would use ServletRequest.getParameter the
documentation says the following:

"If the parameter data was sent in the request body, such as occurs with an
HTTP POST request, then reading the body directly via getInputStream()

 or getReader()

can
interfere with the execution of this method."

According to my understanding of the original Tomcat request code,
Request.getParam depends on Request.parseParameters which in turn uses
Request.readPostBody that uses Request.getStream to obtain the data.
getStream also fetches the inputStream of a request so I believe it won't
work in combination with a call to getReader.

Since your wrapper is not overwriting any method like getParam
(getParameterNames, getParameterValues, getParameterMap) I believe these
methods will still behave incorrectly when called by the target application.

I could indeed build a wrapper that would overwrite getStream, getReader,
getInputStream, getParam, getParameterNames, etc. But then I would be
generating a lot of duplicate code. Since my implementation is purely
experimental I don't think it's such big of a problem to modify Tomcat
internals (the Connector class).

Roel

2015-12-09 18:06 GMT+01:00 Christopher Schultz :

> Roel,
>
> On 12/9/15 8:03 AM, Roel Storms wrote:
> > The real requirement is being able to process the body of a request in a
> > Valve without restricting the servlet to call request.getInputStream,
> > getReader and getStream. I have tried by wrapping the request but some
> > behavior can't be masked. It is also much more simple to implement by
> just
> > extending the Request class and using this in Connector.createRequest().
> >
> > So the actual requirement is a Valve wanting to process the body but
> still
> > allowing the target application to call whatever processing method they
> > chose. When the Valve would chose to process the body by calling
> > Request.getInputStream(). The servlet wouldn't be able to call getReader
> or
> > getParam anymore. I would like my Valve to be transparent in that sense.
>
> What you want to do can be done with a Valve as long as you don't mind a
> bit of typing.
>
> See this thread where I built pretty much exactly what you're requesting:
> http://tomcat.markmail.org/thread/fumpfuspt7a3nesz
>
> I implemented mine as a Filter, not as a Valve.
>
> There's no need to go writing your own Request implementation.
>
> -chris
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Re: How to build tc-natvie for solaris sparc 64 bit using 64 bit java JDK

2015-12-12 Thread Rainer Jung

Am 11.12.2015 um 20:27 schrieb Nithesh Kb:

*HI, I'm using Solaris sparc 64 bit machine. i wanted to build tc native
using 64 bit version of java.*

*i installed java in my Solaris box by referring*
http://docs.oracle.com/javase/7/docs/webnotes/install/solaris/solaris-jdk.html

*when i check the*

/usr/jdk/jdk1.7.0_80/bin/java -version
java version "1.7.0_80"Java(TM) SE Runtime Environment (build
1.7.0_80-b15)Java HotSpot(TM) Server VM (build 24.80-b11, mixed mode)

*export JAVA_HOME=/usr/jdk/jdk1.7.0_80*

*./configure --with-apr=/usr/local/apr/bin/apr-1-config
--with-java-home=$JAVA_HOME --with-ssl=/usr/local/ssl
--prefix=$CATALINA_HOME*

*i'm able to build using this java 32 bit but 64 bit java is there in*

/usr/jdk/jdk1.7.0_80/bin/sparcv9/java -version
java version "1.7.0_80"Java(TM) SE Runtime Environment (build
1.7.0_80-b15)Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed
mode)

*So how do i tell my tc-native configure to use 64 bit java instead of* 32
bit java

Issue is here i can build with 32 bit java and tomcat will work. but in
production there is no 32 bit JRE only 64 bit JRE is there is if is use the
same 32 bit tc-native library i'l get

*wrong ELF class: ELFCLASS32 (Possible cause: architecture word width
mismatch)]*

So i must use 64 JDK for tc native build. please help me


From your other mail it seems you are using gcc to do the build. If so, 
make sure to include "-m64" in your CFLAGS for all components (OpenSSL, 
APT, tcnative). To build tcnative for 65 Bits, you need to have 64 Bit 
OpenSSL and 64 Bit APR first.


The 64 Bit part of the JVM will then be chosen automatically, not 
sparcv9 or similar needed.


Regards,

Rainer


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



Re: How to build tc-natvie for solaris sparc 64 bit using 64 bit java JDK

2015-12-12 Thread Nithesh Kb
HI Rainer,
Interestingly i tried this as well.

*APR,*
*CC="cc" CFLAGS="-m64" LDFLAGS="-m64" ./configure*

*TC-native,*
*CC="cc" CFLAGS="-m64 -fPIC" LDFLAGS="-m64" ./configure
--with-apr=/usr/local/apr/bin/apr-1-config
--with-java-home=/usr/jdk/jdk1.7.0_80/ --with-ssl=/usr/local/ssl
--prefix=/tomcat*

*But i get this error,*

*ld: fatal: file /usr/local/ssl/lib/libssl.so: wrong ELF class: ELFCLASS32*
*ld: fatal: file /usr/local/ssl/lib/libcrypto.so: wrong ELF class:
ELFCLASS32*
*ld: fatal: file processing errors. No output written to
.libs/libtcnative-1.so.0.1.33*
 Error code 2*
*make: Fatal error: Command failed for target `libtcnative-1.la
'*
*Current working directory /tomcat/bin/tomcat-native-1.1.33-src/jni/native*


Does it mean my openssl is not 64 bit, actually i'm not sure about my
openssl architecture ?

Thanks,
Nithesh KB

On Sat, Dec 12, 2015 at 10:52 PM, Nithesh Kb  wrote:

> HI Rainer,
> Thanks i was able to succeed this step but still tomcat is not starting.
>
> *APR,*
>  CFLAGS="-m64" ./configure
>
>
> *TC-native,*
>
> * CFLAGS="-m64" ./configure --with-apr=/usr/local/apr/bin/apr-1-config
> --with-java-home=/usr/jdk/instances/jdk1.7.0/ --with-ssl=/usr/local/ssl
> --prefix=/tomcat7*
>
>
> *but i get this error in tomcat logs,*
>
> INFO: Loaded APR based Apache Tomcat Native library 1.1.33 using APR version 
> 1.5.2.Dec 12, 2015 8:02:42 PM org.apache.catalina.core.AprLifecycleListener 
> lifecycleEvent
> INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], 
> random [true].Dec 12, 2015 8:02:42 PM 
> org.apache.catalina.core.AprLifecycleListener initializeSSL
> INFO: OpenSSL successfully initialized (OpenSSL 1.0.1p 9 Jul 2015)Dec 12, 
> 2015 8:02:43 PM org.apache.coyote.AbstractProtocol init
> INFO: Initializing ProtocolHandler ["http-apr-0.0.0.0-8081"]Dec 12, 2015 
> 8:02:43 PM org.apache.coyote.AbstractProtocol init
> INFO: Initializing ProtocolHandler ["http-apr-0:0:0:0:0:0:0:0-8081"]Dec 12, 
> 2015 8:02:43 PM org.apache.coyote.AbstractProtocol init
> INFO: Initializing ProtocolHandler ["http-apr-0.0.0.0-8444"]
> ld.so.1: java: fatal: relocation error: file 
> /tomcat7/lib/libtcnative-1.so.0.1.33: symbol EC_KEY_new_by_curve_name: 
> referenced symbol not found
>
>
>
> On Sat, Dec 12, 2015 at 9:35 PM, Rainer Jung 
> wrote:
>
>> Am 11.12.2015 um 20:27 schrieb Nithesh Kb:
>>
>>> *HI, I'm using Solaris sparc 64 bit machine. i wanted to build tc native
>>> using 64 bit version of java.*
>>>
>>> *i installed java in my Solaris box by referring*
>>>
>>> http://docs.oracle.com/javase/7/docs/webnotes/install/solaris/solaris-jdk.html
>>>
>>> *when i check the*
>>>
>>> /usr/jdk/jdk1.7.0_80/bin/java -version
>>> java version "1.7.0_80"Java(TM) SE Runtime Environment (build
>>> 1.7.0_80-b15)Java HotSpot(TM) Server VM (build 24.80-b11, mixed mode)
>>>
>>> *export JAVA_HOME=/usr/jdk/jdk1.7.0_80*
>>>
>>> *./configure --with-apr=/usr/local/apr/bin/apr-1-config
>>> --with-java-home=$JAVA_HOME --with-ssl=/usr/local/ssl
>>> --prefix=$CATALINA_HOME*
>>>
>>> *i'm able to build using this java 32 bit but 64 bit java is there in*
>>>
>>> /usr/jdk/jdk1.7.0_80/bin/sparcv9/java -version
>>> java version "1.7.0_80"Java(TM) SE Runtime Environment (build
>>> 1.7.0_80-b15)Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed
>>> mode)
>>>
>>> *So how do i tell my tc-native configure to use 64 bit java instead of*
>>> 32
>>> bit java
>>>
>>> Issue is here i can build with 32 bit java and tomcat will work. but in
>>> production there is no 32 bit JRE only 64 bit JRE is there is if is use
>>> the
>>> same 32 bit tc-native library i'l get
>>>
>>> *wrong ELF class: ELFCLASS32 (Possible cause: architecture word width
>>> mismatch)]*
>>>
>>> So i must use 64 JDK for tc native build. please help me
>>>
>>
>> From your other mail it seems you are using gcc to do the build. If so,
>> make sure to include "-m64" in your CFLAGS for all components (OpenSSL,
>> APT, tcnative). To build tcnative for 65 Bits, you need to have 64 Bit
>> OpenSSL and 64 Bit APR first.
>>
>> The 64 Bit part of the JVM will then be chosen automatically, not sparcv9
>> or similar needed.
>>
>> Regards,
>>
>> Rainer
>>
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: users-h...@tomcat.apache.org
>>
>>
>


Re: How to build tc-natvie for solaris sparc 64 bit using 64 bit java JDK

2015-12-12 Thread Nithesh Kb
HI Rainer,
Thanks i was able to succeed this step but still tomcat is not starting.

*APR,*
 CFLAGS="-m64" ./configure


*TC-native,*

* CFLAGS="-m64" ./configure --with-apr=/usr/local/apr/bin/apr-1-config
--with-java-home=/usr/jdk/instances/jdk1.7.0/ --with-ssl=/usr/local/ssl
--prefix=/tomcat7*


*but i get this error in tomcat logs,*

INFO: Loaded APR based Apache Tomcat Native library 1.1.33 using APR
version 1.5.2.Dec 12, 2015 8:02:42 PM
org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters
[false], random [true].Dec 12, 2015 8:02:42 PM
org.apache.catalina.core.AprLifecycleListener initializeSSL
INFO: OpenSSL successfully initialized (OpenSSL 1.0.1p 9 Jul 2015)Dec
12, 2015 8:02:43 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-apr-0.0.0.0-8081"]Dec 12,
2015 8:02:43 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler
["http-apr-0:0:0:0:0:0:0:0-8081"]Dec 12, 2015 8:02:43 PM
org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-apr-0.0.0.0-8444"]
ld.so.1: java: fatal: relocation error: file
/tomcat7/lib/libtcnative-1.so.0.1.33: symbol EC_KEY_new_by_curve_name:
referenced symbol not found



On Sat, Dec 12, 2015 at 9:35 PM, Rainer Jung 
wrote:

> Am 11.12.2015 um 20:27 schrieb Nithesh Kb:
>
>> *HI, I'm using Solaris sparc 64 bit machine. i wanted to build tc native
>> using 64 bit version of java.*
>>
>> *i installed java in my Solaris box by referring*
>>
>> http://docs.oracle.com/javase/7/docs/webnotes/install/solaris/solaris-jdk.html
>>
>> *when i check the*
>>
>> /usr/jdk/jdk1.7.0_80/bin/java -version
>> java version "1.7.0_80"Java(TM) SE Runtime Environment (build
>> 1.7.0_80-b15)Java HotSpot(TM) Server VM (build 24.80-b11, mixed mode)
>>
>> *export JAVA_HOME=/usr/jdk/jdk1.7.0_80*
>>
>> *./configure --with-apr=/usr/local/apr/bin/apr-1-config
>> --with-java-home=$JAVA_HOME --with-ssl=/usr/local/ssl
>> --prefix=$CATALINA_HOME*
>>
>> *i'm able to build using this java 32 bit but 64 bit java is there in*
>>
>> /usr/jdk/jdk1.7.0_80/bin/sparcv9/java -version
>> java version "1.7.0_80"Java(TM) SE Runtime Environment (build
>> 1.7.0_80-b15)Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed
>> mode)
>>
>> *So how do i tell my tc-native configure to use 64 bit java instead of* 32
>> bit java
>>
>> Issue is here i can build with 32 bit java and tomcat will work. but in
>> production there is no 32 bit JRE only 64 bit JRE is there is if is use
>> the
>> same 32 bit tc-native library i'l get
>>
>> *wrong ELF class: ELFCLASS32 (Possible cause: architecture word width
>> mismatch)]*
>>
>> So i must use 64 JDK for tc native build. please help me
>>
>
> From your other mail it seems you are using gcc to do the build. If so,
> make sure to include "-m64" in your CFLAGS for all components (OpenSSL,
> APT, tcnative). To build tcnative for 65 Bits, you need to have 64 Bit
> OpenSSL and 64 Bit APR first.
>
> The 64 Bit part of the JVM will then be chosen automatically, not sparcv9
> or similar needed.
>
> Regards,
>
> Rainer
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Re: How to build tc-natvie for solaris sparc 64 bit using 64 bit java JDK

2015-12-12 Thread Rainer Jung

Am 12.12.2015 um 18:29 schrieb Nithesh Kb:

HI Rainer,
Interestingly i tried this as well.

*APR,*
*CC="cc" CFLAGS="-m64" LDFLAGS="-m64" ./configure*

*TC-native,*
*CC="cc" CFLAGS="-m64 -fPIC" LDFLAGS="-m64" ./configure
--with-apr=/usr/local/apr/bin/apr-1-config
--with-java-home=/usr/jdk/jdk1.7.0_80/ --with-ssl=/usr/local/ssl
--prefix=/tomcat*

*But i get this error,*

*ld: fatal: file /usr/local/ssl/lib/libssl.so: wrong ELF class: ELFCLASS32*
*ld: fatal: file /usr/local/ssl/lib/libcrypto.so: wrong ELF class:
ELFCLASS32*
*ld: fatal: file processing errors. No output written to
.libs/libtcnative-1.so.0.1.33*
 Error code 2*
*make: Fatal error: Command failed for target `libtcnative-1.la
'*
*Current working directory /tomcat/bin/tomcat-native-1.1.33-src/jni/native*


Does it mean my openssl is not 64 bit, actually i'm not sure about my
openssl architecture ?


Yes, that's why I suggested you should build OpenSSL as well. It will 
not have any further dependencies.


You can check bitness using

file /usr/local/ssl/lib/libssl.so
file /usr/local/ssl/lib/libcrypto.so

Pick yourself a 1.0.2e OpenSSl download, build it (with -m64) and 
install it into a separate directory. Check the bitness of the result 
with the "file" command. Then point tcnative at it when running its 
configure etc.


You are pretty close.

Note that there's also a more recent tcnative 1.2.2 and the versions 
1.3.34 and 1.2.3 are currently in the voting process, so will likely be 
released very soon. So once your build works, you might want to check 
for the recent version and redo the build. You can use the same APR and 
OpenSSL builds, so no need to redo them for the nex tcnative.


Regards,

Rainer

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



Re: How to build tc-natvie for solaris sparc 64 bit using 64 bit java JDK

2015-12-12 Thread Nithesh Kb
HI Rainer,
You are right.
i compiled new openssl by setting variable  export KERNEL_BITS=64. followed
by tc native. and now tomcat is working fine in 64 bit JRE environment.

Thanks a lot!!

Regards,
Nithesh

On Sat, Dec 12, 2015 at 11:18 PM, Rainer Jung 
wrote:

> Am 12.12.2015 um 18:29 schrieb Nithesh Kb:
>
>> HI Rainer,
>> Interestingly i tried this as well.
>>
>> *APR,*
>> *CC="cc" CFLAGS="-m64" LDFLAGS="-m64" ./configure*
>>
>> *TC-native,*
>> *CC="cc" CFLAGS="-m64 -fPIC" LDFLAGS="-m64" ./configure
>> --with-apr=/usr/local/apr/bin/apr-1-config
>> --with-java-home=/usr/jdk/jdk1.7.0_80/ --with-ssl=/usr/local/ssl
>> --prefix=/tomcat*
>>
>> *But i get this error,*
>>
>> *ld: fatal: file /usr/local/ssl/lib/libssl.so: wrong ELF class:
>> ELFCLASS32*
>> *ld: fatal: file /usr/local/ssl/lib/libcrypto.so: wrong ELF class:
>> ELFCLASS32*
>> *ld: fatal: file processing errors. No output written to
>> .libs/libtcnative-1.so.0.1.33*
>>  Error code 2*
>> *make: Fatal error: Command failed for target `libtcnative-1.la
>> '*
>> *Current working directory
>> /tomcat/bin/tomcat-native-1.1.33-src/jni/native*
>>
>>
>> Does it mean my openssl is not 64 bit, actually i'm not sure about my
>> openssl architecture ?
>>
>
> Yes, that's why I suggested you should build OpenSSL as well. It will not
> have any further dependencies.
>
> You can check bitness using
>
> file /usr/local/ssl/lib/libssl.so
> file /usr/local/ssl/lib/libcrypto.so
>
> Pick yourself a 1.0.2e OpenSSl download, build it (with -m64) and install
> it into a separate directory. Check the bitness of the result with the
> "file" command. Then point tcnative at it when running its configure etc.
>
> You are pretty close.
>
> Note that there's also a more recent tcnative 1.2.2 and the versions
> 1.3.34 and 1.2.3 are currently in the voting process, so will likely be
> released very soon. So once your build works, you might want to check for
> the recent version and redo the build. You can use the same APR and OpenSSL
> builds, so no need to redo them for the nex tcnative.
>
>
> Regards,
>
> Rainer
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>