2015-08-28 86 views
0

我剛剛創建了一個使用tycho的eclipse插件。我可以運行mvn clean install,到目前爲止沒有錯誤。運行tycho eclipse插件作爲Eclipse應用程序

現在我想運行該插件作爲Eclipse應用程序(它基本上是一個生成器)。當我按run as Eclipse Application時,第二個eclipse實例顯示出來。當我有創建一個新項目,並添加我的建設者,日食引發我此異常:

org.eclipse.e4.core.di.InjectionException: org.eclipse.core.commands.ExecutionException: Failed to toggle nature 

Caused by: org.eclipse.core.commands.ExecutionException: Failed to toggle nature 

Caused by: org.eclipse.core.runtime.CoreException: Problems encountered while setting project description 

在此方法中發生的錯誤:

private void toggleNature(IProject project) throws CoreException { 

     IProjectDescription description = project.getDescription(); 
     String[] natures = description.getNatureIds(); 

     for (int i = 0; i < natures.length; ++i) { 
      if (SidecarNature.NATURE_ID.equals(natures[i])) { 
       // Remove the nature 
       String[] newNatures = new String[natures.length - 1]; 
       System.arraycopy(natures, 0, newNatures, 0, i); 
       System.arraycopy(natures, i + 1, newNatures, i, natures.length - i - 1); 
       description.setNatureIds(newNatures); 
       project.setDescription(description, null); 
       return; 
      } 
     } 

     // Add the nature 
     String[] newNatures = new String[natures.length + 1]; 
     System.arraycopy(natures, 0, newNatures, 0, natures.length); 
     newNatures[natures.length] = SidecarNature.NATURE_ID; 
     description.setNatureIds(newNatures); 


     // --------------------------------------- 
     // The Error is thrown here 
     // --------------------------------------- 
     project.setDescription(description, null); 
    } 

我不知道什麼是錯,因爲這是日食模板代碼。我沒有改變任何東西。它應該工作,當我不使用maven。

這是基本的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
<modelVersion>4.0.0</modelVersion> 
<groupId>tycho_example</groupId> 
<artifactId>com.codeandme.tycho.plugin</artifactId> 
<version>1.0.0-SNAPSHOT</version> 
<packaging>eclipse-plugin</packaging> 

<properties> 
    <tycho.version>0.23.0</tycho.version> 
</properties> 

<repositories> 
    <!-- add Mars repository to resolve dependencies --> 
    <repository> 
    <id>Mars</id> 
    <layout>p2</layout> 
    <url>http://download.eclipse.org/releases/mars/</url> 
    </repository> 
</repositories> 

<build> 
    <plugins> 
    <plugin> 
    <!-- enable tycho build extension --> 
    <groupId>org.eclipse.tycho</groupId> 
    <artifactId>tycho-maven-plugin</artifactId> 
    <version>${tycho.version}</version> 
    <extensions>true</extensions> 
    </plugin> 
    </plugins> 
</build> 
</project> 

編輯 如這裏要求是完整的堆棧跟蹤:

org.eclipse.e4.core.di.InjectionException: org.eclipse.core.commands.ExecutionException: Failed to toggle nature 
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:68) 
    at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:252) 
    at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:234) 
    at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132) 
    at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:152) 
    at org.eclipse.core.commands.Command.executeWithChecks(Command.java:493) 
    at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:486) 
    at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210) 
    at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:799) 
    at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.handleWidgetSelection(HandledContributionItem.java:675) 
    at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.access$7(HandledContributionItem.java:659) 
    at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem$4.handleEvent(HandledContributionItem.java:592) 
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) 
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4230) 
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1491) 
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1514) 
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1499) 
    at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1299) 
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4072) 
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3698) 
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127) 
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337) 
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018) 
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156) 
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:654) 
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337) 
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:598) 
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150) 
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139) 
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) 
    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(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:497) 
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669) 
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608) 
    at org.eclipse.equinox.launcher.Main.run(Main.java:1515) 
    at org.eclipse.equinox.launcher.Main.main(Main.java:1488) 
Caused by: org.eclipse.core.commands.ExecutionException: Failed to toggle nature 
    at de.ustutt.sidewise.eclipseintegration.builder.AddRemoveSidewiseNatureHandler.execute(AddRemoveSidewiseNatureHandler.java:37) 
    at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:295) 
    at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90) 
    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:497) 
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56) 
    ... 41 more 
Caused by: org.eclipse.core.runtime.CoreException: Problems encountered while setting project description. 
    at org.eclipse.core.internal.resources.Project.setDescription(Project.java:1256) 
    at org.eclipse.core.internal.resources.Project.setDescription(Project.java:1281) 
    at de.ustutt.sidewise.eclipseintegration.builder.AddRemoveSidewiseNatureHandler.toggleNature(AddRemoveSidewiseNatureHandler.java:78) 
    at de.ustutt.sidewise.eclipseintegration.builder.AddRemoveSidewiseNatureHandler.execute(AddRemoveSidewiseNatureHandler.java:34) 
    ... 48 more 

EDIT2IStatus

Status WARNING: org.eclipse.core.resources code=568 Problems encountered while setting project description. null children=[[type: WARNING], [path: null], [message: Nature does not exist: eclipseintegration.builder.SidewiseNature.], [plugin: org.eclipse.core.resources], [exception: null] 
] 
+0

向我們展示完整的堆棧跟蹤 –

+0

@ greg-449感謝,編輯我的問題 – Robin

+1

您需要查看'設置項目描述時遇到的問題'CoreException'中的'IStatus',因爲這將包含更多關於究竟是什麼問題。 –

回答

2

IStatus Nature does not exist: eclipseintegration.builder.SidewiseNature.中的消息說您正在嘗試添加一個不存在的特性。

你是否聲明瞭org.eclipse.core.resources.natures擴展點的性質?這個ID是否與SidecarNature.NATURE_ID常數匹配?

+0

plugin.xml在某種程度上配置錯誤,儘管我沒有觸及它。感謝greg修復。 – Robin

相關問題