I am trying to deploy JavaFX application, but when I run it in browser, it looks like it cannot find the classes in external jar files.
java.lang.RuntimeExcepti
Sorry guys, I did mislead you a little bit. The problem, why my application works under Netbeans and in browser not was this line in static block in my jar:
String osName = (String) System.getProperties().get("os.name");
which return correct value in Netbeans (windows Xp), but Null in Browser. But when I slightly change the code to this>
String osName = (String) System.getProperty("os.name");
it return correct value in browser too. So it has nothing to do with external jars or signing the application. The problem still remains, because that external jars is part of our corporal java infrastructure, so I just cannot change the code directly, but this would be another topic :)
Judging by jnlp you haven't recreate jnlp after switching on Unrestricted access
. Try to run Clean and Build
or add next tag to your jnlp manually:
<security>
<all-permissions/>
</security>
I faced similar situations .. I dont know exactly which solution is what may help you .. so I will list them all :
1- be sure that the jar you are using are signed and signature is valid .. you can use jarsigner for this purposes .. because if the jars you are using are expired.. app will crash @ web. if there is a jar signed and expired . just remove all file from META-INF. ( jar is zip file btw)
2-I see your JNLP .. you need to add this attribute for the application class: main="true" so your will be :
<resources>
<j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
<jar href="JavaFXSklad2.jar" main="true" size="164987" download="eager" />
<jar href="lib/common.jar" size="965131" download="eager" />
<jar href="lib/ifxjdbc.jar" size="705534" download="eager" />
<jar href="lib/infra.jar" size="588915" download="eager" />
<jar href="lib/jdawt.jar" size="726475" download="eager" />
<jar href="lib/toplink.jar" size="1450414" download="eager" />
<jar href="lib/weblogic.jar" size="55582010" download="eager" />
</resources>
Its important to tell app which is your application class .. I dont know why .. but I found this structure in previous version of JavaFX and it solved my problem ..
3- if you are using webPage instead of generic one .. so just check that JNLP_content serial is the same .. because each time you add/remove jars to project, the serial will be changed .consider checking URL as well .. I mean this section in HTML:
function javafxEmbed() {
dtjava.embed(
{
url : 'BSigner_v1.5_release.jnlp',
placeholder : 'javafx-app-placeholder',
width : 500,
height : 100,
jnlp_content : 'PD94bWwgd0iYnNwc2lnbmVyX3YxLnBrZzRfcmVsZWFzZS5NYWluIiAgbmFtZT0iQlNQU2lnbmVyX3YxLjVfcmVsZWFzZSIgLz4NCiAgPHVwZGF0ZSBjaGVjaz0iYWx3YXlzIi8+DQo8L2pubHA+DQo='
},
{
javafx : '2.2+'
},
{}
);
}
hope that is gonna help you or anyone facing the same issue ..
Good luck
If you are using NetBeans 7.1, you need to update your NetBeans to the latest nightly version http://bits.netbeans.org/download/trunk/nightly/latest/.
Earlier versions of NetBeans have a bug packaging jar files http://netbeans.org/bugzilla/show_bug.cgi?id=205844.
You can see if your NetBeans generated package has this bug by unjarring your application's jar files and checking that it's META-INF/MANIFEST.MF file includes references to your external jar files.
It looks like the jars you are using (things like Toplink, jdbc and WebLogic) require security privileges above what you are available to an unsigned application, so you also need to request further security permissions as Sergey recommends and sign your application. To do this:
Note that once you do this, users will now get Info and Alert boxes when they use your application because the application is requesting increased privileges over what a normal web page would have.
In Java, if static initialization of a class fails, the class load will fail to complete, even though the class is available and on the class path. This means that the first reference to the class will generate an ExceptionInInitializerError
and subsequent references to the class will generate, an often misleading, ClassNotFoundException
.
ExceptionInInitializerError
is thrown to indicate that an exception occurred during evaluation of a static initializer or the initializer for a static variable. The Jar containing the class file throwing the error was found and loading of the class commenced but could not be completed because errors were experienced in it's static variables or constructor.
Suspect code would be TextAttributeProp.checkLimit(TextAttributeProp.java:125)
, although the root cause of your issue may be elsewhere. Check what the TextAttributeProp static code is doing, and wrap static initialization methods in try catch blocks to get more debugging info, take fallback action or ignore the static initialization error.
System.getProperties()
will not return you the properties you want in an unsigned applet - it will just return null. You then try to dereference this null value in a static initializer which generates a NullPointerException and causes your class load to fail and subsequent references to the class to turn up ClassNotFoundException.
If you directly get the property "os.name"
via System.getProperty("os.name")
rather than getting all System properties, it works because "os.name"
is not marked as security sensitive. To see which properties you can and cannot request from an Applet, refer to: http://docs.oracle.com/javase/tutorial/deployment/doingMoreWithRIA/properties.html. Also note that an unsigned applet cannot set any System properties.
If your application is properly signed, you should be able to get and set any System properties you want. If you cannot do this, then you can file a bug against the JavaFX browser plugin at http://javafx-jira.kenai.com. First check that you have signed your app correctly by trying to do something else which requires elevated privileges, for example, read a file from your root file system from the signed applet and ensure that the read does not fail.