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
8
votes
4 answers

When does List.addAll() throw IllegalStateException?

I have code private List subFields; private Collection subFieldsCollection; ... try { if (subFields == null && subFieldsCollection != null && !subFieldsCollection.isEmpty()) { subFields = new ArrayList<>(); …
Marcel Bro
  • 4,907
  • 4
  • 43
  • 70
8
votes
3 answers

java.lang.IllegalArgumentException: bad base-64

I am trying to encode and decode a String using android.util.Base64, but it gives a bad base-64 error. The code with the problem is: private byte[] base64ToByte(String str) throws IOException { Log.i("encription", str); byte[]…
8
votes
1 answer

IllegalArgumentException when instantiating HttpClient in Android

In the google play console, I can see crash reports from users who complain because my application crashes just after starting. The cause seems to be an exception thrown when instantiating HttpClient. What am I doing wrong? Here is an extract from…
8
votes
3 answers

Java Reflection - Get size of array object

I was wondering if any knows hows to get the size of an array object using reflection? I have a Vehicles component containing an array object of type Car. Vehicles.java public class Vehicles{ private Car[] cars; // Getter and…
Harvey Sembhi
  • 287
  • 1
  • 5
  • 13
8
votes
2 answers

View not attached to window manager (whats the solution?)

I got hundreads of error reports from my app and all of them is the same. It is really annoying because in my test devices (HTC Wildfire, Galaxy S I-II-III, Galaxy Mini, Galaxy Tab 10) this error NEVER occured, neither to me or my test buddy, looks…
Adam Varhegyi
  • 11,307
  • 33
  • 124
  • 222
7
votes
2 answers

Android Proguard - IllegalArgumentException in Jackson's TypeReference class

Android application crashes if proguard is used for obfuscating. Below is the stacktrace. Caused by: java.lang.IllegalArgumentException: Internal error: TypeReference constructed without actual type information at…
500865
  • 6,920
  • 7
  • 44
  • 87
7
votes
2 answers

Runtime Error--java.lang.IllegalArgumentException: provider=gps

I got this error from the user logs on an android app I created. I have been unable to replicate the error thus far. Any help would be extremely appreciated. The error is: java.lang.IllegalArgumentException: provider=gps at…
Tommy Devoy
  • 13,441
  • 3
  • 48
  • 75
7
votes
2 answers

"Automatic" join fetching of nested entities fails after updating Hibernate

After upgrading to a newer hibernate version (guess it came with the switch from JBoss 4.2.2 to JBoss 6), some queries fail with the message: Caused by: java.lang.IllegalArgumentException: org.hibernate.QueryException: query specified join…
Sebastian Wramba
  • 10,087
  • 8
  • 41
  • 58
7
votes
8 answers

Invalid version number: Version number may be negative or greater than 255

I am getting below error when I try to access a page in my application. SEVERE: Servlet.service() for servlet [jsp] threw exception java.lang.IllegalArgumentException: Invalid version number: Version number may be negative or greater than 255 at…
JAVA_CAT
  • 737
  • 3
  • 13
  • 33
7
votes
2 answers

IllegalArgumentException: wrong number of arguments in Java Constructor.newInstance()

Consider the following code, public class StartUp { public StartUp(String[] test){} public static void main(String[] args) throws Exception{ Constructor cd = StartUp.class.getConstructor(String[].class); …
xandy
  • 27,357
  • 8
  • 59
  • 64
7
votes
1 answer

javafx IllegalArgumentException (is already set as root of another scene)

I have problem with changing scenes in my application which looks like Main screen > Login screen I am storing screens in main file as hashmap and everything is good until I go back from login screen to main screen and want to load…
Jason Bourne
  • 95
  • 1
  • 5
7
votes
4 answers

java.lang.IllegalArgumentException - dialog.dismiss

I am getting this error in my published application, only clients receive this error. I already tried several times to replicate the same mistake however unsuccessfully. I also already tried to use the below code at all locations where there is a…
tiagosito
  • 111
  • 2
  • 11
7
votes
1 answer

java.lang.IllegalArgumentException: Servlet mapping specifies an unknown servlet name GCMBroadcast

I'm trying to incorporate GCM(Google cloud messaging) in my android app. For this, I have been following this tutorial. Comments below it report success, so definitely the problem is on my side and not the tutorial. Info- I'm running latest Eclipse…
7
votes
1 answer

java.lang.IllegalArgumentException: No view found for id 0x7f090047 ("project name":id/content) for fragment FmMenu

Just wanted to share an issue that I have with a project that I am doing for a client. Whenever I enter to my IntroActivity and press the button to take me to MenuActivity, it crashes. Here is the error log: 02-16 18:49:49.393 …
w_lpz
  • 613
  • 4
  • 15
  • 28
7
votes
3 answers

Is this the correct way to use an IllegalArgumentException?

I'm trying to work on a Java assignment. This is what it asks: Write a class named TestScores. The class constructor should accept an array of the test scores as its argument. The class should have a method that returns the average of the test…
Alexandria
  • 87
  • 1
  • 1
  • 3