• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't deploy EJB to JBOSS after adding '@ejb.finder' clause

 
Ivan
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I use Eclipse to build CMP, I could deploy the applicaton to JBOSS previously, but encounter the following error message after adding the '@ejb.finder' clause in UserBean. Please help.

[Server.log]
2005-07-26 02:06:32,562 WARN [org.jboss.ejb.EJBDeployer.verifier] EJB spec violation:
Bean : User
Method : public abstract Collection listAll() throws FinderException, RemoteException
Section: 12.2.9
Warning: Each home method must match a method defined in the entity bean class.

2005-07-26 02:06:32,578 DEBUG [org.jboss.ejb.EJBDeployer.verifier] Bean checked: Fibo: Verified.
2005-07-26 02:06:32,578 ERROR [org.jboss.deployment.MainDeployer] Could not create deployment: file:/C:/jboss-4.0.3RC1/server/default/tmp/deploy/tmp55480FiboApp.ear-contents/FiboEJB.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)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:118)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)



[UserBean]
.....
/**
* @ejb.bean name="User"
* display-name="Name for User"
* description="Description for User"
* jndi-name="ejb/User"
* type="CMP"
* cmp-version="2.x"
* view-type="both"
*
* @ejb.finder
* signature="java.util.Collection listAll()"
* query="SELECT OBJECT(c) FROM USER c"
*
* @jboss.query
* signature="java.util.Collection listAll()"
* query="SELECT OBJECT(c) FROM USER c"
*/
public abstract class UserBean implements EntityBean {

public UserBean() {
super();
// TODO Auto-generated constructor stub
}
......




[ejb-jar.xml]
.....
<!-- Entity Beans -->
<entity >
<description><![CDATA[Description for User]]></description>
<display-name>Name for User</display-name>

<ejb-name>User</ejb-name>

<home>tutorial.interfaces.UserHome</home>
<remote>tutorial.interfaces.User</remote>
<local-home>tutorial.interfaces.UserLocalHome</local-home>
<local>tutorial.interfaces.UserLocal</local>

<ejb-class>tutorial.ejb.UserCMP</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>tutorial.interfaces.UserPK</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>User</abstract-schema-name>
<cmp-field >
<description><![CDATA[Getter for CMP Field userid]]</description>
<field-name>userid</field-name>
</cmp-field>
<cmp-field >
<description><![CDATA[Getter for CMP Field password]]</description>
<field-name>password</field-name>
</cmp-field>
<cmp-field >
<description><![CDATA[Getter for CMP Field group]]></description>
<field-name>group</field-name>
</cmp-field>

<query>
<query-method>
<method-name>listAll</method-name>
<method-params>
</method-params>
</query-method>
<ejb-ql><![CDATA[SELECT OBJECT(c) FROM USER c]]></ejb-ql>
</query>
<!-- Write a file named ejb-finders-UserBean.xml if you want to define extra finders. -->
</entity>
.....



Ivan
 
norman richards
Author
Ranch Hand
Posts: 367
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Finder methods must start with "find", so change your method name to "findAll".
 
Ivan
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks ! I can now deploy the application to Jboss successfully.
However, there is an exception when I can call the "findAll()" function in CMP thru' JSP.

11:20:09,734 ERROR [User#findAll] Find failed
java.sql.SQLException: Table 'irs.xuser' doesn't exist
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2921)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1570)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2978)

I haven't defined any sql setting like 'irs.xuser' and I don't know where it come from. Seems it is generated by xdoclet or EJBQL.
"irs" is the mySQL database name of my application and 'user' should be the valid table name of my bean

Below please find my program setting

[UserBean]
.....
import ....
/**
* @ejb.bean name="User"
* display-name="Name for User"
* description="Description for User"
* jndi-name="ejb/User"
* type="CMP"
* cmp-version="2.x"
* view-type="both"
*
* @ejb.persistence table-name = "user"
*
* @ejb.transaction type= "Required"
*
* @ejb.finder
* signature="java.util.Collection findAll()"
* query="SELECT OBJECT(u) FROM User AS u"
*
*/
public abstract class UserBean implements EntityBean {

private EntityContext _context;

public UserBean() {
super();
// TODO Auto-generated constructor stub
}
........


[ejb-jar]
.....
<!-- Entity Beans -->
<entity >
<description><![CDATA[Description for User]]></description>
<display-name>Name for User</display-name>

<ejb-name>User</ejb-name>

<home>tutorial.interfaces.UserHome</home>
<remote>tutorial.interfaces.User</remote>
<local-home>tutorial.interfaces.UserLocalHome</local-home>
<local>tutorial.interfaces.UserLocal</local>

<ejb-class>tutorial.ejb.UserCMP</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>tutorial.interfaces.UserPK</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>User</abstract-schema-name>
<cmp-field >
<description><![CDATA[Getter for CMP Field userid]]></description>
<field-name>userid</field-name>
</cmp-field>
<cmp-field >
<description><![CDATA[Getter for CMP Field password]]></description>
<field-name>password</field-name>
</cmp-field>
<cmp-field >
<description><![CDATA[Getter for CMP Field group]]></description>
<field-name>group</field-name>
</cmp-field>

<query>
<query-method>
<method-name>findAll</method-name>
<method-params>
</method-params>
</query-method>
<ejb-ql><![CDATA[SELECT OBJECT(c) FROM User AS c]]></ejb-ql>
</query>
<!-- Write a file named ejb-finders-UserBean.xml if you want to define extra finders. -->
</entity>
.......

[jbosscmp-jdbc.xml]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 3.0//EN" "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_0.dtd">

<jbosscmp-jdbc>
<defaults>
<datasource>java:/MySqlDS</datasource>
<datasource-mapping>mySQL</datasource-mapping>
<create-table>false</create-table>
</defaults>
<enterprise-beans>
<!--
To add beans that you have deployment descriptor info for, add
a file to your XDoclet merge directory called jbosscmp-jdbc-beans.xml
that contains the <entity></entity> markup for those beans.
-->
<entity>
<ejb-name>User</ejb-name>
<cmp-field>
<field-name>userid</field-name>
<column-name>userid</column-name>
</cmp-field>
<cmp-field>
<field-name>password</field-name>
<column-name>password</column-name>
</cmp-field>
<cmp-field>
<field-name>group</field-name>
<column-name>group</column-name>
</cmp-field>
</entity>
</enterprise-beans>
</jbosscmp-jdbc>

Thanks
Ivan
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic