views:

54

answers:

1

I have a Java application, built with eclipse, that uses QTJambi. Running the application from the command line works perfectly.

java -d32 -XstartOnFirstThread -jar MyApplication.jar someArg

However, trying to deploy the application with WebStart is proving difficult. I've done a whole lot of reading and it seems many people have issues getting this to work on Mac OS X. The issue seems to be that the native libraries aren't being correctly loaded. The stack trace is provided below.


CWindow's _nativeHide encountered error: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.javaws.Launcher.invokeMainMethod(Launcher.java:1819)
Caused by: java.lang.ExceptionInInitializerError
    at com.trolltech.qt.QtJambiObject.(QtJambiObject.java:60)
    at com.engage.agentdesktop.Application.main(Application.java:25)
    ... 5 more
Caused by: java.lang.RuntimeException: Loading library failed, progress so far:
No 'qtjambi-deployment.xml' found in classpath, loading libraries via 'java.library.path'
Loading library: 'libQtCore.4.dylib'...
 - using 'java.library.path'

    at com.trolltech.qt.internal.NativeLibraryManager.loadNativeLibrary(NativeLibraryManager.java:431)
    at com.trolltech.qt.internal.NativeLibraryManager.loadQtLibrary(NativeLibraryManager.java:355)
    at com.trolltech.qt.Utilities.loadQtLibrary(Utilities.java:140)
    at com.trolltech.qt.Utilities.loadQtLibrary(Utilities.java:136)
    at com.trolltech.qt.QtJambi_LibraryInitializer.(QtJambi_LibraryInitializer.java:56)
    ... 7 more
Caused by: java.lang.RuntimeException: Library 'libQtCore.4.dylib' was not found in 'java.library.path'=/Users/smeatonj/Desktop/Engage Agent Desktop.app/Contents/Resources/Java:/System/Library/PrivateFrameworks/JavaApplicationLauncher.framework/Resources:.:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
    at com.trolltech.qt.internal.NativeLibraryManager.loadLibrary_helper(NativeLibraryManager.java:486)
    at com.trolltech.qt.internal.NativeLibraryManager.loadNativeLibrary(NativeLibraryManager.java:426)
    ... 11 more

This is an extract of the webstart.jnlp file:

   `[resources`]
        `[j2se version="1.5+"/`]
    `[jar href="${MEDIA_URL}application/webstart/MyApplication.jar" /`]
        ....
        `[jar href="${MEDIA_URL}application/webstart/MyApplication_lib/qtjambi-4.5.2_01.jar" /`]

  `[resources os="Mac OS X"`]
    `[j2se version="1.5+" java-vm-args="-d32 -XstartOnFirstThread"/`]
    `[jar href="${MEDIA_URL}application/webstart/MyApplication_lib/qtjambi-macosx-gcc-4.5.2_01.jar" /`]
  `[/resources`]

The error tells me that qtjambi-deployment.xml is not found in the classpath. I've opened up qtjambi-macosx-gcc-4.5.2_01.jar and there is definitely the qtjambi-deployment.xml file there.

The resources os="Max OS X" node is definitely being loaded by the JNLP, because I was receiving different errors before that required me to put -d32 into the vm args. Does anyone know what the hell could be causing this error?

Edit:

The application runs fine when webstarting to Windows.

A: 

For those that come after, this is the information that we discovered about deploying Jambi via webstart to Mac OS X.

qtjambi-macosx-gcc-4.5.2_01 can not be found when installing/launching from webstart. If this library is on your path, webstart is able to find it and use it, and will launch correctly. Further, there are some JNLP properties that need to be set.

  <resources os="Mac OS X">
    <!-- Currently Unsupported-->
    <property name="com.trolltech.launcher.webstart" value="true" />
    <property name="com.trolltech.verbose-loading" value="true" />
    <j2se version="1.5+" java-vm-args="-d32 -XstartOnFirstThread"/>
    <jar href="/path/to/qtjambi-macosx-gcc-4.5.2_01.jar" />
  </resources>

The property com.trolltech.launcher.webstart is required to inform the Jambi libraries that we are starting via webstart, and to configure itself in such a way that allows webstart to work. Unfortunately, it's broken for mac os x at this point in time.

The QTJambi Community Port to 4.6 solves the above problem, but introduces a new problem.

http://qt.gitorious.org/qt-jambi/community-port-to-4_6 http://sourceforge.net/apps/trac/qtjambi/ticket/37

I've investigated this bug as well, and it requires changing one line of code to get working, namely, changing the class loader to play nice with webstart (more secure class loader). I haven't attempted yet, due to the build system being quite off putting and not having the time to investigate properly.

So, if you're having troubles deploying QT Jambi applications with webstart on Mac OSX, you now know why. If anyone gets around to changing 4.6, please post here and update this information. Alternatively, if I get around to changing it, I'll post here also.

Useful references:

http://doc.qt.nokia.com/qtjambi-4.3.5_01/com/trolltech/qt/qtjambi-systemproperties.html

Josh Smeaton