How can I add xText editor to Eclipse (e4) RCP Application? - eclipse-rcp

I've already made a xtext editor (2.5).
I try to use this editor in a part in my RCP application.
I use this code:
Injector injector = MyDslActivator.getInstance().getInjector(MyDslActivator.XTEXT_DSL_MYDSL);
EmbeddedEditorFactory factory = injector.getInstance(EmbeddedEditorFactory.class);
editor = factory.newEditor(resourceProvider).showErrorAndWarningAnnotations().withParent(container);
But I got an error
java.lang.LinkageError: loader constraint violation: loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) previously initiated loading for a different type with name "com/google/inject/Injector"
UPD1
The bundle "eclipse.m2e.maven.runtime" has the package "org.google.inject" with another version. The solution was exclude this bundle from the project.
But now I got new error.
Caused by: java.lang.NullPointerException
at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorActions.initialize(EmbeddedEditorActions.java:124)
at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorActions.<init>(EmbeddedEditorActions.java:119)
at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorActions$Factory.createActions(EmbeddedEditorActions.java:63)
at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder.initializeActions(EmbeddedEditorFactory.java:397)
at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder.withParent(EmbeddedEditorFactory.java:233)
It happend because the google injector doesn't inject IWorkbench into EmbeddedEditorActions.Factory.
I haven't idea how to fix it.
The e4 application has org.eclipse.e4.ui.workbench.IWorkbench, bot doesn't have org.eclipse.ui.IWorkbench.

You have to make sure that your RCP contains the bundle com.google.inject only once. Somehow it was loaded in two different versions and both were made available to your DSL plugin.

Related

SONARQUBE preferences page not getting displayed in eclipse

I have installed SONARQUBE from Eclipse marketplace and restarted the eclipse as well.
But I am getting the below error while selecting SonarQube from Preferences page.
An error occurred while automatically activating bundle org.sonar.ide.eclipse.ui (351). And when I tracked through the root exception is below. Please help.
Root exception:
java.lang.LinkageError: loader constraint violation: when resolving method "org.slf4j.impl.StaticLoggerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFactory;" the class loader (instance of org/eclipse/osgi/internal/loader/EquinoxClassLoader) of the current class, org/slf4j/LoggerFactory, and the class loader (instance of org/eclipse/osgi/internal/loader/EquinoxClassLoader) for the method's defining class, org/slf4j/impl/StaticLoggerBinder, have different Class objects for the type org/slf4j/ILoggerFactory used in the signature
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:299)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)
After I installed, " m2e - slf4j over logback logging (Optional)" from the Luna update site, the preferences page worked.

NoClassDefFoundError: in Google App Engine app while creating Gson instance

Is there something tricky about using Gson in Google App Engine App? I placed gson jar in war/lib and included it in the build path. I'm using Eclipse.
Code compiles however app keeps failing at line:
Gson gson = new Gson();
with:
java.lang.NoClassDefFoundError: com/google/gson/Gson
A NoClassDefFoundError specifies that you have a particular class available at compile time but missing or not initialized during runtime. In your case com/google/gson/Gson class is found at compile time as gson jar is in your lib. But during runtime it is either not present or not initialized. Check for a conflict of gson jar or if there is an ExceptionInInitializerError in the stacktrace. You may further understand it here - Debugging a NoClassDefFoundError
I know GAE by name only, but I have that kind of error in Eclipse when I have a dynamic web project and I forget to deploy libs I used to build.
So, maybe you can solve by going into Deployment Assembly section of your project and add libs that you have in your build path.
The problem was that I placed library under war/libs and not under war/WEB-INF/lib

JBoss7 + seam2.3 = java.lang.LinkageError: loader constraint violation: when resolving overridden method

