Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

reflection and overloading, java.lang.IllegalArgumentException: wrong number of arguments

 
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am testing an ejb with a client which uses the Junit framework.
On the ejb I have two public methods

public User getUser(final String email, final String domain)
public User getUser(final Long id)

the client code is something like this


called by a junit test


The test doesn't complete correctly and I get this exception
834 [main] FATAL eu.virtualLab.security.user.test.util.ServiceLocator - java.lang.IllegalArgumentException: wrong number of arguments
835 [main] FATAL eu.virtualLab.security.user.test.junit.JunitUserActions - [testGetUser] wrong number of arguments

Could you please give me some help about it?
Thanks in advance
 
Marshal
Posts: 76486
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't know, sorry, but that looks too difficult for us beginners. Moving.
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks to me like you have to find a better way of caching methods. You have 2 methods with different numbers of parameters. Whichever is the first one that is searched for will be cached and returned for any time another method with the same method name is called. This will cause problems when you would have overloaded methods with different single parameters as well (for example a getUser(Long) and a getUser(Integer)).

I would suggest putting more information in the cache's key, for example the method name and the list of parameter types. For example this would be a utility method that could help you generate a more useful key:


You could call it in your getRemoteMethod() method like:

 
Alessandro Ilardo
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you, you're right
 
Poop goes in a willow feeder. Wipe with this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic