ld_pvl
07-03-2009, 11:45 PM
How can I gain above permission for my Applet?
I've been working on this GUI application. One of the functions of this application is to read some values from a file and from those values generate the content for some tables, the content of the tables is calculated via a class called BlackScholes which uses common-maths library. For the sake of simplicity, in the beginning, I hardwired the path (URL) leading to that file, which is basically the URL of my host. Therefore it would not work on any other locations except the host specified.
In the beginning I decided to write the GUI seperately (for some reasons), then just create one of its object in an applet. Like below:
import fdrs.FX.*;
import javax.swing.*;
public class MainApplet extends JApplet {
public void init() {
Main main = new Main();
main.setVisible(true);
}
}
So far so good, I've been uploading the JApplet-Gui application occasionally onto the host and it runs fine with no problems or incoherences.
Then I decided to "softwire" the path (URL) directing the application to the file, so that the application could run anywhere without throwing me the Security related errors. So I rewrote the applet code as follows:
import fdrs.FX.*;
import java.net.*;
import javax.swing.*;
public class MainApplet extends JApplet {
URL codeBaseURL;
public void init() {
codeBaseURL = this.getCodeBase();
Main main = new Main(codeBaseURL);
main.setVisible(true);
}
}
The application indeed could run anywhere, i tested on different servers. However, the application only partially works correctly, as for some reason it complains about some kind of error from the apache maths library.
This is very strange because I did not change anything besides the code above, and just one line (instead of hardwiring now I use the codeBaseURL parameter) in the class which uses the URL path to read from the file.
This is the error that it throws:
Exception in thread "AWT-EventQueue-1" java.lang.ExceptionInInitializerError
at org.apache.commons.math.special.Gamma.regularizedGammaP(Gamma.java:180)
at org.apache.commons.math.special.Erf.erf(Erf.java:56)
at org.apache.commons.math.distribution.NormalDistributionImpl.cumulativeProbability(NormalDistribution Impl.java:110)
at fdrs.FX.BlackScholes.ND1(BlackScholes.java:53)
at fdrs.FX.BlackScholes.callPrice(BlackScholes.java:77)
at fdrs.FX.Table.UpdateSpotTable(Table.java:42)
at fdrs.FX.Main.UpdateTables(Main.java:112)
at fdrs.FX.Main.MaturityTextFieldKeyReleased(Main.java:1034)
at fdrs.FX.Main.access$700(Main.java:12)
at fdrs.FX.Main$8.keyReleased(Main.java:458)
at java.awt.Component.processKeyEvent(Component.java:6095)
at javax.swing.JComponent.processKeyEvent(JComponent.java:2799)
at java.awt.Component.processEvent(Component.java:5911)
at java.awt.Container.processEvent(Container.java:2023)
at java.awt.Component.dispatchEventImpl(Component.java:4501)
at java.awt.Container.dispatchEventImpl(Container.java:2081)
at java.awt.Component.dispatchEvent(Component.java:4331)
at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1848)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:704)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:969)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:841)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:668)
at java.awt.Component.dispatchEventImpl(Component.java:4373)
at java.awt.Container.dispatchEventImpl(Container.java:2081)
at java.awt.Window.dispatchEventImpl(Window.java:2458)
at java.awt.Component.dispatchEvent(Component.java:4331)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission accessDeclaredMembers)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkMemberAccess(SecurityManager.java:1662)
at java.lang.Class.checkMemberAccess(Class.java:2157)
at java.lang.Class.getDeclaredMethod(Class.java:1934)
at org.apache.commons.math.MathException.<clinit>(MathException.java:49)
Please help me on this matter, thanks in advance
LD
I've been working on this GUI application. One of the functions of this application is to read some values from a file and from those values generate the content for some tables, the content of the tables is calculated via a class called BlackScholes which uses common-maths library. For the sake of simplicity, in the beginning, I hardwired the path (URL) leading to that file, which is basically the URL of my host. Therefore it would not work on any other locations except the host specified.
In the beginning I decided to write the GUI seperately (for some reasons), then just create one of its object in an applet. Like below:
import fdrs.FX.*;
import javax.swing.*;
public class MainApplet extends JApplet {
public void init() {
Main main = new Main();
main.setVisible(true);
}
}
So far so good, I've been uploading the JApplet-Gui application occasionally onto the host and it runs fine with no problems or incoherences.
Then I decided to "softwire" the path (URL) directing the application to the file, so that the application could run anywhere without throwing me the Security related errors. So I rewrote the applet code as follows:
import fdrs.FX.*;
import java.net.*;
import javax.swing.*;
public class MainApplet extends JApplet {
URL codeBaseURL;
public void init() {
codeBaseURL = this.getCodeBase();
Main main = new Main(codeBaseURL);
main.setVisible(true);
}
}
The application indeed could run anywhere, i tested on different servers. However, the application only partially works correctly, as for some reason it complains about some kind of error from the apache maths library.
This is very strange because I did not change anything besides the code above, and just one line (instead of hardwiring now I use the codeBaseURL parameter) in the class which uses the URL path to read from the file.
This is the error that it throws:
Exception in thread "AWT-EventQueue-1" java.lang.ExceptionInInitializerError
at org.apache.commons.math.special.Gamma.regularizedGammaP(Gamma.java:180)
at org.apache.commons.math.special.Erf.erf(Erf.java:56)
at org.apache.commons.math.distribution.NormalDistributionImpl.cumulativeProbability(NormalDistribution Impl.java:110)
at fdrs.FX.BlackScholes.ND1(BlackScholes.java:53)
at fdrs.FX.BlackScholes.callPrice(BlackScholes.java:77)
at fdrs.FX.Table.UpdateSpotTable(Table.java:42)
at fdrs.FX.Main.UpdateTables(Main.java:112)
at fdrs.FX.Main.MaturityTextFieldKeyReleased(Main.java:1034)
at fdrs.FX.Main.access$700(Main.java:12)
at fdrs.FX.Main$8.keyReleased(Main.java:458)
at java.awt.Component.processKeyEvent(Component.java:6095)
at javax.swing.JComponent.processKeyEvent(JComponent.java:2799)
at java.awt.Component.processEvent(Component.java:5911)
at java.awt.Container.processEvent(Container.java:2023)
at java.awt.Component.dispatchEventImpl(Component.java:4501)
at java.awt.Container.dispatchEventImpl(Container.java:2081)
at java.awt.Component.dispatchEvent(Component.java:4331)
at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1848)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:704)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:969)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:841)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:668)
at java.awt.Component.dispatchEventImpl(Component.java:4373)
at java.awt.Container.dispatchEventImpl(Container.java:2081)
at java.awt.Window.dispatchEventImpl(Window.java:2458)
at java.awt.Component.dispatchEvent(Component.java:4331)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission accessDeclaredMembers)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkMemberAccess(SecurityManager.java:1662)
at java.lang.Class.checkMemberAccess(Class.java:2157)
at java.lang.Class.getDeclaredMethod(Class.java:1934)
at org.apache.commons.math.MathException.<clinit>(MathException.java:49)
Please help me on this matter, thanks in advance
LD