on ubuntu 12.04, Java and/or JNI not found

Bug #989490 reported by David Graf
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Zorba
Confirmed
Medium
Chris Hillery

Bug Description

Hey Chris

Java and/or JNI is not found on ubuntu 12.04. Therefore, fop doesn't work. I think the paths to java stuff changed on ubuntu 12.04. Maybe, cmake 2.8.8 is handle those changes. cmake 2.8.7 is not.

David

Changed in zorba:
importance: Undecided → High
Revision history for this message
David Graf (davidagraf) wrote :

Hello Chris
You can close this bug. We don't have this problem anymore. The java modules are working properly on Ubuntu 12.04 since a while.

Revision history for this message
Chris Hillery (ceejatec) wrote :

Not sure how to mark this - don't know if we actually "fixed" it or not (although we probably did). But, I'll just go with "Invalid".

Changed in zorba:
status: New → Invalid
Revision history for this message
David Graf (davidagraf) wrote :

Hello Chris,
Unfortunately, telling you to close the bug was a bad idea. This morning, I found an additional issue. When compiling zorba or sausalito on a clean ubuntu 12.04, I get this:
-- --- Module: util-jvm ---
-- Looking for JNI
-- Looking for Java
-- Building Zorba without util-jvm module.
-- ---

The reason why I didn't catch this on the ubuntu machine I am working on is the following:
On my machine:
ls /usr/lib/jvm/
default-java java-1.5.0-gcj-4.6 java-1.6.0-openjdk java-1.6.0-openjdk-amd64 java-6-openjdk java-6-openjdk-amd64 java-6-openjdk-common java-7-openjdk-amd64

On clean machine:
ls /usr/lib/jvm/
java-1.6.0-openjdk-amd64 java-6-openjdk-amd64 java-6-openjdk-common java-7-openjdk-amd64

I do not know where this difference comes from. I assume because my ubuntu was upgraded from 10.04 to 12.04. Because we want to ship sausalito as soon as possible, I am fixing this issue directly in sausalito instead of waiting for a new merge. But the fixes I did can be applied to zorba too:

0)
FindJNI.cmake is used in the util-jvm module only. But it is 4 times in the zorba repositories. Therefore, I removed the following files and directories:
zorba/cmake_modules/FindJNI.cmake
zorba_modules/data-formatting/cmake_modules
zorba_modules/schema-tools/cmake_modules

1)
The custom FindJNI.cmake in the util-jvm module is not used. Therefore, I did the following change:
=== modified file 'runtime/zorba_modules/util-jvm/CMakeLists.txt'
--- runtime/zorba_modules/util-jvm/CMakeLists.txt 2012-05-22 09:45:57 +0000
+++ runtime/zorba_modules/util-jvm/CMakeLists.txt 2012-06-13 08:26:13 +0000
@@ -19,6 +19,7 @@
 IF (ZORBA_SUPPRESS_JAVA)
   MESSAGE (STATUS "ZORBA_SUPPRESS_JAVA is true - not searching for Java")
 ELSE (ZORBA_SUPPRESS_JAVA)
+ SET (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules ${CMAKE_MODULE_PATH})

   MESSAGE(STATUS "")
   MESSAGE(STATUS "--- Module: util-jvm ---")

2)
I extended the FindJNI.cmake in the util-jvm to find the files on clean ubuntu 12.04. I attached the patch.

I think this patches should go into the zorba 2.5 release. Otherwise, java modules do not work. What do you think?

Changed in zorba:
status: Invalid → Incomplete
Revision history for this message
Chris Hillery (ceejatec) wrote :

In order:

0) It certainly makes sense to consolidate on a single FindJNI.cmake, if in fact we need our own at all. The right place for it is in util-jvm. It will be necessary to ensure that other modules use that version as well, probably by extending the util-jvm "use file" to extend CMAKE_MODULE_PATH.

1) This change also makes sense if we need a custom FindJNI.cmake.

2) I don't like these changes, although I'm not sure of the alternative. IMHO the existing FindJNI code with all of its many specific hard-coded paths is bogus, and your change just extends the bogusness. There Must Be A Better Way(tm).

