Hi everyone,
I wrote an entity EJB(TestBean), which has a findByPrimaryKey(TestPrimaryKey priKey) method, but I always got a NoSuchMethodError while calling it from a client class. Here is the error message:
-----------------------------------------------------
java.lang.NoSuchMethodError
at com.softtracks.skypay.skyfront.info.test.TestBeanHomeImpl.findByPrimaryKey(TestBeanHomeImpl.java:57)
at com.softtracks.skypay.skyfront.info.test.TestBeanHomeImpl_ServiceStub.findByPrimaryKey(TestBeanHomeImpl_Servi
ceStub.java:186)
------------------------------------------------------
I checked the TestBean.jar file and looked into TestBeanHomeImpl.java, which do has findByPrimaryKey() method, the line 57 is:
57: weblogic.ejb.internal.MethodInfo __mi = findMethodInfo(__methodSig);
I used Weblogic ejbc to generate those EJB classes.
Thanks a lot for any help!!!
George
-
findByPrimaryKey() error (8 messages)
- Posted by: George Mu
- Posted on: June 18 2002 14:16 EDT
Threaded Messages (8)
- findByPrimaryKey() error by Mark Hills on June 18 2002 14:41 EDT
- findByPrimaryKey() error by George Mu on June 18 2002 15:09 EDT
-
findByPrimaryKey() error by sony thomas on June 18 2002 03:43 EDT
- findByPrimaryKey() error by Mark Hills on June 18 2002 04:24 EDT
- findByPrimaryKey() error by George Mu on June 18 2002 04:28 EDT
- findByPrimaryKey() error by hoi tsang on June 18 2002 04:18 EDT
-
findByPrimaryKey() error by hoi tsang on June 18 2002 06:04 EDT
- findByPrimaryKey() error by George Mu on June 18 2002 06:43 EDT
-
findByPrimaryKey() error by sony thomas on June 18 2002 03:43 EDT
- findByPrimaryKey() error by George Mu on June 18 2002 15:09 EDT
-
findByPrimaryKey() error[ Go to top ]
- Posted by: Mark Hills
- Posted on: June 18 2002 14:41 EDT
- in response to George Mu
You may want to verify that the findByPrimaryKey() method is using your custom class as the primary key class, versus using one of the basic types like a string or a primitive type, and that that is what you are passing in the call. Do you have a sample of the call and of the method code? -
findByPrimaryKey() error[ Go to top ]
- Posted by: George Mu
- Posted on: June 18 2002 15:09 EDT
- in response to Mark Hills
Thanks Mark,
I do have a custom class as a primary key. Actually, I've studied a lot of sample codes, and beleive ejb-jar.xml and weblogic-ejb-jar.xml has also been defined corretly, but I have no clue about what's wrong here.
---------------------------------------------------
TestBean.java
----------------------------------------------------
public class TestBean implements EntityBean {
EntityContext entityContext;
public TestPrimaryKey ejbCreate() throws CreateException {
/**@todo: Implement this method*/
return null;
}
public void ejbPostCreate() throws CreateException {
}
public void ejbLoad() {
}
public void ejbStore() {
}
public void ejbRemove() throws RemoveException {
}
public void ejbActivate() {
}
public void ejbPassivate() {
}
public void setEntityContext(EntityContext entityContext) {
this.entityContext = entityContext;
}
public void unsetEntityContext() {
entityContext = null;
}
public TestPrimaryKey ejbFindByPrimaryKey(TestPrimaryKey primKey) throws ObjectNotFoundException {
/**@todo: Implement this method*/
System.out.println("Start looking for Test Ejb:"+primKey.toString());
return primKey;
}
}
-------------------------------------------------
TestHome.java
-------------------------------------------------
public interface TestHome extends EJBHome {
public Test create() throws RemoteException, CreateException;
public Test findByPrimaryKey(TestPrimaryKey primKey) throws ObjectNotFoundException, RemoteException, FinderException;
}
------------------------------------------------------
TestClient.java
-----------------------------------------------------
public void test(){
try {
InitialContext initial = new InitialContext();
TestHome testHome = (TestHome)PortableRemoteObject.narrow(initial.lookup("Test"), TestHome.class);
Test test = (Test) PortableRemoteObject.narrow(testHome.findByPrimaryKey(new TestPrimaryKey(102)),Test.class);
} catch (Exception e){
System.out.println(e);
}
}
------------------------------------------------------
Thanks for help!!!
George
-
findByPrimaryKey() error[ Go to top ]
- Posted by: sony thomas
- Posted on: June 18 2002 15:43 EDT
- in response to George Mu
Try changing "ObjectNotFoundException" to "FinderException" in your TestPrimaryKey method signature.
ie :
public TestPrimaryKey ejbFindByPrimaryKey(TestPrimaryKey primKey) throws FinderException {
...
-
findByPrimaryKey() error[ Go to top ]
- Posted by: Mark Hills
- Posted on: June 18 2002 16:24 EDT
- in response to sony thomas
I would also remove the ObjectNotFoundException from the interface definition, at least for now. That may get things working...
Mark -
findByPrimaryKey() error[ Go to top ]
- Posted by: George Mu
- Posted on: June 18 2002 16:28 EDT
- in response to sony thomas
1. The same problem ocurred after removing ObjectNotFoundException from the interface definition.
2. I don't have actual code within the "todo" area.
-
findByPrimaryKey() error[ Go to top ]
- Posted by: hoi tsang
- Posted on: June 18 2002 16:18 EDT
- in response to George Mu
do u have actual code within the "todo" area?
-
findByPrimaryKey() error[ Go to top ]
- Posted by: hoi tsang
- Posted on: June 18 2002 18:04 EDT
- in response to George Mu
dude how are you going to return an remote interface without implementing the ejbFind method? you can return null for "findByPrimaryKey".If it couldn't find anything, it will throw the exception. yes you are passing in a primary key, but if you entity bean is not mapping to anything, what is the point of having this primary key, and of course, how can the container *load* the data?
my suggestion will be to map your entitybean with a dummy table (e.g. a simple user table with username and password),
then map your bean to this dummy table, and then try to run some test.
if you are using CMP, you don't have to implement this method. if you are using BMP, then you have to write the actual JDBC call to lookup the data.
a lot of examples on the net have crazy sql:
"SELECT * FROM [TABLE] WHERE Id=?".
you don't need to do a "SELECT *". you just need to:
"SELECT [primary key] FROM TABLE".
this will speed things up, and let the "ejbLoad" method to load the other data.
i hope that help.
-hoi -
findByPrimaryKey() error[ Go to top ]
- Posted by: George Mu
- Posted on: June 18 2002 18:43 EDT
- in response to hoi tsang
The problem has been solved. It's because of one weblogic jar file didn't included in the classpath.
Thanks everyone!
George