【问题标题】:EMF working with VirgoEMF 与处女座合作
【发布时间】:2013-04-29 15:02:05
【问题描述】:

我正在尝试在 Virgo 容器中使用 EMF。在我的 POM 中,我添加了以下依赖项:

<dependency>
    <groupId>org.eclipse.emf</groupId>
    <artifactId>org.eclipse.emf.ecore</artifactId>
    <version>2.8.0-v20120911-0500</version>
</dependency>
<dependency>
    <groupId>org.eclipse.emf</groupId>
    <artifactId>org.eclipse.emf.common</artifactId>
    <version>2.8.0-v20120911-0500</version>
</dependency>
<dependency>
    <groupId>org.eclipse.core</groupId>
    <artifactId>org.eclipse.core.runtime</artifactId>
    <version>3.6.0.v20100505</version>
</dependency>

虽然当我启动服务器时出现以下异常:

[2013-04-29 15:29:56.880]  TCP Connection(6)-127.0.0.1 <DE0002E> Installation of bundle 'xxx' version '0.0.1' failed. org.eclipse.virgo.nano.deployer.api.core.DeploymentException: commit failed
    at org.eclipse.virgo.kernel.install.pipeline.stage.resolve.internal.CommitStage.process(CommitStage.java:40)
    at org.eclipse.virgo.kernel.install.pipeline.internal.StandardPipeline.doProcessGraph(StandardPipeline.java:62)
    at org.eclipse.virgo.kernel.install.pipeline.internal.CompensatingPipeline.doProcessGraph(CompensatingPipeline.java:73)
    at org.eclipse.virgo.kernel.install.pipeline.stage.AbstractPipelineStage.process(AbstractPipelineStage.java:41)
    at org.eclipse.virgo.kernel.install.pipeline.internal.StandardPipeline.doProcessGraph(StandardPipeline.java:62)
    at org.eclipse.virgo.kernel.install.pipeline.stage.AbstractPipelineStage.process(AbstractPipelineStage.java:41)
    at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.driveInstallPipeline(PipelinedApplicationDeployer.java:359)
    at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.doInstall(PipelinedApplicationDeployer.java:185)
    at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.install(PipelinedApplicationDeployer.java:140)
    at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.deploy(PipelinedApplicationDeployer.java:253)
    at org.eclipse.virgo.kernel.deployer.management.StandardDeployer.deploy(StandardDeployer.java:52)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.jmx.mbeanserver.ConvertingMethod.invokeWithOpenReturn(ConvertingMethod.java:167)
    at com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:96)
    at com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:33)
    at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:208)
    at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:120)
    at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:264)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:762)
    at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1454)
    at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:74)
    at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1295)
    at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1387)
    at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:818)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:303)
    at sun.rmi.transport.Transport$1.run(Transport.java:159)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:680)
Caused by: org.osgi.framework.BundleException: Failed to start bundle 'org.eclipse.emf.ecore' version '2.8.0.v20120606-0717'
    at org.eclipse.virgo.kernel.userregion.internal.quasi.StandardQuasiFramework.startBundle(StandardQuasiFramework.java:386)
    at org.eclipse.virgo.kernel.userregion.internal.quasi.StandardQuasiFramework.startBundles(StandardQuasiFramework.java:376)
    at org.eclipse.virgo.kernel.userregion.internal.quasi.StandardQuasiFramework.commit(StandardQuasiFramework.java:365)
    at org.eclipse.virgo.kernel.install.pipeline.stage.resolve.internal.CommitStage.process(CommitStage.java:38)
    ... 41 common frames omitted
Caused by: org.osgi.framework.BundleException: Exception in org.eclipse.emf.ecore.plugin.EcorePlugin$Implementation.start() of bundle org.eclipse.emf.ecore.
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
    at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:300)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:292)
    at org.eclipse.virgo.kernel.userregion.internal.quasi.StandardQuasiFramework.startBundle(StandardQuasiFramework.java:384)
    ... 44 common frames omitted
Caused by: java.lang.NullPointerException: null
    at org.eclipse.emf.ecore.plugin.RegistryReader.readRegistry(RegistryReader.java:81)
    at org.eclipse.emf.ecore.plugin.EcorePlugin$Implementation.start(EcorePlugin.java:557)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
    ... 49 common frames omitted

