0

Scala (2.9.1.RC3) と PDE (Eclipse Helios) を使用する OSGi バンドルをビルドする方法。Scala IDE (2.0.0-beta) を使用してプロジェクトをビルドし、これを PDE プロジェクトに変換しています。私の MANIFEST.MF はそのようなものです:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: ScalaTest1
Bundle-SymbolicName: ScalaTest1
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: scalatest1.Activator
Import-Package: org.osgi.framework;version="1.3.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6

プロジェクトはエラーなしでビルドされますが、バンドルを開始すると、この例外が表示されます (Apache Felix 3.2.2 を使用):

org.osgi.framework.BundleException: Not found: scalatest1.Activator
        at org.apache.felix.framework.Felix.createBundleActivator(Felix.java:3812)
        at org.apache.felix.framework.Felix.activateBundle(Felix.java:1899)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:1822)
        at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:927)
        at org.apache.felix.gogo.command.Basic.start(Basic.java:758)
        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.apache.felix.gogo.runtime.Reflective.method(Reflective.java:136)
        at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
        at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:469)
        at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:395)
        at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
        at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
        at org.apache.felix.gogo.shell.Console.run(Console.java:62)
        at org.apache.felix.gogo.shell.Shell.console(Shell.java:203)
        at org.apache.felix.gogo.shell.Shell.gosh(Shell.java:128)
        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.apache.felix.gogo.runtime.Reflective.method(Reflective.java:136)
        at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
        at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:469)
        at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:395)
        at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
        at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
        at org.apache.felix.gogo.shell.Activator.run(Activator.java:75)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: scalatest1.Activator not found by ScalaTest1 [27]
        at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:812)
        at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:72)
        at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1807)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:670)
        at org.apache.felix.framework.Felix.createBundleActivator(Felix.java:3808)
        ... 33 more

そしてコード:

package scalatest1

import org.osgi.framework._

class Activator extends BundleActivator {
  def start(context: BundleContext) {
    println("Hello, World!");

    val bundleNames = context.getBundles()
      .map(b => b.getSymbolicName())
      .filter(b => b != context.getBundle());
    println("Installed bundles: " + bundleNames.mkString(", "));
  }

  def stop(context: BundleContext) {
    println("Goodbye, World!");
  }
}

プロセスの何が問題になっていますか? クラス Activator を正しくマップする方法は?

前もって感謝します

4

2 に答える 2

2

JARにファイルをエクスポートせずにこれを行う方法については、http://www.michel-kraemer.com/scala-projects-with-eclipse-pde-build-2を参照してください。.scala

于 2011-11-18T08:48:04.660 に答える
0

私はばかげた問題を見つけました。「ワークスペースでコンパイルされたクラスファイルを使用する」フィールドをエクスポートしているとき、マークが外されていました。動作しますが、.scala ファイルがエクスポートされた .jar ファイルに含まれているという別の問題があります。

于 2011-08-19T13:04:43.917 に答える