Eclipse rcp plugin added to the target can be resolved at compile time, but not run time - eclipse

I've added a plugin to the target platform of my RAP application. I can reference it without issue without any problems while working on the project, and the compile happens without errors. The plugin also shows up in the plugin dependiencies library of my build path. However, when I run the application, the osgi framework gives me the exceptionA
org.osgi.framework.BundleException: The bundle "ate_rap_1.0.0.qualifier [98]" could not
be resolved. Reason: Missing Constraint: Require-Bundle: com.richclientgui.rcptoolbox;
bundle-version="0.0.0"
How do I add a plugin so that I can use it with my application?

First of all, do not use plugin dependencies when you work with OSGi. OSGi doesn't know about your those dependencies in your IDE, it only cares for the dependencies that a bundle defines in its bundle manifest. Therefore, you have to define a dependency in the MANIFEST.MF (Dependencies tab) instead.
Second, you have to add this bundle to your launch configuration. In Eclipse, go Run... -> Run Configurations... Select your launch config, go to the Bundles tab and check your additional plug-in. Before you launch, click on "Validate Bundles" in the Bundles tab.

Is your application built from a PDE feature? If so you may need to add the new plugin to the list of plugins included in your main feature.

To add a plugin to a basic RAP application, select File->New->Other and in the wizard, select Plug-in Development->Plug-in from Existing Jar Archives. This will create a project hosting that plugin which may be added to the build path. After adding to the build path, add this plugin as a dependencies in your MANIFEST.MF. Finally, in the run configuration for the application, select the Bundles tab and make sure the bundle you want to add is checked. This is easily done with the "Add Required Bundles" button. Now the project should run in Eclipse with the bundle.

Related

netbeans 8.01 doesn't recognize gradle for webapp

I create one web app by choosing: new project --> Java Web -> Web Application--> ....--> Spring Web MVC. Then I also want to use gradle, so I added file of build.gradle in the root of the project. Then I can see the file in "Files" tab, but can't see it in "Projects" tab. I want to see it in "Projects" tab so that I can run build command for gradle. (I added some dependency to it, but netbeans doesn't know it. I could use command line gradle to download the dependency jar, but netbeans still can't use the jar).
I know this is an old question, but the answer may still be useful to some people.
There is a plugin available for NetBeans to allow Gradle support: http://plugins.netbeans.org/plugin/44510/gradle-support
I can't see a way to show the build.gradle file in the Projects tab of your existing web project, but the Gradle plugin allows you to create Gradle projects, edit the build.gradle file in the Projects window and even launch Gradle tasks from the right-click context menu on the project node.
Gradle projects may not have some of the conveniences of NetBeans web projects, such as the Deploy option in the project node's context menu, but you can always write your own Gradle deploy task.

Runtime error of NoClassDefFoundError when a eclipse plugin depends on other eclipse plugin

I have an eclipse plugin project com.prosseek.asttest, and I spin off a new plugin project com.prosseek.impactAnalyzer that has one class CallHierarchyGenerator.java. Now asttest project depends on impactAnalyzer project. I had no choice but to make impactAnalyzer project eclipse plugin as it uses JDT library.
After setting up the build path in com.prosseek.asttest, it builds without a problem.
However, when I execute the plugin, I got an error missing CallHierarchyGenerator.java class.
What might be wrong?
If you are running this as an OSGI or Eclipse Application, you need to explicity export packages as available to other plugins as by default they are not. Open your manifest editor in plugin 1. Click on the runtime tab and add the packages as "Exported" then the class loader in blugin 2 will be able to find it.
Also looks like you might be doing the class path configuration wrong. in plugin 2 make sure you add plugin 1 as a dependency in the dependencies tab of the manifest editor. Looks like you are doing a dependency configuration as if it were a regular java application
Based on Duncan's answer, I could fix this issue.
Export packages in impactAnalyzer
Actually I didn't add it manually, but it's already exported, as (I guess) I did it with Quick Assist automatically.
Required Plug-ins
I had to Add com.prosseek.impactAnalyzer in the dependecies.
Run configuration update
I had one more step to do, I had to open run configuration to add required plug-ins.
Export the plugin
When exporting the asttest plugin, I also had to export impactAnalyzer also.

Eclipse 3.7 Required Plug-ins

