QA@IT

Parent.java の 19行目にコンパイルエラー その2

4521 PV

本文

@ITの記事「Play frameworkのDB操作を楽にするEBeanの基礎知識 (1/3)」についての質問です。

Parent.java の 19行目にコンパイルエラーがでますが、原因不明です。

In C:\play-2.2.3\firstProject\app\models\Parent.java at line 19.
16    @Id
17    public Long id;
18
19    @NotNull

コマンドプロンプトの方のエラーは、

play.PlayException$CompilationException: Compilation error[・スG・ス・ス・ス[:
at play.PlayReloader$$anon$1$$anonfun$reload------------------------
(PlayReloader.scala:304)~[na:na]
~[scala-library.jar:na]
(PlayReloader.scala:304) ~[na:na]
(PlayReloader.scala:298) ~[na:na]

本文


差分

Parent.java の全文を掲載致します。

package models;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Version;

import play.db.ebean.Model;

import com.avaje.ebean.annotation.CreatedTimestamp;
import com.avaje.ebean.validation.NotNull;

@Entity
public class Parent extends Model {

    @Id
    public Long id;

    @NotNull
    public String name;

    @CreatedTimestamp
    public Date createDate;

    @Version
    public Date updateDate;

    public String toString() {
        return "Parent [id=" + id + ", name=" + name + ", createDate="
                + createDate + ", updateDate=" + updateDate + "]";
    }
}
# 差分
-------------------------------------------------------------------------------
chcp コマンド後にも追う一度出力させて見ました。
# 差分
[info] Loading project definition from C:\play-2.2.3\firstProject\project
[info] Set current project to firstProject (in build file:/C:/play-2.2.3/firstProject/)
[info] Updating {file:/C:/play-2.2.3/firstProject/}firstproject...
[info] Resolving org.scala-lang#scala-library;2.10.3 ...
[info] Resolving com.typesafe.play#play-java-jdbc_2.10;2.2.3 ...
[info] Resolving com.typesafe.play#play-jdbc_2.10;2.2.3 ...
[info] Resolving com.typesafe.play#play_2.10;2.2.3 ...
[info] Resolving com.typesafe.play#sbt-link;2.2.3 ...
[info] Resolving org.javassist#javassist;3.18.0-GA ...
[info] Resolving com.typesafe.play#play-exceptions;2.2.3 ...
[info] Resolving com.typesafe.play#templates_2.10;2.2.3 ...
[info] Resolving com.github.scala-incubator.io#scala-io-file_2.10;0.4.2 ...
[info] Resolving com.github.scala-incubator.io#scala-io-core_2.10;0.4.2 ...
[info] Resolving com.jsuereth#scala-arm_2.10;1.3 ...
[info] Resolving com.typesafe.play#play-iteratees_2.10;2.2.3 ...
[info] Resolving org.scala-stm#scala-stm_2.10;0.7 ...
[info] Resolving com.typesafe#config;1.0.2 ...
[info] Resolving com.typesafe.play#play-json_2.10;2.2.3 ...
[info] Resolving com.typesafe.play#play-functional_2.10;2.2.3 ...
[info] Resolving com.typesafe.play#play-datacommons_2.10;2.2.3 ...
[info] Resolving joda-time#joda-time;2.2 ...
[info] Resolving org.joda#joda-convert;1.3.1 ...
[info] Resolving com.fasterxml.jackson.core#jackson-annotations;2.2.2 ...
[info] Resolving com.fasterxml.jackson.core#jackson-core;2.2.2 ...
[info] Resolving com.fasterxml.jackson.core#jackson-databind;2.2.2 ...
[info] Resolving org.scala-lang#scala-reflect;2.10.3 ...
[info] Resolving io.netty#netty;3.7.1.Final ...
[info] Resolving com.typesafe.netty#netty-http-pipelining;1.1.2 ...
[info] Resolving org.slf4j#slf4j-api;1.7.5 ...
[info] Resolving org.slf4j#jul-to-slf4j;1.7.5 ...
[info] Resolving org.slf4j#jcl-over-slf4j;1.7.5 ...
[info] Resolving ch.qos.logback#logback-core;1.0.13 ...
[info] Resolving ch.qos.logback#logback-classic;1.0.13 ...
[info] Resolving com.typesafe.akka#akka-actor_2.10;2.2.0 ...
[info] Resolving com.typesafe.akka#akka-slf4j_2.10;2.2.0 ...
[info] Resolving org.apache.commons#commons-lang3;3.1 ...
[info] Resolving com.ning#async-http-client;1.7.18 ...
[info] Resolving oauth.signpost#signpost-core;1.2.1.2 ...
[info] Resolving commons-codec#commons-codec;1.3 ...
[info] Resolving oauth.signpost#signpost-commonshttp4;1.2.1.2 ...
[info] Resolving org.apache.httpcomponents#httpcore;4.0.1 ...
[info] Resolving org.apache.httpcomponents#httpclient;4.0.1 ...
[info] Resolving commons-logging#commons-logging;1.1.1 ...
[info] Resolving xerces#xercesImpl;2.11.0 ...
[info] Resolving xml-apis#xml-apis;1.4.01 ...
[info] Resolving javax.transaction#jta;1.1 ...
[info] Resolving com.jolbox#bonecp;0.8.0.RELEASE ...
[info] Resolving com.google.guava#guava;14.0.1 ...
[info] Resolving com.h2database#h2;1.3.172 ...
[info] Resolving tyrex#tyrex;1.0.1 ...
[info] Resolving com.typesafe.play#play-java_2.10;2.2.3 ...
[info] Resolving org.yaml#snakeyaml;1.12 ...
[info] Resolving org.hibernate#hibernate-validator;5.0.1.Final ...
[info] Resolving javax.validation#validation-api;1.1.0.Final ...
[info] Resolving org.jboss.logging#jboss-logging;3.1.1.GA ...
[info] Resolving com.fasterxml#classmate;0.8.0 ...
[info] Resolving org.springframework#spring-context;3.2.3.RELEASE ...
[info] Resolving org.springframework#spring-core;3.2.3.RELEASE ...
[info] Resolving org.springframework#spring-beans;3.2.3.RELEASE ...
[info] Resolving org.reflections#reflections;0.9.8 ...
[info] Resolving com.google.code.findbugs#jsr305;2.0.1 ...
[info] Resolving javax.servlet#javax.servlet-api;3.0.1 ...
[info] Resolving com.typesafe.play#play-java-ebean_2.10;2.2.3 ...
[info] Resolving org.avaje.ebeanorm#avaje-ebeanorm;3.2.2 ...
[info] Resolving org.avaje.ebeanorm#avaje-ebeanorm-agent;3.2.1 ...
[info] Resolving org.hibernate.javax.persistence#hibernate-jpa-2.0-api;1.0.1.Final ...
[info] Resolving com.typesafe.play#play-cache_2.10;2.2.3 ...
[info] Resolving net.sf.ehcache#ehcache-core;2.6.6 ...
[info] Resolving com.typesafe.play#play-test_2.10;2.2.3 ...
[info] Resolving junit#junit;4.11 ...
[info] Resolving org.hamcrest#hamcrest-core;1.3 ...
[info] Resolving org.specs2#specs2_2.10;2.1.1 ...
[info] Resolving org.scalaz#scalaz-core_2.10;7.0.2 ...
[info] Resolving org.scalaz#scalaz-concurrent_2.10;7.0.2 ...
[info] Resolving org.scalaz#scalaz-effect_2.10;7.0.2 ...
[info] Resolving com.novocode#junit-interface;0.10 ...
[info] Resolving org.scala-tools.testing#test-interface;0.5 ...
[info] Resolving org.fluentlenium#fluentlenium-festassert;0.8.0 ...
[info] Resolving org.fluentlenium#fluentlenium-core;0.8.0 ...
[info] Resolving org.seleniumhq.selenium#selenium-java;2.32.0 ...
[info] Resolving org.seleniumhq.selenium#selenium-android-driver;2.32.0 ...
[info] Resolving org.seleniumhq.selenium#selenium-remote-driver;2.32.0 ...
[info] Resolving cglib#cglib-nodep;2.1_3 ...
[info] Resolving org.json#json;20080701 ...
[info] Resolving org.seleniumhq.selenium#selenium-api;2.32.0 ...
[info] Resolving org.apache.httpcomponents#httpclient;4.2.1 ...
[info] Resolving org.apache.httpcomponents#httpcore;4.2.1 ...
[info] Resolving commons-codec#commons-codec;1.6 ...
[info] Resolving org.apache.commons#commons-exec;1.1 ...
[info] Resolving net.java.dev.jna#jna;3.4.0 ...
[info] Resolving net.java.dev.jna#platform;3.4.0 ...
[info] Resolving org.seleniumhq.selenium#selenium-chrome-driver;2.32.0 ...
[info] Resolving org.seleniumhq.selenium#selenium-htmlunit-driver;2.32.0 ...
[info] Resolving net.sourceforge.htmlunit#htmlunit;2.12 ...
[info] Resolving xalan#xalan;2.7.1 ...
[info] Resolving xalan#serializer;2.7.1 ...
[info] Resolving commons-collections#commons-collections;3.2.1 ...
[info] Resolving org.apache.httpcomponents#httpmime;4.2.3 ...
[info] Resolving net.sourceforge.htmlunit#htmlunit-core-js;2.12 ...
[info] Resolving net.sourceforge.nekohtml#nekohtml;1.9.18 ...
[info] Resolving net.sourceforge.cssparser#cssparser;0.9.9 ...
[info] Resolving org.w3c.css#sac;1.3 ...
[info] Resolving commons-io#commons-io;2.2 ...
[info] Resolving org.eclipse.jetty#jetty-websocket;8.1.9.v20130131 ...
[info] Resolving org.eclipse.jetty#jetty-util;8.1.9.v20130131 ...
[info] Resolving org.eclipse.jetty#jetty-io;8.1.9.v20130131 ...
[info] Resolving org.eclipse.jetty#jetty-http;8.1.9.v20130131 ...
[info] Resolving org.seleniumhq.selenium#selenium-firefox-driver;2.32.0 ...
[info] Resolving org.seleniumhq.selenium#selenium-ie-driver;2.32.0 ...
[info] Resolving org.seleniumhq.selenium#selenium-iphone-driver;2.32.0 ...
[info] Resolving org.seleniumhq.selenium#selenium-safari-driver;2.32.0 ...
[info] Resolving org.webbitserver#webbit;0.4.14 ...
[info] Resolving org.seleniumhq.selenium#selenium-support;2.32.0 ...
[info] Resolving org.easytesting#fest-assert;1.4 ...
[info] Resolving org.easytesting#fest-util;1.1.6 ...
[info] Resolving com.typesafe.play#play-docs_2.10;2.2.3 ...
[info] Resolving com.typesafe.play#play-doc_2.10;1.0.3 ...
[info] Resolving org.pegdown#pegdown;1.4.0 ...
[info] Resolving org.parboiled#parboiled-java;1.1.5 ...
[info] Resolving org.parboiled#parboiled-core;1.1.5 ...
[info] Resolving org.ow2.asm#asm;4.1 ...
[info] Resolving org.ow2.asm#asm-tree;4.1 ...
[info] Resolving org.ow2.asm#asm-analysis;4.1 ...
[info] Resolving org.ow2.asm#asm-util;4.1 ...
[info] Resolving commons-io#commons-io;2.4 ...
[info] Resolving org.scala-lang#scala-compiler;2.10.3 ...
[info] Resolving org.scala-lang#jline;2.10.3 ...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.

--- (Running the application from SBT, auto-reloading is enabled) ---

[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000

(Server started, use Ctrl+D to stop and go back to the console...)

[info] Compiling 4 Scala sources and 3 Java sources to C:\play-2.2.3\firstProject\target\scala-2.10\classes...
[error] C:\play-2.2.3\firstProject\app\models\Parent.java:19: G���[: V���{�����������܂���
[error]     @NotNull
[error]      ^
[error]   V���{��:   N���X NotNull
[error]   �ꏊ: N���X Parent
[error] G���[1��
[error] (compile:compile) javac returned nonzero exit code
[error] application - 

! @6jhj2fipn - Internal server error, for (GET) [/] ->

play.PlayExceptions$CompilationException: Compilation error[G���[: V���{�����������܂���]
    at play.PlayReloader$$anon$1$$anonfun$reload$2$$anonfun$apply$14$$anonfun$apply$16.apply(PlayReloader.scala:304) ~[na:na]
    at play.PlayReloader$$anon$1$$anonfun$reload$2$$anonfun$apply$14$$anonfun$apply$16.apply(PlayReloader.scala:304) ~[na:na]
    at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
    at play.PlayReloader$$anon$1$$anonfun$reload$2$$anonfun$apply$14.apply(PlayReloader.scala:304) ~[na:na]
    at play.PlayReloader$$anon$1$$anonfun$reload$2$$anonfun$apply$14.apply(PlayReloader.scala:298) ~[na:na]
    at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
[warn] play - No application found at invoker init
[info] Compiling 4 Scala sources and 3 Java sources to C:\play-2.2.3\firstProject\target\scala-2.10\classes...
[error] C:\play-2.2.3\firstProject\app\models\Parent.java:19: G���[: V���{�����������܂���
[error]     @NotNull
[error]      ^
[error]   V���{��:   N���X NotNull
[error]   �ꏊ: N���X Parent
[error] G���[1��
[error] (compile:compile) javac returned nonzero exit code
[error] application - 

! @6jhj2g18o - Internal server error, for (GET) [/] ->

play.PlayExceptions$CompilationException: Compilation error[G���[: V���{�����������܂���]
    at play.PlayReloader$$anon$1$$anonfun$reload$2$$anonfun$apply$14$$anonfun$apply$16.apply(PlayReloader.scala:304) ~[na:na]
    at play.PlayReloader$$anon$1$$anonfun$reload$2$$anonfun$apply$14$$anonfun$apply$16.apply(PlayReloader.scala:304) ~[na:na]
    at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
    at play.PlayReloader$$anon$1$$anonfun$reload$2$$anonfun$apply$14.apply(PlayReloader.scala:304) ~[na:na]
    at play.PlayReloader$$anon$1$$anonfun$reload$2$$anonfun$apply$14.apply(PlayReloader.scala:298) ~[na:na]
    at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]

[success] Total time: 41 s, completed 2014/09/18 22:01:43
# 差分
  • エラーメッセージを削られると判断できません(In ~ at line 19 の前にエラーメッセージがあると思います、通常そこに原因が書いてあります)。19行目がエラー対象なら20行目以降も数行あったあった方がいいでしょう。 -
  • ご指摘のParent.java の全文を掲載致しました。 -
  • 文字化けが悩ましいですね。ためしに一度、実行する手順を、コマンドプロンプトを開いて、プロジェクトのディレクトリに移動して、「chcp 65001」を実行してから「play」「run」にしてみてもらえますか?(実行方法は「play」を入力して「run」を入力してると思って言っていますが、実行方法が違う場合はお知らせください) -
  • お世話になっております。コマンドプロンプトを開いて、プロジェクトのディレクトリに移動して、「chcp 65001」を実行してから「play」「run」にしました。@ITのこちらのフォームから投稿すると文字化けするので、コマンドプロンプトの出力をブログに書きました。
    http://blogs.yahoo.co.jp/playframework2
    何卒宜しく御願い致します。
    -
  • コマンドプロンプトの画像をクリック後に、「拡大」をクリックで画像を拡大できます。 -

回答

原因は最初サンプルのParent.javaの12行目でエラーが出ていたと思いますが、それを適当に修正してしまったからですね。

現状出ているのはおそらくNotNullアノテーションがなんだかわからないというエラーです。
削除してしまったので当然です。

元の12行目

import com.avaje.ebean.validation.NotNull;

は確かにエラーが出ますが

import javax.validation.constraints.NotNull;

に変えてみてください。とりあえず目的の画面(needs evolution!)は表示できました。

今回はたまたま気が付きましたが、同じソースの問題を別の質問として挙げてしまうと前回の質問は見ませんので、以前の質問の中での修正が原因と気づかない場合があります。
継続できそうな場合は乱立せず同じ質問の中でつづけた方がいいでしょう。

(回答がつきすぎたりして、同じ質問で継続するには見づらい状態であれば新しい質問に仕切り直すのもありだとは思います)

編集 履歴 (0)
  • ご指摘の通り、12行目が問題でした。修正した所、目的の画面(needs evolution!)は表示できました。ありがとう御座いました。しかし、http://www.atmarkit.co.jp/ait/articles/1206/06/news130.html
    こちらの12行目は、間違って掲載している事になりますね。どうなんでしょう?
    -
  • Play Frameworkが2.1あたりまでなら動く記述のようです。
    ページでは2.0をダウンロードしていますので間違いではありません。ハマって苦労したのはわかりますが(エラーもわかりにくいですしね)、簡単に記事の間違いと決めつけるのは良くないですよ。
    -
  • flied_onionさん 対応して下さる皆様に感謝です。 -
ウォッチ

この質問への回答やコメントをメールでお知らせします。