Update To JRE7, can not load nativelib jar, but JRE6 works fine - native

For my JNLP file , there is some nativelib info like below:
<resources os="Windows">
<nativelib href="lib/x264-win.jar" />
</resources>
<resources os="SunOS" arch="sparc">
<nativelib href="lib/x264-SunOS-sparc.jar" />
</resources>
<resources os="SunOS" arch="x86">
<nativelib href="lib/x264-SunOS-x86.jar" />
</resources>
When I Update To JRE7, can not load nativelib jar, but JRE6 works fine.
The load nativelib code like below:
String source = "x264.jar";
ClassLoader cl = Thread.currentThread().getContextClassLoader();
URL url= cl.getResource(source);
"x264.jar" is one jar in x264-win.jar,lib/x264-SunOS-sparc.jar or lib/x264-SunOS-x86.jar.
When I used JRE6 to load x264.jar, it worked fine.
But when I updated to JRE7, it can not load x264.jar.
When use JRE6, url would be"x264.jar" info, like jar:http://test.local:8080/JNLP.jar!/x264.jar,
but use JRE7, url would be null, and I found code not load nativelib "x264.jar"
Does any one have find JRE7 can not load nativelib.jar?
Is the problem of using Thread.currentThread().getContextClassLoader() to load "x264.jar"?

Ensure that you have the correct bitwise native binary to match your JRE. If you are testing on a 64-bit JRE, you need a 64-bit native binary. If you're testing on a 32-bit JRE, you need a 32-bit native binary. You might need to include resources for each of these three:
<resources os="Windows" arch="amd64">
<resources os="Windows" arch="x86_64">
<resources os="Windows" arch="x86">

I had similar trouble ; however even in JRE 6 this didn't get this to work.
Found a bug that could be related to that :
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6758884
Apparently JRE can have trouble downloading nativelib resources.
The bug is still opened, and targeted towards version 8 of java ...

The following "dll relying" applet is working fine (besides the security problems when using 1.7.0_51 (you need to decrease the security settings to medium since it is self signed)).
So if the native lib loading mechanism of the jnlp file is broken then you can distribute your .dll files alongside a normal jar file like in the upper example.
Put the dlls/sos in your jar file like in the example: jssc.jar
Load the libraries with System.load(libFolderPath + fileSeparator + libName); like used here.
As mentioned by Joseph please note the fine grained version differentiation between win, solaris, linux, arm and i86 and amd64 bit systems. So if you e.g. don't supply a 64Bit dll and run it with 64Bit Java it won't work...

I had forgot I solved this a while ago. I found that I had to handle this in Java code with System.loadLibrary( "jarNameNoExtension" );
Hopefully that helps others.

Related

Playframework 2.5 and Intellij IDEA

