Apache Geronimo Error Fix

How to Fix JDK Was Unexpected at This Time in Apache Geronimo

You may got the error something similar in this format when you try to run Apache Geronimo with ./geronimo run

\Java\jdk1.6.0_17\jre) was unexpected at this time

\Java\jdk1.6.0_75\jre) was unexpected at this time

\Java\jdk1.7.0_55\jre) was unexpected at this time

etc …

This is likely a known problem with the “parenthesis” character handling in Geronimo batch file. You have have a Windows machine, which installs the 64 bit applications under C:\Program Files and 32 bit applications under C:\Program Files (x86), and your JAVA_HOME or JRE_HOME is probably set to the Java library in  C:\Program Files (x86). 

So, how do you solve the problem without changing the default version of Java? The easiest solution is simply to set JAVA_HOME variable inside  geronimo.bat file. Follow the steps to run the Geronimo with a Java version installed under Windows 32 bit folder (Program Files (x86)).

STEPS TO FOLLOW:

STEP 1:

Locate the directory where you installed your Apache Geronimo. Locate the folder called bin, which has the different batch files including geronimo.bat and shutdown.bat. geronimo.bat file is what we are looking for.

STEP 2:

Open the file with the text editor of your choice.

STEP 3:

You will see a bunch of batch scripts. On the top, right after the last comment @REM———– , introduce the following line:

  SET “JAVA_HOME=C:\Progra~2\Java\jdkx.x.x_xx” 

where C:\Progra~2 is something called Windows short name and interprets to Program Files (x86). Basically, it is saying “this is the second directory with the same starting with the prefix Progra“. With this logic, C:\Progra~1 will be C:\Program Files.

And replace jdkx.x.x._xx with whatever JDK version that you are referring to under C:\Program Files (x86).

Thus, you have something similar to the screeshot below:

Setting the custom JDK inside geronimo.bat
Setting the custom JDK inside geronimo.bat

What is going to happen is that JAVA_HOME is going to temporarily set to the JDK path you specify above. geronimo.bat file is going to look for JRE_HOME first. If not found, it is going to look for JAVA_HOME and set as the JDK to run.

Save the file and close it.

STEP 4:

Run geronimo.bat in your command console (Windows cmd, Windows Powershell, or Cygwin). And you should have Geronimo successfully run in your environment!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s