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.
Related
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.
I downloaded gflot for my gwt project. To get to know the library I created a test project called "FlotDemo". I'm using Eclipse and created a plain vanilla gwt project with the help of the project creation wizard (the stuff with the greeting servlet and so on)
This is what I did:
Downloaded gflot-3.1.1.jar and copied it into /war/WEB-INF/lib
Added in Project->Properties->Java Build Path->Libraries gflot-jar to the path
Added <inherits name="ca.nanometrics.gflot.GFlot"/> to my "FlotDemo.gwt.xml"
Went to gFlot example and copy an pasted it to my EntryPoint class
So after step 4, eclipse strangly cannot resolve the objects from gflot I used in the code. I tried to run the web app anyway in the gwt simulator but it quit with the error message:
2013-06-05 17:24:51.212 java[12069:707] [Java CocoaComponent compatibility mode]: Enabled
2013-06-05 17:24:51.213 java[12069:707] [Java CocoaComponent compatibility mode]: Setting timeout for SWT to 0.100000
Loading modules
flotdemo.FlotDemo
Loading inherited module 'flotdemo.FlotDemo'
Loading inherited module 'ca.nanometrics.gflot.GFlot'
[ERROR] Unable to find 'ca/nanometrics/gflot/GFlot.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
[ERROR] Line 11: Unexpected exception while processing element 'inherits'
com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries)
at com.google.gwt.dev.cfg.ModuleDefLoader.nestedLoad(ModuleDefLoader.java:308)
What am I doing wrong here?
<inherits name="ca.nanometrics.gflot.GFlot"/> is the old one.
Since 3.0, use <inherits name='com.googlecode.gflot.GFlot'/> instead.
See the example.
I am receiving an NoClassDefFoundError in Eclipse when I try to run my project.
My Project looks like this:
JavaProject: BulkAdmin
- src
- com.mycompany.bulkadmin.SDK.util
- Login.java
Dynamic Web Project: JSPTesting
- src
- com.mycompany.bulkadmin.jspController
- Controller.java
- WebContent
- index.html
- execute.jsp
This is the control flow:
index.html loads
index.html has a form that redirects to execute.jsp
execute.jsp takes the info returned in the form and makes a static call to Login.java
execute.jsp prints the results of the call
Controller.java uses Login.java. I was receiving compilation errors. To resolve them I did this:
Right click on JSPTesting -> properties
Choose java build path on the left bar
Choose projects tab
Click add
Choose BulkAdmin (Project)
I am not sure why but now when I am getting a NoClassDefFoundError. I have done some googling. I think that this means that I have messed up my classpath somehow but I am not sure how to resolve this.
java.lang.NoClassDefFoundError: com/myCompany/bulkadmin/SDK/util/Login
at com.myCompany.bulkadmin.jspController.Controller.process(Controller.java:44)
at org.apache.jsp.execute_jsp._jspService(execute_jsp.java:63)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:257)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:873)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)
Other information:
I am using tomcat (in Eclipse) as my server
The exception shows up in the browser and the eclipse console
execute.jsp is a JSP
It seems like there are many similar questions to this on SO. I have read about 15 of them and tried various things however I think that my question has a different solution. I can provide more information.
Rightclick your dynamic web project, go to Properties > Deployment Assembly and add the dependent projects there. This way they will end up as JAR in /WEB-INF/lib, exactly there where you want it to be.
In Eclipse versions older than 3.5 you need to go to Properties > Java EE Module Dependencies.
See also:
ClassNotFoundException when using User Libraries in Eclipse build path
Difference between Deployment Assembly and J2EE Module Dependencies in Eclipse
The NoClassDefFoundError indicates that a class that was available during compilation is no longer available at runtime. Your problem is that the com/myCompany/bulkadmin/cSDK/util/Login class is available in the compilation classpath (in Eclipse via the Project reference you added to the build path) but not in the runtime classpath (Tomcat, which has no idea how to find this class).
You need to add the BulkAdmin project to the web-app class path when deployed on Tomcat as well.
One way to do this would be to export the BulkAdmin project as a JAR and put it into the WEB-INF/lib directory of your JSPTesting project.
I am just starting with GWT. I use Eclipse and have installed the GWT plugin.
I have followed the directions here Maven GWT 2.0 and Eclipse to set up a GWT project using the gwt-maven-plugin. When I run the Maven goals gwt:compile gwt:run, GWT Development Mode is launched and I can copy the url from it to my browser and view the label.
However, the project has this problem:
Description: The web.xml file does not exist
Resource: WEB-INF
Path: /GWTExample/war
Location: Unknown
Type: Google Web App Problem
If I try to run the project as a Google Web Application, I get this warning:
[WARN] No startup URLs supplied and no plausible ones found -- use -startupUrl
I can get rid of the problem by copying the web.xml to the war directory, but I still get the URL issue when running as a Google Web App.
If I'm using Maven and GWT in Eclipse, should I just ignore the web.xml problem and always run applications in development mode via the Maven goals? Or is there a way to set things so I can run as a Google Web App?
EDIT: Related to the above, is it possible to debug a GWT app running in development mode started by gwt:compile gwt:run? I have added breakpoints to my application but it doesn't stop on them. I'm not sure if it is something I've configured wrong or if it's just not possible.
Update:
In response to Prem's answer...
When I run a compile gwt:run, the web.xml file isn't copied. When I run the install gwt:run, I get this error:
[INFO] --- gwt-maven-plugin:1.2:test (default) # SampleGWT ---
[INFO] using GWT jars from project dependencies : 2.0.4
[INFO] establishing classpath list (scope = test)
[ERROR] java.lang.NoClassDefFoundError: org/codehaus/mojo/gwt/test/MavenTestRunner
[ERROR] Caused by: java.lang.ClassNotFoundException: org.codehaus.mojo.gwt.test.MavenTestRunner
[ERROR] at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
[ERROR] at java.security.AccessController.doPrivileged(Native Method)
[ERROR] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
[ERROR] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
[ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
[ERROR] Could not find the main class: org.codehaus.mojo.gwt.test.MavenTestRunner. Program will exit.
[ERROR] Exception in thread "main"
I’m guessing that bug http://jira.codehaus.org/browse/MGWT-24 is included in version 1.2 of the gwt-maven-plugin. Normally I wouldn’t run install on a project that builds a war file, but I would expect to at least get past the test phase of the build cycle.
Does anybody have any idea why I would get this error on the install but not the compile goals? Also, should I be expecting either goal to copy the web.xml file from src/main/webapp/WEB-INF/web.xml to the /war directory?
Description: The web.xml file does not exist
gwt-maven-plugin creates a project with 'war' packaging format (it's a web app so no surpirse here). Web.xml for this project will be under 'src/main/webapp' folder which will be copied to the 'war' directory (which is set as the output directory) as part of the 'resources' phase in the maven build life-cycle. You should always use
mvn compile gwt:run
or
mvn install gwt:run
so that resources are copied, all java files are compiled and gwt:compile is also invoked (since it is bound to the 'compile' phase automatically)
[WARN] No startup URLs supplied and no plausible ones found -- use -startupUrl
As per the stackoverflow link you used as reference, only your maven build file is setup with startupUrl. In order for it to work in Eclipse, you must edit the Run Configuration of your project and add the '-statupUrl' command line arguments to the existing arguments in the "Arguments" panel.
However, this is just a warning and it should not stop you from running your GWT application from eclipse. If you are facing the same "web.xml" problem here as well, it could be because you did not compile your project in your IDE before invoking "Run as Web Application". I suggest you to disable "Build Automatically" option for this project and always build it manually and invoke "GWT Compile" and then try "Run as web application"
EDIT: Related to the above, is it possible to debug a GWT app running in development mode started by gwt:compile gwt:run?
In general you must use "Remote Application" debug configuration for remote debugging a process. However I am not sure if it will work for GWT projects.
I got me too this warning:
No startup URLs supplied and no plausible ones found
when I have followed this gwt tutorial
In that screenshot there is no checkbox with "Generate sample code" . In my IDE ( sdk 2.5) it is, so I have unchecked...
It wasn't created any of the server and client packages, I have created the client manually, as the tutorial required. The tutorial until that step doesn't say I must have a server package too. That and his configuration is missing from project.
If you right-click on your project and go to Properties -> Google -> Web Application, your WAR directory might be something like either war or src/main/webapp/WEB-INF/classes.
Change that to src/main/webapp.
Also un-check the box next to "Launch and delploy from this directory..."
That's what fixed this problem for me. It also fixed the "can't find gwt-servlet.jar" problem at the same time.
I have a RCP application which constitutes of a number of plugins. And now, I try to develop RAP application which uses my old plugins. My RAP has a dependency of one old plugin. I created my own target platform and I added RAP sdk and other many eclipse platform libraries. When I run my RAP application, I get this exception. Do you have any idea to solve that? Depended plugin uses "org.eclipse.ui" package.
org.osgi.framework.BundleException: The bundle could not be resolved. Reason: Missing Constraint: Require-Bundle: org.unicase.link; bundle-version="1.0.0"
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1313)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1297)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:319)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:370)
at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1069)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:554)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:461)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:246)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:442)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:227)
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:337)
2009-12-02 01:13:23.625::WARN: ERROR: /rap
java.lang.IllegalArgumentException: An entry point named 'hello' does not exist.
at org.eclipse.rwt.internal.lifecycle.EntryPointManager.createUI(EntryPointManager.java:77)
at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:227)
at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:115)
at java.lang.Thread.run(Unknown Source)
at org.eclipse.rwt.internal.lifecycle.UIThread.run(UIThread.java:80)
It's failing because it can't load the org.unicase.link bundle. And the reason that it can't load that is probably a missing dependency in that bundle. So look in the manifest for that plugin and look at all of the dependent plugins and make sure they are all there. It should also have a list for the plugins that were not loaded for some reason in the log. One thing you can do is make all of the dependencies in the org.unicase.link bundle optional, which should get you further along.