I am currently running Eclipse 3.7 Indigo
My current project is a Plug-in Project
I wanted to try out the product called icePDF in my existing project.
So I downloaded the two required jar files from the binary download.
icepdf-core.jar and icepdf-viewer.jar
So I created a new plug-in project from existing jars. I am added the two jar files and created the plug-in project. I then exported the project and produced a project jar file .
Went back in to my existing project where I want to use the features of icePDF.
Went to dependencies -> Required Plug-ins -> Added my new icePDF plugin.
I am sure that I am missing a key step. Because as soon as I close the icePDF project in Package Explorer. I get a error in my main project.
Error : Missing Required Plug-in
What I don't understand is I have at least 12 other required plug-ins, none of them are open.
Was this the right way to try and add the icePDF jars to my existing project? Was there a way to just incorporate the jars in to the plug-in project without having to create the new project?
EDIT
Looks like icePDF primarily uses Swing. My project is SWT based, I do not want to use Swing in the project. I am looking for something that will view a existing pdf, convert a pdf and print a pdf to local printer.
Any suggestions??
It is normal behavior that Eclipse reports an error when a required plugin is closed, if this plugin is only available through your workspace. I assume that the other required plugins are 'standard' Eclipse plugins, such as EMF; those do not have to be in your workspace, as they are directly installed into your Eclipse platform.
Another way would be to put the original Jars into your plugin project. Just create a folder, e.g. lib/, paste the Jars there, and add them to the plugin project's class path. The latter is a bit tricky, as you have to add them in the Project Properties as well as in the Manifest.ml (in the 'runtime' tab of the plugin.xml-editor, IIRC) and the build.properties file.
Please read about the Eclipse target platform, as you seem not to be aware of that concept.
Generally speaking, there is an Eclipse environment in which you develop your code (which you use), and there is another Eclipse environment, in which your developed plugin runs (i.e. which a user of your plugin uses). That second one is called "target platform" in Eclipse terms. And they can be different, e.g. you develop in Eclipse 4.2, but your plugins shall run in Eclipse 3.7.
If you don't create a target platform yourself, then Eclipse just assumes its current installation to be the target platform (i.e. your development environment). That is why all "normal" plugins can be used as dependencies without them being in the workspace. But your icePdf plugin is not part of the Eclipse installation (and therefore not part of the target platform), which is why it needs to be available in the workspace.
If you define a target platform, you can then simply add those icepdf plugins to it and don't need to have them in the workspace any longer.

Grails Project - Common Java Project Dependency in Eclipse

All,
We have standard java projects that contain our common data model, common util classes, etc...
What I can’t seem to figure out is how, to make my Grails project (in Eclipse) have a dependency on the other standard (non Grails) java project in the workspace. When I add the project in the “Java Build Path” the project doesn’t show any compiler errors, but it when I run “Grails Tools -> Refresh Dependencies” or attempt to run the project (run-app) it fails.
This seems like it would be a pretty common thing, but I have searched all over the web and have been unable to find a solution. We are not using maven in our environment. Since we build Eclipse RCP applications on the client side, we use OSGI manifests to manage our project / bundle dependencies.
You can use linked source directories to include the Java or Groovy dependencies in the grails project and you need to set the output directory to Project/target/classes (these configurations go into the grails project preferences in Java Build Path options -> Source Tab).
The change in the output directory allows Eclipse to detect changes in the dependencies and auto load it when running the app using grails run-app.
You can use autocomplete and debug the sources of the dependencies with this configuration.
I prepared a step and step process that includes screenshots for Java and Groovy here
The documentation includes information on customizing the build.
You can add this to your BuildConfig.groovy:
grails.compiler.dependencies = {
fileset (dir:"/path/to/jars")
}
That should get you started.
If the dependencies are not stored in an Ivy/Maven repository then AFAIK your only option is to copy the dependencies to the lib directory of the Grails project.

How can I add the external jar to the eclipse rcp application?

I tried to add the apache vfs jar file as the runtime dependency. Even though it throws the below error:
java.lang.ClassNotFoundException: org.apache.commons.vfs.VFS
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:489)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:405)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:393)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at file_explorer.View.setInput(View.java:295)
at file_explorer.View.initialize(View.java:130)
How can i resolve this, thanks in advance.
If you are looking for adding the required jars to your project classpath.Add the required files to lib directory in the project structure.Then from project click the 'run time' tab of plugin.xml and add the required jars from the lib directory to the project classpath.
The best way to include external Jar in Eclipse RCP application is to package it as a plugin and then use classic plugin dependency.
Just create a new plugin containing only your Jar. Then in the build tab of the manifest editor, add your jar to the classpath (at the bottom right) and export all its packages in this same runtime tab. Also be sure to check that you jar is checked in the Build tab.
Nevertheless you should be able to use the jar in a Given plugin source code if you only add it to the classpath as I mentioned previously.
Because some other of your plugins may be interested in using the vfs jar and for separtion of concerns matter I think you should wrap it in its own plugin
The easiest way is to find bundle in an existing OSGI bundle repository.
http://bundles.osgi.org/Main/Repository
http://www.springsource.com/repository/app/
http://www.eclipse.org/orbit/
http://www.knopflerfish.org/repo/index.html
springsource repo contains apache VFS bundle
Then you need to add the bundle to the target platform (or just copy it to the dropins folder)
In order to properly install bundle into a newer version of eclipse you should use an existing p2 repository and install bundle from p2 repository into your runtime platform. There are two ways: you could use existing one (like orbit p2 repo), or you could create your own using p2 publisher as described at https://docs.sonatype.org/display/TYCHO/How+to+make+existing+OSGi+bundles+consumable+by+Tycho
Eclipse RCP is an OSGi environment which extends the Java dependency model, so you can't simply take a jar file and hope it works. To use an external jar, you have to build it to a plugin first, which p2-maven-plugin can help, you can follow the readme document.
With the plugin ready, you should install the plugin and add it to MANIFEST.MF. Then restart Eclipse to make the plugin work.
A more easily way, you needn't install the plugin, just follow(but build the jar):
go to plugin.xml -> Runtime tab;
click Add at the classpath section, then add the plugin to classpath;
make sure there is . path in the text area, otherwise New it.