Questions tagged [illegalargumentexception]

An exception that indicates that the arguments supplied to a method or function are not valid for their intended purpose, or are different to the format expected by the method.

An exception that indicates that the arguments supplied to a method or function are not valid for their intended purpose, or are different to the format expected by the method.

This could occur as a result of many different actions, such as...

  1. You are calling a method that accepts a low-level object type for an argument (such as Object) but you're passing an object that is not one of the types expected by the method. For example, the method might be declaring the argument as an Object so that it can capture a range of different objects in the one method, but the code implementation of the method only allows objects of certain types (such as expecting a Number-based object, and you're passing a String).
  2. You're using methods that are building a dynamic structure for use in a different context, and the argument that you're passing is not valid for the other context. For example, you might be building an SQL statement, and you're passing an argument as a String for a database field that expects a Number. The database context would detect the error and report back the exception.

This type of exception may be hard to predict, as it won't be detected at compile-time, and may only show up under certain circumstances.

965 questions
3
votes
3 answers

Java validating parameters in a parameter wrapper class

I have a class whose constructor takes an object containing the parameters for that class (I'm sure there's a pretty name for this, but I don't know it), and I am considering my options for handling validation of the parameters. Should I do…
sara
  • 3,521
  • 14
  • 34
3
votes
2 answers

IllegalArgumentException: Not enough variable values available with RestTemplate?

I am trying to execute URL using RestTemplate like this - public static void main(String[] args) throws UnsupportedEncodingException { RestTemplate restTemplate = new RestTemplate(); String url =…
john
  • 11,311
  • 40
  • 131
  • 251
3
votes
1 answer

Bitmap size exceeds 32bits

I am scaling a Bitmap by using a seekbar. Whenever i increase the progress of seekbar, image scaling fails by giving error "Bitmap size exceeds 32bits". If i scale the image with default seekbar value. it gives an error "Illegal argument exception:…
user3864752
  • 143
  • 3
  • 15
3
votes
0 answers

getting random IllegalArgumentException on ContentResolver.delete() calls

On my android app we have a ContentProvider with a few tables and every content resolver call is done against the same list of URIs (one for each table) and all of them are working fine on testing enviroment. I can't reproduce the bug but from…
Budius
  • 39,391
  • 16
  • 102
  • 144
3
votes
3 answers

Spring 4 + Hibernate 4 IllegalArgumentException: Property 'sessionFactory' is required

I'm writing a DAL with Spring Data and Hibernate but I'm running into a IllegalArgumentException exception which is stopping my work. Here is the DALConf.java class which contains DataSource and persistence exception translation processor…
gvdm
  • 3,006
  • 5
  • 35
  • 73
3
votes
2 answers

About throwing IllegalArgumentException

I'm new to exceptions and this is what I know so far: throws and throw are different doing throw IllegalArgumentException I'll probably have to add throws IllegalArgumentException to the method signature IllegalArgumentException is an unchecked…
user3511965
  • 195
  • 1
  • 3
  • 9
3
votes
2 answers

Receiver not registered

I have a progamm with async task and a broadcast receiver to send a result code, so that Asynctask will know that app is working. But it crashes, sayin the receiver is unreggistred in main activity. I've registred one receiver in main activity,…
Mabjik
  • 255
  • 3
  • 5
  • 10
3
votes
3 answers

Android - Error - IllegalArgumentException: Window type can not be changed after the window is added

I am debugging an android app (which was unfortunately written by someone else). The app has a splash activity which lasts for 1 second and then the transitions to a landing page activity using an intent. The app was running fine until I noticed…
Surya
  • 173
  • 1
  • 3
  • 15
3
votes
2 answers

Apache POI: Exception while calculating formulae

I have gone through many questions posted here and referred POI documentation too, but i am not able to resolve this issue. Issue: When trying to re-calculate the formula i am getting an exception. Formula:…
Gaurav Gupta
  • 4,586
  • 4
  • 39
  • 72
3
votes
4 answers

setting Component Z Order results to illegal position

I have a JFrame where it uses a background Image as the content pane. I successfully did it my having an ImagePanel class. However, when I try to add others components, these components do not show. I guess that it is about the Z order so I tried to…
dgzz
  • 2,929
  • 6
  • 34
  • 56
3
votes
1 answer

IllegalArgumentException when Event occur, javafx

I have a fxml file which has registered a Controller. The Controller implements EventHandler and so the method handle(ActionEvent e). If the registered event occur the code in the handler method is processed, but not always. But this following…
mr.wolle
  • 1,148
  • 2
  • 13
  • 21
3
votes
3 answers

Should I throw IllegalArgmentException when 'user of given id not exist'?

Say we have a method changeUserName(Long id,String newName) which invokes the repository's findUser(Long id) to find the right user entity and then change its name. Is it appropriate to thow an IllegalArgmentException when findUser returns null ?…
Nozama
  • 244
  • 4
  • 8
3
votes
1 answer

How to use Invoke() if the invoked method takes in a variable number of parameters

I'm just starting to learn reflection and to do so I have a little Math app. The program wraps a logic class, and at runtime looks through the logic class it wraps for methods (in this case, add, subtract, multiply, and divide). The methods look…
Josh Monks
  • 129
  • 1
  • 2
  • 9
3
votes
2 answers

IllegalArgumentException caught when parsing URL with JSON String

I need to formulate a url with JSON data that will look something like http://someurl.com/passfail?parameter={"data1":"123456789","data2":"123456789"}, and I will need to pass it using JBoss's ClientResponse to get a response status. I first tried…
prog rice bowl
  • 788
  • 3
  • 19
  • 36
3
votes
1 answer

Compojure: Trap 500 URL Decoding Error

I have a web service in Compojure with one route that looks like this: "/myapp/dosomething/:input" This works well when :input is something normal for the app to handle, such as a word, a string of digits etc, but when garbage is put in, such…
David Williams
  • 8,388
  • 23
  • 83
  • 171