而且我感觉 Activator 正在尝试做某事,假设 Eclipse 插件环境没有,但实际上并没有。有没有人在 Virgo 捆绑包中成功使用过 EMF? 谢谢!

【问题讨论】:

    标签: eclipse emf eclipse-virgo


    【解决方案1】:

    您是对的,因为 EMF 认为是在 Eclipse 环境中运行。我们已按照以下步骤将 EMF 与 Virgo 集成:

    1. 使用名为 lib 的文件夹创建捆绑包装器并将其放入 将 EMF jar 文件夹。在我们的例子中,我们放置了库: org.eclipse.emf.common-2.7.0.v20110128-1409.jar, org.eclipse.emf.ecore-2.7.0.v20110128-1409.jar 和 org.eclipse.emf.ecore.xmi-2.6.0.v20110126-1727.jar
    2. 在 MANIFEST.MF 的 bundle 类路径中添加这些库
    3. 重新导出 MANIFEST.MF 中的 EMF 包
    4. 创建一个 Activator 类并设置注册表。代码是:

      @Override
      public void start(BundleContext arg0) throws Exception {
          Properties props = System.getProperties();
          props.setProperty("org.eclipse.emf.ecore.EPackage.Registry.INSTANCE",
                  "org.eclipse.emf.ecore.impl.EPackageRegistryImpl");
      
      }
      
      @Override
      public void stop(BundleContext arg0) throws Exception {
          Properties props = System.getProperties();
          props.remove("org.eclipse.emf.ecore.impl.EPackageRegistryImpl");
      
      }
      

    最后,MANIFEST.MF 应该是这样的:

    Manifest-Version: 1.0
    Bundle-Version: 2.7.0
    Bundle-Name: EMF-Wrapper
    Bundle-ManifestVersion: 2
    Bundle-SymbolicName: emf-wrapper
    Bundle-ClassPath: .,
     lib/org.eclipse.emf.common-2.7.0.v20110128-1409.jar,
     lib/org.eclipse.emf.ecore-2.7.0.v20110128-1409.jar,
     lib/org.eclipse.emf.ecore.xmi-2.6.0.v20110126-1727.jar
    Export-Package: your.activator.package,
     org.eclipse.emf.common;version="2.7.0.v20110128-1409",
     org.eclipse.emf.common.archive;version="2.7.0.v20110128-1409",
     org.eclipse.emf.common.notify;version="2.7.0.v20110128-1409",
     org.eclipse.emf.common.notify.impl;version="2.7.0.v20110128-1409",
     org.eclipse.emf.common.util;version="2.7.0.v20110128-1409",
     org.eclipse.emf.ecore;version="2.7.0.v20110128-1409",
     org.eclipse.emf.ecore.impl;version="2.7.0.v20110128-1409",
     org.eclipse.emf.ecore.plugin;version="2.7.0.v20110128-1409",
     org.eclipse.emf.ecore.resource;version="2.7.0.v20110128-1409",
     org.eclipse.emf.ecore.resource.impl;version="2.7.0.v20110128-1409",
     org.eclipse.emf.ecore.util;version="2.7.0.v20110128-1409",
     org.eclipse.emf.ecore.xmi;version="2.6.0.v20110126-1727",
     org.eclipse.emf.ecore.xmi.impl;version="2.6.0.v20110126-1727",
     org.eclipse.emf.ecore.xmi.util;version="2.6.0.v20110126-1727",
     org.eclipse.emf.ecore.xml.namespace;version="2.7.0.v20110128-1409",
     org.eclipse.emf.ecore.xml.type;version="2.7.0.v20110128-1409",
     org.eclipse.emf.ecore.xml.type.internal;version="2.7.0.v20110128-1409",
     org.eclipse.emf.ecore.xml.type.util;version="2.7.0.v20110128-1409"
    Bundle-Activator: your.activator.package.Activator
    Import-Package: org.osgi.framework;version="[1.7.0,1.7.0]"
    

    【讨论】:

      【解决方案2】:

      根据上述灵感,我创建了这个包装器来完成这项工作。请注意,我没有包含 EMF 库的副本,而只是通过 maven 依赖项引入它们。

      https://github.com/tarelli/emfwrapper

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-10-17
        • 2015-07-01
        • 2014-08-11
        • 2012-02-24
        • 2011-04-17
        • 2011-11-12
        • 1970-01-01
        • 2013-03-30
        相关资源
        最近更新 更多