e(fx)clipse equinox编译错误 [英] e(fx)clipse equinox compilation error

查看:164
本文介绍了e(fx)clipse equinox编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个基于OSGI(Equinox)的系统,我遇到了JavaFX,我正在尝试e(fx)clipse {OSGI bundle project},我写了一个简单的测试项目,但是它给了我一些编译错误。
我有一个主类:

I'm developing an OSGI (Equinox) Based-System and i came across JavaFX, i was trying the e(fx)clipse {OSGI bundle project} and i wrote a simple test project, but it is giving me some compilation errors. i have a main class :

import java.io.IOException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class main extends Application {
    private static main _main ;
    public main () {
        _main = this;
    }
    public static main Get_Main(){
        return _main;
    }
    @Override
    public void start(Stage primaryStage) 
    {
        try 
        {
            FXMLLoader loader = new FXMLLoader();
            loader.setLocation(main.class.getResource("fxml.fxml"));

            primaryStage.setScene(new Scene(loader.load()));
        } 
        catch (IOException e) 
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

我有一个控制器FXML

and i have a controller for the FXML

import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;

public class controller {
    @FXML
    private AnchorPane _AnchorPane;
    @FXML
    private Button _Btn;

    @FXML
    private void initialize() {
        _AnchorPane.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                _AnchorPane.setStyle("-fx-background-color:red");
            }
        });
    }

    @FXML
    private void _BtnClick() {
        _AnchorPane.setStyle("-fx-background-color:blue");
    }
}

和捆绑包的Activator

and an Activator for the bundle

import javafx.stage.Stage;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class aCTIVATOR implements BundleActivator {
    private Stage _stage = new Stage();
    private main _main;
    @Override
    public void start(BundleContext context) throws Exception {
        _main = main.Get_Main();
        _main.start(_stage);
    }

    @Override
    public void stop(BundleContext context) throws Exception {
        _stage.close();
    }
}

这是我的清单文件:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: 
Bundle-SymbolicName: root
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: javafx.animation;version="2.0.0",
 javafx.application;version="2.0.0",
 javafx.beans;version="2.0.0",
 javafx.beans.binding;version="2.0.0",
 javafx.beans.property;version="2.0.0",
 javafx.beans.value;version="2.0.0",
 javafx.collections;version="2.0.0",
 javafx.concurrent;version="2.0.0",
 javafx.event;version="2.0.0",
 javafx.fxml;version="2.0.0",
 javafx.geometry;version="2.0.0",
 javafx.scene;version="2.0.0",
 javafx.scene.chart;version="2.0.0",
 javafx.scene.control;version="2.0.0",
 javafx.scene.control.cell;version="2.0.0",
 javafx.scene.effect;version="2.0.0",
 javafx.scene.image;version="2.0.0",
 javafx.scene.input;version="2.0.0",
 javafx.scene.layout;version="2.0.0",
 javafx.scene.media;version="2.0.0",
 javafx.scene.paint;version="2.0.0",
 javafx.scene.shape;version="2.0.0",
 javafx.scene.text;version="2.0.0",
 javafx.scene.transform;version="2.0.0",
 javafx.scene.web;version="2.0.0",
 javafx.stage;version="2.0.0",
 javafx.util;version="2.0.0"
Bundle-Activator: aCTIVATOR
Require-Bundle: org.eclipse.osgi;bundle-version="3.10.0"

所以当我去运行配置,我选择OSGI-FrameWork并选择

so when i go to the Run-Configuration, i choose OSGI-FrameWork and select the


  1. 项目

  2. org.eclipse。 osgi

  3. org.eclipse.fx.javafx

  4. org.eclipse.fx.osgi

  1. project
  2. org.eclipse.osgi
  3. org.eclipse.fx.javafx
  4. org.eclipse.fx.osgi

最后它给出了我的编译错误:

and finally it si giving my this compilation error:

!SESSION 2014-10-21 13:32:14.128 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_20
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Command-line arguments:  -dev file:/home/hany/workspace/JavaFX/.metadata/.plugins/org.eclipse.pde.core/New_configuration/dev.properties -os linux -ws gtk -arch x86_64 -consoleLog -console

!ENTRY root 4 0 2014-10-21 13:32:14.618
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Error starting module.
    at org.eclipse.osgi.container.Module.doStart(Module.java:567)
    at org.eclipse.osgi.container.Module.start(Module.java:429)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1551)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1531)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1502)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1445)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
Caused by: java.lang.NoClassDefFoundError: javafx/stage/Stage
    at aCTIVATOR.<init>(aCTIVATOR.java:8)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at java.lang.Class.newInstance(Class.java:433)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.loadBundleActivator(BundleContextImpl.java:755)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:706)
    at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:928)
    at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:317)
    at org.eclipse.osgi.container.Module.doStart(Module.java:558)
    ... 8 more
Caused by: java.lang.ClassNotFoundException: javafx.stage.Stage cannot be found by osgi.identity; osgi.identity="root"; type="osgi.bundle"; version:Version="1.0.0.qualifier"
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:365)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:331)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:323)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 19 more
Root exception:
java.lang.NoClassDefFoundError: javafx/stage/Stage
    at aCTIVATOR.<init>(aCTIVATOR.java:8)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at java.lang.Class.newInstance(Class.java:433)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.loadBundleActivator(BundleContextImpl.java:755)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:706)
    at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:928)
    at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:317)
    at org.eclipse.osgi.container.Module.doStart(Module.java:558)
    at org.eclipse.osgi.container.Module.start(Module.java:429)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1551)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1531)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1502)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1445)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
Caused by: java.lang.ClassNotFoundException: javafx.stage.Stage cannot be found by osgi.identity; osgi.identity="root"; type="osgi.bundle"; version:Version="1.0.0.qualifier"
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:365)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:331)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:323)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 19 more

!ENTRY org.eclipse.osgi 4 0 2014-10-21 13:32:14.621
!MESSAGE Bundle root_1.0.0.qualifier [4] is not active.

!ENTRY org.eclipse.osgi 4 0 2014-10-21 13:32:14.622
!MESSAGE Could not find bundle: org.eclipse.equinox.console
!STACK 0
org.osgi.framework.BundleException: Could not find bundle: org.eclipse.equinox.console
    at org.eclipse.core.runtime.internal.adaptor.ConsoleManager.checkForConsoleBundle(ConsoleManager.java:58)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:323)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:222)
    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:483)
    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)

!!!!!!!(这是一个很长的一个)
所以对此有任何想法或帮助吗?

!!!!!!!(this was a long one) So any idea or help about this?

推荐答案

你看到java.lang.NoClassDefFoundError的原因是Equinox没有参考Ext-classpath并且很可能你不要告诉Equinox使用我们的调制器挂钩,他们让equinox参考这条路径。

The reason you see the "java.lang.NoClassDefFoundError" is that Equinox does not consult the Ext-classpath and most likely you don't tell Equinox to use our adaptor hooks who make equinox consult that path.

你需要做的是:


  1. 确保在启动时有org.eclipse.fx.osgi片段

  2. 确保传递-Dosgi.framework.extensions = org.eclipse.fx.osgi作为启动配置中的VM参数

  3. (更新)使用-Dorg.osgi.framework.bundle.parent = ext
  4. $ b启动首选选项$ b
  1. Ensure that you have org.eclipse.fx.osgi fragment in your launch
  2. Make sure you pass -Dosgi.framework.extensions=org.eclipse.fx.osgi as VM arguments in your launch config
  3. (Update) Preferred option launch with -Dorg.osgi.framework.bundle.parent=ext

现在我已经回答了你真正的问题。我不能最后说明你的询问和回复人的风格。这不好,我多次想过我是否应该回答。停止在你的问题中加上惊叹号并回复,然后在让某人失望之前三思而后行,如果这是与试图帮助你的人交谈的正确方法!

Now that I've answered your real question. I can not end with a final note on your style of asking and replying to people. This is not good and I've thought multiple times about whether I should answer. Stop putting exclamation marks in your questions and reply and before putting someone down think twice if this the correct way to talk to someone who tried to help you!

这篇关于e(fx)clipse equinox编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