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
45
votes
3 answers

Appcompat "java.lang.IllegalArgumentException: parameter must be a descendant of this view" in ViewGroup.offsetRectBetweenParentAndChild

I'm experiencing this problem randomly in the last month: java.lang.IllegalArgumentException: parameter must be a descendant of this view at android.view.ViewGroup.offsetRectBetweenParentAndChild(ViewGroup.java:4479) at…
bonnyz
  • 13,458
  • 5
  • 46
  • 70
44
votes
20 answers

Eclipse tomcat error: Document base does not exist or is not a readable directory

13-dic-2011 17.00.36 org.apache.catalina.core.AprLifecycleListener init INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path:…
Claudio Pomo
  • 2,392
  • 7
  • 42
  • 71
44
votes
2 answers

java.lang.IllegalArgumentException: Invalid in servlet mapping

myservlet workflow.WDispatcher 2 myservlet
40
votes
2 answers

Why do I get "object is not an instance of declaring class" when invoking a method using reflection?

public class Shared { public static void main(String arg[]) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { Shared s1 = new Shared(); Object obj[] =…
Pratik
  • 30,639
  • 18
  • 84
  • 159
34
votes
5 answers

Using GregorianCalendar with SimpleDateFormat

So, I've been racking my brain over this (should-be) simple exercise to make the program turn a date string into a GregorianCalendar object, format it, and return it again as a string when it's done. This is the last little bit of a program that…
29
votes
5 answers

Wrong number of arguments error when invoking a method

I have class AClass and a method someMethod that gets an Object array as parameter. public class AClass { public void someMethod(Object[] parameters) { } } In main, when I try to invoke this method on the the object that I have created and…
iargin
  • 808
  • 1
  • 9
  • 19
29
votes
11 answers

Android: java.lang.IllegalArgumentException: Invalid payload item type

Some users tell me about the exception the got: java.lang.IllegalArgumentException: Invalid payload item type at android.util.EventLog.writeEvent(Native Method) at android.app.Activity.onMenuItemSelected(Activity.java:2452) at…
22
votes
1 answer

java.lang.IllegalArgumentException: register too many Broadcast Receivers

I'm getting an java.lang.IllegalArgumentException with the following message regist too many Broadcast Receivers (yes, the message says regist and not register) when trying to get the latest ACTION_BATTERY_CHANGED sticky intent. I use the following…
22
votes
1 answer

what does exception java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@4205eb18 does not exist mean

I am trying to login into the app but after the login is success and it is about to go to next screen, it restarts. Following is the exception that I guess would have caused this, as there is no other exception. 11-14 15:09:54.841:…
21
votes
3 answers

Input byte array has incorrect ending byte at 40

I have a string that is base64 encoded. It looks like this: eyJibGExIjoiYmxhMSIsImJsYTIiOiJibGEyIn0= Any online tool can decode this to the proper string which is {"bla1":"bla1","bla2":"bla2"}. However, my Java implementation fails: import…
toom
  • 12,864
  • 27
  • 89
  • 128
20
votes
5 answers

Getting an error on Android 8 on a Samsung device using SCameraCaptureSession

I'm trying to capture a video using SCameraCaptureSession class. While using a function of this class - setRepeatingRequest (which described here), I'm getting the following error: java.lang.IllegalArgumentException: CaptureRequest contains…
lior_13
  • 577
  • 7
  • 18
20
votes
7 answers

java.lang.IllegalArgumentException: The servlets named [X] and [Y] are both mapped to the url-pattern [/url] which is not permitted

I tried to add this servlet package com.classmgt.servlet; @WebServlet("/ControllerServlet") public class ControllerServlet extends HttpServlet {} to my Eclipse project, by editing the web.xml as below Servlet to print…
Dan
  • 810
  • 2
  • 11
  • 29
18
votes
5 answers

When to throw IllegalStateException vs IllegalArgumentException?

Let's start with the Javadocs: IllegalStateException Signals that a method has been invoked at an illegal or inappropriate time. In other words, the Java environment or Java application is not in an appropriate state for the requested…
Abhijit Sarkar
  • 21,927
  • 20
  • 110
  • 219
18
votes
4 answers

Android - java.lang.IllegalArgumentException: contentIntent required error caused by notification?

I have a service running that updates a notification in the notification bar when it recieves a message saying it has to be changed. However I get the following error sometimes when the notification is to be…
Donal Rafferty
  • 19,707
  • 39
  • 114
  • 191
17
votes
8 answers

how to url encode in android?

I am using grid view for displaying image using xml parsing,i got some exception like java.lang.IllegalArgumentException: Illegal character in path at index 80: http://www.theblacksheeponline.com/party_img/thumbspps/912big_361999096_Flicking …
sivaraj
  • 1,849
  • 9
  • 35
  • 52
1
2
3
64 65