I am using IDEA for my Playframework development. However, I don't seem to be able to run/debug my application anymore I was able to do two months ago. I haven't done any active development on this project, and there have been updates to IDEA.
When I now debug my application it doesn't not load the 'dev' configuration file.
This is specified as -Dconfig.resource=application.dev.conf under JVM options on the Run/Debug configurations.
This used to work fine, but it now loads the application.conf which contains the default db parameters to connect to a MySQL server and not the mem server. I don't think I have changed anything. A ny pointers what can be wrong?
I am still on sbt-plugin 2.5.16.
[Edit]
Loading config from properties {jline.esc.timeout=0, config.resource=application.dev.conf, java.runtime.name=Java(TM) SE Runtime Environment, sun.boot.library.path=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib, java.vm.version=25.25-b02, user.country.format=IE, gopherProxySet=false, java.vm.vendor=Oracle Corporation, java.vendor.url=http://java.oracle.com/, path.separator=:, java.vm.name=Java HotSpot(TM) 64-Bit Server VM, file.encoding.pkg=sun.io, user.country=GB, sun.java.launcher=SUN_STANDARD, sun.os.patch.level=unknown, java.vm.specification.name=Java Virtual Machine Specification, user.dir=/Users/xxx/Documents/Java/Y2kBooking, java.runtime.version=1.8.0_25-b17, java.awt.graphicsenv=sun.awt.CGraphicsEnvironment, java.endorsed.dirs=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/endorsed, os.arch=x86_64, java.io.tmpdir=/var/folders/6g/mllv8zcn73v3p9mgt8f78jd80000gn/T/, line.separator=
, java.vm.specification.vendor=Oracle Corporation, os.name=Mac OS X, sun.jnu.encoding=UTF-8, java.library.path=/Users/xxx/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:., jboss.modules.system.pkgs=com.intellij.rt, java.specification.name=Java Platform API Specification, java.class.version=52.0, sun.management.compiler=HotSpot 64-Bit Tiered Compilers, os.version=10.13.2, http.nonProxyHosts=local|*.local|169.254/16|*.169.254/16, user.home=/Users/xxx, user.timezone=Europe/Dublin, java.awt.printerjob=sun.lwawt.macosx.CPrinterJob, java.specification.version=1.8, file.encoding=UTF-8, user.name=xxx, java.class.path=/Users/xxx/Library/Application Support/IntelliJIdea2017.3/Scala/launcher/sbt-launch.jar:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar:/Users/xxx/Library/Caches/IntelliJIdea2017.3/captureAgent/debugger-agent.jar, jline.shutdownhook=false, java.vm.specification.version=1.8, sun.arch.data.model=64, java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre, sun.java.command=xsbt.boot.Boot run, java.specification.vendor=Oracle Corporation, user.language=en, awt.toolkit=sun.lwawt.macosx.LWCToolkit, config.trace=loads, java.vm.info=mixed mode, java.version=1.8.0_25, java.ext.dirs=/Users/xxx/Library/Java/Extensions:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/ext:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java, sun.boot.class.path=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/sunrsasign.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/classes:/Users/xxx/Library/Caches/IntelliJIdea2017.3/captureAgent/debugger-agent-storage.jar, java.vendor=Oracle Corporation, file.separator=/, java.vendor.url.bug=http://bugreport.sun.com/bugreport/, sun.cpu.endian=little, sun.io.unicode.encoding=UnicodeBig, socksNonProxyHosts=local|*.local|169.254/16|*.169.254/16, ftp.nonProxyHosts=local|*.local|169.254/16|*.169.254/16, sun.cpu.isalist=}
Loading config from class loader sbt.PluginManagement$PluginClassLoader#4cc89246 but there were no resources called application.dev.conf
exception loading application.dev.conf: java.io.IOException: resource not found on classpath: application.dev.conf
Loading config from a String akka {
log-dead-letters = 0
log-dead-letters-during-shutdown = off
}
Loading config from resource 'reference.conf' URL jar:file:/Users/xxx/.ivy2/cache/scala_2.10/sbt_0.13/com.typesafe.sbt/sbt-js-engine/jars/sbt-js-engine-1.1.3.jar!/reference.conf from class loader sbt.PluginManagement$PluginClassLoader#4cc89246
Loading config from a URL: jar:file:/Users/xxx/.ivy2/cache/scala_2.10/sbt_0.13/com.typesafe.sbt/sbt-js-engine/jars/sbt-js-engine-1.1.3.jar!/reference.conf
Try debugging the configuration loading with -Dconfig.trace=loads as described here.
The -Dconfig.resource option loads a file from the classpath so make sure that file is in your IntelliJ classpath. I assume you put the file in the usual conf directory? You may need to check the IntelliJ Project Structure settings to make sure it includes that directory as a Resource Folder.
Finally, you may wish to check that the application works correctly when run using sbt run or sbt start.

Kotlin - Error: Could not find or load main class _DefaultPackage

I followed the Kotlin tutorial for eclipse here : Getting Started With Eclipse Luna
However, I'm running into this error:
Error: Could not find or load main class _DefaultPackage
Anyone who knows to get around this?
This was a severe bug (KT-10221) in automatic generation of Launch Configuration in plugin version 0.4.0. It was fixed in 0.5.0 so the recommendend way to workaround is to update plugin.
The source of the problem was that the plugin used an old pattern for generating name of the class for main function that had been abandoned by Kotlin compiler.
It's possible to workaround it by editing launch configuration (Eclipse Menu -> Run -> Run Configurations...) by hand and changing Main class field in Java Application group. If the file is named hello.kt with no package directive, as it is described in tutorial, than corrected string should be HelloKt.
If file has name other.kt with package my.tutorial than the Main Class should contain my.tutorial.HelloKt. You can read more about it in the section Package-Level Functions of Calling Kotlin From Java page.
I have been getting the same issue. And after putting the right compiler output path, it got resolved.
Go to Project -> Project Compiler output :
In the text box, fill this:
[Absolute Path]/{Project Name}/out
In my case I was having this problem while trying to run the program using the Application Gradle plugin. The problem was in the mainClassName property using single quotes instead of double ones
This didn't work:
mainClassName = 'demo.HelloWorldKt'
With double quotes, it works:
mainClassName = "demo.HelloWorldKt"
For me it worked after I installed the correct JDK. I first had JDK 11 but the tutorial I did was with JDK 8 so after I installed this and set it in the "installed JREs" options it found the main class without having any "mainClassName" or any other option in the build.gradle file.
For me, it worked in a fresh eclipse workspace. Possibly, the Kotlin eclipse plugin is not playing well with other plugins (in my case, PyDev).
I'm creating a Kotlin Application with JavaFX and I had this issue until I went to:
Run > Run Configurations > Java Application > Common
I unticked "Allocate console" and it fixed the issue.

Jython does not resolve python imports from bundled Lib files/folders on Weblogic 10.3.5

I am new to Jython and Python, trying to build a prototype that makes use of Python code to be called from within Java. The code I am developing works in Jetty and in standalone mode (running java -jar from the command line), but not when deployed to weblogic.
How can I make weblogic(10.3.5) server/Jython recognize the Lib folder within jython-standalone-2.5.4-rc1.jar?
My Java code uses the JythonObjectFactory to invoke python modules as outlined in the Jython book:
http://www.jython.org/jythonbook/en/1.0/JythonAndJavaIntegration.html
The Python modules are using external libraries like csv, logging etc. that are not packaged with jython.jar, hence I am using jython-standalone jar.
The java code includes an interface that would define the class type of the first invoked py module from within java. The interface and the input and output (to python modules) type classes are in a package structure as com.abc.xpackage. and the py modules exist at the root of this package. A controller layer calls the objectfactory and in turn executes the python code thus:
JythonObjectFactory calFactory = new JythonObjectFactory(CalcType.class, "Calculate", "Calculate");
CalcType engine = (CalcType)calFactory.createObject();
output = engine.execute(input);
The entire code is bundled as a jar file which would become part of a web application deployed on weblogic. The code was compiled with maven (with jython dependencies included in the repository) and runs fine on the included Jetty runtime within eclipse.
When deployed on weblogic, however, I get a "ImportError: no module named csv" error.
To analyze what is happening, I tried printing the Jython system state path on weblogic and the standalone environment/Jetty. What I found is,
on Jetty, the system path consists of the following:
C:\.m2\repo\org\python\jython\jython-standalone-2.5.3-rc1.jar\Lib, ____classpath__, ____pyclasspath__
on Weblogic, printing the system path by default shows the following:
____classpath__, ____pyclasspath__
I tried forcing the inclusion of the missing path using the code as follows:
public JythonObjectFactory(PySystemState state, Class interfaceType, String moduleName, String className) {
String pathToAppend = new File(state.getClass().getProtectionDomain().getCodeSource().getLocation().toURI().getPath()).getAbsolutePath()+"\\Lib";
state.path.insert(0, new PyString(pathToAppend));
state.path.append(new PyString(pathToAppend));
System.out.println("Jython sys path: "+state.path);
Please note, I prepended as well as appended the path in different trials. The sys path on weblogic now displays the following:
Jython sys path: ['C:\\wldomain\\wls135\\servers\\cgServer\\tmp\\app-1\\war\\WEB-INF\\lib\\jython-standalone-2.5.4-rc1.jar\\Lib', '__classpath__', '__pyclasspath__/', 'C:\\wldomain\\wls135\\servers\\cgServer\\tmp\\app-1\\war\\WEB-INF\\lib\\jython-standalone-2.5.4-rc1.jar\\Lib']
I am still getting ImportError despite this forcing of sys path. Please help why this works in a local environment, and not on weblogic, and if there is any configuration I am missing. Apologize for the rambling long post, I did not know how to explain the problem better. I will try and include any code/artifacts as needed.
Based on a comment(by Lassi) on the blog post below:
http://www.petervannes.nl/files/e1c3c56d15d25dcfd4adb5397a9ef71e-53.php
The jython issue was resolved after explicitly adding the Lib folder python.path to the weblogic startup script as a JAVA_OPTION.
In my case I added the exploded Lib folder to the domain server lib, but based on my test this works also from within the jython jar. Both the following JAVA_OPTIONS worked:
-Dpython.path=C:\wldomain\wls135\lib\Lib
-Dpython.path=C:\wldomain\wls135\lib\jython-standalone-2.5.4-rc1.jar\Lib
The programmatic way of sys.path.append worked for the local environment(jetty) but did not seem to work for weblogic.

CompositeELResolver Null Pointer Exception

I've got a problem with "javax.el.CompositeELResolver" which is used by TomEE's "javaee-api-6.0-5.jar".
Version information and svn-repository here:
http://mvnrepository.com/artifact/org.apache.geronimo.specs/geronimo-el_2.2_spec/1.0.2
Source of class CompositeELResolver here:
http://svn.apache.org/viewvc/geronimo/specs/tags/geronimo-el_2.2_spec-1.0.2/src/main/java/javax/el/CompositeELResolver.java?view=log
In the "invoke" method I get a null pointer exception because the for-loop iterates through the whole resolvers-array which has got fields with value "null". I suppose this is not avoidable because of the "add" method that doubles the array size if required but does not initialize any values. Shouldn't there be a check if the resolver is "null" in the "invoke" method before using it?
For comparison I ran my application with another javax.el implementation and it's working properly:
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<version>2.2</version>
</dependency>
Am I wrong with my supposition?
I found a similar-sounding issue here:
https://issues.apache.org/bugzilla/show_bug.cgi?id=50293
Is it possible that multi-threading causes my problem?
Solved.
TomEE uses version 1.0.2 of http://mvnrepository.com/artifact/org.apache.geronimo.specs/geronimo-el_2.2_spec
The bug is fixed in version 1.0.4
Based on the fixed geronimo el spec 1.0.4 version it is easy to fix the javaee-api-6.0-5.jar package.
Just download the newest jar file from here http://mvnrepository.com/artifact/org.apache.geronimo.specs/geronimo-el_2.2_spec/1.0.4
and change the javax.el package in javaee-api-6.0-5.jar with the files comes from geronimo el 2.2 spec 1.0.4 jar files
I did it using mc under linux browse the content and copy from one to another. And I tested and works perfect.
Of course you can do it with jar utils as well :-)
It was strange for me that this problem did not exist in 32 bit windows environment but only in 64 bit linux environment. Anyhow the fix solves the problem.
Hope that there will be a javaee-api-6.0-6.jar soon :-)

Package xxx requires unavailable shared library - Maps API

I am working with a sample app that uses the Maps API and getting the following error:
Package xxx requires unavailable shared library com.google.android.maps; failing!
I have obtained a Maps API key from my debug certificate fingerprint and inserted it into my main xml file thusly:
<com.google.android.maps.MapView
android:id="#+id/mapmain"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="lotsoflettersandnumbers" />
I have also loaded the maps jar file onto my device. What am I doing wrong or not doing right? What else do you need to know to help answer this question?
I tried this on another device (Android 2.3; the device getting the error is 2.1) and it works. One thing I noticed is that on the 2.1 device, the permissions for the maps.jar file are -rwxrwxrwx, and on the 2.3 device they are -rw-r--r--. Could that be contributing to the error?
Problem solved. I was missing the file /system/etc/permissions/com.google.android.maps.xml, which is also required. FWIW, I am working with a ruggedized Android device that does not come with the google maps jar or xml files on it. That's why I had to add them myself.