tomcat

How to Set %JAVA_HOME% Variable on Apache Tomcat’s Catalina Script

Usually im using Apache Tomcat’s catalina script to launch and start Apache Tomcat, but sometimes the script wont run because of not having JAVA_HOME variables on your OS environment variables or you cant add new environment variables due to lack of privileges.

So instead of adding JAVA_HOME variable into my OS, i set the JAVA_HOME on my catalina scripts. This is how i do it, i add this script on the top of catalina.bat file.

set JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_07

Note, there is no space before and after “=” sign.

Easy isnt it 😉

Setup Apache Tomcat and Ubuntu VM on Windows Azure

Recently i got a project which need me to deploy on a cloud infrastructure. After spending some time finding the right cloud provider, finally i choose Microsoft’s product Windows Azure. According to Wikipedia, Windows Azure is a Microsoft cloud computing platform used to build, host and scale web applications through Microsoft data centers.

Actually, i was a little suprised because Microsoft provided Ubuntu Server images for its VM OS selection. I tought the only OS available for Mcrosoft’s cloud platform would be from windows server family.

Okay, first i start by picking New Virtual Machine,and pick Ubuntu from list of Virtual Machines.

Next is selecting your VM name, username and password, and your virtual machine’s size, For this example, im trying a small size server.

Select your DNS name and region and your availability set. Finish your configuration, and start creating your Ubuntu VM on Azure.

Next is connect to your Ubuntu via SSH, and start downloading apache tomcat using this command.

sudo apt-get install tomcat7

It will install Apache Tomcat 7, and start your tomcat using this command,

sudo services tomcat7 start

check whether your Tomcat’s port (8080) has opened yet or not,

netstat -aon | grep 8080

Next is adding your tomcat port to your VM’s endpoints.

After youve add your endpoint, it’s time to test your tomcat server. Try accessing your public virtual ip address via browser and see whether your Tomcat Server is ready. 😉

Error “java.lang.ClassNotFoundException: com.ibm.icu.text.SimpleDateFormat” When Deploying GWT Application

Today i’ve met a very weird error when trying to deploy my GWT application to my tomcat 7,

SEVERE: Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract java.util.List id.net.baculsoft.app.client.service. LoginService.getUtilDao(java.lang.String,java.util.Map)' 
threw an unexpected exception: java.lang.NoClassDefFoundError: com/ibm/icu/text/SimpleDateFormat
	at com.google.gwt.user.server.rpc.RPC. encodeResponseForFailure(RPC.java:385)
	at com.google.gwt.user.server.rpc.RPC. invokeAndEncodeResponse(RPC.java:588)
	at com.google.gwt.user.server.rpc.RPC. invokeAndEncodeResponse(RPC.java:551)
	at org.gwtrpcspring.RemoteServiceDispatcher. invokeAndEncodeResponse(RemoteServiceDispatcher.java:57)
	at org.gwtrpcspring.RemoteServiceDispatcher. processCall(RemoteServiceDispatcher.java:38)
	at com.google.gwt.user.server.rpc. RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
	at com.google.gwt.user.server.rpc. AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)

which somehow, never happen on my development mode. After searching and trying various workarounds for several hours, i finally make it work by adding icu4j.jar. Well despite icu4j.jar’s size is more than 3mb, at least i’ve make my application running well. Thank God 😉

A Simple HTTPS Configuration Example on Apache Tomcat 6

This idea comes suddenly on my head while i was reading a question on Kaskus’ programmer forum about how to setup a https connection on Apache Tomcat, thats why today im trying to write a simple how-to example on creating a simple HTTPS connection using Apache Tomcat 6. Who knows perhaps someone would find it useful.

Let’s start with creating a simple certificate file using keytool.exe

C:\Program Files\Java\jdk1.6.0_19\bin>keytool.exe -genkey -alias tomcat -keyalg RSA -keystore edw.jks

after you insert your keystore password (i entered “secret” as my password) and several simple questions such as “What is your first and last name?”, it would create a file.

What you need to do next is to link your certificate to Tomcat’s server.xml configuration. This is what i add to my server.xml configuration.

<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" keystoreFile="D:\edw.jks" 
               keystorePass="secret" />
<!-- keystorePass use the same password -->

And i also add this to my web.xml file, located under my tomcat’s conf folder

	<security-constraint>
		<web-resource-collection>
			<web-resource-name>Automatic SLL Forwarding</web-resource-name>
			<url-pattern>/*</url-pattern>
		</web-resource-collection>
		<user-data-constraint>
			<transport-guarantee>CONFIDENTIAL</transport-guarantee>
		</user-data-constraint>
	</security-constraint>

This is what my page will look like,

Hope it would help others, cheers (B)