简体   繁体   English

无法将Eclipse RCP应用程序导出为产品

[英]Unable to export Eclipse RCP application as a product

I have an application which I want to export as a product. 我有一个要导出为产品的应用程序。 For that purpose I have create a product for my RCP application. 为此,我为我的RCP应用程序创建了一个产品。 While creating the product definition, I have chose the Application as EditorApp.application. 创建产品定义时,我选择了Application作为EditorApp.application。 Added EditorApp(My application) as dependency and added also the required plug ins. 添加了EditorApp(我的应用程序)作为依赖项,还添加了所需的插件。 Also under the configuration tab, I have added the recommended start levels for the plugins. 同样在配置选项卡下,我为插件添加了建议的启动级别。

The product is exporting. 该产品正在出口。 But while I am trying to run the product, it gives the following error: 但是,当我尝试运行产品时,它出现以下错误:

    !SESSION 2016-01-26 15:56:56.353 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_45
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Command-line arguments:  -os win32 -ws win32 -arch x86

!ENTRY org.eclipse.osgi 4 0 2016-01-26 15:56:57.897
!MESSAGE Application error
!STACK 1
org.eclipse.core.runtime.CoreException: Plug-in EditorApp was unable to load class com.app.application.Application.
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.throwException(RegistryStrategyOSGI.java:194)
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:176)
    at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:905)
    at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
    at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:191)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
    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:648)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
Caused by: java.lang.ClassNotFoundException: com.app.application.Application cannot be found by EditorApp_1.0.0.201601261556
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:432)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:345)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:337)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at org.eclipse.osgi.internal.framework.EquinoxBundle.loadClass(EquinoxBundle.java:568)
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:174)
    ... 15 more

Please note, 1. This application is running properly when I am running this from Eclipse. 请注意,1.当我从Eclipse运行此应用程序时,该应用程序正在正常运行。 2. I have Application.java file present in my project. 2.我的项目中存在Application.java文件。 But, I have kept it inside the package - com.app.application. 但是,我将其保存在com.app.application包中。 The code for Application.java looks like this: Application.java的代码如下所示:

package com.app.application;

import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;

import com.app.editor.ApplicationWorkbenchAdvisor;

/**
 * This class controls all aspects of the application's execution.
 */
public class Application implements IApplication {

    /*
     * (non-Javadoc)
     * 
     * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.
     * IApplicationContext)
     */
    public Object start(IApplicationContext context) throws Exception {
        Display display = PlatformUI.createDisplay();
        try {
            int returnCode = PlatformUI.createAndRunWorkbench(display,
                    new ApplicationWorkbenchAdvisor());
            if (returnCode == PlatformUI.RETURN_RESTART) {
                return IApplication.EXIT_RESTART;
            } else {
                return IApplication.EXIT_OK;
            }
        } finally {
            display.dispose();
        }

    }

Please suggest. 请提出建议。

Thanks! 谢谢!

Update: 更新:

MANIFEST.MF 清单文件

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: EditorApp
Bundle-SymbolicName: EditorApp;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: APP
Bundle-ClassPath: .,
 library/log4j-1.2.17.jar,
 library/mariadb-java-client-1.2.3.jar
Require-Bundle: org.eclipse.ui,
 org.eclipse.core.runtime,
 com.ibm.icu,
 org.eclipse.jface.databinding,
 org.eclipse.core.databinding.property,
 org.eclipse.core.databinding.observable,
 org.eclipse.core.databinding.beans,
 org.eclipse.core.databinding,
 org.eclipse.core.resources;bundle-version="3.9.1"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Export-Package: com.app.editor;
  uses:="org.osgi.framework,
   org.eclipse.ui,
   org.eclipse.jface.action,
   org.eclipse.equinox.app,
   org.eclipse.jface.resource,
   org.eclipse.ui.application,
   org.eclipse.ui.plugin",
 com.app.editor.actions;uses:="org.eclipse.jface.action",
 com.app.editor.beans,
 com.app.editor.functionalities;
  uses:="org.eclipse.swt.graphics,
   org.eclipse.swt.widgets,
   org.eclipse.jface.dialogs,
   javax.swing.tree",
 com.app.editor.handlers;uses:="org.eclipse.core.commands",
 com.app.editor.perspectives;uses:="org.eclipse.ui",
 com.app.editor.views;
  uses:="com.app.editor.beans,
   org.eclipse.swt.widgets,
   org.eclipse.swt.custom,
   com.app.editor.functionalities,
   org.eclipse.core.databinding,
   org.eclipse.jface.viewers,
   org.eclipse.ui.part"

Plugin.xml Plugin.xml

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>

   <extension
         id="application"
         point="org.eclipse.core.runtime.applications">
      <application>
         <run
               class="com.app.application.Application">
         </run>
      </application>
   </extension>
   <extension
         point="org.eclipse.ui.perspectives">
      <perspective
            name="RCP Perspective"
            class="com.app.editor.perspectives.Perspective"
            id="com.app.Editor.perspective">
      </perspective>
      <perspective
            class="com.app.editor.perspectives.NewFilePerspective"
            id="com.app.Editor.newFileperspective"
            name="New File Prespective">
      </perspective>
      <perspective
            class="com.app.editor.perspectives.OpenFilePerspective"
            id="com.app.Editor.openFileperspective"
            name="Open File Perspective">
      </perspective>
      <perspective
            class="com.app.editor.perspectives.CloseViewPerspective"
            id="com.app.Editor.closeViewperspective"
            name="Close View Prespective">
      </perspective>
   </extension>
   <extension
         point="org.eclipse.ui.commands">
      <command
            defaultHandler="com.app.editor.handlers.NewFileHandler"
            id="com.app.Editor.New"
            name="New">
      </command>
      <command
            defaultHandler="com.app.editor.handlers.OpenHandler"
            id="com.app.Editor.Open"
            name="Connect To Database">
      </command>
      <command
            defaultHandler="com.app.editor.handlers.ExitHandler"
            id="com.app.Editor.commands.Exit"
            name="Exit">
      </command>
      <command
            defaultHandler="com.app.editor.handlers.CloseHandler"
            id="com.app.Editor.close"
            name="Close">
      </command>
      <command
            defaultHandler="com.app.editor.handlers.AboutHandler"
            description="About"
            id="com.app.Editor.about"
            name="About">
      </command>
      <command
            defaultHandler="com.app.editor.handlers.SaveHandler"
            id="com.app.Editor.Save"
            name="Save">
      </command>
      <command
            defaultHandler="com.app.editor.handlers.SaveAsHandler"
            id="com.app.Editor.SaveAs"
            name="Save As..">
      </command>
      <command
            defaultHandler="com.app.editor.handlers.RestartHandler"
            id="com.app.Editor.Restart"
            name="Restart">
      </command>
   </extension>
   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            allPopups="false"
            locationURI="menu:org.eclipse.ui.main.menu">
         <menu
               id="fileMenu"
               label="File">
            <command
                  commandId="com.app.Editor.New"
                  label="New"
                  style="push">
            </command>
            <command
                  commandId="com.app.Editor.Open"
                  label="Connect To Database"
                  style="push">
            </command>
            <command
                  commandId="com.app.Editor.Save"
                  label="Save"
                  style="push">
            </command>
            <command
                  commandId="com.app.Editor.close"
                  label="Close"
                  style="push">
            </command>
            <command
                  commandId="com.app.Editor.Restart"
                  label="Restart"
                  style="push">
            </command>
            <command
                  commandId="com.app.Editor.commands.Exit"
                  label="Exit"
                  style="push">
            </command>
         </menu>
         <menu
               id="helpMenu"
               label="Help">
            <command
                  commandId="com.app.Editor.about"
                  label="About"
                  style="push">
            </command>
         </menu>
      </menuContribution>
   </extension>
   <extension
         point="org.eclipse.ui.views">
      <view
            class="com.app.editor.views.OpenView"
            id="com.app.Editor.openView"
            name="OpenView"
            restorable="true">
      </view>
      <view
            class="com.app.editor.views.CloseView"
            id="com.app.Editor.closeView"
            name="CloseView"
            restorable="true">
      </view>
      <view
            allowMultiple="false"
            class="com.app.editor.views.NewView"
            id="com.app.Editor.newView"
            name="NewView"
            restorable="true">
      </view>
      <view
            class="com.app.editor.views.TreeView"
            id="com.app.Editor.treeView"
            name="TreeView"
            restorable="true">
      </view>
   </extension>
   <extension
         point="org.eclipse.ui.bindings">
   </extension>
   <extension
         id="product"
         point="org.eclipse.core.runtime.products">
      <product
            application="EditorApp.application"
            name="Tree Editor">
         <property
               name="appName"
               value="Tree Editor">
         </property>
      </product>
   </extension>
   <extension
         id="product1"
         point="org.eclipse.core.runtime.products">
      <product
            application="EditorApp.application"
            name="Tree Editor">
         <property
               name="appName"
               value="Tree Editor">
         </property>
      </product>
   </extension>
   <extension
         id="product2"
         point="org.eclipse.core.runtime.products">
      <product
            application="EditorApp.application"
            name="Tree Editor">
         <property
               name="appName"
               value="Tree Editor">
         </property>
      </product>
   </extension>
   <extension
         id="product3"
         point="org.eclipse.core.runtime.products">
      <product
            application="EditorApp.application"
            name="Tree Editor">
         <property
               name="appName"
               value="Tree Editor">
         </property>
      </product>
   </extension>
   <extension
         id="product4"
         point="org.eclipse.core.runtime.products">
      <product
            application="EditorApp.application"
            name="Tree Editor">
      </product>
   </extension>
</plugin>

build.properties build.properties

