• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

findByPrimaryKey not being called

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When attempting to set a remote equal to the results of a findByPrimaryKey method call, all that is returned is null. The relevant code is below.

From home class:

public BlueMCBPNetPMPMFactorsEJBRemote findByPrimaryKey(BlueMCBPNetPMPMFactorsEJBPK pk)
throws ObjectNotFoundException, RemoteException, FinderException ;

From ejb class:

public BlueMCBPNetPMPMFactorsEJBPK ejbFindByPrimaryKey(BlueMCBPNetPMPMFactorsEJBPK pk) throws ObjectNotFoundException, RemoteException, FinderException {
System.out.println("findbypk");
return pk;
}

From calling class:

Object obj = ctx.lookup("com/anthem/corp/bms/user/group/benefits/rating/health/blue/BlueMCBPNetPMPMFactorsEJB");

BlueMCBPNetPMPMFactorsEJBHome home = (BlueMCBPNetPMPMFactorsEJBHome) PortableRemoteObject.narrow(obj,BlueMCBPNetPMPMFactorsEJBHome.class);

BlueMCBPNetPMPMFactorsEJBRemote remote = home.findByPrimaryKey(pk);

When this last line runs, the servlet simply returns 'null' and stops. I've used print lines and know that the home and pk objects are NOT null. Also, the println code in the ejbFindByPrimaryKey method of the ejb does not write to the console. It appears that the method is never being executed but I don't know why.

Any help would be greatly appreciated!
 
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



BlueMCBPNetPMPMFactorsEJBRemote remote = home.findByPrimaryKey(pk);



What is the type of pk in home.findByPrimaryKey(pk), you didn't mention that. That might be the cause of not calling the program findByPrimaryKey(...PKclass pk). The function signature might be different between calling and being called program.
 
Joe Honaker
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The pk type is BlueMCBPNetPMPMFactorsEJBPK which matches the method signature. Here's the line that creates the pk:

BlueMCBPNetPMPMFactorsEJBPK pk = new BlueMCBPNetPMPMFactorsEJBPK(....);
 
Damanjit Kaur
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Now I am also getting this problem. But I don't get this problem when I call findByPrimaryKey method from a session bean by using local interfaces. I get this problem only while accessing this method from a client program using remote interface to directly interact with entity beans. I get the exception for invalid invokation, check deployment packaging.

In my jboss.xml and ejb-jar.xml file I have mentioned the local references ( <ejb-local-ref> to entity bean in session bean tags. I don't know if that is prohibiting the use of remote method call. But it should not be, because its just mentioned specifically for session bean only which has to use local interfaces to invoke methods locally.
 
Joe Honaker
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem was in the primary key class. I was attempting to create the hashcode value with the following line of code:

public int hashCode() {
return new Integer(assocID + String.valueOf(effectiveDate) + groupState + product + edition + groupRateAs).intValue();
}

The Integer constructor when using a String parm states that it throws a NumberFormatException. However, the compiler did not enforce me using the statement above in a try/catch block. When the code ran, it did throw the error because you can't get an intValue() from a String - you need to use hashCode() for a string. Because this code wasn't in a try/catch it just "got lost" in the ejb container and simply threw back 'null' as an error. Below is the code that replaced the above and is working fine:

public int hashCode() {
if(hashCode == 0){
hashCode = new String(assocID + String.valueOf(effectiveDate) + groupState + product + edition + groupRateAs).hashCode();
}
}
Note: The hashCode variable is an instance variable to the pk class.
return hashCode;
 
Damanjit Kaur
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
O.K. strange problem!! but good to know that things like this can also happen.

But my problem got solved itself without me doing anything and to this date I couldn't make how exactly. Although it seemed to be relating to JVM. I was running eclipse3.0.1,Jboss4.0 with jdk1.5 but was having some problem running JBoss from eclipse. It ran with some errors. So I re-install jdk1.4 and things are fine.

Happy New Year!!
 
Why fit in when you were born to stand out? - Seuss. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic