I have plugin A which depends on Plugin B, I am trying to load a class defined in Plugin B from plugin A. And I am sure the class is in the exported packages. but I got ClassNotFoundException, did I miss any thing ?
page = (IPage) Class.forName(pageClass).newInstance();
error messages :
java.lang.ClassNotFoundException: amarsoft.dbmp.credit.web.dataobject.DOListPage
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at amarsoft.rcp.base.widgets.DefaultPageRegistry.findPage(DefaultPageRegistry.java:27)
at amarsoft.rcp.base.widgets.AbstractPageControler.showPage(AbstractPageControler.java:27)
at amarsoft.rcp.base.widgets.AbstractPageControler.showPage(AbstractPageControler.java:37)
at amarsoft.dbmp.function.ui.FunctionListPage$3.linkActivated(FunctionListPage.java:261)
at org.eclipse.ui.forms.widgets.AbstractHyperlink.handleActivate(AbstractHyperlink.java:233)
at org.eclipse.ui.forms.widgets.AbstractHyperlink.handleMouseUp(AbstractHyperlink.java:327)
at org.eclipse.ui.forms.widgets.AbstractHyperlink.access$2(AbstractHyperlink.java:311)
at org.eclipse.ui.forms.widgets.AbstractHyperlink$4.handleEvent(AbstractHyperlink.java:125)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at amarsoft.adt.rcp.ADTApplication.start(ADTApplication.java:29)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
If you Require-Bundle; pluginB from pluginA, then a Class.forName(*) should have worked. Although I'll point out that using PageClass class = new PageClass(); would also work. Why are you trying to use reflection when you can just depend on that class directly?
For the common pattern where you provide a framework behaviour that other plugins should extend by providing implementations, eclipse provides the notion of Extension Points/Extensions.
Plugin A would provide an extension point. Plugin B would list an extension for that extension point, and provide an implementation class. In this case, Plugin B requires Plugin A, not the other way around.
Then Plugin A uses org.eclipse.core.runtime.IExtensionRegistry.getConfigurationElementsFor(String) to read all of the extension contributed and org.eclipse.core.runtime.IConfigurationElement.createExecutableExtension(String) to instantiate the contributed implementations (the registry takes care of making sure the class can be instantiated).
Related
I'm writing a LabyMod addon to create a shop bot for minecraft clients.
I've well succeeded to do so, at least in my dev-environement in eclipse. Now I wanted to publish it, and to do this, LabyMod provides a possibility to use gradle for wrapping up all stuff that is relevant to the addon in the addon jar, that can then simply be dragged into the "addons"-Folder.
However, when I do this, the plugin didn't appear in the plugin overview, and I found out that there was an error when loading the plugin (Class def not found). I use okhttp3 to send some web requests to my verification server, so I just added it in eclipse as dependent jar, but they were not included when gradle built the jar. So I wasn't very surprised with that, and looked for a possibility to add my dependencies to the jar directly.
I found out in the commments of the predefined build.gradle to simply put all files in a predefined "libs"-folder which seemed to be fine. Here's the issue: Although the jars definitely are a part of the jar, the classdefnotfound-thing still happenes. Here's what I mean.
JD-GUI says of my jar:
So, the jars definitely are there, and jd-gui can find them in the code as well, since you can click on the imports and get taken to the place where okhttp3 defined the imported class.
Here's however the error that I get, when trying to load the addon:
catching
java.lang.NoClassDefFoundError: okhttp3/OkHttpClient$Builder
at borg.locutus.grieferbot.utils.NetworkUtilities.sendGet(NetworkUtilities.java:70)
at borg.locutus.grieferbot.utils.NetworkUtilities.getPermissionLevelOfPlayer(NetworkUtilities.java:51)
at borg.locutus.grieferbot.GrieferBOTAddon.initPermissionLevel(GrieferBOTAddon.java:50)
at borg.locutus.grieferbot.GrieferBOTAddon.onEnable(GrieferBOTAddon.java:43)
at net.labymod.addon.AddonLoader.enableAddon(AddonLoader.java:349)
at net.labymod.addon.AddonLoader.enableAddons(AddonLoader.java:309)
at net.labymod.main.LabyMod.init(LabyMod.java:256)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:560)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:211)
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:189)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118)
at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:737)
at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:310)
at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:495)
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:329)
at net.minecraft.client.main.Main.main(SourceFile:124)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
Caused by: java.lang.ClassNotFoundException: okhttp3.OkHttpClient$Builder
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 44 more
Caused by: java.lang.NullPointerException
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:182)
... 46 more
How can I make my jar find the missing dependencies?
You can't just put the dependency jars into the main jar. You need to shade the dependencies into them.
I am developing a plugin for Eclipse Kepler. Adding #RunWith(JMockit.class) to my test class causes the following error:
JMockit: Reinitializing under custom class loader org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader#b7ccec1[com.mypackage.myclass:2.3.9.201508161221(id=1)]
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:382)
at sun.instrument.InstrumentationImpl.loadClassAndCallAgentmain(InstrumentationImpl.java:407)
Caused by: java.lang.VerifyError
at sun.instrument.InstrumentationImpl.redefineClasses0(Native Method)
at sun.instrument.InstrumentationImpl.redefineClasses(InstrumentationImpl.java:170)
at mockit.internal.startup.Startup.redefineMethods(Startup.java:242)
at mockit.internal.startup.Startup.redefineMethods(Startup.java:236)
at mockit.internal.mockups.MockClassSetup.applyClassModifications(MockClassSetup.java:134)
at mockit.internal.mockups.MockClassSetup.redefineMethodsInClassHierarchy(MockClassSetup.java:91)
at mockit.internal.mockups.MockClassSetup.redefineMethods(MockClassSetup.java:76)
at mockit.MockUp.redefineMethods(MockUp.java:240)
at mockit.MockUp.redefineClassOrImplementInterface(MockUp.java:222)
at mockit.MockUp.<init>(MockUp.java:131)
at mockit.integration.junit4.internal.RunNotifierDecorator.<init>(RunNotifierDecorator.java:21)
at mockit.internal.startup.JMockitInitialization.loadInternalStartupMocksForJUnitIntegration(JMockitInitialization.java:42)
at mockit.internal.startup.JMockitInitialization.initialize(JMockitInitialization.java:27)
at mockit.internal.startup.Startup.applyStartupMocks(Startup.java:72)
at mockit.internal.startup.Startup.reapplyStartupMocks(Startup.java:124)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at mockit.internal.util.MethodReflection.invoke(MethodReflection.java:94)
at mockit.internal.util.MethodReflection.invoke(MethodReflection.java:159)
at mockit.internal.startup.Startup.reinitializeJMockitUnderCustomClassLoader(Startup.java:118)
at mockit.internal.startup.Startup.agentmain(Startup.java:101)
... 6 more
java.lang.IllegalStateException: com.sun.tools.attach.AgentInitializationException: Agent JAR loaded but agent failed to initialize
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:262)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:208)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:156)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:82)
at org.eclipse.tycho.surefire.osgibooter.OsgiSurefireBooter.run(OsgiSurefireBooter.java:91)
at org.eclipse.tycho.surefire.osgibooter.AbstractUITestApplication$1.run(AbstractUITestApplication.java:35)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4145)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3762)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:140)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:611)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
at org.eclipse.tycho.surefire.osgibooter.UITestApplication.runApplication(UITestApplication.java:31)
at org.eclipse.tycho.surefire.osgibooter.AbstractUITestApplication.run(AbstractUITestApplication.java:120)
at org.eclipse.tycho.surefire.osgibooter.UITestApplication.start(UITestApplication.java:37)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
Caused by: com.sun.tools.attach.AgentInitializationException: Agent JAR loaded but agent failed to initialize
... 39 more
Am I doing something wrong or it is a JMockIt bug? I am using version JMockIt 1.18, JUnit 4.12
I would expect that #RunWith(JMockit.class) should have taken care of this problem.
In any case, from JMockit tutorial here, there are some notes that you should check, in case these resolve your issue. In particular, these two seem to be most relevant:
(Note for Eclipse users: when specifying the order of jars in the >classpath, make sure to use the "Order and Export" tab of the "Java Build >Path" window. Also, make sure the Eclipse project uses the JRE from a JDK >installation instead of a "plain" JRE, since the latter lacks the >"attach" native library.)
In other situations (like running on JDK implementations other than >the Oracle JDKs), you may need to pass "-javaagent:path>/jmockit.jar" as a JVM initialization parameter. This can be done in >the "Run/Debug Configuration" for both Eclipse and IntelliJ IDEA, or with >build tools such as Ant and Maven.
Right click your project in Package Explorer
click Properties.
go to Java Build Path.
Libraries tab.
click on 'Add Library' button select JUnit click Next.
You should be able to handle it from there.
After that if you use coverage as : you will be able to see the coverage.
pass the following paramter through the VM args.
-javaagent:<path>/jmockit.jar
I get a java.lang.IncompatibleClassChangeError when i try to run my project on AIX machine.
The project generate XML files using JAXB API (2.0).
The development environment installed in Windows XP and use JDK1.5.0(the same JDK as AIX machine ones).
In the developement environment the project works good. but in the AIX machine it doesn't work (throws the exception).
Here is the stack trace when I try to run the project :
........................./build.xml:176: java.lang.IncompatibleClassChangeError
at com.sun.xml.bind.v2.model.impl.ElementPropertyInfoImpl$1.size(ElementPropertyInfoImpl.java:82)
at java.util.AbstractList$Itr.hasNext(AbstractList.java:431)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:260)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:104)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:85)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:214)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:99)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:85)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:320)
at com.sun.xml.bind.v2.model.impl.RegistryInfoImpl.<init>(RegistryInfoImpl.java:103)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.addRegistry(ModelBuilder.java:362)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:332)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:460)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:298)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:141)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1163)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:145)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:236)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:615)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:186)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:146)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:348)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:446)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:409)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:313)
at gen.utils.Util.unmarshalling(Unknown Source)
at gen.utils.Util.mvtConfig(Unknown Source)
at gen.utils.Util.mvtGenConfig(Unknown Source)
at gen.start.StartGen.mvtGeneration(Unknown Source)
at gen.start.StartGen.start(Unknown Source)
at gen.start.StartGen.main(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:615)
at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217)
at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152)
at org.apache.tools.ant.taskdefs.Java.run(Java.java:771)
at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:221)
at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135)
at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:615)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:390)
at org.apache.tools.ant.Target.performTasks(Target.java:411)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.Main.runBuild(Main.java:809)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Please help.
Thanks.
Check your classpath on AIX and make sure you are using compatible versions of jaxb-api and jaxb-impl libraries. I have encountered IncompatibleClassChangeError when only the minor version is different by one increment (e.g. 2.2.5 versus 2.2.6).
To check what version of each library you are using and what is required for compatibility, look in the manifest file located in the META-INF directory within each jar file. The jaxb-impl manifest declares (in addition to its own version) the specification-version, which is the version of jaxb-api jar that it requires. Since v2.2.2, the version numbers of compatible instances of jaxb-api and jaxb-impl no longer match: e.g. jaxb-impl v2.2.4 is compatible with jaxb-api v2.2.3
I only have experience using the Sun implementation of JAXB (com.sun.xml.bind), so this might not apply if you are using a different implementation.
Following situation:
At work we have an own plugin that extends some JDT features and builds some helper functions for our own framework. So far so good.
The plugin includes following class:
public class MoxLogFactory extends org.apache.commons.logging.LogFactory {
...
}
(I left out the concrete implementation because it's really comprehensive)
Now I added the WindowBuilder-Plugin to my eclipse installation. I can create new projects and classes with the wizards included. But the main feature - the editor himself - isn't working. It comes out, that the WindowBuilder tries to load the class "MoxLogFactory" from our plugin! I attached the stacktrace which comes up if I open the editor:
java.lang.ClassNotFoundException: org.dreamox.moxanos.log.MoxLogFactory
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.commons.logging.LogFactory.createFactory(LogFactory.java:1261)
at org.apache.commons.logging.LogFactory$2.run(LogFactory.java:1065)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:1062)
at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:497)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:704)
at org.apache.commons.digester.Digester.<init>(Digester.java:340)
at org.eclipse.wb.internal.core.model.description.helpers.ComponentDescriptionHelper.getDescription0(ComponentDescriptionHelper.java:375)
at org.eclipse.wb.internal.core.model.description.helpers.ComponentDescriptionHelper.getDescription0(ComponentDescriptionHelper.java:289)
at org.eclipse.wb.internal.core.model.description.helpers.ComponentDescriptionHelper.getDescription(ComponentDescriptionHelper.java:258)
at org.eclipse.wb.internal.core.model.JavaInfoUtils.createJavaInfo(JavaInfoUtils.java:386)
at org.eclipse.wb.internal.rcp.parser.ParseFactory.getRootContext(ParseFactory.java:184)
at org.eclipse.wb.internal.core.parser.JavaInfoParser.prepareParseContext(JavaInfoParser.java:1185)
at org.eclipse.wb.internal.core.parser.JavaInfoParser.parse(JavaInfoParser.java:244)
at org.eclipse.wb.internal.core.parser.JavaInfoParser.access$9(JavaInfoParser.java:240)
at org.eclipse.wb.internal.core.parser.JavaInfoParser$1.runObject(JavaInfoParser.java:153)
at org.eclipse.wb.internal.core.parser.JavaInfoParser$1.runObject(JavaInfoParser.java:1)
at org.eclipse.wb.internal.core.utils.execution.ExecutionUtils.runDesignTime(ExecutionUtils.java:153)
at org.eclipse.wb.internal.core.parser.JavaInfoParser.parse(JavaInfoParser.java:151)
at org.eclipse.wb.internal.core.editor.DesignPage.internal_refreshGEF(DesignPage.java:522)
at org.eclipse.wb.internal.core.editor.DesignPage.access$9(DesignPage.java:510)
at org.eclipse.wb.internal.core.editor.DesignPage$8$1.run(DesignPage.java:437)
at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:180)
at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:150)
at org.eclipse.swt.widgets.Display.syncExec(Display.java:4683)
at org.eclipse.wb.internal.core.editor.DesignPage$8.run(DesignPage.java:434)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372)
at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:507)
at org.eclipse.wb.internal.core.editor.DesignPage.internal_refreshGEF_withProgress(DesignPage.java:453)
at org.eclipse.wb.internal.core.editor.DesignPage.internal_refreshGEF(DesignPage.java:403)
at org.eclipse.wb.internal.core.editor.UndoManager.refreshDesignerEditor(UndoManager.java:381)
at org.eclipse.wb.internal.core.editor.UndoManager.activate(UndoManager.java:90)
at org.eclipse.wb.internal.core.editor.DesignPage.handleActiveState_True(DesignPage.java:251)
at org.eclipse.wb.internal.core.editor.DesignPage.handleActiveState(DesignPage.java:229)
at org.eclipse.wb.internal.core.editor.multi.DefaultMultiMode.showPage(DefaultMultiMode.java:125)
at org.eclipse.wb.internal.core.editor.multi.DefaultMultiMode$1.widgetSelected(DefaultMultiMode.java:63)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:240)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:774)
at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:2746)
at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1433)
at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:257)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:999)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:893)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:85)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:579)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:534)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:352)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
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 org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:624)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:579)
at org.eclipse.equinox.launcher.Main.run(Main.java:1433)
at org.eclipse.equinox.launcher.Main.main(Main.java:1409)
Our plugin doesn't export anything, so why is the WindowBuilder trying to load a class from it? Where do it gets the information to load this class? If I uninstall our plugin the WindowBuilder works fine, but I need both plugins to work efficiently.
I found, that in MoxLogFactory in one static method there is a line
System.setProperty("org.apache.commons.logging.LogFactory","org.dreamox.moxanos.log.MoxLogFactory");
I thought every plugin runs in a sandbox and so this isn't really a problem, but when I see the stacktrace, it seems, that this system property is "global in eclipse". The MoxLogFactory class is also used in our application server framework so this code is needed - the plugin uses the framework itself to work.
I don't know how to solve this problem and would appreciate any hint or idea.
Here are some options:
Remove that static initialization of the JVM level system property and replace it by a command line option only when needed
In your static initializer, test Eclipse execution context by asking the ClassLoader for org.eclipse.equinox.launcher.Main class for instance, and if so, do not set the logfactory property
System properties belong to the JVM, not to a class loader. By setting your logger as a System property, presumably so that it will be loaded automatically, you have told the entire system to use it. When the other plugin loads and attempts to initialize its logging (which appears to also use Apache Commons Logging), it reads the System property, attempts to load the class found therein, and promptly fails because it cannot see into your plugin.
I'm using Eclipse Helios and for every refactoring that spans multiple files it plainly fails! Nothing happens. On examining the logs here's the error that I see:
!ENTRY org.eclipse.ltk.ui.refactoring 4 10000 2011-03-13 14:15:31.842
!MESSAGE Internal Error
!STACK 0
java.lang.reflect.InvocationTargetException
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:421)
at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:330)
at org.eclipse.ltk.ui.refactoring.RefactoringWizard.internalPerformFinish(RefactoringWizard.java:573)
at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.performFinish(UserInputWizardPage.java:153)
at org.eclipse.jdt.internal.ui.refactoring.reorg.RenameTypeWizardInputPage.performFinish(RenameTypeWizardInputPage.java:144)
at org.eclipse.ltk.ui.refactoring.RefactoringWizard.performFinish(RefactoringWizard.java:646)
at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.okPressed(RefactoringWizardDialog2.java:454)
at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:472)
at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:234)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
at org.eclipse.jface.window.Window.open(Window.java:801)
at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation$1.run(RefactoringWizardOpenOperation.java:180)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:192)
at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:115)
at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:38)
at org.eclipse.jdt.internal.ui.refactoring.UserInterfaceStarter.activate(UserInterfaceStarter.java:62)
at org.eclipse.jdt.internal.ui.refactoring.reorg.RenameUserInterfaceStarter.activate(RenameUserInterfaceStarter.java:31)
at org.eclipse.jdt.ui.refactoring.RenameSupport.openDialog(RenameSupport.java:159)
at org.eclipse.jdt.ui.refactoring.RenameSupport.openDialog(RenameSupport.java:116)
at org.eclipse.jdt.internal.corext.refactoring.RefactoringExecutionStarter.startRenameRefactoring(RefactoringExecutionStarter.java:438)
at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run(RenameJavaElementAction.java:203)
at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run(RenameJavaElementAction.java:101)
at org.eclipse.jdt.ui.actions.RenameAction.run(RenameAction.java:108)
at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:274)
at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:250)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
Caused by: java.lang.NoClassDefFoundError: org/eclipse/jst/jsp/core/internal/java/search/JSPIndexManager
at org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport.searchRunnable(JSPSearchSupport.java:424)
at org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport.searchRunnable(JSPSearchSupport.java:349)
at org.eclipse.jst.jsp.ui.internal.java.refactoring.JSPRenameParticipant.createChangesFor(JSPRenameParticipant.java:215)
at org.eclipse.jst.jsp.ui.internal.java.refactoring.JSPRenameParticipant.createChange(JSPRenameParticipant.java:153)
at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.createChange(ProcessorBasedRefactoring.java:308)
at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:124)
at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:209)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975)
at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Root exception:
java.lang.NoClassDefFoundError: org/eclipse/jst/jsp/core/internal/java/search/JSPIndexManager
at org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport.searchRunnable(JSPSearchSupport.java:424)
at org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport.searchRunnable(JSPSearchSupport.java:349)
at org.eclipse.jst.jsp.ui.internal.java.refactoring.JSPRenameParticipant.createChangesFor(JSPRenameParticipant.java:215)
at org.eclipse.jst.jsp.ui.internal.java.refactoring.JSPRenameParticipant.createChange(JSPRenameParticipant.java:153)
at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.createChange(ProcessorBasedRefactoring.java:308)
at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:124)
at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:209)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975)
at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
This error doesn't make much sense for me to be able to navigate around and even 'try' fixing it. For refactorings that are 'local' to the file/methods it seems to work fine. I've tried figuring this one out but just aghast! I tend to use the refactor feature A LOT. I'm working with J2EE + Glassfish v3. I have JARs for freemarker, restlet and that for DBUtils on the build path.
Any ideas? Has anyone encountered (and fixed :) this problem??
Thanks in advance!
Looks like a plugin issue. The root exception is,
Caused by: java.lang.NoClassDefFoundError: org/eclipse/jst/jsp/core/internal/java/search/JSPIndexManager
Meaning some class that should exist can't be found. Have you recently installed/removed plugins? You might have to reinstall eclipse.
Since I only had 2 plugins it was easy to figure out the problem. It seems there is a dependency conflict between JBoss and Glassfish Plugins (says so on update). Removing the JBoss Plugin (Help > Eclipse MarketPlace > Installed - select a plugin, click 'uninstall' and select all the components in it and click Next/Finish).
That seemed to fix the refactoring without reinstalling. Thanks to user654801 for pointing it out as a plug-in issue. It'd have been difficult to nail it down otherwise!
I have the same problem. I solve it similarly to Nupul.
I disabled the J2EE standard tools sience i don't need them:
Eclipse Europa:
Help -> Sowtware Updates -> Manage Configuration
disable J2EE Standard Tools (JST) Project SDK