1

我尝试通过 PlayFramework 2.x 连接到 cassandra,但出现常见异常 ClassNotFoundException: play.Plugin。我已经完成了 wiki 页面https://github.com/deanhiller/playorm/wiki/PlayFramework-2.x-support上的所有内容。这是我的 maven(我使用 mvn 存储库中的 playorm.jar)项目http://code.google.com/p/cassandranosql-firebrandocm-playorm/source/browse/trunk/,如您所见,有一个测试类UserPlayormDaoImplTest,其中调用NoSql.em();抛出 ClassNotFoundException。我将 plugin2.1.jar 添加到类路径中,但是找不到该类。我不知道有什么问题。感谢帮助。

堆栈跟踪:

java.lang.NoClassDefFoundError: play/Plugin
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.alvazan.play.NoSql.<clinit>(NoSql.java:16)
at cz.muni.fi.cassandra.Playorm.UserPlayormDaoImplTest.setUp(UserPlayormDaoImplTest.java:34)
at junit.framework.TestCase.runBare(TestCase.java:132)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: play.Plugin
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 30 more
4

2 回答 2

1

你用的是哪个版本的play?play.Plugin 是 play2.1.0 框架的一部分。您能否检查位于 play-2.1.0/repository/local/play/play_2.10/2.1.0/jars/play_2.10.jar 的 jar “play_2.10.jar”是否在您项目的类路径中。

于 2013-02-25T06:47:27.350 回答
0

我的错,我之前没有将 play-2.1.0/repository/local/play/play_2.10/2.1.0/jars/play_2.10.jar 中的 play_2.10.jar 添加到我的项目的类路径中。我正在使用 playframework 2.1.0(从 playframework 网站下载)。我添加了那个 jar,但现在我与其他类有类似的问题。似乎类路径中缺少更多的罐子。堆栈跟踪:

java.lang.NoClassDefFoundError: scala/Function0
at play.api.Play.current(Play.scala)
at play.Play.application(Play.java:12)
at com.alvazan.play2.NoSqlForPlay2.em(NoSqlForPlay2.java:25)
at com.alvazan.play.NoSql.em(NoSql.java:60)
at cz.muni.fi.cassandra.Playorm.UserPlayormDaoImplTest.setUp(UserPlayormDaoImplTest.java:35)
at junit.framework.TestCase.runBare(TestCase.java:132)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: scala.Function0
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 19 more
于 2013-02-26T11:36:51.817 回答