Strict Standards: Only variables should be assigned by reference in C:\xampp\htdocs\kpg\plugins\system\jsecurelite\jsecurelite.php on line 40
Knowledge Power Group - Enable Tomcat Native on Solaris SPARC

787-425-3900

# Enable Tomcat Native on Solaris SPARC

HomeDev BlogEnable Tomcat Native on Solaris SPARC
HomeDev BlogEnable Tomcat Native on Solaris SPARC

Notice: Undefined variable: postType in C:\xampp\htdocs\kpg\templates\envor\html\com_k2\templates\blog\item.php on line 80

Notice: Undefined variable: postType in C:\xampp\htdocs\kpg\templates\envor\html\com_k2\templates\blog\item.php on line 88

Notice: Undefined variable: postType in C:\xampp\htdocs\kpg\templates\envor\html\com_k2\templates\blog\item.php on line 106

Notice: Undefined variable: postType in C:\xampp\htdocs\kpg\templates\envor\html\com_k2\templates\blog\item.php on line 120

Notice: Undefined variable: postType in C:\xampp\htdocs\kpg\templates\envor\html\com_k2\templates\blog\item.php on line 136

### Enable Tomcat Native on Solaris SPARC

posted in DevBlog by Marcos Acevedo

Of all the bizarre things that are required to do on our day to day I had this one in the back burner for some time now. A while ago I was tasked to setup a few Apache Tomcat instances to serve a Java web application in the current infrastructure. Part of the challenge was to curb the poor performance given by the existing product being utilized in production to serve as a JEE container for their primary Java based web application. Tomcat by default usually results in a lighter install and is relatively easy to set up in most cases but in this particular infrastructure there were other considerations in the stack that impacted our approach to performance tuning. Apache provides a native library that should result in a performance increase across the board.

Per their description:

The Apache Tomcat Native Library is an optional component for use with Apache Tomcat that allows Tomcat to use certain native resources for performance, compatibility, etc.

Specifically, the Apache Tomcat Native Library gives Tomcat access to the Apache Portable Runtime (APR) library's network connection (socket) implementation and random-number generator. See the Apache Tomcat documentation for more information on how to configure Tomcat to use the APR connector.

• Features of the APR connector:
• Non-blocking I/O for Keep-Alive requests (between requests)
• Uses OpenSSL for TLS/SSL capabilities (if supported by linked APR library)
• FIPS 140-2 support for TLS/SSL (if supported by linked OpenSSL library)

On a Solaris installation using the SPARC architecture most of the packages you would be used to find readily available in binary have to be compiled from source. Most of us that dabble on Web Development seldom engage in the dark arts of Unix C++ and its tooling. Also, most Tomcat installs consist of a Linux stack where community maintained repositories contain precompiled binaries of whatever library we need for our deployments. What was supposed to be a routine performance tuning for Tomcat turned in to a journey of taming the intricacies of building Tomcat Native on Solaris SPARC. I hope this step by step provides a distilled way of compiling your own native tomcat while avoiding most pitfalls:

1. Download and install Solaris Studio. You need Solaris' own C compiler binary. While you may be able to use gcc, my endeavor in that direction provided to be fruitless.
2. Download the Apache Portable Runtime (APR) source and corresponding APR Utils source code
3. On your shell, configure the following environment variables. Take note that the CFLAGS environment variable is being set to the SPARC 64bit arch. If you’re going to run Tomcat on a 32 bit JVM, you probably don’t want it set:
export CATALINA_HOME=/app/tomcat (or whatever your tomcat installation is located at)
export PATH=$PATH:/opt/solarisstudio12.4/bin/ && export CFLAGS="-m64 -xarch=native" 4. If you haven’t already done so, configure a loopback interface for IPV6. APR will fail tests if it can't use an IPV6 interface during one of the tests: ifconfig lo0 inet6 plumb && ifconfig lo0 inet6 ::1 up 5. Change to the APR directory and run: ./configure make && make test && make install 6. Let them run and when you finnish with make install you should have a compiled APR library in (typically) /usr/local/apr/ 7. Change to the APR Util directory where the source code was extracted and run: ./configure --with-apr=/usr/local/apr/ ( --with-apr parameter is where your recently compiled APR library was installed) 8. Compile and install APR Utils ./configure && make && make test && make install 9. Clear the CFLAGS environment variable if it was set before: export CFLAGS= 10. Change to the tomcat native directory where you extracted the source. Execute the following: ./configure CC=cc --with-apr=/usr/local/apr/ --with-java-home=/app/jdk1.7.0/ --with-ssl=no --prefix=$CATALINA_HOME

You should have a newly minted tomcat native binary in your tomcat/lib directory. When you run tomcat the log will tell you if native APR was successfully loaded. Note that I didn’t enable SSL. There are 2 reasons for that. First, the post-heartbleed open SSL binary was not available, and we do SSL ofloading on our reverse proxy/load balancer so I don’t need the additional overhead. Make sure to replace the paths of the corresponding java home and \$CATALINA_HOME parameters with the proper paths for java/tomcat.

01 06, 15

### 1 comment

posted on June 29, 2015 - 09:56 am

Superb blog you have here but I was curious about if you knew of any discussion boards that cover the same topics discussed in this article? I'd really like to be a part of group where I can get opinions from other knowledgeable people that share the same interest. If you have any suggestions, please let me know. Bless you!