下記のエラーが出た。
org.springframework.batch.item.file.FlatFileParseException
DelimitedLineTokenizerで定義している変数名と、FieldSetMapperで実装しているマッピング変数の名前と数が合っているかを確かめよう。私の場合は、うっかりスペルミス。
下記のエラーが出た。
org.springframework.batch.item.file.FlatFileParseException
DelimitedLineTokenizerで定義している変数名と、FieldSetMapperで実装しているマッピング変数の名前と数が合っているかを確かめよう。私の場合は、うっかりスペルミス。
MySQL では動作するのだが、Oracleに移行した途端にエラー。
シーケンスが無いとのこと。
どうやら、MySQLの場合は、下記をテーブルとして実装しても動作するのだが、Oracleだとシーケンスとして作成する必要があるようだ。
MySQLだと下記でも動作する。
CREATE TABLE BATCH_STEP_EXECUTION_SEQ ( ID BIGINT NOT NULL ); CREATE TABLE BATCH_JOB_EXECUTION_SEQ ( ID BIGINT NOT NULL ); CREATE TABLE BATCH_JOB_SEQ ( ID BIGINT NOT NULL ); INSERT INTO BATCH_STEP_EXECUTION_SEQ VALUES(0); INSERT INTO BATCH_JOB_EXECUTION_SEQ VALUES(0); INSERT INTO BATCH_JOB_SEQ VALUES(0);
Oracleでは、Tableではなく、Sequenceを定義。
CREATE SEQUENCE BATCH_STEP_EXECUTION_SEQ MAXVALUE 9223372036854775807 CYCLE; CREATE SEQUENCE BATCH_JOB_EXECUTION_SEQ MAXVALUE 9223372036854775807 CYCLE; CREATE SEQUENCE BATCH_JOB_SEQ MAXVALUE 9223372036854775807 CYCLE;
こちらを参考にした。
Oracleで、リサイクルBIN(BIN$w/40spiFy6rgQAB/AQAZGg==$0)のようなゴミテーブルが見えることがあると思います。
一覧表示等する場合に、結構邪魔だったりします。
そんなときは、下記のコマンドで。
PURGE RECYCLEBIN;
ちなみに、そのままリサイクルBINに入れたくない場合は、下記のコマンドらしい。
DROP TABLE テーブル名 PURGE;
おそらくやらないと思うけど。
Mac環境へ、Spring Roo をダウンロードして解凍し、インストールした場合の設定。
/usr/local/roo/bin 配下に、roo.sh と roo.bat が存在する為、パスを通してシンボリックリンクを作成して、パスを通す。
$ ln -s /usr/local/roo/bin/roo.sh roo
$ vi .bashrc export PATH=$PATH:/usr/local/roo/bin
rooコマンドにて起動する。
$ roo ____ ____ ____ / __ \/ __ \/ __ \ / /_/ / / / / / / / / _, _/ /_/ / /_/ / /_/ |_|\____/\____/ 1.2.2.RELEASE [rev 7d75659] Welcome to Spring Roo. For assistance press TAB or type "hint" then hit ENTER. @rooinaction: @SpringRoo Second blog post on testing Roo Add-ons is here - Mockito and the Argument Captor. http://t.co/S4wfLyAI Version is required for org.apache.maven.plugins:maven-compiler-plugin
結論から言うと、プロキシのせいでインストールがこける。
直接ダウンロードして、下記のようにインストールしようと思ってもダメ。
$ sudo gem install /usr/local/src/rails-3.2.8.gem ERROR: http://rubygems.org/ does not appear to be a repository ERROR: Error installing /usr/local/src/rails-3.2.8.gem: rails requires activesupport (= 3.2.8, runtime)
環境変数にプロキシの場所をしていしてもダメ。
$ export http_proxy=http://proxy:8888/
ダメな理由はわからないのだが、どうやら gemコマンド自身にも、プロキシ設定するオプションがあるようだ。
$ sudo gem install --remote rails -p http://proxy:8888/
Ruby の gem にせよ、Java の Maven にせよ、git にせよ。
インストールや依存関係の管理は便利なのだが、サーバ環境による設定は難しい。というより、知らないと時間をようしてしまう。この辺は、カンを働かせていかないとなぁ。
インストール後の初回プロジェクト作成時に、eclipseベースの SpringSource Tool Suite を使用していると、動作が調子悪く思ったので覚え書き。
どうやら、eclipse の設定ファイルに下記のオプションを付けるべきなようだ。
-vm \c:\\jdk1.6\bin\javaw.exe
これは、maven 起動時に、java sdk のコンパイラを使用するかららしい。
デフォルトでは、jreのランタイムによって eclipse が起動している場合が多いので、このオプションで対応すると上手くいくと思う。
それにしても、maven経由でコンパイル等が行われるとやはり遅い。
そもそも Maven を使用すること自体経験上無く、今更インストールして使用することとなった訳だが、具体的に何をしてくれるのかが不明。
しかし、SpringSource Tool Suite で、プロジェクトを新規作成してみると、プロジェクトのビルドパスに、いつの間にやら必要なjarファイル群が設定されている。
そもそも、これらのjarファイル群はどこから来たのか?
調べてみると、WindowsXP の場合、C:\Documents and Settings\xxxxxx\.m2\repository の中に、ダウンロードされている。
これ自体がMaven の設定で、Mavenレポジトリとして、デフォルトとしてダウンロードされているようだ。
これらは、プロジェクト内にあるpom.xml に必須ライブラリとして記載されているようだ。
知らないと面倒だが、少しづつ勉強中である。
Blogのエントリには記載していないが、JavaのFrameworkとしては、Seasar2を使用してきた。
今回どういうわけか、SpringFrameworkに接する機会があったので、現在勉強中なのであるが、勢い余って Spring Roo に挑戦してみようと思った。
そもそも、SpringFramework に関しては約10年前程に知識不足で脱落していた。
それ以来、興味も何もなかったが、Seasar2 に慣れて、概念的な部分の理解はクリアしているつもりなので、今回は、SpringFramework 自体も、10年前よりもスンナリと頭で想像できた。つもり。
大方は、SpringRoo のサイト(英語)に記載してある通りだが。
準備としては、Maven と Roo をダウンロード&インストールして、システムのパスに含めてさぁ開始。
C:\works\hello>roo ____ ____ ____ / __ \/ __ \/ __ \ / /_/ / / / / / / / / _, _/ /_/ / /_/ / /_/ |_|\____/\____/ 1.2.2.RELEASE [rev 7d75659] Welcome to Spring Roo. For assistance press TAB or type "hint" then hit ENTER. @krimple: Just submitted my talk proposal for SpringOne/2GX on Roo add-on development. Keeping finge rs crossed? @SpringRoo At this time you have not authorized Spring Roo to download an index of available add-ons. This will reduce Spring Roo features available to you. Please type 'download status' and press ENTER for further information. roo>
お手本通りに、hint コマンド。
roo> hint Welcome to Roo! We hope you enjoy your stay! Before you can use many features of Roo, you need to start a new project. To do this, type 'project' (without the quotes) and then hit TAB. Enter a --topLevelPackage like 'com.mycompany.projectname' (no quotes). When you've finished completing your --topLevelPackage, press ENTER. Your new project will then be created in the current working directory. Note that Roo frequently allows the use of TAB, so press TAB regularly. Once your project is created, type 'hint' and ENTER for the next suggestion. You're also welcome to visit http://forum.springframework.org for Roo help.
トップレベルのパッケージを打ってくれとのことなので。とりあえず、sampleパッケージ。
roo> project --topLevelPackage com.whoocus.sample Created ROOT\pom.xml Created SRC_MAIN_RESOURCES Created SRC_MAIN_RESOURCES\log4j.properties Created SPRING_CONFIG_ROOT Created SPRING_CONFIG_ROOT\applicationContext.xml
わお!!雛形が作成されている。
次は、DBの設定。正直、jpa とか hibernate に関しては無知なので、後に調べるとして、お手本通りにコマンド打ってみる。
ちなみに、DBは、MySql。”MYSQL” と大文字で打ち込まないと、エラーになった。
roo> jpa setup --provider HIBERNATE --database MYSQL --hostname localhost --databaseName roo_db - -userName hoge --password hoge Created SPRING_CONFIG_ROOT\database.properties Please update your database details in src/main/resources/META-INF/spring/database.properties. Updated SPRING_CONFIG_ROOT\applicationContext.xml Created SRC_MAIN_RESOURCES\META-INF\persistence.xml Updated ROOT\pom.xml [added dependencies mysql:mysql-connector-java:5.1.18, org.hibernate:hibernate- core:3.6.9.Final, org.hibernate:hibernate-entitymanager:3.6.9.Final, org.hibernate.javax.persistence :hibernate-jpa-2.0-api:1.0.1.Final, commons-collections:commons-collections:3.2.1, org.hibernate:hib ernate-validator:4.2.0.Final, javax.validation:validation-api:1.0.0.GA, cglib:cglib-nodep:2.2.2, jav ax.transaction:jta:1.1, org.springframework:spring-jdbc:${spring.version}, org.springframework:sprin g-orm:${spring.version}, commons-pool:commons-pool:1.5.6, commons-dbcp:commons-dbcp:1.3]
わおっ!!設定ファイルが生成された。pom.xml も更新されるようだ。正直、pom.xml は過去にも良く見かけたことがあったのだが、何者であるか知らなかった。Maven関連のファイルらしいと気付く。Mavenも、名前だけで何だか知らなかったのだけどね。
これも、これから勉強予定。
そして、今度はエンティティクラス生成かな?
Memberクラスを打ち込む。
が、しかし生成されず、Userクラスはどうか?
やはり駄目。
roo> entity jpa --class model.Member --testAutomatically Reserved SQL keyword 'Member' is not permitted as simple type name model.Member roo> field string --fieldName lastName --notNull The type specified, 'model.Member'doesn't exist model.Member roo> entity jpa --class ~.User --testAutomatically Reserved SQL keyword 'User' is not permitted as simple type name
お手本通り、Timerクラスで打ち込むと成功。でも、そんなエンティティはいらない。
調べてみると、オプション(–permitReservedWords)を付加すると、作成されるらしい。
どうも簡単な単語は、はじかれてしまうようだ。Order とか。ちょっと腑に落ちない。
~.Member roo> entity jpa --class ~.Member --testAutomatically --permitReservedWords Created SRC_MAIN_JAVA\com\whoocus\sample\Member.java Created SRC_TEST_JAVA\com\whoocus\sample\MemberDataOnDemand.java Created SRC_TEST_JAVA\com\whoocus\sample\MemberIntegrationTest.java Created SRC_MAIN_JAVA\com\whoocus\sample\Member_Roo_Configurable.aj Created SRC_MAIN_JAVA\com\whoocus\sample\Member_Roo_Jpa_Entity.aj Created SRC_MAIN_JAVA\com\whoocus\sample\Member_Roo_Jpa_ActiveRecord.aj Created SRC_MAIN_JAVA\com\whoocus\sample\Member_Roo_ToString.aj Created SRC_TEST_JAVA\com\whoocus\sample\MemberDataOnDemand_Roo_Configurable.aj Created SRC_TEST_JAVA\com\whoocus\sample\MemberDataOnDemand_Roo_DataOnDemand.aj Created SRC_TEST_JAVA\com\whoocus\sample\MemberIntegrationTest_Roo_Configurable.aj Created SRC_TEST_JAVA\com\whoocus\sample\MemberIntegrationTest_Roo_IntegrationTest.aj
成功!!
ソースファイルフォルダを見てみると、ソースファイル出来てます。感動です。
まるで、Ruby on Rails のようです。まあ、Rails っぽかったから、SpringRoo に挑戦している訳ですが…。
そして、Memberクラスのフィールド定義。
~.Member roo> field string --fieldName lastName --notNull Updated SRC_MAIN_JAVA\com\whoocus\sample\Member.java Updated SRC_TEST_JAVA\com\whoocus\sample\MemberDataOnDemand_Roo_DataOnDemand.aj Created SRC_MAIN_JAVA\com\whoocus\sample\Member_Roo_JavaBean.aj ~.Member roo> field string --fieldName firstName --notNull Updated SRC_MAIN_JAVA\com\whoocus\sample\Member.java Updated SRC_TEST_JAVA\com\whoocus\sample\MemberDataOnDemand_Roo_DataOnDemand.aj Updated SRC_MAIN_JAVA\com\whoocus\sample\Member_Roo_JavaBean.aj ~.Member roo> field int --fieldName age --notNull
わおっわおっ。Javaのソースコードも更新されている。ナイス。
package com.whoocus.sample; import javax.validation.constraints.NotNull; import org.springframework.roo.addon.javabean.RooJavaBean; import org.springframework.roo.addon.jpa.activerecord.RooJpaActiveRecord; import org.springframework.roo.addon.tostring.RooToString; @RooJavaBean @RooToString @RooJpaActiveRecord public class Member { @NotNull private String lastName; @NotNull private String firstName; }
調子に乗って、int型のフィールドを定義しようとしたが、エラー。
Integer型ならどうだっ? エラー。
~.Member roo> field int --fieldName age --notNull Command 'field int --fieldName age --notNull' not found (for assistance press TAB or type "hint" then hit ENTER) At this time you have not authorized Spring Roo to download resources from VMware domains. Some Spring Roo features are therefore unavailable. Please type 'download status' and press ENTER for further information. Spring Roo automatic add-on discovery service currently unavailable ~.Member roo> field integer --fieldName age --notNull Command 'field integer --fieldName age --notNull' not found (for assistance press TAB or type "hint" then hit ENTER)
どうやら、int型の指定方法は下記のようだ。
~.Member roo> field number --fieldName age --type int
おやつの時間なので、とりあえずここまで。
また次回。
何度もやっているのだが、たまにしか行わないために覚え書き。
まずは、httpd設定ファイルへの設定。
http://xxx.xxx.xxx/hoge へアクセスする場合の設定となる。
$ mv /etc/httpd/conf.d/ $ vi hoge.conf <Location /hoge> AuthType Basic AuthName "Whoocus" AuthUserFile /etc/httpd/auth_file/.hoge_passwd_file # パスワードファイルの場所 Require valid-user </Location>
そして、パスワードファイルの作成
新規にパスワードファイルを作成する場合は -c オプションを付加する。
$ htpasswd -c /etc/httpd/auth_file/.hoge_passwd_file whoocus New password: ***** Re-type new password: *****
Webサーバの再起動。
$ /etc/rc.d/init.d/httpd restart
これでBasic認証の設定完了。