カテゴリ: JPA

https://blogs.oracle.com/wlc/entry/%E9%80%A3%E8%BC%89_weblogic_server_12c%E3%81%A7java_ee3
をやると、
Java Resources/src/managed/IndexBean.java の import javax.faces.bean.ManagedBean; がエラー。
何かライブラリをリンクする必要があるのかしら。
→OEPEにて、プロジェクトのプロパティからプロジェクトファセットを表示、JSFファセットを追加。その際にMojarraのライブラリ(javax.faces.jar)がダウンロードされるのでそれを使うととりあえずコンパイルは通るが…WebLogicJSFのライブラリ持ってるような気がするんだよな。

Separate JSF and JSTL JAR files and implementation JAR files are also provided in the WL_HOME/server/lib/api.jar file. You can reference these JAR files for compilation purposes or when using other utilities while developing Web applications.

http://docs.oracle.com/cd/E24329_01/web.1211/e21049/configurejsfandjtsl.htm

と言ってるけど。しかしapi.jarはとっくにクラスパスに入ってた謎。
→上のは12.1.1の話だった。12.1.2では

The JSF and JSTL libraries are bundled as WAR files and are located in the WL_HOME/common/deployable-libraries directory. The JSF libraries include the JSTL JAR files for convenience, so that if an application references a JSF library, it automatically gets JSTL support as well.

http://docs.oracle.com/middleware/1212/wls/WBAPP/configurejsfandjtsl.htm#WBAPP198

というか https://blogs.oracle.com/wlc/entry/%E9%80%A3%E8%BC%89_weblogic_server_12c%E3%81%A7java_ee1 をやってみればいいのか。

このエントリーをはてなブックマークに追加 mixiチェック

こないだから動かないOpenJPA、どうもTopLinkと異なり、ビルド時にエンハンスという作業が必要らしい。

このエントリーをはてなブックマークに追加 mixiチェック

実行時にまた別のエラー。

Exception in thread "main" org.apache.openjpa.persistence.ArgumentException: This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at class load time with a javaagent: "
com.ufjis.jpa.company.entity.Employee".
at org.apache.openjpa.enhance.ManagedClassSubclasser.prepareUnenhancedClasses(ManagedClassSubclasser.java:116)
at org.apache.openjpa.kernel.AbstractBrokerFactory.loadPersistentTypes(AbstractBrokerFactory.java:317)
at org.apache.openjpa.kernel.AbstractBrokerFactory.initializeBroker(AbstractBrokerFactory.java:241)
at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:215)
at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:156)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:227)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:154)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:60)
at com.ufjis.jpa.company.main.JpaSelectMain.main(JpaSelectMain.java:25)

このメッセージは、リストされたエンティティー・タイプにおいて期待されるランタイム拡張が実行されなかったことを示しています
ほとんどの場合、これは単なるビルド時の障害であり、リストされたクラスに対して PCEnhancer を実行する必要があります。
また、特にエンティティー拡張でコンテナー・クラス・ローダーの変換を実行する予定である場合などで、
他の問題が関係していることも示している可能性があります。
このエントリーをはてなブックマークに追加 mixiチェック

昨日動いたTopLinkサンプルJavaソースをそのままに、JPAの実装ライブラリだけOpen JPAのopenjpa-all-2.0.1.jarに置換。persistence.xmlを書き換えればそのまま動く……と美しいんだけど、やはりそうは上手く行かず実行時に以下のエクセプション

1000 MyPersistenceUnit WARN [main] openjpa.jdbc.Schema - Existing column "DEPARTMENT_NAME" on table "APP.EMPLOYEE" is incompatible with the same column in the given schema definition. Existing column:
Full Name: EMPLOYEE.DEPARTMENT_NAME
Type: varchar
Size: 30
Default: null
Not Null: false
Given column:
Full Name: EMPLOYEE.DEPARTMENT_NAME
Type: varchar
Size: 255
Default: null
Not Null: true

1000 MyPersistenceUnit WARN [main] openjpa.jdbc.Schema - Existing column "EMPLOYEE_NAME" on table "APP.EMPLOYEE" is incompatible with the same column in the given schema definition. Existing column:
Full Name: EMPLOYEE.EMPLOYEE_NAME
Type: varchar
Size: 30
Default: null
Not Null: false
Given column:
Full Name: EMPLOYEE.EMPLOYEE_NAME
Type: varchar
Size: 255
Default: null
Not Null: true

Exception in thread "main" org.apache.openjpa.persistence.ArgumentException: This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at class load time with a javaagent: "
com.ufjis.jpa.company.entity.Employee".
at org.apache.openjpa.enhance.ManagedClassSubclasser.prepareUnenhancedClasses(ManagedClassSubclasser.java:116)
at org.apache.openjpa.kernel.AbstractBrokerFactory.loadPersistentTypes(AbstractBrokerFactory.java:317)
at org.apache.openjpa.kernel.AbstractBrokerFactory.initializeBroker(AbstractBrokerFactory.java:241)
at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:215)
at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:156)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:227)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:154)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:60)
at com.ufjis.jpa.company.main.JpaSelectMain.main(JpaSelectMain.java:25)

実際、カラム長は30が正解なので255は一体どこから…。値からしてデフォルト値っぽいのでOpenJPAの場合はどこかでカラム長の指定が必要なのだろうか。必要なのだろうな。

このエントリーをはてなブックマークに追加 mixiチェック

マスタリングJavaEE5 (CD-ROM付) (Programmer’s SELECTION)TopLinkのサンプルを手入力して実行してみたら…

The following providers:
oracle.toplink.essentials.PersistenceProvider
Returned null to createEntityManagerFactory.

素直にCD-ROMのを見るか。
→persistence.xmlのどこかが間違ってた模様。入れ替えたら成功(いい加減だな)。
■豆知識
必要なjarはtoplink-essensial.jarとJDBCドライバ(今回はderby.jar)
■豆知識
Derbyに直接接続しようとして org.apache.derby.jdbc.EmbeddedDriver を使うとき、persistence.xml 中にプロパティ USER を記述してはならない。記述するとエクセプションが発生する。

Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: Schema 'USER' does not exist
以下エクセプション
Caused by: ERROR 42Y07: Schema 'USER' does not exist
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.getSchemaDescriptor(Unknown Source)
at org.apache.derby.impl.sql.compile.QueryTreeNode.getSchemaDescriptor(Unknown Source)
at org.apache.derby.impl.sql.compile.QueryTreeNode.getSchemaDescriptor(Unknown Source)
at org.apache.derby.impl.sql.compile.FromBaseTable.bindTableDescriptor(Unknown Source)
at org.apache.derby.impl.sql.compile.FromBaseTable.bindNonVTITables(Unknown Source)
at org.apache.derby.impl.sql.compile.FromList.bindTables(Unknown Source)
at org.apache.derby.impl.sql.compile.SelectNode.bindNonVTITables(Unknown Source)
at org.apache.derby.impl.sql.compile.DMLStatementNode.bindTables(Unknown Source)
at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(Unknown Source)
at org.apache.derby.impl.sql.compile.CursorNode.bindStatement(Unknown Source)
at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source)
at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source)
at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown Source)
... 29 more

まぁそういう事もある。
ちなみにderbyを別プロセスで起動して org.apache.derby.jdbc.ClientDriver で接続する時は必要と思う。
■豆知識
toplink.logging.levelに ログレベル Fine を指定すると、発行するSQLがログに出る。

このエントリーをはてなブックマークに追加 mixiチェック

いつも忘れるので。
Oracle の sqlplusにあたるのは ij.bat。
ありかは

C:\Program Files\Sun\JavaDB\bin

最初は create=true を付ける。

connect 'jdbc:derby:c:\tmp\samle1;create=true';

show tables;

でテーブル一覧

このエントリーをはてなブックマークに追加 mixiチェック

JPAの実装はTopLinkを推すのかKodoを推すのか…。
GlassFishWebLogicか、に置き換えて考えると後者なのかな?

このエントリーをはてなブックマークに追加 mixiチェック

↑このページのトップヘ