We are trying to migrate seam2.2 + jboss4.2.3 to jboss7.1.1 + seam2.3 and we are currently facing:
Caused by: java.lang.LinkageError: loader constraint violation:
when resolving overridden method
"org.jboss.seam.faces.DateConverter.getAsString
(Ljavax/faces/context/FacesContext;
Ljavax/faces/component/UIComponent;Ljava/lang/Object;)Ljava/lang/String;"
the class loader (instance of org/jboss/modules/ModuleClassLoader)
of the current class, org/jboss/seam/faces/DateConverter,
and its superclass loader (instance of org/jboss/modules/ModuleClassLoader),
have different Class objects for the type ext/FacesContext;
Ljavax/faces/component/UIComponent;
Ljava/lang/Object;)
Ljava/lang/String;
used in the signature
Base on the articles I've found on google it seems like we are loading 2x the jboss-seam jar. 1 from the app and 1 from JBoss, but I'm not 100% sure though.
Any idea what's causing the problem?
Thanks,
czetsuya
Some jars are needed to build your application, but shouldn't be deployed with it.
Check the deployed-jars.list in your Seam app and make sure you're not deploying jars already loaded by jboss.
It won't be a Seam jars, those are not included with the jboss loader unless you add them. It will probably be a JSF jar.

Unable to create editor ID org.eclipse.jst.pagedesigner.PageDesignerEditor: An unexpected exception was thrown

when i added JSF support to my project, following this tutorial
http://www.mkyong.com/jsf2/how-to-make-eclipse-ide-supports-jsf-2-0/
after restarting the eclipse, i am getting the error:
Unable to create editor ID org.eclipse.jst.pagedesigner.PageDesignerEditor: An unexpected exception was thrown.
any ideas why, and how to solve it ?
UPDATE:
when i tried to select java server faces again from the project facets, i found that it says on the right:
Conflicts with the following facets:
Application Client module
Dynamic Web Module
EAR
EJB Module
JCA Module
Static Web Module
Utility Module
Web Fragment Module
i was having JSF and ICEFaces dependencies in my pom, and i was having their libraries too in the classpath, fixed the error by removing them, and adding JSF,icefaces capabilities to my project, everything works fine now.

Eclipse workbench application start up problem

I have created one workbench application plugin not eclipse rcp application. I have not created any plugin template for that workbench application.
Now When I run the workbench application Activator is not calling. I put System.out.println("Insided start()") inside the start method of the
Activator.java. But it is not calling the start method. How I make call the start method? But when I make the option,Autostart=true in the runconfiguration,plug-ins,
It is starting the activator. But the problem is When I call IWorkbenchWindow window = Workbench.getInstance().getActiveWorkbenchWindow();
It is giving the error message saying could not create the workbench window. This error message is giving only when I make this plugin as AutoStart=true. What couldbe the problem?
Following are the error message I get..When I use
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
java.lang.IllegalStateException: Workbench has not been created yet.
at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:92) at
myworkbenchplugin.Activator.custom(Activator.java:43) at
myworkbenchplugin.Activator.start(Activator.java:36) at
org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:783)
at java.security.AccessController.doPrivileged(Native Method) at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:774)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:755)
at
org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:370)
at
org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:374)
at
org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1067)
at
org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:561)
at
org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:546)
at
org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:459)
at
org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
at
org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:440)
at
org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:227)
at
org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:337)
As you already saw, you need to manage your OSGi bundle manifest to specify the right activation policy. Note though that:
The Eclipse-AutoStart and Eclipse-LazyStart headers have been deprecated in Eclipse 3.4.
As of the OSGi R4.1 specification the lazy activation policy has been adopted by the OSGi specification. The new OSGi bundle manifest header Bundle-ActivationPolicy can be used to specify a lazy activation policy.
The Equinox Framework version 3.4 or later will continue to support the deprecated Eclipse-LazyStart and Eclipse-AutoStart headers.
Bundle developers that want their bundles to work across other OSGi Framework implementations should add the Bundle-ActivationPolicy header to their manifest. In most cases you can simply add the following header:
Bundle-ActivationPolicy: lazy
See OSGi LazyStart design.
In your case, you can try Bundle-ActivationPolicy: lazy;exclude:="yourPluginId" if you want to be sure your plugin starts no matter what.
For getting the Active WorkbenchWindow, you can use PlatformUI.getWorkbench().getActiveWorkbenchWindow() as detailed in How to get the project name in eclipse?.
If you start your plugin when Eclipse starts, the Activator.start() will be called before the workbench is fully started. You need to push the code inside a UIJob/WorkbenchJob in the Activator, so that it will be called after the workbench windows are ready.