Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NoSuchMethodError while accessing Entity bean via a Struts Action

 
Subhash Bhushan C
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have an action class ProfileDetailAction, which implements the getter/setter methods related to Profiles. I have 2 classes RegistrationAction and AlterProfileAction extending from it.

I have an EJB 3.0 entity class called ProfileDetail which is mapped to an underlying table in MySQL.

ProfileDetailAction.java:


RegistrationAction.java:


ProfileDetail.java:


The firstName variable in ProfileDetail action is getting filled properly (I am able to see them in debug mode.)
When setFirstName() gets called in RegistrationAction, I get the following error:

java.lang.NoSuchMethodError: com.justbooks.entities.ProfileDetail.setFirstName(Ljava/lang/String


I am not sure whether this is a classloader problem, or I am doing something wrong. I am using JBoss, with MySQL DB. I am using Eclipse, and the IDE does not throw up any errors too.

Any clues are welcome.
 
Marimuthu Madasamy
Ranch Hand
Posts: 72
Java Monad Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got one clue from the error message you got,

java.lang.NoSuchMethodError: com.justbooks.entities.ProfileDetail.setFirstName(Ljava/lang/String


see there is 'L' in the parameter class, that means it is expecting a method having a String array as parameter like this,

com.justbooks.entities.ProfileDetail.setFirstName(String[] arg)

- Marimuthu M
 
Anubhav Anand
Ranch Hand
Posts: 341
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I once received similar kind of error message
java.lang.NoSuchMethodError: .Something.(Ljava/lang/String


In my case it was a problem because of conflict of JDK versions.The error was caused by a JDK (Java Development Kit) version incompatibility.

So, as far as my knowledge goes such errors occur when you compile a class with one version of the JDK, then run them with an older JVM (Java Virtual Machine).

Might be same is true in your case.
 
Subhash Bhushan C
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Marimuthu Madasamy:
I got one clue from the error message you got,



see there is 'L' in the parameter class, that means it is expecting a method having a String array as parameter like this,

com.justbooks.entities.ProfileDetail.setFirstName(String[] arg)

- Marimuthu M


Hmm... Actually, the signature seems to be correct. Please refer this link: http://www.rgagnon.com/javadetails/java-0286.html

From that, its clear that my method's signature is right.
-----------------------------------------
public java.awt.Label(java.lang.String);
/* (Ljava/lang/String V */
-----------------------------------------

Anand,
I have only one Java version on my laptop, jdk1.5.0_01, which is being used by both Eclipse (my IDE) and JBoss (my App Server). I saw quite a number of posts on the net indicating it might be a version mismatch. But I dont think that applies to this situation. But will keep looking.
 
Anubhav Anand
Ranch Hand
Posts: 341
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just for a check. Verify if the version of JRE libraries is also consistent(between eclipse and JBoss). I mean if both use the same JDK but if somehow by chance both use differenr patches of JRE libraries .
They may also pose problems.
 
Marimuthu Madasamy
Ranch Hand
Posts: 72
Java Monad Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh.. sorry.. i misunderstood. Thanks for the link Subhash.

coming to your problem, one more thing you can do is,

use javap to inspect the compiled ProfileDetail class in the deployed web application whether it has the setFirstName method. If it is not there, then try cleaning and rebuilding the project.

- Marimuthu M
 
Anubhav Anand
Ranch Hand
Posts: 341
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Marimuthu Madasamy:
use javap to inspect the compiled ProfileDetail class in the deployed web application whether it has the setFirstName method. If it is not there, then try cleaning and rebuilding the project.
- Marimuthu M


Very true. This can also be the case. well pointed Marimuthu
 
Subhash Bhushan C
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solved it...


You guys wont believe what the problem was...
JBoss was not replacing old class files with new files in a newly deployed EAR. So, the first version of the file was being referenced. Once I cleaned up the deployment directory, everything worked just fine...

Thanks for the help, guys...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic