Setting a custom JRE for Tomcat

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Setting a custom JRE for Tomcat

Postby avaldez314 » 02. October 2009 20:55

Hello, I just downloaded XAMPP 1.7.2 with the Tomcat add-on and installed it on C:\dev\xampp, it works ok but I would like to use another JDK / JRE installed in "C:\Program Files\Java\jdk1.6.0_16", do anyone know where should I set the JAVA_HOME environment variable?

I tried setting it on tomcat\bin\setenv.bat:

SET JRE_HOME="C:\Program Files\Java\jdk1.6.0_16\jre"
SET JAVA_HOME="C:\Program Files\Java\jdk1.6.0_16"

but then Tomcat don't start, in the catalina.log there are only 2 lines:

02-oct-2009 16:42:59 org.apache.catalina.core.AprLifecycleListener init
INFO: La biblioteca nativa de Apache Tomcat basada en ARP que permite un rendimiento óptimo en entornos de desarrollo no ha sido hallada en java.library.path: C:\dev\xampp\tomcat\bin
(In english: Native Apache Tomcat library based on APR that... could not be found in java.library.path: C:\dev\xampp\tomcat\bin)

Any suggestion?
avaldez314
 
Posts: 6
Joined: 02. October 2009 20:30

Re: Setting a custom JRE for Tomcat

Postby Izzy » 02. October 2009 22:01

After changing the bat file did you run it and then try and start Tomcat?

If Tomcat won't start try running the tomcat_start.bat file and see if it returns the reason it can't start.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: Setting a custom JRE for Tomcat

Postby avaldez314 » 02. October 2009 22:14

Yes I tried to start Tomcat after the setenv.bat changes, when I run tomcat_start.bat it make a pause for about a minute and then tell "tomcat is not started.', here is the output of tomcat_start.bat:

C:\dev\xampp>tomcat_start.bat
Now we start Tomcat
Starting "tomcat"...
"tomcat" is not started.
Press any key to continue. . .
C:\dev\xampp>
avaldez314
 
Posts: 6
Joined: 02. October 2009 20:30

Re: Setting a custom JRE for Tomcat

Postby Izzy » 02. October 2009 22:30

Izzy wrote:After changing the bat file did you run it?
The setenv.bat file is not a configuration file that may be read by Tomcat when it tries to start but is a batch of commands that needs to be run, so you would need to double click on it to run it - but I am not sure if Tomcat runs that bat file on startup.

If you made a backup of the setenv.bat file then try using it again instead of your edited version and see if Tomcat starts - this will point to your edits.

If no backup then revert the setenv.bat file back to it's original state and try again.

Try changing only 1 line at a time and then try and start Tomcat again to see which line may be the cause of your issue

BTW what editor are you using - make sure that it is Notepad or similar and that no extra characters are added to the first line of the file as do some international text editor and word type processors.

Also see if there is any error log file entries in the apache\logs\error.log file.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: Setting a custom JRE for Tomcat

Postby avaldez314 » 02. October 2009 22:53

I'm using UtraEdit as text editor, as far as I know it preserves the encoding and line ending format of text files.

I followed your suggestion and start the installation from the beginning with a fresh install:

- Installed XAMPP in c:\xampp
- Run c:\xampp\setup_xampp.bat
- Copied the content of the tomcat add-on into c:\xampp
- DELETED c:\xampp\tomcat\jre (because I want to use another jdk / jre)
- Run c:\xampp\setup_xampp.bat
- Run 'SET' in cmd, relevant output:
JAVA_HOME=C:\Program Files\Java\jdk1.6.0_16
- Run c:\xampp\tomcat_start.bat, output:
C:\xampp>tomcat_start.bat
Now we start Tomcat
Starting "tomcat"...
"tomcat" is not started.

No log files were created in tomcat\logs or apache\logs.

It seems that Tomcat or the startup bat files are not aware of the JAVA_HOME environment variable...

:-(
avaldez314
 
Posts: 6
Joined: 02. October 2009 20:30

Re: Setting a custom JRE for Tomcat

Postby Izzy » 02. October 2009 23:39

Sorry, not sure about your issue but a silly question, have you checked the Task Manager>Processes to see if Tomcat has already started?

You can also check if it running by using Port Check in the XAMPP Control Panel (XCP) also see if there is a green running next to Tomcat in the XCP.

If Tomcat is already started then the tomcat_start.bat file may return that message.

Have you tried to add the variable to the System variables in the Windows Control Panel>System>Advanced>Environment Variables?

You may have to wait until the bat file guru spots your post and replies to it, if not then I am at a loss to suggest alternatives.

Good luck.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: Setting a custom JRE for Tomcat

Postby avaldez314 » 03. October 2009 00:04

Yes, I have checked the Task Manager, after run tomcat_start.bat a xampp_cli.exe is created and runs for about a minute, then it closes and the tomcat_start.bat shows the message about not starting Tomcat.

The JAVA_HOME variable is already set as a System variable and it works ok for other java applications.

Izzy thank you for your suggestions, I guess I'll wait for the bat file guru...
avaldez314
 
Posts: 6
Joined: 02. October 2009 20:30

Re: Setting a custom JRE for Tomcat

Postby Izzy » 03. October 2009 01:27

Sorry I could not be more directly helpful.

Try this by using:
Code: Select all
if defined JAVA_HOME set JAVA_HOME=
leave blank.
(because you have the System variable set then try leaving both those entries blank ie "" and see if that helps)

from this post:
http://www.coderanch.com/forums/posts/list/87999

From this topic:
http://www.coderanch.com/t/87999/Tomcat ... env-values

From these search results of which you may not feel so alone after reading them - sorry, I ran out of time but you may have more time and be able to understand better these search results.

There was also another tip I found (not tested) that may return some message about the issue by adding:
Code: Select all
echo %errorlevel%
before and after that set JAVA_HOME= line
Perhaps here should also be an echo off line also somewhere after you have finished with the error messages.

Good luck.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: Setting a custom JRE for Tomcat

Postby yangman » 09. October 2009 19:43

I have a similar problem where the jre needs to be changed in tomcat to match my jdk version. As a workaround I renamed \xampp\tomcat\jre and copied my jdk's jre directory to \xampp\tomcat with success in then being able to run my webapp.

Not elegant and haven't thoroughly tested but seems to work.
yangman
 
Posts: 2
Joined: 09. October 2009 19:04

Re: Setting a custom JRE for Tomcat

Postby avaldez314 » 09. October 2009 20:38

Thank you for sharing, I also tried that but tomcat didn't start. By now I'll keep my old XAMPP release ( 1.6.8 ) where I can freely set the JDK.
avaldez314
 
Posts: 6
Joined: 02. October 2009 20:30

Re: Setting a custom JRE for Tomcat

Postby yangman » 09. October 2009 22:06

Did you try after rolling back these changes in setenv.bat?

SET JRE_HOME="C:\Program Files\Java\jdk1.6.0_16\jre"
SET JAVA_HOME="C:\Program Files\Java\jdk1.6.0_16"

back to the original:

SET "JRE_HOME=%CATALINA_HOME%\jre"
SET "JAVA_HOME="

According to your posts this is where tomcat stopped working. Just in case it helps.
yangman
 
Posts: 2
Joined: 09. October 2009 19:04

Re: Setting a custom JRE for Tomcat

Postby manzolo » 11. October 2009 22:57

Hi,
The problem is the missing file "tcnative-1.dll" in the tomcat path.
A workaround is download this file from
http://www.apache.org/dist/tomcat/tomca ... /binaries/
and put this file in your JRE_HOME - JAVA_HOME folder and the server should start!
I have the same problem to start tomcat from eclispe...
I'm looking for a solution more "elegant"...
(sorry for my english)
manzolo
 
Posts: 1
Joined: 11. October 2009 22:47

Re: Setting a custom JRE for Tomcat

Postby avaldez314 » 12. October 2009 15:34

manzolo wrote:Hi,
The problem is the missing file "tcnative-1.dll" in the tomcat path.
A workaround is download this file from
http://www.apache.org/dist/tomcat/tomca ... /binaries/
and put this file in your JRE_HOME - JAVA_HOME folder and the server should start!
I have the same problem to start tomcat from eclispe...
I'm looking for a solution more "elegant"...
(sorry for my english)


Hi manzolo, copying the tcnative-1.dll file to the jre\bin directory solved the problem, thank you a lot.

About how to specify another location for the Tomcat JRE, I successfully did it modifying the tomcat\bin\setenv.bat in this way:

rem SET "JRE_HOME=%CATALINA_HOME%\jre"
SET "JRE_HOME=C:\Program Files\Java\jdk1.6.0_16\jre"

And then copying the tcnative-1.dll file to C:\Program Files\Java\jdk1.6.0_16\jre\bin .

It's only one little issue with this changes: After successfully starting Tomcat from XAMPP Control Panel, the Control Panel don't update the Tomcat status to 'running' (but tomcat is really running), please can anyone report this to the XAMPP team?
avaldez314
 
Posts: 6
Joined: 02. October 2009 20:30

Re: Setting a custom JRE for Tomcat

Postby max4ever » 13. October 2009 16:44

yeah, an ufficial fix would be nice
anyways thanks for the temporary solution :lol:
max4ever
 
Posts: 1
Joined: 13. October 2009 16:42

Re: Setting a custom JRE for Tomcat

Postby mrtomcat65 » 20. January 2010 23:15

My solution was the same as yangman's. I tried playing around with the paths in the setenv.bat file, but for some reason once I hit the "start button" in the XAMPP gui, it started Tomcat, but the green 'Running' label was not displayed. The admin button was also disabled, even though Tomcat was running. Copying this directory into my XAMPP directory did the trick: C:\Program Files\Java\jdk1.6.0_17\jre
mrtomcat65
 
Posts: 1
Joined: 20. January 2010 23:07

Next

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 101 guests