Jar with WorldWind Library

时间:2015-03-23 10:34:24

标签: java maven jar worldwind

大家好! 我在libriary WorldWind(它是NASA lib)上遇到了一些麻烦。 我在JetBrains Idea 14中用Java 8编写我的应用程序。 在Idea中,我可以成功编译和运行我的应用程序,但是当我尝试使用Maven创建jar并运行我的jar时 - 我有一个带有异常的大堆栈跟踪。 这里的堆栈跟踪:

    Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library /tmp/jogamp_0000/file_cache/jln2853478832317459843/jln6471099643623499225/libgluegen-rt.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
Exception in Application constructor
13:18:52.415 [main] ERROR e.p.a.geotarget.GeoTargetApplication - java.lang.RuntimeException: Unable to construct Application instance: class myapp.GeoTargetApplication
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:907)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$152(LauncherImpl.java:182)
        at com.sun.javafx.application.LauncherImpl$$Lambda$55/1556956098.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$158(LauncherImpl.java:819)
        at com.sun.javafx.application.LauncherImpl$$Lambda$56/793261514.run(Unknown Source)
        at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(PlatformImpl.java:326)
        at com.sun.javafx.application.PlatformImpl$$Lambda$51/1766822961.run(Unknown Source)
        at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
        at com.sun.javafx.application.PlatformImpl$$Lambda$53/1889656903.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:294)
        at com.sun.javafx.application.PlatformImpl$$Lambda$52/1496724653.run(Unknown Source)
        at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
        at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
        at com.sun.glass.ui.gtk.GtkApplication.lambda$null$48(GtkApplication.java:139)
        at com.sun.glass.ui.gtk.GtkApplication$$Lambda$41/1364335809.run(Unknown Source)
        ... 1 more
Caused by: myapp.GeoTargetException: java.util.concurrent.ExecutionException: java.lang.UnsatisfiedLinkError: /tmp/jogamp_0000/file_cache/jln2853478832317459843/jln6471099643623499225/libgluegen-rt.so: /tmp/jogamp_0000/file_cache/jln2853478832317459843/jln6471099643623499225/libgluegen-rt.so: неправильный класс ELF: ELFCLASS32 (Possible cause: architecture word width mismatch)
        at myapp.ui.controls.WorldWindNode.<init>(WorldWindNode.java:40)
        at myapp.GeoTargetApplication.<init>(GeoTargetApplication.java:53)
        ... 18 more
Caused by: java.util.concurrent.ExecutionException: java.lang.UnsatisfiedLinkError: /tmp/jogamp_0000/file_cache/jln2853478832317459843/jln6471099643623499225/libgluegen-rt.so: /tmp/jogamp_0000/file_cache/jln2853478832317459843/jln6471099643623499225/libgluegen-rt.so: неправильный класс ELF: ELFCLASS32 (Possible cause: architecture word width mismatch)
        at java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.util.concurrent.FutureTask.get(FutureTask.java:192)
        at myapp.ui.controls.WorldWindNode.<init>(WorldWindNode.java:36)
        ... 19 more
Caused by: java.lang.UnsatisfiedLinkError: /tmp/jogamp_0000/file_cache/jln2853478832317459843/jln6471099643623499225/libgluegen-rt.so: /tmp/jogamp_0000/file_cache/jln2853478832317459843/jln6471099643623499225/libgluegen-rt.so: неправильный класс ELF: ELFCLASS32 (Possible cause: architecture word width mismatch)
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1937)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1822)
        at java.lang.Runtime.load0(Runtime.java:809)
        at java.lang.System.load(System.java:1086)
        at com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLoaderBase.java:575)
        at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.java:64)
        at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNILibLoaderBase.java:96)
        at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.java:459)
        at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibrary(DynamicLibraryBundle.java:388)
        at com.jogamp.common.os.Platform$1.run(Platform.java:209)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.jogamp.common.os.Platform.<clinit>(Platform.java:179)
        at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:120)
        at gov.nasa.worldwind.Configuration.getMaxCompatibleGLProfile(Unknown Source)
        at gov.nasa.worldwind.Configuration.getRequiredGLCapabilities(Unknown Source)
        at gov.nasa.worldwind.awt.WorldWindowGLJPanel.<init>(Unknown Source)
        at myapp.ui.controls.WorldWindNode.lambda$new$12(WorldWindNode.java:25)
        at myapp.ui.controls.WorldWindNode$$Lambda$80/619798096.call(Unknown Source)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:749)
        at java.awt.EventQueue.access$500(EventQueue.java:97)
        at java.awt.EventQueue$3.run(EventQueue.java:702)
        at java.awt.EventQueue$3.run(EventQueue.java:696)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:719)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