     output.. = bin/
bin.includes = plugin.xml,\
               .,\
               META-INF/,\
               library/log4j-1.2.17.jar,\
               library/mariadb-java-client-1.2.3.jar

Update: Changed the code above and I have now removed the jar file from classpath. 更新:更改了上面的代码,现在我从类路径中删除了jar文件。 Now, the application is running, but while accessing the jar (fr example database connection) it breaks. 现在,该应用程序正在运行,但是在访问jar(例如数据库连接示例)时会中断。

Your build.properties file is not including the class files in the built plugin. 您的build.properties文件不包括内置插件中的类文件。 You must include . 您必须包含. in the bin.includes list: bin.includes列表中:

output.. = bin/
bin.includes = plugin.xml,\
               .,\
               META-INF/,\
               library/

If you are using additional jars you should add them to the plugin (using Jars external to the RCP is very tricky). 如果您正在使用其他jar,则应将其添加到插件中(使用RCP外部的jar非常棘手)。

So for example: 因此,例如:

output.. = bin/
bin.includes = META-INF/,\
               .,\
               plugin.properties,\
               plugin.xml,\
               lib/jogg-0.0.7.jar,\
               lib/jorbis-0.0.15.jar,\
               lib/vorbisspi1.0.2.jar

Here I have three jars in the 'lib' directory of my plugin. 在这里,我插件的'lib'目录中有三个jar。

The 'Build' tab of the plugin.xml/MANIFEST.MF editor lets you specify this. plugin.xml / MANIFEST.MF编辑器的“构建”选项卡使您可以指定此选项。

You must also include the jars in the `Bundle-Classpath' header in the MANIFEST.MF. 您还必须在MANIFEST.MF的`Bundle-Classpath'标头中包含jar。 So for my example: 因此,对于我的示例:

Bundle-ClassPath: .,
 lib/jogg-0.0.7.jar,
 lib/jorbis-0.0.15.jar,
 lib/vorbisspi1.0.2.jar

Note: The . 注意: . entry must also be specified to include the main plugin code. 还必须指定条目以包含主插件代码。

You can specify this using the 'Classpath' section of the 'Runtime' tab of the plugin.xml/MANIFEST.MF editor. 您可以使用plugin.xml / MANIFEST.MF编辑器的“运行时”选项卡的“类路径”部分进行指定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM