Problem with return cardinality of my Entity-Bean

Hi all,

i'm using Sun Java Studio Enterprise 8.1 and i try to create a EJB CMP Entity-Bean, it's name is Customer. But i become an error during the deploy. By the method findByName(String name) i selected as return cardinality "Many" and become below error. If i select "One" as return cardinality then is this error away.

What is here wrong? Every time when i create an EntityBean i become this error, but just by "Many" return cardinality. Can anyone help me to solve this problem?

thanks

Bean: CustomerBean

Method : public abstract Collection findByName(String) throws FinderException

Section: 10.5.6

Warning: Every finder method except findByPrimaryKey(key) must be associated with a query element in the deployment descriptor.

01:06:32,031 ERROR [MainDeployer] Could not create deployment: file:/C:/jboss-4.0.3SP1/server/default/tmp/deploy/tmp26541bank.ear-co

ntents/Bank-ejb.jar

org.jboss.deployment.DeploymentException: Verification of Enterprise Beans failed, see above for error messages.

at org.jboss.ejb.EJBDeployer.create(EJBDeployer.java:575)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:14 1)

at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)

at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:11 8)

at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)

at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperat ionInterceptor.java:127)

at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:80)

at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)

at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)

at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)

at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)

at $Proxy24.create(Unknown Source)

at org.jboss.deployment.MainDeployer.create(MainDeployer.java:935)

at org.jboss.deployment.MainDeployer.create(MainDeployer.java:925)

at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:789)

at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:753)

at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:14 1)

at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)

at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:11 8)

at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)

at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperat ionInterceptor.java:127)

at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)

at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)

at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)

at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)

at $Proxy9.deploy(Unknown Source)

at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.j ava:319)

at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.jav a:489)

at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(Abs tractDeploymentScanner.java:192)

at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(Abstr actDeploymentScanner.java:203)

at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(Abstra ctDeploymentScanner.java:182)

01:07:17,406 INFO [EJBDeployer] Undeploying: file:/C:/jboss-4.0.3SP1/server/default/tmp/deploy/tmp26541bank.ear-contents/Ban k-ejb.j

ar

[4307 byte] By [mrXa] at [2007-11-27 9:49:20]
# 1

Since the error happens only when 'many' cardinality is used, the problem could that ejb-jar.xml could be missing a findAll entry, somwhat like

<query>

<query-method>

<method-name>findAll</method-name>

<method-params>

</method-params>

</query-method>

<ejb-ql><! [CDATA [SELECT OBJECT (o) from Table AS o]] ></ejb-ql>

</query>

Can you check if this is the case?

KarthikRa at 2007-7-13 0:17:51 > top of Java-index,Development Tools,Java Tools...
# 2

Hi KarthikR,

thak you for your help. this was the problem. but i don't know why must be "findAll"-function available in ejb-jar.xml. i thought there must be just "findByPrimaryKey"-function.

best regards

p.s.: do you know, when can we use EJB 3.0 with Sun Java Studio Enterprise or we must pay costs.

mrXa at 2007-7-13 0:17:51 > top of Java-index,Development Tools,Java Tools...
# 3

As you have noted, for 'One' cardinality findByPrimaryKey is sufficient since a primary key is used to locate unique records. But for 'many' cardinality, the system needs to know how to locate a collection of records and hence the need for findAll in the specification.

Regarding EJB 3.0, i suggest that you use NetBeans.

Note: Java Studio Enterprise 8.1 is itself built on top of NetBeans version 5.0. NetBeans is an ide developed as opensource at www.netbeans.org; it is extensible ide and so add-on modules can be developed to run on top of netbeans. And that is what JSE8.1 does; JSE 8.1 is NetBeans 5.0 plus several add-on modules (like UML etc).

The latest stable version of NetBeans is 5.5.1 and NetBeans 6.0 is currently under development with milestone 10 being the latest release.

Home page: www.netbeans.org

Download: http://www.netbeans.info/downloads/index.php (From the main page, you can also download several packs which are addons that provide various functionality).

Docs: http://www.netbeans.org/kb/index.html

Docs on EE apps: http://www.netbeans.org/kb/trails/java-ee.html

Further community resources (mailing lists, issue tracking etc) : http://www.netbeans.org/community/index.html

wiki.netbeans.org

NetBeans download is free. And since it is developed as an opensource project, the source is freely available under CDDL license (http://www.netbeans.org/about/legal/license.html)

KarthikRa at 2007-7-13 0:17:51 > top of Java-index,Development Tools,Java Tools...