我不介意为什么在Idea ide我可以运行应用程序,一切都很棒,但我无法从jar运行它。 我用maven中的插件创建我的jar:

    <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.5.3</version>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>myapp.mainClass</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>com.github.igor-petruk.protobuf</groupId>
            <artifactId>protobuf-maven-plugin</artifactId>
            <version>0.6.5</version>
            <executions>
                <execution>
                    <configuration>
                        <outputDirectory>src/main/java</outputDirectory>
                        <cleanOutputFolder>false</cleanOutputFolder>
                    </configuration>

                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Thanx为您提供答案和帮助! 它应该适用于Windows和Linux:)

1 个答案:

答案 0 :(得分:1)

通过分析异常中的以下行,当您拥有32位库时,它看起来像平台依赖性问题,并且您尝试将其加载到64位进程中。

        ... 1 more
Caused by: myapp.GeoTargetException: java.util.concurrent.ExecutionException: java.lang.UnsatisfiedLinkError: /tmp/jogamp_0000/file_cache/jln2853478832317459843/jln6471099643623499225/libgluegen-rt.so: /tmp/jogamp_0000/file_cache/jln2853478832317459843/jln6471099643623499225/libgluegen-rt.so: неправильный класс ELF: ELFCLASS32 (Possible cause: architecture word width mismatch)
        at myapp.ui.controls.WorldWindNode.<init>(WorldWindNode.java:40)
        at myapp.GeoTargetApplication.<init>(GeoTargetApplication.java:53)
        ... 18 more
Caused by: java.util.concurrent.ExecutionException: java.lang.UnsatisfiedLinkError: /tmp/jogamp_0000/file_cache/jln2853478832317459843/jln6471099643623499225/libgluegen-rt.so: /tmp/jogamp_0000/file_cache/jln2853478832317459843/jln6471099643623499225/libgluegen-rt.so: неправильный класс ELF: ELFCLASS32 (Possible cause: architecture word width mismatch)
        at java.util.concurrent.FutureTask.report(FutureTask.java:122)

以下SO文件存在jogl插件问题。

/tmp/jogamp_0000/file_cache/jln2853478832317459843/jln6471099643623499225/libgluegen-rt.so

<强>解决方案: 尝试从Source

中采取以下提到的步骤
Running under 64-bit Linux
    Without installing the AMD64 version of JOGL you will likely see errors like Exception in thread "main" java.lang.UnsatisfiedLinkError: no gluegen-rt in java.library.path or Exception in thread "main" java.lang.UnsatisfiedLinkError: ~/wwj/libgluegen-rt.so: ~/wwj/libgluegen-rt.so: wrong ELF class: ELFCLASS32
    To get it working:
    Download the amd64 version of JOGL http://download.java.net/media/jogl/www/
    Unzip the downloaded file and copy the content of the lib directory to your WWJ directory (e.g. cp jjogl-1.1.1-pre-20070511-linux-amd64/lib/* /path_to_WWJ/)
    Edit run-demo.bash and replace the last line in the file with:
    java -Xmx512m -Dsun.java2d.noddraw=true -Djava.library.path=. -classpath ./src:./classes:./
    worldwind.jar:./jogl.jar:./gluegen-rt.jar $1
    (Note: the only change is the addition of -Djava.library.path=.)

您还可以看到link遇到类似问题。