JBoss Server Version : 7.3
Java Version : 1.8
IDE : eclipse
Exception
Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/logging/Logger
at org.jboss.naming.remote.client.InitialContextFactory.<clinit>(InitialContextFactory.java:64)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at test.Client.main(Client.java:17)
Caused by: java.lang.ClassNotFoundException: org.jboss.logging.Logger
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 10 more
Below mentioned jars are added in build-path even after getting exception. java.lang.ClassNotFoundException: org.jboss.logging.Logger .
jbossall-client.jar
jboss-common-client.jar
jboss-logging-3.3.2.Final.jar
jboss-remote-naming-1.0.7.final.jar
Code
Main.java
public static void main(String[] args) {
try {
InputStream input;
input = new FileInputStream("/lookup.properties");
Properties prop = new Properties();
prop.load(input);
InitialContext initialContext = new InitialContext(getJBossClientProperties());
Object obj = initialContext.lookup(prop.getProperty("lookup"));
System.out.println("Got EJB : "+obj);
} catch (Exception e) {
System.out.println("Error : "+e);
}
}
private static Properties getJBossClientProperties() throws Exception {
InputStream input = new FileInputStream("/config.properties");
Properties prop = new Properties();
prop.load(input);
return prop;
}
lookup.properties
lookup=jndi_lookup
config.properties
java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory
java.naming.provider.url=remote://localhost:4447
jboss.naming.client.ejb.context=true
I tried above in glassfish works fine , i know its jboss...
I found another relevant post here
java.lang.ClassNotFoundException: org.jboss.logging.Logger
grep for;
When I added the jbossall-client.jar from tje jboss installtion path(../jboss-5.1.0.GA\client) and not from the lib folder, it worked.
that could be your answer.....
Related
Here is my code I am trying to run:
import scala.swing._
object MyApp extends SimpleSwingApplication{
def top = new MainFrame{
contents = new Label("GUI stuff")
}
}
I am running the code through command line. In my directory, I have the code above (app2.scala), a scala swing jar file (scala-swing_2.13-2.1.1.jar).
I am compiling the scala file like:
scalac -cp "scala-swing_2.13-2.1.1.jar" app2.scala
then trying to run it through
scala MyApp
But I get an error:
Exception in thread "main" java.lang.NoClassDefFoundError: scala/swing/MainFrame
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at scala.reflect.internal.util.ScalaClassLoader.run(ScalaClassLoader.scala:101)
at scala.reflect.internal.util.ScalaClassLoader.run$(ScalaClassLoader.scala:97)
at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:130)
at scala.tools.nsc.CommonRunner.run(ObjectRunner.scala:29)
at scala.tools.nsc.CommonRunner.run$(ObjectRunner.scala:28)
at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:43)
at scala.tools.nsc.CommonRunner.runAndCatch(ObjectRunner.scala:35)
at scala.tools.nsc.CommonRunner.runAndCatch$(ObjectRunner.scala:34)
at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:70)
at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:91)
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:103)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:108)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
Caused by: java.lang.ClassNotFoundException: scala.swing.MainFrame
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 18 more
How can I fix this?
I checked that my scala version is the same as the version for swing. I am running 2.13.2
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).
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