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
5
votes
2 answers

Java Rest Template throws java.lang.IllegalArgumentException: Comparison method violates its general contract

I am not using any Comparators/Sorting in my Java code, still it is throwing " java.lang.IllegalArgumentException: Comparison method violates its general contract!" Exception. Below is the piece of code that throws exception on the…
Atharva
  • 83
  • 7
5
votes
1 answer

IllegalArgumentException: Wrong state class

For an Activity, I have two different layout files for portrait and landscape orientations. The elements of one orientation have direct relation to elements in the other orientation except that they may be related by base class but are not the exact…
jchristof
  • 2,794
  • 7
  • 32
  • 47
5
votes
4 answers

problem formatting fields in a JTable - differences between Integer and Double

Update Confirmed as a bug on JTable can't format given Object as Number when columnClass is Double (bug ID: 7051636). Feel free to vote for it, or if if you have an alternate (better) work-around, post it as a comment to the report. I'm building a…
Heisenbug
  • 38,762
  • 28
  • 132
  • 190
5
votes
1 answer

crash when making selection in AutoCompleteTextView

Apparently, this and this are the same problems that I am having, though my Textview is an AutoCompleteTextView. I am selecting from my contacts list. Whenever I make a selection, I get the following error: java.lang.IllegalArgumentException:…
5
votes
0 answers

Android Studio 2.0 IllegalArgumentException: button doesn't exist 0

Using android studio 2.0 stable version and previous version 1.5 I on Ubuntu, I always get this exception all the time. Any ideas? It appears in the EventLog
5
votes
4 answers

IllegalArgumentException using Java8 Base64 decoder

I wanted to use Base64.java to encode and decode files. Encode.wrap(InputStream) and decode.wrap(InputStream) worked but runned slowly. So I used following code. public static void decodeFile(String inputFileName, String outputFileName) …
Leo.W
  • 539
  • 1
  • 7
  • 18
5
votes
1 answer

Error : java.lang.IllegalArgumentException: Extra samples are not supported

If I execute this method tiff = TiffImage.getTiffImage(rafa,i,false); Then it's through the below exception. Can anyone give me any solution for this exception? Exception Stack Trace: java.lang.IllegalArgumentException: Extra samples are not…
user5093084
  • 51
  • 1
  • 3
5
votes
1 answer

OpenGL ES 2.0 IllegalArgumentException

right now i'm trying to create the graphics for a little game. First I'm trying to create my obstacles. These are just rectangles. I try to make all data, which is the same for all rectangles, static. Color,Startposition,shader. I'm trying to to…
stubiklaus
  • 151
  • 8
5
votes
2 answers

IllegalArgumentException : Trying to set foreign cookie while downloading Google Spreadsheet via API?

I am trying to download the Google spreadsheet using download API version 3 ( v3 ). I am getting "java.lang.IllegalArgumentException: Trying to set foreign cookie" error message while downloading spreadsheet. I am tried by my google apps account…
5
votes
2 answers

Setting value of array using java reflection

I have created generic json parser using java reflection, but there is a error that i am not able to solve. Method (at the bottom of this question), receives subclass of my custom Model class. I iterate through fields and set values from json. If…
bajicdusko
  • 1,630
  • 1
  • 17
  • 32
5
votes
5 answers

Illegal Argument Exception

I am working on a really simple point class but I am getting an error and I can't pinpoint where the String/double problem is happening or how to fix it. public String getDistance (double x1,double x2,double y1,double y2) { double X=…
user2954611
  • 57
  • 1
  • 1
  • 3
5
votes
1 answer

IllegalArgumentException: Color parameter outside of expected range: Red Green Blue

when I tested my code with JUnit, the following error occured: java.lang.IllegalArgumentException: Color parameter outside of expected range: Red Green Blue Honestly, I don't know why. My code is not very long, so I would like to post it for better…
Hagi
  • 87
  • 1
  • 1
  • 5
5
votes
4 answers

Is it OK to use Assert as preconditions?

I was going through this post related to handling of nulls. One of the recommendation (as per the SO post) is to use Assert when nulls are not valid. I have (so far) used nulls extensively in Test Projects. It looks strange to me to use Asserts…
Tilak
  • 30,108
  • 19
  • 83
  • 131
5
votes
1 answer

eBay Finding API in Java throws 'IllegalArgumentException: Not supported: indent-number' exception

I'm playing around with the eBay Finding API for Java, and executing a basic test search based on the tutorial included. The call completes, but a java.lang.IllegalArgumentException exception is thrown during execution. Here's the basic code adapted…
Ric
  • 808
  • 1
  • 6
  • 18
5
votes
2 answers

playing .mp3 file in java using notepad

I know this is a repeat question. check original one here or here. So my code is just the copy paste : import javafx.scene.media.*; class Gui { public static void main(String[] args) { try{ Media hit = new Media("skin.mp3"); …
user1574009
  • 71
  • 2
  • 4