I created an new application iteration using install4j v5.1.15.
The application starts a windows service after installation which has couple of steps to try and hit few URLs to get the updates or make sure some other configuration is available.
All I am getting is this below exception after installation is complete(used debugger mode). Is there any way I can configure the installer to give out more information(either point out which URL it is accessing), I have made sure that the all URLs added as present in the .install4j file are available.
What else can I try?
[INFO] com.install4j.runtime.beans.screens.BannerFormScreen [ID 1202]: Show screen
[INFO] com.install4j.runtime.beans.actions.control.RunScriptAction [ID 1203]: Execute action
Property script: I4jScript_Internal_97
Property rollbackSupported: false
Property rollbackScript: null
java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at I4jScript_Internal_97$1.execute(I4jScript_Internal_97.java:68)
at com.install4j.runtime.installer.ContextImpl.runElevatedInt(Unknown Source)
at com.install4j.runtime.installer.ContextImpl.runElevated(Unknown Source)
at I4jScript_Internal_97.eval(I4jScript_Internal_97.java:34)
at I4jScript_Internal_97.evaluate(I4jScript_Internal_97.java:99)
at com.install4j.runtime.installer.helper.Script.evaluate(Unknown Source)
at com.install4j.runtime.installer.ContextImpl.runScript(Unknown Source)
at com.install4j.runtime.installer.ContextImpl.runScript(Unknown Source)
at com.install4j.runtime.beans.actions.control.RunScriptAction.execute(Unknown Source)
at com.install4j.runtime.beans.actions.SystemInstallOrUninstallAction.install(Unknown Source)
at com.install4j.runtime.installer.InstallerContextImpl$2.fetchValue(Unknown Source)
at com.install4j.runtime.installer.helper.comm.actions.FetchObjectAction.execute(Unknown Source)
at com.install4j.runtime.installer.helper.comm.HelperCommunication.executeActionDirect(Unknown Source)
at com.install4j.runtime.installer.helper.comm.HelperCommunication.executeActionInt(Unknown Source)
at com.install4j.runtime.installer.helper.comm.HelperCommunication.executeActionChecked(Unknown Source)
at com.install4j.runtime.installer.helper.comm.HelperCommunication.fetchObjectChecked(Unknown Source)
at com.install4j.runtime.installer.InstallerContextImpl.performActionIntStatic(Unknown Source)
at com.install4j.runtime.installer.InstallerContextImpl.performActionInt(Unknown Source)
at com.install4j.runtime.installer.ContextImpl.performAction(Unknown Source)
at com.install4j.runtime.installer.controller.Controller.executeActions(Unknown Source)
at com.install4j.runtime.installer.controller.Controller.handleCommand(Unknown Source)
at com.install4j.runtime.installer.controller.Controller.start(Unknown Source)
at com.install4j.runtime.installer.Installer.runInProcess(Unknown Source)
at com.install4j.runtime.installer.Installer.main(Unknown Source)
Edit-1:
#Ingo Kegel
Adding the script that I believe is failing:
//Get the "Click Finish to start..." label and update the text once the application is starting.
Screen otherScreen = context.getScreenById("1202");
FormEnvironment otherFormEnvironment = ((FormPanelContainer)otherScreen).getFormEnvironment();
FormComponent finishLabel = otherFormEnvironment.getFormComponentById("1207");
((JLabel)finishLabel.getConfigurationObject()).setText(context.getMessage("Please.Be.Patient.While.Application.Name.Is.Starting"));
//Start spinning the progress bar
context.getProgressInterface().setIndeterminateProgress(true);
//Get a handle on the port the user chose
final Long port = (Long)context.getVariable("user.specified.port");
//It's necessary to run this task elevated, otherwise install4j can have permissions issues and throw exceptions.
//See: http://blog.ej-technologies.com/2012/06/migrating-to-install4j-51.html
Boolean result = (Boolean)context.runElevated(new RemoteCallable()
{
public Serializable execute()
{
int numRetries = 50;
int retries = 0;
java.net.URL url = null;
try
{
url = new java.net.URL("http", "localhost", port.intValue(), "");
}
catch (java.net.MalformedURLException mue)
{
//If something goes wrong, return false.
return false;
}
while(retries < numRetries)
{
try
{
Thread.sleep(5000);
}
catch(InterruptedException ie)
{
return false;
}
try
{
java.net.HttpURLConnection connection = (java.net.HttpURLConnection)url.openConnection();
int responseCode = connection.getResponseCode();
if (responseCode == java.net.HttpURLConnection.HTTP_OK)
{
return true;
}
else
{
retries++;
}
}
catch (Throwable t)
{
t.printStackTrace();
retries++;
}
}
//We did not successfully find an application running on the port.
return false;
}
}, true);
context.getProgressInterface().setIndeterminateProgress(false);
return result;
Providing an update as the root cause was found to be unrelated to the install4j tool.
The jar I was using for packaging the installable was invalid. We had recently updated the maven plugin versions. The newer version changed the way our jar was packaged, which did not allow the service to start post the installation.
I am still receiving the same error as listed in the initial post, not sure of the source (I am ignoring that one for now).
Related
We are installing our product via script for automated UI tests.
Sometimes the installation failes with the following error.
java.lang.InternalError: Unexpected CryptoAPI failure generating seed
at java.base/sun.security.provider.NativeSeedGenerator.getSeedBytes(Unknown Source)
at java.base/sun.security.provider.SeedGenerator.generateSeed(Unknown Source)
at java.base/sun.security.provider.AbstractDrbg.lambda$static$0(Unknown Source)
at java.base/sun.security.provider.AbstractDrbg.getEntropyInput(Unknown Source)
at java.base/sun.security.provider.AbstractDrbg.getEntropyInput(Unknown Source)
at java.base/sun.security.provider.AbstractDrbg.instantiateIfNecessary(Unknown Source)
at java.base/sun.security.provider.AbstractDrbg.engineNextBytes(Unknown Source)
at java.base/sun.security.provider.AbstractDrbg.engineNextBytes(Unknown Source)
at java.base/sun.security.provider.AbstractDrbg$SeederHolder.lambda$static$0(Unknown Source)
at java.base/sun.security.provider.AbstractDrbg.getEntropyInput(Unknown Source)
at java.base/sun.security.provider.AbstractDrbg.getEntropyInput(Unknown Source)
at java.base/sun.security.provider.AbstractDrbg.instantiateIfNecessary(Unknown Source)
at java.base/sun.security.provider.AbstractDrbg.engineNextBytes(Unknown Source)
at java.base/sun.security.provider.AbstractDrbg.engineNextBytes(Unknown Source)
at java.base/sun.security.provider.DRBG.engineNextBytes(Unknown Source)
at java.base/java.security.SecureRandom.nextBytes(Unknown Source)
at java.base/java.security.SecureRandom.next(Unknown Source)
at java.base/java.util.Random.nextLong(Unknown Source)
at java.base/java.io.File$TempDirectory.generateFile(Unknown Source)
at java.base/java.io.File.createTempFile(Unknown Source)
at java.base/java.io.File.createTempFile(Unknown Source)
at com.exe4j.runtime.util.WinDel.scheduleDeletion(WinDel.java:85)
at com.exe4j.runtime.WinLauncher$3.run(WinLauncher.java:118)
Is there any known bug or fix for this?
I had this problem in Oracle Weblogic. Adding the following to the java options helped me
-Djava.security.egd=file:/dev/./urandom
We upgraded to latest JRE/install4j for our minor upgrade installer, and we started getting the following error when we try to use install4j API:
2017-02-17 19:29:42 SEVERE: #{14} [StandardContext.loadOnStartup] Servlet [ConfigServlet] in web application [] threw load() exception
java.lang.UnsatisfiedLinkError: com.install4j.runtime.installer.platform.win32.Common.setWindows95(Z)V
at com.install4j.runtime.installer.platform.win32.Common.setWindows95(Native Method)
at com.install4j.runtime.installer.platform.win32.Common.init(Unknown Source)
at com.install4j.runtime.installer.platform.win32.Misc.<clinit>(Unknown Source)
at com.install4j.api.windows.WinEnvVars.getenv(Unknown Source)
at com.install4j.runtime.installer.helper.InstallerUtil.is64BitWindows(Unknown Source)
at com.install4j.api.Util.is64BitWindows(Unknown Source)
...
We get the same error when we try to launch the uninstaller:
Exception:
java.lang.UnsatisfiedLinkError: com.install4j.runtime.installer.platform.win32.Common.setWindows95(Z)V
at com.install4j.runtime.installer.platform.win32.Common.setWindows95(Native Method)
at com.install4j.runtime.installer.platform.win32.Common.init(Unknown Source)
at com.install4j.runtime.installer.platform.win32.Win32UserInfo.<clinit>(Unknown Source)
at com.install4j.runtime.installer.platform.UserInfo.isAdminGroup(Unknown Source)
at com.install4j.api.Util.isAdminGroup(Unknown Source)
at com.install4j.runtime.installer.InstallerVariables.initAdminRights(Unknown Source)
at com.install4j.runtime.installer.InstallerVariables.initCommandLine(Unknown Source)
at com.install4j.runtime.installer.Uninstaller.getScreenExecutor(Unknown Source)
at com.install4j.runtime.installer.Uninstaller.runInProcess(Unknown Source)
at com.install4j.runtime.installer.Uninstaller.main(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.exe4j.runtime.LauncherEngine.launch(Unknown Source)
at com.exe4j.runtime.WinLauncher.main(Unknown Source)
at com.install4j.runtime.launcher.WinLauncher.main(Unknown Source)
What is causing this?
There is a mismatch between the API JAR file (i4jruntime.jar) and the native library (i4jinst.dll). It seems that you have an old version of i4jruntime.jar in your classpath.
I tried to load the package from the Guvnor using the following piece of code :-
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("GenderFact.xml"),ResourceType.CHANGE_SET);
System.out.println("fair trial");
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
and the contents of the GenderFact.xml are :-
<change-set xmlns="http://drools.org/drools-5.0/change-set"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-5.0/change-set http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd">
<add>
<resource
source="http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/MyLastTrial/LATEST/"
type="PKG" basicAuthentication="disabled" username="admin" password="admin" />
</add>
When I tried to execute this from Eclipse , I get the following error :-
java.lang.RuntimeException: java.io.InvalidClassException: org.drools.rule.MVELDialectRuntimeData; local class incompatible: stream classdesc serialVersionUID = 5166066541265170937, local class serialVersionUID = -64624826351992706
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:705)
at org.drools.compiler.PackageBuilder.addPackageFromChangeSet(PackageBuilder.java:772)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:694)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:45)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:34)
at com.sample.DroolsTest.readKnowledgeBase(DroolsTest.java:43)
at com.sample.DroolsTest.main(DroolsTest.java:26)
Caused by: java.io.InvalidClassException: org.drools.rule.MVELDialectRuntimeData; local class incompatible: stream classdesc serialVersionUID = 5166066541265170937, local class serialVersionUID = -64624826351992706
at java.io.ObjectStreamClass.initNonProxy(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at java.util.HashMap.readObject(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at org.drools.rule.DialectRuntimeRegistry.readExternal(DialectRuntimeRegistry.java:59)
at java.io.ObjectInputStream.readExternalData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at org.drools.rule.Package.readExternal(Package.java:208)
at java.io.ObjectInputStream.readExternalData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at org.drools.core.util.DroolsStreamUtils.streamIn(DroolsStreamUtils.java:205)
at org.drools.core.util.DroolsStreamUtils.streamIn(DroolsStreamUtils.java:189)
at org.drools.compiler.PackageBuilder.addPackageFromInputStream(PackageBuilder.java:781)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:692)
... 6 more
Preconditions :-
I use Guvnor 5.3 with jboss AS 7.0.
Both the client and the server are sharing the same jre7.
Drools runtime 5.3 in Eclipse Indigo (Service Release 2)
Requesting for a workaround ...
Drools related jars used in java project are NOT of same version as used in GUvnor 5.3.
Use jars from Guvnor 5.3 into your java project.
It will solve problem. :)
I have a TreeViewer where some nodes represent folders, so I wanted to show the icon of an open folder when the node is expanded and a closed folder when it is collapsed. Sounds easy, I just need to add a tree listener (the code is in Scala, but Java equivalent should be easy to imagine):
val tree = new TreeViewer(contents)
tree.addTreeListener(folderIconFixingListener)
private def folderIconFixingListener = new ITreeViewerListener {
def treeCollapsed(event: TreeExpansionEvent) {
tree.update(event.getElement, null)
}
def treeExpanded(event: TreeExpansionEvent) {
tree.update(event.getElement, null)
}
}
Unfortunately, this gives an exception:
Ignored reentrant call while viewer is busy. This is only logged once per viewer instance, but similar calls will still be ignored.
java.lang.RuntimeException
at org.eclipse.jface.viewers.ColumnViewer.checkBusy(ColumnViewer.java:763)
at org.eclipse.jface.viewers.ColumnViewer.update(ColumnViewer.java:552)
at scsadmin.NodesTreeScreen$$anon$1.treeExpanded(NodesTreeScreen.scala:64)
at org.eclipse.jface.viewers.AbstractTreeViewer$3.run(AbstractTreeViewer.java:1101)
at org.eclipse.jface.util.SafeRunnable$1.run(SafeRunnable.java:128)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
at org.eclipse.jface.viewers.AbstractTreeViewer.fireTreeExpanded(AbstractTreeViewer.java:1099)
at org.eclipse.jface.viewers.AbstractTreeViewer.handleTreeExpand(AbstractTreeViewer.java:1444)
at org.eclipse.jface.viewers.TreeViewer.handleTreeExpand(TreeViewer.java:937)
at org.eclipse.jface.viewers.AbstractTreeViewer$4.treeExpanded(AbstractTreeViewer.java:1453)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Tree.gtk_test_expand_row(Unknown Source)
at org.eclipse.swt.widgets.Widget.windowProc(Unknown Source)
at org.eclipse.swt.widgets.Display.windowProc(Unknown Source)
at org.eclipse.swt.internal.gtk.OS._gtk_main_do_event(Native Method)
at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(Unknown Source)
at org.eclipse.swt.widgets.Display.eventProc(Unknown Source)
at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
at org.eclipse.jface.window.Window.open(Window.java:801)
at scsadmin.BootStrapper$.main(BootStrapper.scala:64)
at scsadmin.BootStrapper.main(BootStrapper.scala)
How can I fix this?
You might try to put your code in your listener into a asyncExec, to postpone its execution a bit:
display.asyncExec(new Runnable(){
public void run(){
tree.update(.);
}
});
The solution I eventually went with was to use a TreeListener on the Tree control itself instead, which worked fine.
I would like to marshall Java objects into XML and vice-versa from within an Unsigned Applet and I can't change any of the security permission/policy files, or sign the application.
I seem to get a Security exception, because JAXB is attempting to access fields or constructors that it can't in the applet sandbox.
The browser is running JRE 1.6.0_17
I'm also open to solutions based on some other XML (or JSON) library but have tried the following and pretty much run into a similar problem;
- XStream
- Gson
Given (something like) the following object:
#XmlType
#XmlRootElement
public class SimpleObject {
public String sampleText;
public SimpleObject() {
}
public String getSampleText() {
return sampleText;
}
public void setSampleText(String sampleText) {
this.sampleText = sampleText;
}
}
And the following simple JAXB code:
public void actionPerformed(ActionEvent e) {
try {
JAXBContext jc = JAXBContext.newInstance(SimpleObject.class);
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
SimpleObject object = new SimpleObject();
object.setSampleText("Hello");
marshaller.marshal(object, System.out);
}
catch (JAXBException e1) {
throw new RuntimeException(e1);
}
}
I get the following exception:
Exception in thread "AWT-EventQueue-2" java.security.AccessControlException: access denied (java.lang.RuntimePermission accessDeclaredMembers)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkMemberAccess(Unknown Source)
at java.lang.Class.checkMemberAccess(Unknown Source)
at java.lang.Class.getDeclaredConstructor(Unknown Source)
at com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.hasDefaultConstructor(Unknown Source)
at com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.hasDefaultConstructor(Unknown Source)
at com.sun.xml.internal.bind.v2.model.impl.ClassInfoImpl.<init>(Unknown Source)
at com.sun.xml.internal.bind.v2.model.impl.RuntimeClassInfoImpl.<init>(Unknown Source)
at com.sun.xml.internal.bind.v2.model.impl.RuntimeModelBuilder.createClassInfo(Unknown Source)
at com.sun.xml.internal.bind.v2.model.impl.RuntimeModelBuilder.createClassInfo(Unknown Source)
at com.sun.xml.internal.bind.v2.model.impl.ModelBuilder.getClassInfo(Unknown Source)
at com.sun.xml.internal.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(Unknown Source)
at com.sun.xml.internal.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(Unknown Source)
at com.sun.xml.internal.bind.v2.model.impl.ModelBuilder.getClassInfo(Unknown Source)
at com.sun.xml.internal.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(Unknown Source)
at com.sun.xml.internal.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(Unknown Source)
at com.sun.xml.internal.bind.v2.model.impl.ModelBuilder.getTypeInfo(Unknown Source)
at com.sun.xml.internal.bind.v2.model.impl.ModelBuilder.getTypeInfo(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(Unknown Source)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
at javax.xml.bind.ContextFinder.find(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at nz.co.zeal.maker.application.actions.build.JAXBTestAction.actionPerformed(JAXBTestAction.java:24)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
I never did quite figure this one out. What I did instead was to grab a fairly simple JSON library called Flexjson. It also threw a similar security exception but the library was simple enough that I was able to switch-off the library code that causes the exception in an Applet with a boolean flag.
I also tried to find a solution with JAXB without any success.
I switched to Axis2 (1.5.4) with ADB binding, but it also tried accessing system properties which failed with security manager checks.
In the end, I got a workable solution together by using AspectJ and using an aspect that rewrites System.getProperty() calls to return null when they fail. Since all the properties Axis2 needed were non-critical anyway this worked. I also needed to apply an aspect over org.apache.axiom.util.stax.dialect.StAXDialectDetector.getRootUrlForResource() to always return null since it tried to make a ClassLoader.getSystemClassLoader() call which also failed under a security manager. Again this seemed like a non-critical call. Got AspectJ to rewrite the Axis2 classes at build-time and it ran as an unsigned applet.
It's a really messy solution, but at least it worked.
I couldn't get the same AspectJ hack working with JAXB because JAXB requires direct access to the private fields of classes which doesn't fly under a security manager if JAXB is bundled with the applet (which we need to do if AspectJ is used to rewrite classes).
This may solve your problem. I know it solved mine :)
public void actionPerformed(ActionEvent e) {
try {
JAXBContext jc = AccessController.doPrivileged(new PrivilegedExceptionAction<JAXBContext>() {
public JAXBContext run() throws JAXBException {
// needs to run here otherwise throws AccessControlException
return JAXBContext.newInstance(SimpleObject.class);
}
});
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
SimpleObject object = new SimpleObject();
object.setSampleText("Hello");
marshaller.marshal(object, System.out);
}
catch (JAXBException e1) {
throw new RuntimeException(e1);
}
} catch (PrivilegedActionException e2) {
throw new RuntimeException(e2);
}
}
Hope it helps