(Also - what was the reason you changed JAVA_AWT_INCLUDE_DIRECTORIES to JAVA_AWT_INCLUDE_PATH? That doesn't seem to make sense.)

FYI, it seems to work for me on Ubuntu 11.10, and I am using Sun JDK rather than OpenJDK which might also be better supported.

At any rate, no, I do not believe that this should be in Zorba 2.5 because it's too late, and because I'm unwilling to toss in a hack at the last minute that I'm not sure I agree with. Also, it appears that the work-around for anyone who runs into trouble is easy: Set JAVA_HOME in your environment before running CMake.

Changed in zorba:
status: Incomplete → Confirmed
importance: High → Medium
Revision history for this message
David Graf (davidagraf) wrote :

Hey Chris

>> (Also - what was the reason you changed JAVA_AWT_INCLUDE_DIRECTORIES to JAVA_AWT_INCLUDE_PATH? That doesn't seem to make sense.)

That's a typo. Thanks for telling me.

2) I don't like these changes, although I'm not sure of the alternative. IMHO the existing FindJNI code with all of its many specific hard-coded paths is bogus, and your change just extends the bogusness. There Must Be A Better Way(tm).
>> We should tell our fixes to the cmake guys.

>> At any rate, no, I do not believe that this should be in Zorba 2.5 because it's too late, and because I'm unwilling to toss in a hack at the last minute that I'm not sure I agree with. Also, it appears that the work-around for anyone who runs into trouble is easy: Set JAVA_HOME in your environment before running CMake.

True.

Revision history for this message
David Graf (davidagraf) wrote :

Hey Chris

After reading your last comments, I decided to bypass the problem differently. Without changing FindJNI.cmake. I generate the JAVA_HOME variable with a bash script and set it before searching the JNI stuff. Here is the code:

1 === modified file 'runtime/zorba_modules/util-jvm/CMakeLists.txt'
2 --- runtime/zorba_modules/util-jvm/CMakeLists.txt 2012-05-22 09:45:57 +0000
3 +++ runtime/zorba_modules/util-jvm/CMakeLists.txt 2012-06-13 13:23:06 +0000
4 @@ -23,6 +23,18 @@
5 MESSAGE(STATUS "")
6 MESSAGE(STATUS "--- Module: util-jvm ---")
7
8 + # 28msec special
9 + IF (UNIX AND NOT APPLE)
10 + EXECUTE_PROCESS(
11 + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/generate-java-home.sh
12 + OUTPUT_VARIABLE _JAVA_HOME
13 + RESULT_VARIABLE RES)
14 + IF (RES EQUAL 0)
15 + MESSAGE(STATUS "GENERATED JAVA_HOME: " ${_JAVA_HOME})
16 + set(ENV{JAVA_HOME} ${_JAVA_HOME})
17 + ENDIF()
18 + ENDIF()
19 +
20 MESSAGE (STATUS "Looking for JNI")
21 FIND_PACKAGE(JNI)
22
23
24 === added file 'runtime/zorba_modules/util-jvm/generate-java-home.sh'
25 --- runtime/zorba_modules/util-jvm/generate-java-home.sh 1970-01-01 00:00:00 +0000
26 +++ runtime/zorba_modules/util-jvm/generate-java-home.sh 2012-06-13 13:23:06 +0000
27 @@ -0,0 +1,4 @@
28 +WHICH_JAVA=$(which java)
29 +RESULT_CODE=$?
30 +echo -n $(cd $(dirname $(readlink -f $WHICH_JAVA))/../..; pwd)
31 +exit $RESULT_CODE

I like it much more then the other solution. Setting JAVA_HOME is a much better idea.

Revision history for this message
Chris Hillery (ceejatec) wrote : Re: [Bug 989490] Re: on ubuntu 12.04, Java and/or JNI not found
Download full text (3.2 KiB)

I like your solution too. Could you propose that for merging into the main
util-jvm module?

One minor suggestion: generate-java-home.sh should start with a #!/bin/sh
shebang line, I think.

One question: is $(which java)/../.. always JAVA_HOME? Could it be
different if you only have the JRE installed?

Also note that you could do this entirely within CMake if you wanted. Use
FIND_FILE(_JAVA_LOC NAMES java PATHS ENV PATH) (or something similar) to
find the Java command, GET_FILENAME_COMPONENT(_JAVA_LOC "${_JAVA_LOC}"
REALPATH) to resolve to a real location, and then
GET_FILENAME_COMPONENT(_JAVA_HOME "${_JAVA_LOC}/../.." ABSOLUTE) to go up
two directories. (You might be able to combine the last two steps, not
sure.) Not saying that you *should* do that, just letting you know in case
those abilities would be useful in future.

Ceej
aka Chris Hillery

On Wed, Jun 13, 2012 at 8:06 AM, David Graf <david.graf@28msec.com> wrote:

> Hey Chris
>
> After reading your last comments, I decided to bypass the problem
> differently. Without changing FindJNI.cmake. I generate the JAVA_HOME
> variable with a bash script and set it before searching the JNI stuff.
> Here is the code:
>
>
> 1 === modified file 'runtime/zorba_modules/util-jvm/CMakeLists.txt'
> 2 --- runtime/zorba_modules/util-jvm/CMakeLists.txt 2012-05-22
> 09:45:57 +0000
> 3 +++ runtime/zorba_modules/util-jvm/CMakeLists.txt 2012-06-13
> 13:23:06 +0000
> 4 @@ -23,6 +23,18 @@
> 5 MESSAGE(STATUS "")
> 6 MESSAGE(STATUS "--- Module: util-jvm ---")
> 7
> 8 + # 28msec special
> 9 + IF (UNIX AND NOT APPLE)
> 10 + EXECUTE_PROCESS(
> 11 + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/generate-java-home.sh
> 12 + OUTPUT_VARIABLE _JAVA_HOME
> 13 + RESULT_VARIABLE RES)
> 14 + IF (RES EQUAL 0)
> 15 + MESSAGE(STATUS "GENERATED JAVA_HOME: " ${_JAVA_HOME})
> 16 + set(ENV{JAVA_HOME} ${_JAVA_HOME})
> 17 + ENDIF()
> 18 + ENDIF()
> 19 +
> 20 MESSAGE (STATUS "Looking for JNI")
> 21 FIND_PACKAGE(JNI)
> 22
> 23
> 24 === added file
> 'runtime/zorba_modules/util-jvm/generate-java-home.sh'
> 25 --- runtime/zorba_modules/util-jvm/generate-java-home.sh
> 1970-01-01 00:00:00 +0000
> 26 +++ runtime/zorba_modules/util-jvm/generate-java-home.sh
> 2012-06-13 13:23:06 +0000
> 27 @@ -0,0 +1,4 @@
> 28 +WHICH_JAVA=$(which java)
> 29 +RESULT_CODE=$?
> 30 +echo -n $(cd $(dirname $(readlink -f $WHICH_JAVA))/../..; pwd)
> 31 +exit $RESULT_CODE
>
> I like it much more then the other solution. Setting JAVA_HOME is a much
> better idea.
>
> --
> You received this bug notification because you are a bug assignee.
> https://bugs.launchpad.net/bugs/989490
>
> Title:
> on ubuntu 12.04, Java and/or JNI not found
>
> Status in Zorba - The XQuery Processor:
> Confirmed
>
> Bug description:
> Hey Chris
>
> Java and/or JNI is not found on ubuntu 12.04. Therefore, fop doesn't
> work. I think the paths to java stuff changed on ubuntu 12.04. Maybe,
> cmake 2.8.8 is handle those changes. cmake 2.8.7 is not.
>
> David
>
> To manage notifications...

Read more...

Revision history for this message
David Graf (davidagraf) wrote :

Hey Chris
I made merge proposals. I implemented everything in cmake. Because it is less lines of code :-).

I am wondering if the same should be done here: swig/java/CMakeLists.txt

What do you think?

Revision history for this message
Chris Hillery (ceejatec) wrote :

If it makes sense in the modules, it probably makes sense in Zorba core as well, I think, yes.

David Graf (davidagraf)
Changed in zorba:
status: Confirmed → Incomplete
assignee: Chris Hillery (ceejatec) → David Graf (davidagraf)
Revision history for this message
David Graf (davidagraf) wrote :

Change is missing in Zorba core ...

Revision history for this message
Chris Hillery (ceejatec) wrote :

FYI - "Incomplete" means that the bug report itself is incomplete (ie, the reporter needs to provide more information), not that the work is incomplete. Moving back to Confirmed. Thanks for working on this.

Changed in zorba:
status: Incomplete → Confirmed
Changed in zorba:
assignee: David Graf (davidagraf) → Chris Hillery (ceejatec)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.