- PR -

JBossのデプロイエラーについて

1
投稿者投稿内容
ヤミーズ
常連さん
会議室デビュー日: 2004/09/06
投稿数: 27
お住まい・勤務地: 東京都世田谷区
投稿日時: 2005-10-10 17:53
いつもお世話になっております。
 ヤミーズと申します。

 JBoss入門という書籍を参考にEJBを勉強しておりますが、
書籍内にあるサンプルソースをデプロイすると下記エラーが発生し、
原因がわからず困っております。
申し訳ございませんが原因を指摘して頂けないでしょうか?

【エラー内容】
Bean : Counter
Method : public abstract Counter findByPrimarykey(String) throws RemoteException, FinderException
Section: 10.5.6
Warning: Every finder method except findByPrimaryKey(key) must be associated with a query element in the deployment descriptor.

16:59:37,956 ERROR [MainDeployer] Could not create deployment: file:/usr/local/jboss-4.0.3RC2/server/default/deploy/step1-ejb.jar
org.jboss.deployment.DeploymentException: Verification of Enterprise Beans failed, see above for error messages.
at org.jboss.ejb.EJBDeployer.create(EJBDeployer.java:564)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)


【ソース】
<ホームビーン>
public interface CounterHome extends EJBHome {

public Counter create(String Name, long Value)
throws RemoteException,CreateException;

public Counter findByPrimarykey(String Name)
throws RemoteException,FinderException;


public Collection findAll()
throws RemoteException,FinderException;

}

<ローカルビーン>
public interface Counter extends EJBObject {
public String getName() throws RemoteException;

public long getValue() throws RemoteException;
public void setValue(long Value) throws RemoteException;

public long getNextValue() throws RemoteException;
}

<ビーン>
public abstract class CounterBean implements EntityBean {
EntityContext ctx;

public abstract String getName();
public abstract void setName(String Name);

public abstract long getValue();
public abstract void setValue(long Value);

public String ejbCreate(String Name, long Value) throws CreateException {
setName(Name);
setValue(Value);
return null;
}

public long getNextValue(){
setValue(getValue() + 1);
return getValue();
}

public void ejbPostCreate(String Name, long Value){
}

public void setEntityContext(EntityContext ctx){
this.ctx = ctx;
}

public void unsetEntityContext(){
this.ctx = null;
}

public void ejbActivate(){ }
public void ejbPassivate(){}
public void ejbLoad(){}
public void ejbStore(){}
public void ejbRemove() {}
}

<設定ファイル>
<jbosscmp-jdbc>
<defaults>
<create-table>true</create-table>
<remove-table>true</remove-table>
</defaults>
<enterprise-beans>
<entity>
<ejb-name>Counter</ejb-name>
<table-name>Counter</table-name>
</entity>
</enterprise-beans>
</jbosscmp-jdbc>

<jboss>
<enterprise-beans>
<entity>
<ejb-name>Counter</ejb-name>
<jndi-name>ejb/step1/counter</jndi-name>
</entity>
</enterprise-beans>
</jboss>

<ejb-jar>
<enterprise-beans>
<entity>
<ejb-name>Counter</ejb-name>
<home>sample.ejb.CounterHome</home>
<remote>sample.ejb.Counter</remote>
<ejb-class>sample.ejb.CounterBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>

<abstract-schema-name>Counter</abstract-schema-name>
<cmp-field><field-name>name</field-name></cmp-field>
<cmp-field><field-name>value</field-name></cmp-field>
<primkey-field>name</primkey-field>
</entity>
</enterprise-beans>
</ejb-jar>
ヤミーズ
常連さん
会議室デビュー日: 2004/09/06
投稿数: 27
お住まい・勤務地: 東京都世田谷区
投稿日時: 2005-10-10 17:57
お世話になっております。

環境が記載しておりませんでしたので記載します。

Jboss    :jboss-4.0.3RC2
linuxカーネル:2.4.20-8

以上 宜しくお願いいたします。
typer
会議室デビュー日: 2003/09/30
投稿数: 13
投稿日時: 2005-10-13 17:31
findAll()メソッドに対するEJB-QLの指定が、ejb-jar.xmlに無いのが原因だと思います。
ejb-jar.xml内の"<primkey-field>name</primkey-field>"の次に以下の定義を
追加してみてください。

<query>
<query-method>
<method-name>findAll</method-name>
<method-params>
</method-params>
</query-method>
<ejb-ql><![CDATA[SELECT OBJECT(o) from Counter AS o]]></ejb-ql>
</query>

1

スキルアップ/キャリアアップ(JOB@IT)