You are on page 1of 208

Compile and Runtime Errors in Java

Mordechai (Moti) Ben-Ari

Department of Science Teaching

Weizmann Institute of Science

Rehovot 76100 Israel

http://stwww.weizmann.ac.il/g-cs/benari/

January 24, 2007


This work is licensed under the Creative Commons Attribution-Noncommercial-No Derivative
Works 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/
by-nc-nd/2.5/; or, (b) send a letter to Creative Commons, 543 Howard Street, 5th Floor, San
Francisco, California, 94105, USA.

Acknowledgement
Otto Seppälä and Niko Myller contributed many helpful suggestions.
Contents

1 Introduction 5

2 Compile-time Errors 6
2.1 Syntax errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.1 . . . expected . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.2 unclosed string literal . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.3 illegal start of expression . . . . . . . . . . . . . . . . . . . . . . 8
2.1.4 not a statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2 Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2.1 cannot find symbol . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2.2 . . . is already defined in . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2.3 array required but . . . found . . . . . . . . . . . . . . . . . . . . 10
2.2.4 . . . has private access in . . . . . . . . . . . . . . . . . . . . . . . . 10
2.3 Computation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3.1 variable . . . might not have been initialized . . . . . . . . . . . . 11
2.3.2 . . . in . . . cannot be applied to . . . . . . . . . . . . . . . . . . . . . 11
2.3.3 operator . . . cannot be applied to . . . ,. . . . . . . . . . . . . . . . . 12
2.3.4 possible loss of precision . . . . . . . . . . . . . . . . . . . . . . . 12
2.3.5 incompatible types . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3.6 inconvertible types . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.4 Return statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.4.1 missing return statement . . . . . . . . . . . . . . . . . . . . . . 13
2.4.2 missing return value . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.4.3 cannot return a value from method whose result type is void . 14
2.4.4 invalid method declaration; return type required . . . . . . . . 14
2.4.5 unreachable statement . . . . . . . . . . . . . . . . . . . . . . . . 15
2.5 Access to static entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.5.1 non-static variable cannot be referenced from a static context . . 16
2.5.2 non-static method cannot be referenced from a static context . . 16

3
3 Runtime Errors 17
3.1 Out of range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.1.1 ArrayIndexOutOfRange . . . . . . . . . . . . . . . . . . . . . . . 18
3.1.2 StringIndexOutOfRange . . . . . . . . . . . . . . . . . . . . . . . 18
3.2 Dereferencing null . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.2.1 NullPointerException . . . . . . . . . . . . . . . . . . . . . . . . 18
3.3 Computation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.3.1 InputMismatchException . . . . . . . . . . . . . . . . . . . . . . 20
3.3.2 IllegalFormatException . . . . . . . . . . . . . . . . . . . . . . . 20
3.3.3 NumberFormatException . . . . . . . . . . . . . . . . . . . . . . 20
3.3.4 ArithmeticException . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.4 Insufficient memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.4.1 outOfMemoryError . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.4.2 StackOverFlowArea . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.5 Program execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.5.1 NoClassDefFoundError . . . . . . . . . . . . . . . . . . . . . . . 22
3.5.2 NoSuchMethodFoundError: main . . . . . . . . . . . . . . . . . 23

4 Assignment and equality 24


4.1 String equality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.2 Assignment of references . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

5 On debugging without a debugger 26


5.1 Printing number data and arrays . . . . . . . . . . . . . . . . . . . . . . 26
5.2 Converting objects to strings . . . . . . . . . . . . . . . . . . . . . . . . . 27
5.3 Forcing a stack trace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
5.4 Leave the debug statements in the program . . . . . . . . . . . . . . . . 28

4
Chapter 1

Introduction

Compilers are notorious for their obscure error messages like “not a statement” that
leave you wondering what they mean. J AVA is the most widely used language for
teaching and learning introductory programming, and most students and teachers
use the Sun SDK (System Development Kit) either directly or indirectly through a
development environment like BlueJ or DrJava. The error messages produced by
this compiler are terse and many novices find it difficult to achieve even syntactically
correct programs. This document is a guide to understanding and fixing errors in
J AVA. Chapter 2 lists the error messages from the compiler and describes typical
mistakes that give rise to them. Chapter 3 does the same for runtime exceptions.
Chapter 4 is a short discussion of equality and assignment in J AVA, while Chapter 5
presents ways of debugging without the use of a debugger.
The E CLIPSE development environment has its own compiler for J AVA. While the
environment is not as elementary as those intended for novices, it has much to rec-
ommend it—even in introductory courses—because of its superior error messages
and its support for identifying and correcting syntax errors. The compiler is incre-
mental meaning that it checks the correctness of your program as you type. E CLIPSE
error message are different from those of the Sun SDK and will be presented along-
side them.
If you doubt that an error message is correct, you can consult the formal definition of
the J AVA language which is contained in the book The Java Language Specification by
James Gosling, Bill Joy, Guy L. Steele Jr. and Gilad Bracha. It can also be downloaded
from http://java.sun.com/docs/books/jls/index.html.

5
Chapter 2

Compile-time Errors

Before we discuss the various errors, it is important to understand that compilers are
not very good at recovering from errors. Frequently, a single small mistake will cause
the compiler to issue a cascade of messages. For example, in the following code, we
forgot to write the closing brace of the method f:
class MyClass {
void f() {
int n = 10;
// Error, closing brace is missing
void g() {
int m = 20;
}
}

An attempt to compile the program results in three error messages:

MyClass.java:5: illegal start of expression


void g() {
^
MyClass.java:8: ’;’ expected
}
^
MyClass.java:9: ’}’ expected
^

Do not invest any effort in trying to fix multiple error messages! Concentrate on
fixing the first error and then recompile.
E CLIPSE is much better at diagnosing this error and produces only one message:
Syntax error, insert "}" to complete MethodBody.

6
2.1 Syntax errors

Some errors are caused by violations of the syntax of J AVA. Although they are easy
to understand, there is no easy way to find the exact cause of such errors except by
checking the code around the location of the error character by character looking for
the syntax error.

2.1.1 . . . expected

The syntax of J AVA is very specific about the required punctuation. This error occurs,
for example, if you forget a semicolon at the end of a statement or don’t balance
parentheses:
if (i > j // Error, unbalanced parentheses
max = i // Error, missing semicolon
else
max = j;

Unfortunately, this syntax error is not necessarily caught precisely at the point of the
mistake so you must carefully check the preceding characters in the line or even in a
previous line in order to find the problem.
E CLIPSE:
Syntax error, insert ") Statement" to complete IfStatement.
Syntax error, insert ";" to complete Statement
E CLIPSE is more informative as to the precise syntax error encountered.

2.1.2 unclosed string literal

String literals must be enclosed in quotation marks.1 This error occurs if you fail to
terminate the literal with quotation marks. Fortunately, the syntax of J AVA requires
that a string literal appear entirely on one line so the error message appears on the
same line as the mistake. If you need a string literal that is longer than a single line,
create two or more literals and concatenate them with +:
String longString =
"This is first half of a long string " +
"and this is the second half.";

E CLIPSE: String literal is not properly closed by a double-quote. In E CLIPSE you


can write a string literal of arbitrary length and the environment will break the string
and insert the + automatically.
1A literal is a source-code representation of a value; most literals are of primitive types like int or
char, but there are also literals of type String and the literal null of any reference type.

7
2.1.3 illegal start of expression

Most programming constructs are either statements or expressions. This error occurs
when an expression is expected but not found. In J AVA, an assignment statement is
considered to be an expression which returns a value, so errors concerning expressions
also apply to assignment statements.2 Examples:

• An extra right parenthesis after the condition of an if-statement:


if (i > j) ) // Error, extra parenthesis
max = i;

E CLIPSE: Syntax error on token ")", delete this token.3 E CLIPSE diagnoses this
as a simple syntax error and does not mention expressions.

• Forgetting the right-hand side of an assignment statement:


max = ; // Error, missing right-hand side

E CLIPSE: Syntax error on token "=", Expression expected after this token.

2.1.4 not a statement

This error occurs when a syntactically correct statement does not appear where it
should. Examples:

• Writing an assignment statement without the assignment operator:


max ; // Error, missing =

E CLIPSE:
Syntax error, insert "AssignmentOperator Expression"
to complete Expression.

• Misspelling else:
if (i > j)
max = i;
els ; // Error, else not spelled correctly

The reason you do not get “else expected” is that you need not write an else
alternative so this just looks like a bad statement.

2 The value of an assignment statement considered as an expression is the value of the expression on
the right-hand side that is assigned to the variable on the left-hand side.
3 The syntax of a programming language is defined in terms of tokens consisting of one or more

characters. Identifiers and reserved keywords are tokens as are single characters like + and sequences
of characters like !=.

8
E CLIPSE:
els cannot be resolved4
Syntax error, insert "AssignmentOperator Expression"
to complete Expression.

• The following code:


if (i > j)
max = i;
els // Error, else not spelled correctly
max = j;

results in a weird error message:

x.java:6: cannot find symbol


symbol : class els
location: class x
els

The reason is that the compiler interprets this as a declaration:


els max = j;

and can’t find a class els as the type of the variable max.
E CLIPSE:
Duplicate local variable max
els cannot be resolved to a type.
These messages are more helpful: first, the use of the word type instead of class
is more exact because the type of a variable need not be a class (it could be a
primitive type or interface); second, the message about the duplicate variable
gives an extra clue as to the source of the error.

• The error can also be caused by attempting to declare a variable whose name is
that of a reserved keyword:
void f() {
int default = 10;
}

E CLIPSE: Syntax error on token "default", invalid VariableDeclaratorId.


4 The same identifier can be used in different methods and classes. An important task of the compiler
is to resolve the ambiguity of multiple uses of the same identifer; for example, if a variable is declared
both directly within a class and also within a method, the use of its unqualified name is resolved in
favor of the local variable. This error message simply means that the compiler could not obtain an
(unambiguous) meaning for the identifier els.

9
2.2 Identifiers

2.2.1 cannot find symbol

This is probably the most common compile-time error. All identifiers in J AVA must
be declared before being used and an inconsistency between the declaration of an
identifier and its use will give rise to this error. Carefully check the spelling of the
identifier. It is easy to make a mistake by using a lower-case letter instead of an
upper case one, or to confuse the letter O with the numeral 0 and the letter l with the
numeral 1.
Other sources of this error are: calling a constructor with an incorrect parameter
signature, and using an identifier outside its scope, for example, using an identifier
declared in a for-loop outside the loop:
int[] a = {1, 2, 3};
int sum = 0;
for (int i = 0; i < a.length; i++)
sum = sum + a[i];
System.out.println("Last = " + i); // Error, i not in scope

E CLIPSE: . . . cannot be resolved.

2.2.2 . . . is already defined in . . .

An identifier can only be declared once in the same scope:


int sum = 0;
double sum = 0.0; // Error, sum already defined

E CLIPSE: Duplicate local variable sum.

2.2.3 array required but . . . found

This error is caused by attempting to index a variable which is not an array.


int max(int i, int j) {
if (i > j) return i;
else return j[i]; // Error, j is not an array
}

E CLIPSE: The type of the expression must be an array type but it resolved to int.

2.2.4 . . . has private access in . . .

It is illegal to access a variable declared private outside its class.


E CLIPSE: The field . . . is not visible.

10
2.3 Computation

This group of errors results from code that is syntactically correct but violates the
semantics of J AVA, in particular the rules relating to type checking.

2.3.1 variable . . . might not have been initialized

An instance variable declared in a class has a default initial value.5 However, a local
variable declared within a method does not, so you are required to initialize it before
use, either in its declaration or in an assignment statement:
void m(int n) { // n is initialized from the actual parameter
int i, j;
i = 2; // i is initialized by the assignment
int k = 1; // k is initialized in its declaration
if (i == n) // OK
k = j; // Error, j is not initialized
else
j = k;
}

The variable must be initialized on every path from declaration to use even if the
semantics of the program ensure that the path cannot be taken:
void m(int n) {
int i;
if (n == n) // Always true
i = n;
else
n = i; // Error, although never executed!!
}

E CLIPSE: The local variable . . . may not have been initialized.


Note: If the expression in the if-statement can be computed at compile-time:
if (true) // OK
if (’n’ == ’n’) // OK

the error will not occur.

2.3.2 . . . in . . . cannot be applied to . . .

This error message is very common and results from an incompatibility between a
method call and the method’s declaration:
5A class is a template that is used to create or instantiate instances called objects. Since memory is
allocated separately for each object, these variables are called instance variables.

11
void m(int i) { ... }

m(5.5); // Error, the literal is of type double, not int

Check the declaration and call carefully. You can also get the error message cannot
find symbol if the declaration of the method is in the API.6
E CLIPSE: The method . . . in the type . . . is not applicable for the arguments . . . .

2.3.3 operator . . . cannot be applied to . . . ,. . .

Operators are only defined for certain types, although implicit type conversion is
allowed between certain numeric types:
int a = 5;
boolean b = true;
int c = a + b; // Error, can’t add a boolean value
double d = a + 1.4; // OK, int is implicitly converted to double

E CLIPSE: The operator + is undefined for the argument type(s) int, boolean.

2.3.4 possible loss of precision

This error arises when trying to assign a value of higher precision to a variable of
lower precision without an explicit type cast. Surprisingly, perhaps, floating point
literals are of type double and you will get this message if you try to assign one to a
variable of type float:
float sum = 0.0; // Error, literal is not of type float

The correct way to do this is to use a literal of type float or an explicit type cast:
float sum = 0.0f; // OK
float sum = (float) 0.0; // OK

E CLIPSE: Type mismatch: cannot convert from double to float.

2.3.5 incompatible types

J AVA checks that the type of an expression is compatible with the type of the variable
in an assignment statement and this error will result if they are incompatible:
boolean b = true;
int a = b; // Error, can’t assign boolean to int

E CLIPSE: Type mismatch: cannot convert from boolean to int.

6 The Application Programming Interface (API) describes how to use the library of classes supplied as

part of the J AVA system. By extension, it is also used as a name for the library itself.

12
Important note

In the C language it is (unfortunately!) legal to write


if (a = b)

using the assignment operator instead of


if (a == b)

using the equality operator. The meaning is to execute the assignment,


convert the value to an integer and use its value to make the decision
for the if-statement (zero is false and non-zero is true). In J AVA, the as-
signment is legal and results in a value, but (unless a is of type boolean!)
this error message will result because the expression in an if-statement
must be of type boolean, not int. Writing == instead of = becomes a sim-
ple compile-time error in J AVA, whereas in C this error leads to runtime
errors that are extremely difficult to find.

2.3.6 inconvertible types

Not every type conversion is legal:


boolean b = true;
int x = (int) b; // Error, can’t convert boolean to int

E CLIPSE: Type mismatch: cannot convert from . . . to . . . .

2.4 Return statements

There are a number of errors related to the structure of methods and their return
statements; in general they are easy to fix.

2.4.1 missing return statement

When a method returns a non-void type, every path that leaves the method must have
a return-statement,7 even if there is no way that the path can be executed:
int max(int i, int j) {
if (i > j) return i;
else if (i <= j) return j;
// Error: what about the path when i>j and i<=j are both false?!!
}

7A path may also leave the method via a throw statement.

13
Adding a dummy alternative else return 0; at the end of the method will enable
successful compilation.
E CLIPSE: This method must return a result of type int. This E CLIPSE message is
rather hard to understand because, clearly, the method does return a result of type
int, just not on all paths.

2.4.2 missing return value

A method returning a type must have a return-statement that includes an expression


of the correct type:
int max(int i, int j) {
return; // Error, missing int expression
}

E CLIPSE: This method must return a result of type int.

2.4.3 cannot return a value from method whose result type is void

Conversely, a return-statement in a void method must not have an expression:


void m(int i, int j) {
return i + j; // Error, the method was declared void
}

E CLIPSE: Void methods cannot return a value.

2.4.4 invalid method declaration; return type required

Every method except constructors must have a return type or void specified; if not, this
error will arise:
max(int i, int j) {
...
}

The error frequently occurs because it is easy to misspell the name of a constructor;
the compiler then thinks that it is a normal method without a return type:
class MyClass {
MyClass(int i) { ... }
Myclass(int i, int j) { ... } // Error because of the lowercase c
}

E CLIPSE: Return type for the method is missing.

14
2.4.5 unreachable statement

The error can occur if you write a statement after a return statement:
void m(int j) {
System.out.println("Value is " + j);
return;
j++;
}

The check is purely syntactic, so the error will occur in the following method:
if (true) {
return n + 1; // Only this alternative executed, but ...
}
else {
return n - 1;
n = n + 1; // ... this is an error
}

E CLIPSE: Unreachable code.

2.5 Access to static entities

The modifier static means that a variable or method is associated with a class and
not with individual objects of a class.8 Normally, static entities are rarely used in J AVA
(other than for the declaration of constants), because programs are written as classes
to be instantiated to create at least one object:
class MyClass {
int field;
void m(int parm) {
field = parm;
}
public static void main(String[] args) {
MyClass myclass = new MyClass(); // Create object
myclass.m(5); // Call object’s method
System.out.println(myclass.field); // Access object’s field
}
}

Some teachers of elementary programming in J AVA prefer to start with a procedural


approach that involves writing a class containing static variables and static methods
that are accessed from the main method without instantiating an object as was done
above:
8 static has other uses that we do not consider here: (a) as a modifier for nested classes and (b) in
static initializers.

15
class MyClass1 {
static int field;
static void m(int parm) {
field = parm;
}
public static void main(String[] args) {
m(5); // OK
System.out.println(field); // OK
}
}

2.5.1 non-static variable . . . cannot be referenced from a static context

Since the method main is (required to be) static, so must any variable declared in the
class that is accessed by the method. Omitting the modifier results in a compile-time
error:
int field; // Forgot "static"
...
System.out.println(field); // Error, which field?

The variable field does not exist until an object of the class is instantiated, so using
the identifier field by itself is impossible before objects are instantiated. Further-
more, it is ambiguous afterwards, as there may be many objects of the same class.
E CLIPSE: Cannot make a static reference to the non-static field . . . .

2.5.2 non-static method . . . cannot be referenced from a static context

Similarly, a non-static method cannot be called from a static method like main; the
reason is a bit subtle. When a non-static method like m is executed, it receives as an
implicit parameter the reference to an object. (The reference can be explicitly referred
to using this.) Therefore, when it accesses variables declared in the class like field:
void m(int parm) { // Forgot "static"
field = parm; // Error, which field?
}

public static void main(String[] args) {


m(5);
}

it is clear that the variable is the one associated with the object referenced by this.
Thus, in the absence of an object, it is meaningless to call a non-static method from a
static method.
E CLIPSE:
Cannot make a static reference to the non-static method . . . from the type . . . .

16
Chapter 3

Runtime Errors

When the J AVA interpreter encounters an error during runtime it throws an exception
and prints a stack trace showing the entire call stack—the list of methods called from
the main program until the statement that caused the exception.1 Consider the fol-
lowing program:
class Test {
public static void main(String[] args) {
String s = "Hello world";
System.out.println(s.substring(10,12));
}
}

We are trying to extract a substring of the string s but the upper index 12 is not within
the string. Attempting to execute this code will cause an exception to be thrown:

Exception in thread "main"


java.lang.StringIndexOutOfBoundsException:
String index out of range: 12
at java.lang.String.substring(Unknown Source)
at Test.main(Test.java:4)

The exception was thrown from within the library class String during the execution
of the method substring. This method was called at line 4 of method main in the class
Test. It is unlikely that there is an error that causes an exception in a well established
class of the J AVA library like String; more likely, the String class itself identified the
error and threw the exception explicitly, so we are advised to seek the error starting
at the deepest method of our own program.
The calls in the stack trace are listed in reverse order of invocation, that is, the first
call listed is the deepest method (where the exception occurred), while the last call
listed is the shallowest method, namely main.
1 Many programming languages prefer the term raises an exception and even The Java Language Spec-

ification uses this term on occasion.

17
Exceptions can be caught by writing a block of code called an exception handler that
will be executed when an exception is thrown.2 Exception handlers are discussed in
textbooks on the J AVA language; here we limit ourselves to explaining the exceptions
that indicate programming errors. We further limit ourselves to exceptions com-
monly thrown by the language core; classes in the API define their own exceptions
and these are explained in the API documentation.

3.1 Out of range

These exceptions are the most common and are caused by attempting to access an
array or string with an index that is outside the limits of the array or string. C pro-
grammers will be familiar with the difficult bugs that are caused by such errors which
“smear” memory belonging to other variables; in J AVA the errors cause an exception
immediately when they occur thus facilitating debugging.

3.1.1 ArrayIndexOutOfRange

This exception is thrown when attempting the index an array a[i] where the index
i is not within the values 0 and a.length-1, inclusive. Zero-based arrays can be con-
fusing; since the length of the array is larger than the last index, it is not unusual to
write the following in a for-statement by mistake:
final static int SIZE = 10;
int a = new int[SIZE];

for (int i = 0; i <= SIZE; i++) // Error, <= should be <

for (int i = 0; i <= a.length; i++) // Better, but still an error

3.1.2 StringIndexOutOfRange

This exception is thrown by many methods of the class String if an index is not within
the values 0 and s.length(), inclusive. Note that s.length() is valid and means the
position just after the last character in the string.

3.2 Dereferencing null

3.2.1 NullPointerException

A variable in J AVA is either of a primitive type such as int or boolean or of a reference


type: an array type, the type of a class defined in the J AVA API such as String, or
the type of a class that you define such as MyClass. When declaring a variable of a
2 An alternate terminology is to say that an exception is handled by an exception handler.

18
reference type, you only get a variable that can hold a reference to an object of that
class. At this point, attempting to access a field or method of the class will cause the
exception NullPointerException to be thrown:3
public static void main(String[] args) {}
MyClass my; // Can hold a reference but doesn’t yet
my.m(5); // Throws an exception
}

Only after instantiating the class and executing the constructor do you get an object:
public static void main(String[] args) {}
MyClass my; // Can hold a reference but doesn’t yet
my = new MyClass(); // Instantiates an object and assigns reference
my.m(5); // OK
}

This exception is not often seen in this context because J AVA style prefers that the
declaration of the variable include the instantiation as its initial value:
public static void main(String[] args) {}
MyClass my = new MyClass(); // Declaration + instantiation
my.m(5); // OK
}

If the variable is declared directly within its class, you should initialize it either at its
declaration or within the constructor:
class YourClass {
MyClass[] my; // Can’t initialize here because ...

YourClass(int size) { // ... size of array different for each


object my = new MyClass[size];
}
}

The exception is likely to occur when you declare an array whose elements are of
reference type. It is easy to forget that the array contains only references and that
each element must be separately initialized:
MyClass[] my = new MyClass[4]; // Array of references
my[1].m(5); // Raises an exception

for (int i = 0; i < my.length; i++)


my[i] = new MyClass(); // Instantiate objects
my[1].m(5); // OK

3 The name of the exception is an anachronism, because there are no (explicit) pointers in J AVA.

19
Finally, NullPointerException will occur if you get a reference as a return value from
a method and don’t know or don’t check that the value is non-null:4
Node node = getNextNode();
if (node.key > this.key) ... // Error if node is null!

if (node != null) { // This should be done first


if (node.key > this.key) ...
}

3.3 Computation

The following three exceptions occur when you try to convert a string to a number
and the form of the string does not match that of a number, for example "12a3".

3.3.1 InputMismatchException

This exception is thrown by the class Scanner, which is a class introduced into version
5 of J AVA to simplify character-based input to programs.

3.3.2 IllegalFormatException

This exception is thrown by the method format in class String that enables output
using format specifiers as in the C language.

3.3.3 NumberFormatException

This exception is thrown by methods declared in the numeric “wrapper” classes such
as Integer and Double, in particular by the methods parseInt and parseDouble that
convert from strings to the primitive numeric types.

3.3.4 ArithmeticException

This exception is thrown if you attempt to divide by zero.

4 You could know this if the method has been verified for a postcondition that specifies a non-null

return value.

20
Important note

Most computational errors do not result in the raising of an exception!


Instead, the result is an artificial value called NaN, short for Not a Number.
This value can even be printed:
double x = Math.sqrt(-1); // Does not throw an exception!
System.out.println(x);

Any attempt to perform further computation with NaN does not change
the value. That is, if x is NaN then so is y after executing y = x+5. It follows
that an output value of NaN gives no information as to the statement that
first produced it. You will have to set breakpoints or use print statements
to search for it.

3.4 Insufficient memory

Modern computers have very large memories so you are unlikely to encounter these
exceptions in routine programming. Nevertheless, they can occur as a side effect of
other mistakes.

3.4.1 outOfMemoryError

This exception can be thrown if you run out of memory:


int a = new int[100000000];

3.4.2 StackOverFlowArea

A stack is used to store the activation record of each method that is called; it contains
the parameters and the local variables as well as other information such as the return
address. Unbounded recursion can cause the Java Virtual Machine to run out of
space in the stack:
int factorial(int n) {
if (n == 0) return 1;
else return n * factorial(n + 1); // Error, you meant n - 1
}

21
3.5 Program execution

You can run a J AVA program from within an environment or by executing the inter-
preter from the command line:

java Test

where Test is the name of a class containing a main method.


Suggestion: It is convenient to write main methods in most classes and to use then
for testing classes individually. After the classes are integrated into a single program,
you only need ensure that the interpreter is invoked on the class that contains the
“real” main method.
Two runtime errors can occur if the interpreter is not successful in finding and run-
ning the program.

3.5.1 NoClassDefFoundError

The interpreter must be able to find the file containing a class with the main method,
for example, Test.class. If packages are not used, this must be in the directory
where the interpreter is executed. Check that the name of the class is the same as the
name of the file without the extension. Case is significant!
Warning! If you are compiling and running J AVA from a command window or shell
with a history facility, you are likely to encounter this error. First, you compile the
program:

javac MyClass.java

and then you recall that line and erase the c from javac to obtain the command for
the interpreter:

java MyClass.java

Unfortunately, MyClass.java is not the name of the class so you will get this excep-
tion. You must erase the .java extension as well to run the interpreter:

java MyClass

If you are using packages, the main class must be in a subdirectory of that name. For
example, given:
package project1.userinterface;
class Test {
public static void main(String[] args) {
...
}
}

22
the file Test.class must be located in the directory userinterface that is a subdi-
rectory of project1 that is a subdirectory of the directory where the interpreter is
executed:

c:\projects> dir
<DIR> project1
c:\projects> dir project1
<DIR> userinterface
c:\projects> dir project1\userinterface
Test.class

The program is invoked by giving the fully qualified name made up of the package
names and the class name:

c:\projects> java project1.userinterface.Test

3.5.2 NoSuchMethodFoundError: main

This error will occur if there is no method main in the class, or if the declaration is not
precisely correct: the static modifier, the void return type, the method name main
written in lower case, and one parameter of type String[]. If you forget the public
modifier, the error message is Main method not public.

23
Chapter 4

Assignment and equality

J AVA programmers make mistakes in the use of the assignment and equality oper-
ators, especially when strings are used. The concept of reference semantics is (or
should be) explained in detail in your textbook, so we limit ourselves to a reminder
of the potential problems.

4.1 String equality

Given:
String s1 = "abcdef";
String s2 = "abcdef";
String s3 = "abc" + "def";
String s4 = "abcdef" + "";
String s5 = s1 + "";
String t1 = "abc";
String t2 = "def";
String s6 = t1 + t2;

all strings sn are equal when compared using the method equals in the class String
that compares the contents pointed to by the reference:
if (s1.equals(s5)) // Condition evaluates to true

The string literal "abcdef" is stored only once, so strings s1, s2 and (perhaps surpris-
ingly) s3 and s4 are also equal when compared using the equality operator == that
compares the references themselves:
if (s1 == s3) // Condition evaluates to true

However, s5 and s6 are not equal (==) to s1 through s4, because their values are
created at runtime and stored separately; therefore, their references are not the same
as they are for the literals created at compile-time.
Always use equals rather than == to compare strings, unless you can explain why the
latter is needed!

24
4.2 Assignment of references

The assignment operator copies references, not the contents of an object. Given:
int[] a1 = { 1, 2, 3, 4, 5 };
int[] a2 = a1;
a1[0] = 6;

since a2 points to the same array, the value of a2[0] is also changed to 6. To copy an
array, you have to write an explicit loop and copy the elements one by one.
To copy an object pointed to by a reference, you can create a new object and pass the
old object as a parameter to a constructor:
class MyClass {
int x;
MyClass(int y) { x = y; }
MyClass(MyClass myclass) { this.x = myclass.x; }
}

class Test {
public static void main(String[] args) {
MyClass myclass1 = new MyClass(5);
MyClass myclass2 = new MyClass(myclass1);
myclass1.x = 6;
System.out.println(myclass1.x); // Prints 6
System.out.println(myclass2.x); // Prints 5
}
}

Alternatively, you can use clone as described in J AVA textbooks.

25
Chapter 5

On debugging without a debugger

Debugging is perhaps best done using a debugger such as those provided by inte-
grated development environments. Nevertheless, many programmers debug pro-
grams by inserting print statements. This section describes some of the techniques
that can be used in J AVA.

5.1 Printing number data and arrays

The methods System.out.print and System.out.println are predefined for primitive


types as well as for strings:
int i = 1;
double d = 5.2;
System.out.print(i);
System.out.println(d);

Furthermore, automatic conversion to String type is performed by the concatenation


operator +:
System.out.println("d = " + d + "and i = " + i);

The print statements can not print an entire array, so a method must be written:
public static void print(int[] a) {
for (int i = 0; i < a.length; i++)
System.out.print(a[i]);
System.out.println();
}

public static void main(String[] args) {


int[] a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
print(a);
}

Since the number of elements of an array can be large, it is better to write the method
so that it inserts a newline after printing a fixed number of elements:

26
public static void print(int[] a) {
for (int i = 0; i < a.length; i++) {
System.out.print(a[i]);
if (i % 8 == 7) System.out.println();
}
System.out.println();
}

You can put this static method in a publicly accessible class and use it to print any
integer array. Similar methods can be written for the other primitive types.

5.2 Converting objects to strings

Within the class Object, the root class for all other classes, a method toString is de-
clared. The default implementation will not give useful information, so it is a good
idea to override it in each class that you write:
class Node {
int key;
double value;
public String toString() {
return "The value at key " + key + " is " + value;
}
}

Then, you can simply call the print statements for any object of this class and the
conversion to String is done automatically:
Node node = new Node();
...
System.out.println(node);

The predefined class java.util.Arrays constains a lot of useful (static) methods for
working with arrays, among them toString methods for arrays whose elements are
of any primitive type:
int[] a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
System.out.println(java.util.Arrays.toString(a));

or
import java.util.Arrays;
...
System.out.println(Arrays.toString(a));

You will receive a predefined representation of the array (the elements are separated
by commas), so if you want an alternate representation (such as printing on multiple
lines) you will have to write your own print method as we did in the previous section.

27
An array of objects of any reference type can be printed by defing a single method since
any object can be converted to Object:
public static void print(Object[] a) {
for (int i = 0; i < a.length; i++)
System.out.print(a[i]);
System.out.println();
}

Node[] nodes = new Node[];


... // Create elements of the array
print(nodes);

or by calling the predefined method deepToString:


Node[] nodes = new Node[];
... // Create elements of the array
System.out.println(java.util.Arrays.deepToString(node));

5.3 Forcing a stack trace

Suppose that you have isolated a bug to a certain method but you do not know which
call of that method was responsible. You can force the interpreter to print a trace of
the call stack by inserting the line:
new Exception().printStackTrace();

within the method. It creates a new object of type Exception and then invokes the
method printStackTrace. Since the exception is not thrown, the execution of the
program proceeds with no interruption. A program can always be terminated by
calling System.exit(n) for an integer n.

5.4 Leave the debug statements in the program

Once you have found a bug, it is tempting to delete the print statements used for
debugging, but it is better not to do so because you may need them in the future.
You can comment out the statements that you don’t need, but a better solution is to
declare a global constant and then use it to turn the print statements on and off:
public class Global {
public static boolean DEBUG = false;
public static void print(int[] a) {...}
public static void print(Object[] a) {...}
}

if (Global.DEBUG) Global.print(nodes);

28

 

Top Java Software Errors: 50 Common Java
Errors and How to Avoid Them
STACKIFY | OCTOBER 17, 2017 |
DEVELOPER TIPS, TRICKS & RESOURCES (HTTPS://STACKIFY.COM/DEVELOPERS/), INSIGHTS
FOR DEV MANAGERS (HTTPS://STACKIFY.COM/TEAM/) |
 LEAVE A COMMENT (HTTPS://STACKIFY.COM/TOP­JAVA­SOFTWARE­ERRORS/#RESPOND)

    

There are many types of errors (https://stackify.com/error­monitoring/) that could be
encountered while developing Java software, from, but most are avoidable. We’ve
rounded up 50 of the most common Java software errors, complete with code examples
and tutorials to help you work around common coding problems.

For more tips and tricks for coding better Java programs, download our Comprehensive
Java Developer’s Guide (http://info.stackify.com/buildbetter­2.2­the­comprehensive­java­
developers­guide), which is jam­packed with everything you need to up your Java game –
from tools to the best websites and blogs, YouTube channels, Twitter influencers, LinkedIn
groups, podcasts, must­attend events, and more.

If you’re working with .NET, you should also check out our guide to the 50 most common
.NET software errors (https://stackify.com/top­net­software­errors/) and how to avoid them.
But if your current challenges are Java­related, read on to learn about the most common
issues and their workarounds.
Compiler Errors
Compiler error messages are created when the Java software code is run through the
compiler. It is important to remember that a compiler may throw many error messages for
one error. So fix the first error and recompile. That could solve many problems.

1. “… expected”
This error occurs when something is missing from the code. Often this is created by a
private static double volume(String solidom, double alturam, double areaBasem, double 
missing semicolon or closing parenthesis.
raiom) {
double vol;

    if (solidom.equalsIgnoreCase("esfera"){
        vol=(4.0/3)*Math.pi*Math.pow(raiom,3);
    }
    else {
        if (solidom.equalsIgnoreCase("cilindro") {
            vol=Math.pi*Math.pow(raiom,2)*alturam;
        }
        else {
            vol=(1.0/3)*Math.pi*Math.pow(raiom,2)*alturam;
        }
    }
    return vol;
}

Often this error message does not pinpoint the exact location of the issue. To find it:

Make sure all opening parenthesis have a corresponding closing parenthesis.
Look in the line previous to the Java code line indicated. This Java software error
doesn’t get noticed by the compiler until further in the code.
Sometimes a character such as an opening parenthesis shouldn’t be in the Java code
in the first place. So the developer didn’t place a closing parenthesis to balance the
parentheses.

Check out an example of how a missed parenthesis
(https://stackoverflow.com/questions/19752135/java­expected­error) can create an error
(@StackOverflow (https://twitter.com/StackOverflow)).

2. “unclosed string literal”
The “unclosed string literal” error message is created when the string literal ends without
quotation marks, and the message will appear on the same line as the error
(http://www.dreamincode.net/forums/topic/116743­unclosed­string­literal­error/).
(@DreamInCode (https://twitter.com/dreamincode)) A literal is a source code of a value.

 public abstract class NFLPlayersReference {

    private static Runningback[] nflplayersreference;

    private static Quarterback[] players;

    private static WideReceiver[] nflplayers;

    public static void main(String args[]){

    Runningback r = new Runningback("Thomlinsion");

    Quarterback q = new Quarterback("Tom Brady");

    WideReceiver w = new WideReceiver("Steve Smith");

Commonly, this happens when:
    NFLPlayersReference[] NFLPlayersReference;

The string literal does not end with quote marks. This is easy to correct by closing the
string literal with the needed quote mark.
        Run();// {
The string literal extends beyond a line. Long string literals can be broken into multiple
literals and concatenated with a plus sign (“+”).
        NFLPlayersReference = new NFLPlayersReference [3];
Quote marks that are part of the string literal are not escaped with a back slash (“\”).
        nflplayersreference[0] = r;

Read a discussion of the unclosed string literal (https://www.quora.com/What­is­an­
        players[1] = q;
unclosed­string­literal) Java software error message. (@Quora (https://twitter.com/Quora))
        nflplayers[2] = w;
 

3. “illegal start of an expression”
            for ( int i = 0; i < nflplayersreference.length; i++ ) {
There are numerous reasons why an “illegal start of an expression” error occurs. It ends
            System.out.println("My name is " + " nflplayersreference[i].getName());
up being one of the less­helpful error messages. Some developers say it’s caused by bad
code.
            nflplayersreference[i].run();

Usually expressions are created to produce a new value or assign a value to a variable.
            nflplayersreference[i].run();
The compiler expects to find an expression and cannot find it because the syntax does not
match expectations (https://stackoverflow.com/questions/19581173/java­getting­illegal­
            nflplayersreference[i].run();
start­of­expression­and­expected­errors­for­a­metho). (@StackOverflow
            System.out.println("NFL offensive threats have great running abilities!");
(https://twitter.com/StackOverflow)) It is in these statements that the error can be found.

        }

    }
} // ADD IT HERE

       public void newShape(String shape) {

        switch (shape) {
            case "Line":
                Shape line = new Line(startX, startY, endX, endY);
            shapes.add(line);
            break;
                case "Oval":
            Shape oval = new Oval(startX, startY, endX, endY);
            shapes.add(oval);
            break;
            case "Rectangle":
            Shape rectangle = new Rectangle(startX, startY, endX, endY);
            shapes.add(rectangle);
Browse discussions of how to troubleshoot the “illegal start of an expression”
            break;
(https://stackoverflow.com/search?q=%22illegal+start+of+an+expression%22+java) error.
            default:
(@StackOverflow (https://twitter.com/StackOverflow))
            System.out.println("ERROR. Check logic.");
        }
        }

4. “cannot find symbol”
    } // REMOVE IT FROM HERE
    }

This is a very common issue because all identifiers in Java need to be declared before
they are used. When the code is being compiled, the compiler does not understand what
the identifier means.

There are many reasons you might receive the “cannot find symbol” message:

The spelling of the identifier when declared may not be the same as when it is used in
the code.
The variable was never declared.
The variable is not being used in the same scope it was declared.
The class was not imported.

Read a thorough discussion of the “cannot find symbol” error
(https://stackoverflow.com/questions/25706216/what­does­a­cannot­find­symbol­
compilation­error­mean) and examples of code that create this issue. (@StackOverflow
(https://twitter.com/StackOverflow))

5. “public class XXX should be in file”
The “public class XXX should be in file” message occurs when the class XXX and the Java
program filename do not match (https://coderanch.com/t/628555/java/Netbeans­static­
variables). The code will only be compiled when the class and Java file are the same.
(@coderanch (https://twitter.com/coderanch))

package javaapplication3;  
   
 
  public class Robot {  
        int xlocation;  
        int ylocation;  
        String name;  
        static int ccount = 0;  
           
        public Robot(int xxlocation, int yylocation, String nname) {  
            xlocation = xxlocation;  
            ylocation = yylocation;  
            name = nname;  
            ccount++;         
        } 
  }
To fix this issue:
         
  public class JavaApplication1 { 
Name the class and file the same.
       
Make sure the case of both names is consistent.
       
       
See an example of the “Public class XXX should be in file”
    public static void main(String[] args) {  
(https://stackoverflow.com/questions/13811020/java­class­is­public­should­be­declared­in­
           
a­file­named) error. (@StackOverflow (https://twitter.com/StackOverflow))
        robot firstRobot = new Robot(34,51,"yossi");  
        System.out.println("numebr of robots is now " + Robot.ccount);  
    }
  }
6. “incompatible types”
“Incompatible types” is an error in logic that occurs when an assignment statement tries to
pair a variable with an expression of types. It often comes when the code tries to place a
text string into an integer (https://stackoverflow.com/questions/18861044/what­is­wrong­
with­this­incompatible­type­error) — or vice versa. This is not a Java syntax error.
(@StackOverflow (https://twitter.com/StackOverflow))

test.java:78: error: incompatible types
return stringBuilder.toString();
                             ^
required: int
found:    String
1 error

There really isn’t a easy fix when the compiler gives an “incompatible types” message:

There are functions that can convert types.
Developer may need change what the code is expected to do.

Check out an example of how trying to assign a string to an integer created the
“incompatible types.” (https://stackoverflow.com/questions/7466133/java­error­
incompatible­types­message)  (@StackOverflow (https://twitter.com/StackOverflow))

7. “invalid method declaration; return type required”
This Java software error message means the return type of a method was not explicitly
stated in the method signature.

public class Circle
{
    private double radius;
    public CircleR(double r)
    {
        radius = r;
    }
    public diameter()
    {
       double d = radius * 2;
       return d;
    }
}

There are a few ways to trigger the “invalid method declaration; return type required” error:

Forgetting to state the type
If the method does not return a value then “void” needs to be stated as the type in the
method signature.
Constructor names do not need to state type. But if there is an error in the constructor
name, then the compiler will treat the constructor as a method without a stated type.
Follow an example of how constructor naming triggered the “invalid method declaration;
return type required” (https://stackoverflow.com/questions/7451707/java­error­invalid­
method­declaration­return­type­required) issue. (@StackOverflow
(https://twitter.com/StackOverflow))

8. “method <X> in class <Y> cannot be applied to given types”
This Java software error message is one of the more helpful error messages. It explains
how the method signature is calling the wrong parameters.

RandomNumbers.java:9: error: method generateNumbers in class RandomNumbers cannot be appl
ied to given types;
generateNumbers();

required: int[]

found:generateNumbers();

reason: actual and formal argument lists differ in length

The method called is expecting certain arguments defined in the method’s declaration.
Check the method declaration and call carefully to make sure they are compatible.

This discussion illustrates how a Java software error message identifies the incompatibility
created by arguments (https://stackoverflow.com/questions/13169606/method­in­class­
cannot­be­applied­to­given­types) in the method declaration and method call.
(@StackOverflow (https://twitter.com/StackOverflow))

9. “missing return statement”
The “missing return statement” message occurs when a method does not have a return
statement. Each method that returns a value (a non­void type) must have a statement that
literally returns that value so it can be called outside the method.
public String[] OpenFile() throws IOException {

    Map<String, Double> map = new HashMap();

    FileReader fr = new FileReader("money.txt");
    BufferedReader br = new BufferedReader(fr);

    try{
        while (br.ready()){
            String str = br.readLine();
            String[] list = str.split(" ");
            System.out.println(list);               
        }
    }   catch (IOException e){
        System.err.println("Error ‐ IOException!");
There are a couple reasons why a compiler throws the “missing return statement”
    }
message:
}

A return statement was simply omitted by mistake.
The method did not return any value but type void was not declared in the method
signature.

Check out an example of how to fix the “missing return statement” Java software error
(https://stackoverflow.com/questions/21256469/java­missing­return­statement).
(@StackOverflow (https://twitter.com/StackOverflow))

10. “possible loss of precision”
“Possible loss of precision” occurs when more information is assigned to a variable than it
can hold. If this happens, pieces will be thrown out. If this is fine, then the code needs to
explicitly declare the variable as a new type.
A “possible loss of precision” error commonly occurs when:

Trying to assign a real number to a variable with an integer data type.
Trying to assign a double to a variable with an integer data type.

This explanation of Primitive Data Types in
(http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html) Java
(http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html) shows how the
data is characterized. (@Oracle (https://twitter.com/Oracle))

11. “reached end of file while parsing”
This error message usually occurs in Java when the program is missing the closing curly
brace (“}”). Sometimes it can be quickly fixed by placing it at the end of the code.

public class mod_MyMod extends BaseMod
public String Version()
{
     return "1.2_02";
}
public void AddRecipes(CraftingManager recipes)
{
   recipes.addRecipe(new ItemStack(Item.diamond), new Object[] {
      "#", Character.valueOf('#'), Block.dirt
   });
}

The above code results in the following error:

java:11: reached end of file while parsing }

Coding utilities and proper code indenting can make it easier to find these unbalanced
braces.

This example shows how missing braces can create the “reached end of file while parsing”
(https://stackoverflow.com/questions/4934412/java­compile­error­reached­end­of­file­
while­parsing) error message. (@StackOverflow (https://twitter.com/StackOverflow))

12. “unreachable statement”
“Unreachable statement” occurs when a statement is written in a place that prevents it
from being executed. Usually this is after a break or return statement.
for(;;){
   break;
   ... // unreachable statement
}

int i=1;
if(i==1)
  ...
else
  ... // dead code

Often simply moving the return statement will fix the error. Read the discussion of how to
fix unreachable statement Java software error
(https://stackoverflow.com/questions/18308159/unreachable­statement­compile­error­in­
java). (@StackOverflow (https://twitter.com/StackOverflow))

13. “variable <X> might not have been initialized”
This occurs when a local variable declared within a method has not been initialized. It can
occur when a variable without an initial value is part of an if statement.

int x;
if (condition) {
    x = 5;
}
System.out.println(x); // x may not have been initialized

Read this discussion of how to avoid triggering the “variable <X> might not have been
initialized”
(https://www.reddit.com/r/learnprogramming/comments/1njfui/java_error_variable_x_might_not_ha
(@reddit (https://twitter.com/reddit))

14. “Operator .. cannot be applied to <X>”
This issue occurs when operators are used for types not in their definition.

operator < cannot be applied to java.lang.Object,java.lang.Object

This often happens when the Java code tries to use a type string in a calculation. To fix it,
the string needs to be converted to an integer or float.
Read this example of how non­numeric types were causing a Java software error warning
(https://stackoverflow.com/questions/26890817/error­operator­cannot­be­applied) that an
operator cannot be applied to a type. (@StackOverflow
(https://twitter.com/StackOverflow))

15. “inconvertible types”
The “inconvertible types” error occurs when the Java code tries to perform an illegal
conversion.

TypeInvocationConversionTest.java:12: inconvertible types
found   : java.util.ArrayList<java.lang.Class<? extends TypeInvocationConversionTest.Inte
rface1>>
required: java.util.ArrayList<java.lang.Class<?>>
    lessRestrictiveClassList = (ArrayList<Class<?>>) classList;
                                                     ^

For example, booleans cannot be converted to an integer.

Read this discussion about finding ways to convert inconvertible types
(https://stackoverflow.com/questions/19138960/is­there­any­way­to­convert­these­
inconvertible­types) in Java software. (@StackOverflow
(https://twitter.com/StackOverflow))

16. “missing return value”
You’ll get the “missing return value” message when the return statement includes an
incorrect type. For example, the following code:

public class SavingsAcc2
{
 private double balance;
 private double interest;
 
 
 public SavingsAcc2()
 {
 balance = 0.0;
 interest = 6.17;
 }
 
 public SavingsAcc2(double initBalance, double interested)
 {
 balance = initBalance;
 interest = interested;
Returns the following error:

SavingsAcc2.java:29: missing return value 
return; 

SavingsAcc2.java:35: missing return value 
return; 

SavingsAcc2.java:41: missing return value 
return; 

3 errors 

Usually there is a return statement that doesn’t return anything.

Read this discussion about how to avoid the “missing return value”
(https://coderanch.com/t/566414/java/missing­return­error) Java software error message.
(@coderanch (https://twitter.com/coderanch))

17. “cannot return a value from method whose result type is void”
This Java error occurs when a void method tries to return any value, such as in the
following example:

public static void move()
{
    System.out.println("What do you want to do?");
    Scanner scan = new Scanner(System.in);
    int userMove = scan.nextInt();
    return userMove;
}

public static void usersMove(String playerName, int gesture)
{
    int userMove = move();

    if (userMove == ‐1)
    {
        break;
    }
Often this is fixed by changing to method signature to match the type in the return
statement. In this case, instances of void can be changed to int:
public static int move()
{
    System.out.println("What do you want to do?");
    Scanner scan = new Scanner(System.in);
    int userMove = scan.nextInt();
    return userMove;
}

Read this discussion about how to fix the “cannot return a value from method whose result
type is void” (https://stackoverflow.com/questions/15518399/cannot­return­a­value­from­
method­whose­result­type­is­void­error) error. (@StackOverflow
(https://twitter.com/StackOverflow))

18. “non­static variable . . . cannot be referenced from a static
context”
This error occurs when the compiler tries to access non­static variables from a static
method (https://javarevisited.blogspot.com/2012/02/why­non­static­variable­cannot­
be.html) (@javinpaul (https://twitter.com/javinpaul)):

public class StaticTest {

    private int count=0;
    public static void main(String args[]) throws IOException {
        count++; //compiler error: non‐static variable count cannot be referenced from a 
static context
    }
}

To fix the “non­static variable . . . cannot be referenced from a static context” error, two
things can be done:

The variable can be declared static in the signature.
The code can create an instance of a non­static object in the static method.

Read this tutorial that explains what is the difference between static and non­static
variables (http://www.sitesbay.com/java/java­static­and­non­static­variable). (@sitesbay
(https://twitter.com/sitesbay))

19. “non­static method . . . cannot be referenced from a static
context”
This issue occurs when the Java code tries to call a non­static method in a non­static
class. For example, the following code:

class Sample
{
   private int age;
   public void setAge(int a)
   {
      age=a;
   }
   public int getAge()
   {
      return age;
   }
   public static void main(String args[])
   {
       System.out.println("Age is:"+ getAge());
   }
}
Would return this error:

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
Cannot make a static reference to the non‐static method getAge() from the type Sample

To call a non­static method trom a static method is to declare an instance of the class
calling the non­static method.

Read this explanation of what is the difference between non­static methods and static
methods (http://beginnersbook.com/2013/05/static­vs­non­static­methods/).

20. “(array) <X> not initialized”
You’ll get the “(array) <X> not initialized” message when an array has been declared but
not initialized. Arrays are fixed in length so each array needs to be initialized
(https://stackoverflow.com/questions/5387643/array­initialization­syntax­when­not­in­a­
declaration) with the desired length.

The following code is acceptable:

AClass[] array = {object1, object2}

As is:
AClass[] array = new AClass[2];
...
array[0] = object1;
array[1] = object2;

But not:

AClass[] array;
...
array = {object1, object2};

Read this discussion of how to initialize arrays in Java software
(https://stackoverflow.com/questions/2403477/array­variable­initialization­error­in­java).
(@StackOverflow (https://twitter.com/StackOverflow))

Runtime Exceptions

21. “ArrayIndexOutOfBoundsException”
This is a runtime error message that occurs when the code attempts to access an array
index that is not within the values. The following code
(https://stackoverflow.com/questions/5554734/what­causes­a­java­lang­
arrayindexoutofboundsexception­and­how­do­i­prevent­it) would trigger this exception:

String[] name = {"tom", "dick", "harry"};
for(int i = 0; i<=name.length; i++) {
  System.out.print(name[i] +'\n');
}

Here’s another example
(https://www.cs.duke.edu/csed/ap/subset/doc/ap/java/lang/ArrayIndexOutOfBoundsException.html
(@DukeU (https://twitter.com/DukeU)):

int[] list = new int[5];
  list[5] = 33;            // illegal index, maximum index is 4

Array indexes start at zero and end at one less than the length of the array. Often it is fixed
by using “<” instead of “<=” when defining the limits of the array index.
Check out this example of how an index triggered the “ArrayIndexOutOfBoundsException”
Java software error message (https://stackoverflow.com/questions/42654273/issue­with­
arrayindexoutofrange). (@StackOverflow (https://twitter.com/StackOverflow))

22.  “StringIndexOutOfBoundsException”
This is an issue that occurs when the code attempts to access part of the string that is not
within the bounds of the string. Usually this happens when the code tries to create a
substring of a string that is not as longer as the parameters are set at. Here’s an example
(https://examples.javacodegeeks.com/java­basics/exceptions/java­lang­
stringindexoutofboundsexception­how­to­solve­stringindexoutofboundsexception/)
(@javacodegeeks (https://twitter.com/javacodegeeks)):

public class StringCharAtExample {
    public static void main(String[] args) {
        String str = "Java Code Geeks!";
        System.out.println("Length: " + str.length());
         
        //The following statement throws an exception, because
        //the request index is invalid.
        char ch = str.charAt(50);
    }
}

Like array indexes, string indexes start at zero. When indexing a string, the last character
is at one less than the length of the string. The “StringIndexOutOfBoundsException” Java
software error message usually means the index is trying to access characters that aren’t
there.

Here’s an example that illustrates how the “StringIndexOutOfBoundsException”
(https://stackoverflow.com/questions/19670369/java­stringindexoutofboundsexception) can
occur and be fixed. (@StackOverflow (https://twitter.com/StackOverflow))

23. “NullPointerException”
A “NullPointerException” will occur when the program tries to use an object reference that
does not have a value assigned (http://www.geeksforgeeks.org/null­pointer­exception­in­
java/) to it (@geeksforgeeks (https://twitter.com/geeksforgeeks)).
// A Java program to demonstrate that invoking a method
// on null causes NullPointerException
import java.io.*;
 
class GFG
{
    public static void main (String[] args)
    {
        // Initializing String variable with null value
        String ptr = null;
 
        // Checking if ptr.equals null or works fine.
        try
        {
            // This line of code throws NullPointerException
            // because ptr is null
The Java program raises an exception often when:
            if (ptr.equals("gfg"))
                System.out.print("Same");
A statement references an object with a null value.
            else
Trying to access a class that is defined but isn’t assigned a reference.
                System.out.print("Not Same");
        }
Here’s discussion of when developers may encounter the “NullPointerException”
        catch(NullPointerException e)
(https://stackoverflow.com/questions/218384/what­is­a­nullpointerexception­and­how­do­i­
        {
fix­it) and how to handle it. (@StackOverflow (https://twitter.com/StackOverflow))
            System.out.print("NullPointerException Caught");
        }
    }
}
24. “NoClassDefFoundError”
The “NoClassDefFoundError” will occur when the interpreter cannot find the file containing
a class with the main method. Here’s an example from DZone
(https://dzone.com/articles/java­classnotfoundexception­vs­noclassdeffounderro)
(@DZone (https://twitter.com/DZone)):

If you compile this program:

class A
{
  // some code
}
public class B
{
    public static void main(String[] args)
    {
        A a = new A();
    }
}
Two .class files are generated: A.class and B.class. Removing the A.class file and running
the B.class file, you’ll get the NoClassDefFoundError:

Exception in thread "main" java.lang.NoClassDefFoundError: A
at MainClass.main(MainClass.java:10)
Caused by: java.lang.ClassNotFoundException: A
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

This can happen if:

The file is not in the right directory.
The name of the class must be the same as the name of the file (without the file
extension). The names are case sensitive.

Read this discussion of why “NoClassDefFoundError” occurs when running Java software
(https://stackoverflow.com/questions/34413/why­am­i­getting­a­noclassdeffounderror­in­
java). (@StackOverflow (https://twitter.com/StackOverflow))

25. “NoSuchMethodFoundError”
This error message
(http://wiki.cs.und.edu/java_errors#nosuchmethodfounderrormain_could_not_find_or_load_main_c
will occur when the Java software tries to call a method of a class and the method no
longer has a definition (@myUND (https://twitter.com/myUND)):

Error: Could not find or load main class wiki.java

Often the “NoSuchMethodFoundError” Java software error occurs when there is a typo in
the declaration.

Read this tutorial to learn how to avoid the error message NoSuchMethodFoundError
(https://examples.javacodegeeks.com/java­basics/java­lang­nosuchmethoderror­how­to­
avoid/).” (@javacodegeeks (https://twitter.com/javacodegeeks))

26. “NoSuchProviderException”
“NoSuchProviderException” occurs when a security provider is requested that is not
available (http://alvinalexander.com/blog/post/java/java­javax­mail­
nosuchproviderexception­solved) (@alvinalexander (https://twitter.com/alvinalexander)):
javax.mail.NoSuchProviderException

When trying to find why “NoSuchProviderException” occurs, check:

The JRE configuration.
The Java home is set in the configuration.
Which Java environment is used.
The security provider entry.

Read this discussion of what causes “NoSuchProviderException”
(https://stackoverflow.com/questions/3711754/why­java­security­nosuchproviderexception­
no­such­provider­bc) when Java software is run. (@StackOverflow
(https://twitter.com/StackOverflow))

27. AccessControlException
AccessControlException indicates that requested access to system resources such as a
file system or network is denied, as in this example from JBossDeveloper
(https://developer.jboss.org/thread/274429) (@jbossdeveloper
(https://twitter.com/jbossdeveloper)):

ERROR Could not register mbeans java.security.
 
AccessControlException: WFSM000001: Permission check failed (permission "("javax.manageme
nt.MBeanPermission" "org.apache.logging.log4j.core.jmx.LoggerContextAdmin#‐
[org.apache.logging.log4j2:type=51634f]" "registerMBean")" in code source "(vfs:/C:/wildf
ly‐10.0.0.Final/standalone/deployments/mySampleSecurityApp.war/WEB‐INF/lib/log4j‐core‐2.5
.
jar )" of "null")

Read this discussion of a workaround used to get past an “AccessControlException” error.
(https://github.com/junit­team/junit4/issues/1213) (@github (https://twitter.com/github))

28. “ArrayStoreException”
An “ArrayStoreException” occurs when the rules of casting elements in Java arrays
(http://mindprod.com/jgloss/array.html#ARRAYSTOREEXCEPTION) are broken. Arrays
are very careful about what can go into them. (@Roedyg (https://twitter.com/Roedyg)) For
instance, this example from JavaScan.com
(https://www.javascan.com/306/arraystoreexception­in­java­example) illustrates that this
program (@java_scan (https://twitter.com/java_scan)):
 /* ............... START ............... */
                
public class JavaArrayStoreException {

  public static void main(String... args) {
    Object[] val = new Integer[4];
    val[0] = 5.8;
  }

}
                /* ............... END ............... */

Results in the following output:

Exception in thread "main" java.lang.ArrayStoreException: java.lang.Double
  at ExceptionHandling.JavaArrayStoreException.main(JavaArrayStoreException.java:7)

When an array is initialized, the sorts of objects allowed into the array need to be declared.
Then each array element needs be of the same type of object.

Read this discussion of how to solve for the “ArrayStoreException.”
(https://stackoverflow.com/questions/12369957/dealing­with­an­
arraystoreexception) (@StackOverflow (https://twitter.com/StackOverflow))

29. “bad magic number”
This Java software error message means something may be wrong with the class
definition files on the network. Here’s an example from The Server Side
(http://www.theserverside.com/news/thread.tss?thread_id=33274) (@TSS_dotcom
(https://twitter.com/TSS_dotcom)):

Java(TM) Plug‐in: Version 1.3.1_01
Using JRE version 1.3.1_01 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\Ankur

Proxy Configuration: Manual Configuration

Proxy: 192.168.11.6:80

java.lang.ClassFormatError: SalesCalculatorAppletBeanInfo (Bad magic number)

at java.lang.ClassLoader.defineClass0(Native Method)

at java.lang.ClassLoader.defineClass(Unknown Source)

at java.security.SecureClassLoader.defineClass(Unknown Source)
The “bad magic number” error message could happen when:

The first four bytes of a class file is not the hexadecimal number CAFEBABE.
The class file was uploaded as in ASCII mode not binary mode.
The java program is run before it is compiled.

Read this discussion of how to find the reason for a “bad magic number.”
(https://coderanch.com/t/407789/java/java­bad­magic­number­error) (@coderanch
(https://twitter.com/coderanch))

30. “broken pipe”
This error message (https://www.experts­exchange.com/questions/23307716/Exception­
in­thread­main­java­net­SocketException­Broken­pipe.html) refers to the data stream from
a file or network socket has stopped working or is closed from the other end
(@ExpertsExchange (https://twitter.com/ExpertsExchange)).

Exception in thread "main" java.net.SocketException: Broken pipe
      at java.net.SocketOutputStream.socketWrite0(Native Method)
      at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
      at java.net.SocketOutputStream.write(SocketOutputStream.java:115)
      at java.io.DataOutputStream.write

The causes of a broken pipe often include:

Running out of disk scratch space.
RAM may be clogged.
The datastream may be corrupt.
The process reading the pipe might have been closed.

Read this discussion of what is the Java error “broken pipe.”
(https://stackoverflow.com/questions/3751661/what­is­the­meaning­of­broken­pipe­
exception) (@StackOverflow (https://twitter.com/StackOverflow))

31. “could not create Java Virtual Machine”
This Java error message (https://www.ghacks.net/2014/05/22/fix­error­create­java­virtual­
machine­windows/) usually occurs when the code tries to invoke Java with the wrong
arguments (@ghacksnews (https://twitter.com/ghacksnews)):
Error: Could not create the Java Virtual Machine

Error: A fatal exception has occurred. Program will exit.

It often is caused by a mistake in the declaration in the code or allocating the proper
amount of memory to it.

Read this discussion of how to fix the Java software error “Could not create Java Virtual
Machine.” (https://stackoverflow.com/questions/25609405/error­could­not­create­the­java­
virtual­machine­mac­osx­mavericks) (@StackOverflow (https://twitter.com/StackOverflow))

32. “class file contains wrong class”
The “class file contains wrong class” issue occurs when the Java code tries to find the
class file in the wrong directory, resulting in an error message
(http://www.javalobby.org/java/forums/t80235.html) similar to the following:

MyTest.java:10: cannot access MyStruct 
bad class file: D:\Java\test\MyStruct.java 
file does not contain class MyStruct 
Please remove or make sure it appears in the correct subdirectory of the classpath. 
MyStruct ms = new MyStruct(); 

To fix this error, these tips could help:

Make sure the name of the source file and the name of the class match — including
case.
Check if the package statement is correct or missing.
Make sure the source file is in the right directory.

Read this discussion of how to fix a “class file contains wrong class”
(https://stackoverflow.com/questions/8377239/java­class­file­contains­wrong­class­
error) error. (@StackOverflow (https://twitter.com/StackOverflow))

33. “ClassCastException”
The “ClassCastException” message indicates the Java code is trying to cast an object to
the wrong class. In this example from Java Concept of the Day, running the following
program:
package com;
class A
{
    int i = 10;
}
 
class B extends A
{
    int j = 20;
}
 
class C extends B
{
    int k = 30;
}
 
Results in this error:
public class ClassCastExceptionDemo
{
Exception in thread “main” java.lang.ClassCastException: com.B cannot be cast to com.C
    public static void main(String[] args)
at com.ClassCastExceptionDemo.main(ClassCastExceptionDemo.java:23)
    {
        A a = new B();   //B type is auto up casted to A type
The Java code will create a hierarchy of classes and subclasses. To avoid the
        B b = (B) a;     //A type is explicitly down casted to B type.
“ClassCastException” error, make sure the new type belongs to the right class or one of its
        C c = (C) b;    //Here, you will get class cast exception
        System.out.println(c.k);
parent classes. If Generics are used, these errors can be caught when the code is
    }
compiled.
}

Read this tutorial on how to fix “ClassCastException” Java software errors
(http://javaconceptoftheday.com/classcastexception­in­java/). (@java_concept
(https://twitter.com/java_concept))

34. “ClassFormatError”
The “ClassFormatError” message indicates a linkage error
(https://www.mkyong.com/hibernate/java­lang­classformaterror­absent­code­attribute­in­
method­that­is­not­native­or­abstract­in­class­file/) and occurs when a class file cannot be
read or interpreted as a class file.
Caused by: java.lang.ClassFormatError: Absent Code attribute in method that is
        not native or abstract in class file javax/persistence/GenerationType

  at java.lang.ClassLoader.defineClass1(Native Method)
  at java.lang.ClassLoader.defineClassCond(Unknown Source)
  at java.lang.ClassLoader.defineClass(Unknown Source)
  at java.security.SecureClassLoader.defineClass(Unknown Source)
  at java.net.URLClassLoader.defineClass(Unknown Source)
  at java.net.URLClassLoader.access$000(Unknown Source)
  at java.net.URLClassLoader$1.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)

There are several reasons why a “ClassFormatError” can occur:

The class file was uploaded as in ASCII mode not binary mode.
The web server must send class files as binary not ASCII.
There could be a classpath error that prevents the code from finding the class file.
If the class is loaded twice, the second time will cause the exception to be thrown.
An old version of Java runtime is being used.

Read this discussion about what causes the “ClassFormatError”
(https://stackoverflow.com/questions/10021752/java­what­causes­classformaterror) in
Java. (@StackOverflow (https://twitter.com/StackOverflow))

35. “ClassNotFoundException”
“ClassNotFoundException” only occurs at run time — meaning a class that was there
during compilation is missing at run time. This is a linkage error.
Much like the “NoClassDefFoundError,” this issue can occur if:

The file is not in the right directory.
The name of the class must be the same as the name of the file (without the file
extension). The names are case sensitive.

Read this discussion of what causes “ClassNotFoundException”
(https://stackoverflow.com/questions/17408769/how­do­i­resolve­this­java­class­not­found­
exception) the for more cases. (@StackOverflow (https://twitter.com/StackOverflow))

36. “ExceptionInInitializerError”
This Java issue (https://github.com/square/leakcanary/issues/46) will occur when
something goes wrong with a static initialization (@GitHub (https://twitter.com/github)).
When the Java code later uses the class, the “NoClassDefFoundError” error will occur.

java.lang.ExceptionInInitializerError
  at org.eclipse.mat.hprof.HprofIndexBuilder.fill(HprofIndexBuilder.java:54)
  at org.eclipse.mat.parser.internal.SnapshotFactory.parse(SnapshotFactory.java:193)
  at org.eclipse.mat.parser.internal.SnapshotFactory.openSnapshot(SnapshotFactory.java
:106)
  at com.squareup.leakcanary.HeapAnalyzer.openSnapshot(HeapAnalyzer.java:134)
  at com.squareup.leakcanary.HeapAnalyzer.checkForLeak(HeapAnalyzer.java:87)
  at com.squareup.leakcanary.internal.HeapAnalyzerService.onHandleIntent(HeapAnalyzerS
ervice.java:56)
  at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
  at android.os.Handler.dispatchMessage(Handler.java:102)
  at android.os.Looper.loop(Looper.java:145)
  at android.os.HandlerThread.run(HandlerThread.java:61)
Caused by: java.lang.NullPointerException: in == null
  at java.util.Properties.load(Properties.java:246)
  at org.eclipse.mat.util.MessageUtil.(MessageUtil.java:28)
There needs to be more information to fix the error. Using getCause() in the code can
  at org.eclipse.mat.util.MessageUtil.(MessageUtil.java:13)
return the exception that caused the error to be returned.
  ... 10 more

Read this discussion about how to track down the cause of the ExceptionInInitializerError
(https://stackoverflow.com/questions/3375810/exception­in­initializer­error).
(@StackOverflow (https://twitter.com/StackOverflow))

37. “IllegalBlockSizeException”
An “IllegalBlockSizeException” will occur during decryption when the length message is
not a multiple of 8 bytes. Here’s an example from ProgramCreek.com
(http://www.programcreek.com/java­api­examples/index.php?
api=javax.crypto.IllegalBlockSizeException) (@ProgramCreek
(https://twitter.com/ProgramCreek)):

@Override
protected byte[] engineWrap(Key key) throws IllegalBlockSizeException, InvalidKeyExceptio
n {
try {
byte[] encoded = key.getEncoded();
return engineDoFinal(encoded, 0, encoded.length);
} catch (BadPaddingException e) {
IllegalBlockSizeException newE = new IllegalBlockSizeException();
newE.initCause(e);
throw newE;
}
}

The “IllegalBlockSizeException” could be caused by:

Different encryption and decryption algorithm options used.
The message to be decrypted could be truncated or garbled in transmission.

Read this discussion about how to prevent the IllegalBlockSizeException
(https://stackoverflow.com/questions/16192140/cipher­what­is­the­reason­for­
illegalblocksizeexception) Java software error message. (@StackOverflow
(https://twitter.com/StackOverflow))

38. “BadPaddingException”
A “BadPaddingException” will occur during decryption when padding was used to create a
message than can be measured by a multiple of 8 bytes. Here’s an example from Stack
Overflow (https://stackoverflow.com/questions/4580982/javax­crypto­
badpaddingexception) (@StackOverflow (https://twitter.com/StackOverflow)):

javax.crypto.BadPaddingException: Given final block not properly padded
at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
at com.sun.crypto.provider.AESCipher.engineDoFinal(DashoA13*..)
at javax.crypto.Cipher.doFinal(DashoA13*..)

Encrypted data is binary so don’t try to store it in a string or the data was not padded
properly during encryption.

Read this discussion about how to prevent the BadPaddingException
(https://stackoverflow.com/questions/31944374/badpaddingexception­decryption­error).
(@StackOverflow (https://twitter.com/StackOverflow))
39. “IncompatibleClassChangeError”
An “IncompatibleClassChangeError” is a form of LinkageError that can occur when a base
class changes after the compilation of a child class. This example is from How to Do in
Java (http://howtodoinjava.com/core­java/reflection/solved­java­lang­
incompatibleclasschangeerror­implementing­class/) (@HowToDoInJava
(https://twitter.com/HowToDoInJava)):

Exception in thread "main" java.lang.IncompatibleClassChangeError: Implementing class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at net.sf.cglib.core.DebuggingClassWriter.toByteArray(DebuggingClassWriter.java:73)
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:2
6)
When the “IncompatibleClassChangeError” occurs, it is possible that
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:144)
The static on the main method was forgotten.
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:116)
A legal class was used illegally.
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
A class was changed and there are references to it from an another class by its old
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
signatures. Try deleting all class files and recompiling everything.
at net.sf.cglib.proxy.Enhancer.(Enhancer.java:69)

Try these steps to resolve the “IncompatibleClassChangeError.”
(https://examples.javacodegeeks.com/java­basics/exceptions/java­lang­
incompatibleclasschangeerror­how­to­resolve­incompatible­class­change­
error/) (@javacodegeeks (https://twitter.com/javacodegeeks))

40. “FileNotFoundException”
This Java software error message (http://www.javased.com/?
api=java.io.FileNotFoundException) is thrown when a file with the specified pathname
does not exist.
@Override public ParcelFileDescriptor openFile(Uri uri,String mode) throws FileNotFoundEx
ception {
  if (uri.toString().startsWith(FILE_PROVIDER_PREFIX)) {
    int m=ParcelFileDescriptor.MODE_READ_ONLY;
    if (mode.equalsIgnoreCase("rw"))     m=ParcelFileDescriptor.MODE_READ_WRITE;
    File f=new File(uri.getPath());
    ParcelFileDescriptor pfd=ParcelFileDescriptor.open(f,m);
    return pfd;
  }
 else {
    throw new FileNotFoundException("Unsupported uri: " + uri.toString());
  }
}

In addition to files not existing the specified pathname, this could mean the existing file is
inaccessible.

Read this discussion about why the “FileNotFoundException” could be thrown
(https://stackoverflow.com/questions/19307622/java­new­file­says­filenotfoundexception­
but­file­exists). (@StackOverflow (https://twitter.com/StackOverflow))

41. “EOFException”
An “EOFException” is thrown when an end of file or end of stream has been reached
unexpectedly during input. Here’s an example from JavaBeat
(http://javabeat.net/eofexception/) of an application that throws an EOFException:

import java.io.DataInputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class ExceptionExample {
  public void testMethod1(){
    File file = new File("test.txt");
    DataInputStream dataInputStream =  null;
    try{
      dataInputStream = new DataInputStream(new FileInputStream(file
));
      while(true){
        dataInputStream.readInt(); 
      }     
Running the program above results in the following exception:
    }catch (EOFException e){     
      e.printStackTrace();
    }
    catch (IOException e){
java.io.EOFException
  at java.io.DataInputStream.readInt(DataInputStream.java:392)
  at logging.simple.ExceptionExample.testMethod1(ExceptionExample.java:16)
  at logging.simple.ExceptionExample.main(ExceptionExample.java:36)

When there is no more data while the class DataInputStream is trying to read data in the
stream, “EOFException” will be thrown. It can also occur in the ObjectInputStream and
RandomAccessFile classes.

Read this discussion about when the “EOFException” can occur while running Java
software (https://stackoverflow.com/questions/664331/when­will­an­eofexception­occur­in­
javas­streams). (@StackOverflow (https://twitter.com/StackOverflow))

42. “UnsupportedEncodingException”
This Java software error message is thrown when character encoding is not supported
(https://www.cis.upenn.edu/~bcpierce/courses/629/jdkdocs/api/java.io.UnsupportedEncodingExcep
(@Penn (https://twitter.com/Penn)).

public UnsupportedEncodingException()

It is possible that the Java Virtual Machine being used doesn’t support a given character
set.

Read this discussion of how to handle “UnsupportedEncodingException”
(https://stackoverflow.com/questions/10748440/recommended­method­for­handling­
unsupportedencodingexception­from­string­getbyte) while running Java software.
(@StackOverflow (https://twitter.com/StackOverflow))

43. “SocketException”
A “SocketException” indicates there is an error creating or accessing a socket
(http://www.programcreek.com/java­api­examples/java.net.SocketException)
(@ProgramCreek (https://twitter.com/ProgramCreek)).
public void init(String contextName, ContextFactory factory) {
  super.init(contextName, factory);
      
  String periodStr = getAttribute(PERIOD_PROPERTY);
  if (periodStr != null) {
    int period = 0;
    try {
      period = Integer.parseInt(periodStr);
    } catch (NumberFormatException nfe) {
    }

     if (period <= 0) {
      throw new MetricsException("Invalid period: " + periodStr);
    }
    setPeriod(period);
  }
      
This exception usually is thrown when the maximum connections are reached due to:
  metricsServers = 
    Util.parse(getAttribute(SERVERS_PROPERTY), DEFAULT_PORT); 
No more network ports available to the application.
      
The system doesn’t have enough memory to support new connections.
  unitsTable = getAttributeTable(UNITS_PROPERTY);
  slopeTable = getAttributeTable(SLOPE_PROPERTY);
Read this discussion of how to resolve “SocketException” issues
  tmaxTable  = getAttributeTable(TMAX_PROPERTY);
(https://stackoverflow.com/questions/585599/whats­causing­my­java­net­socketexception­
  dmaxTable  = getAttributeTable(DMAX_PROPERTY);
connection­reset) while running Java software. (@StackOverflow
      
  try {
(https://twitter.com/StackOverflow))
    datagramSocket = new DatagramSocket();
  }
  catch (SocketException se) {
44. “SSLException”
    se.printStackTrace();
  }
This Java software error message occurs when there is failure in SSL­related operations.
}
The following example is from Atlassian (https://confluence.atlassian.com/jirakb/unable­to­
access­ssl­services­due­to­java­security­invalidalgorithmparameterexception­
218269293.html) (@Atlassian (https://twitter.com/Atlassian)):

com.sun.jersey.api.client.ClientHandlerException: javax.net.ssl.SSLException: java.lan
g.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException
: the trustAnchors parameter must be non‐empty
   at com.sun.jersey.client.apache.ApacheHttpClientHandler.handle(ApacheHttpClientHand
ler.java:202)
   at com.sun.jersey.api.client.Client.handle(Client.java:365)
   at com.sun.jersey.api.client.WebResource.handle(WebResource.java:556)
   at com.sun.jersey.api.client.WebResource.get(WebResource.java:178)
   at com.atlassian.plugins.client.service.product.ProductServiceClientImpl.getProduct
VersionsAfterVersion(ProductServiceClientImpl.java:82)
   at com.atlassian.upm.pac.PacClientImpl.getProductUpgrades(PacClientImpl.java:111)
   at com.atlassian.upm.rest.resources.ProductUpgradesResource.get(ProductUpgradesReso
urce.java:39)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
This can happen if:

Certificates on the server or client have expired.
Server port has been reset to another port.

Read this discussion of what can cause the “SSLException” error
(https://stackoverflow.com/questions/30538640/javax­net­ssl­sslexception­read­error­ssl­
0x9524b800­i­o­error­during­system?lq=1) in Java software. (@StackOverflow
(https://twitter.com/StackOverflow))

45. “MissingResourceException”
A “MissingResourceException” occurs when a resource is missing. If the resource is in the
correct classpath, this is usually because a properties file is not configured properly.
Here’s an example
(http://community.jaspersoft.com/questions/823206/javautilmissingresourceexception­cant­
find­bundle­base­name­localemsgsenus­locale) (@TIBCO (https://twitter.com/TIBCO)):

java.util.MissingResourceException: Can't find bundle for base name localemsgs_en_US, loc
ale en_US
java.util.ResourceBundle.throwMissingResourceException
java.util.ResourceBundle.getBundleImpl
java.util.ResourceBundle.getBundle
net.sf.jasperreports.engine.util.JRResourcesUtil.loadResourceBundle
net.sf.jasperreports.engine.util.JRResourcesUtil.loadResourceBundle

Read this discussion of how to fix “MissingResourceException”
(https://javahowto.blogspot.com/2006/05/debug­java­util­missingresourceexcepti.html)
while running Java software.

46. “NoInitialContextException”
A “NoInitialContextException” occurs when the Java application wants to perform a
naming operation but can’t create a connection (https://camel.apache.org/exception­
javaxnamingnoinitialcontextexception.html) (@TheASF (https://twitter.com/TheASF)).
[java] Caused by: javax.naming.NoInitialContextException: Need to specify class name in e
nvironment or system property, or as an applet parameter, or in an application resource f
ile:  java.naming.factory.initial
[java]     at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
[java]     at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
[java]     at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
[java]     at javax.naming.InitialContext.lookup(InitialContext.java:351)
[java]     at org.apache.camel.impl.JndiRegistry.lookup(JndiRegistry.java:51)

This can be a complex problem to solve but here are some possible problems that cause
the “NoInitialContextException” Java error message:

The application may not have the proper credentials to make a connection.
The code may not identify the implementation of JNDI needed.
The InitialContext class may not be configured with the right properties.

Read this discussion of what “NoInitialContextException” means
(https://stackoverflow.com/questions/6387238/what­does­javax­naming­
noinitialcontextexception­mean) when running Java software. (@StackOverflow
(https://twitter.com/StackOverflow))

47. “NoSuchElementException”
A “NoSuchElementException” happens when an iteration (such as a “for” loop) tries to
access the next element when there is none.

public class NoSuchElementExceptionDemo{

    public static void main(String args[]) {
        Hashtable sampleMap = new Hashtable();
        Enumeration enumeration = sampleMap.elements();
        enumeration.nextElement();  //java.util.NoSuchElementExcepiton here because en
umeration is empty
    }
}

Output:
Exception in thread "main" java.util.NoSuchElementException: Hashtable Enumerator
        at java.util.Hashtable$EmptyEnumerator.nextElement(Hashtable.java:1084)
        at test.ExceptionTest.main(NoSuchElementExceptionDemo.java:23)

The “NoSuchElementException” can be thrown by these methods:
Enumeration::nextElement()
NamingEnumeration::next()
StringTokenizer::nextElement()
Iterator::next()

Read this tutorial of how to fix “NoSuchElementException”
(https://javarevisited.blogspot.com/2012/02/how­to­solve­
javautilnosuchelementexcep.html) in Java software. (@javinpaul
(https://twitter.com/javinpaul))

48. “NoSuchFieldError”
This Java software error message is thrown when an application tries to access a field in
an object but the specified field no longer exists
(http://ulibgcj.sourceforge.net/javadoc/java/lang/NoSuchFieldError.html) in the onbject
(@sourceforge (https://twitter.com/sourceforge)).

public NoSuchFieldError()

Usually this error is caught in the compiler but will be caught during runtime if a class
definition has been changed between compile and running.

Read this discussion of how to find what causes the “NoSuchFieldError”
(https://stackoverflow.com/questions/6686753/nosuchfielderror­java) when running Java
software. @StackOverflow (https://twitter.com/StackOverflow)

49. “NumberFormatException”
This Java software error message occurs (http://alvinalexander.com/blog/post/java/java­
faq­what­is­numberformatexception) when the application tries to convert a string to a
numeric type, but that the number is not a valid string of digits (@alvinalexander
(https://twitter.com/alvinalexander)).
package com.devdaily.javasamples;

public class ConvertStringToNumber {

    public static void main(String[] args) {
        try {
            String s = "FOOBAR";
            int i = Integer.parseInt(s);
            // this line of code will never be reached
            System.out.println("int value = " + i);
        }
        catch (NumberFormatException nfe) {
            nfe.printStackTrace();
        }
    }

The can “NumberFormatException” be thrown when:
}

Leading or trailing spaces in the number.
The sign is not ahead of the number.
The number has commas.
Localisation may not categorize it as a valid number.
The number is too big to fit in the numeric type.

Read this discussion of how to avoid “NumberFormatException”
(https://stackoverflow.com/questions/5499523/how­to­avoid­number­format­exception­in­
java) when running Java software. (@StackOverflow (https://twitter.com/StackOverflow))

50. “TimeoutException”
This Java software error message occurs when a blocking operation times out
(http://www.javased.com/index.php?api=java.util.concurrent.TimeoutException).

private void queueObject(ComplexDataObject obj) throws TimeoutException, InterruptedExcep
tion {
  if (!queue.offer(obj,10,TimeUnit.SECONDS)) {
    TimeoutException ex=new TimeoutException("Timed out waiting for parsed elements to be
 processed. Aborting.");
    throw ex;
  }
}

Read this discussion about how to handle “TimeoutException”
(https://stackoverflow.com/questions/36575470/how­to­use­fallbackfuture­to­handle­
timeoutexception) when running Java software. (@StackOverflow
(https://twitter.com/StackOverflow))
For the ultimate Java developer’s toolkit, don’t forget to download The Comprehensive
Java Developer’s Guide (http://info.stackify.com/buildbetter­2.2­the­comprehensive­java­
developers­guide).

 About the Author  Latest Posts

About Stackify
Stackify provides developer teams with unparalleled visibility and
insight into application health and behavior, both proactively in a
monitoring role as well as reactively in a troubleshooting role, while
eliminating the need to login to servers and other resources in order to investigate
application problems.

  (https://www.facebook.com/Stackify/)    (https://twitter.com/stackify)  

(https://www.linkedin.com/company/2596184/)

0 Comments Stackify.com 
1 Login

Sort by Best
  Recommend  1 ⤤ Share

Start the discussion…

LOG IN WITH
OR SIGN UP WITH DISQUS  ?

Name

Be the first to comment.

✉ Subscribe d Add Disqus to your siteAdd DisqusAdd ὑ Privacy

  (https://www.facebook.com/Stackify/) PREFIX (https://stackify.com/prefix/)

  (https://twitter.com/Stackify)  RETRACE
(https://www.linkedin.com/company/stackify) (https://stackify.com/retrace/)
 BLOG (https://stackify.com/blog/)
(https://www.youtube.com/channel/UCnxYNQDtTr_ZYUnMjeACfCg)
SITEMAP
© 2017 Stackify
(https://stackify.com/sitemap_index.xml)
8900 State Line Rd, Ste 100, Leawood, KS 66206
CONTACT
(816) 888­5055
(https://stackify.com/contact­
us/)

SECURITY INFORMATION

(https://stackify.com/stackify­
security­information/)

TERMS & CONDITIONS

(https://stackify.com/terms­
conditions/)

PRIVACY POLICY

(https://stackify.com/privacy­
policy/)
Error Codes and Descriptions Page 1 of 77

Skip Headers

Oracle9iAS TopLink Troubleshooting Guide


Release 2 (9.0.3)
Part Number B10068-01 Core PlatformContents Index

2
Error Codes and Descriptions
This section lists each TopLink error code. Each error entry contains a description of the error, the
probable cause, and the recommended action. Each error code corresponds to an exception class. See
"Runtime and Development Exceptions" for more information.

Format:

A description shown in the actual exception thrown.

Cause: The most probable cause for the error.

Action: Suggestions for resolving the error.

Descriptor Exceptions (1 - 176)


Error code: 1

ATTRIBUTE_AND_MAPPING_WITH_INDIRECTION_ MISMATCH

Cause: <attributeName> is not declared as type ValueHolderInterface but the mapping uses
indirection. Mapping is set to use indirection but the related attribute is not defined as type
ValueHolderInterface. It is thrown on foreign reference mappings.

Action: If you want to use indirection on the mapping, change the attribute to type
ValueHolderInterface. Otherwise, change the mapping associated with the attribute so that it
does not use indirection.

Error code: 2

ATTRIBUTE_AND_MAPPING_WITHOUT_INDIRECTION_ MISMATCH

Cause: <attributeName> is declared as type ValueHolderInterface but the mapping is not


using indirection. Attribute is defined to be of type ValueHolderInterface but the mapping is
not set to use indirection. It is thrown on foreign reference mappings.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 2 of 77

Action: If you do not want to use indirection on the mapping, change the attribute to not be of
type ValueHolderInterface. Otherwise, change the mapping associated with the attribute to use
indirection.

Error code: 6

ATTRIBUTE_NAME_NOT_SPECIFIED

Cause: Attribute name is missing or not specified in the mapping definition.

Action: Specify the attribute name in the mapping by calling method setAttributeName(String
attribute name).

Error code: 7

ATTRIBUTE_TYPE_NOT_VALID

Cause: <attributeName> should be defined as type Vector, or a type that implements Map or
Collection if using Java 2. It happens in one to many mapping, many to many mapping and
collection mapping when mapping is set not to use indirection and attribute type is not declared of
type java.util.Vector.

Action: Declare the attribute to be of type java.util.Vector.

Error code: 8

CLASS_INDICATOR_FIELD_NOT_FOUND

Cause: The class indicator field has not been defined, however the descriptor has been set to use
inheritance. When using inheritance, a class indicator field or class extraction method must be set.
The class indicator field is used to create the right type of domain object

Action: Either a class indicator field or class extraction method must be set.

Error code: 9

DIRECT_FIELD_NAME_NOT_SET

Cause: The direct field name from the target table is not set in the direct collection mapping. The
field values form the collection in this mapping.

Action: Specify the direct field name by calling method setDirectFieldName(String


fieldName).

Error code: 10

FIELD_NAME_NOT_SET_IN_MAPPING

Cause: The field name is not set in the mapping. It is thrown from direct to field mapping, array

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 3 of 77

mapping and structure mapping.

Action: Specify the field name by calling method setFieldName(String fieldName).

Error code: 11

FOREIGN_KEYS_DEFINED_INCORRECTLY

Cause: One to one mapping foreign key defined incorrectly. Multiple foreign key fields were set
for one to one mapping by calling method setForeignKeyFieldName(String fieldName).

Action: Use method addForeignKeyFieldName(String sourceForeignKeyName, String


targetPrimaryKeyFieldName) to add multiple foreign key fields.

Error code: 12

IDENTITY_MAP_NOT_SPECIFIED

Cause: The descriptor must use an identity map to use the Check cache does exist option.
Descriptor has been set to not use identity map but the existence checking is set to be done on
identity map.

Action: Either use identity map or set the existence checking to some other option.

Error code: 13

ILLEGAL_ACCESS_WHILE_GETTING_VALUE_THRU_
INSTANCE_VARIABLE_ACCESSOR

Cause: <attributeName> instance variable in object <objectName> is inaccessible. Instance


variable in the domain object is not accessible. This exception is thrown when TopLink tries to
access the instance variable using Java reflection. The error is purely Java exception and TopLink
only wraps the reflection exception.

Action: Inspect the internal exception and check the Java manuals.

Error code: 14

ILLEGAL_ACCESS_WHILE_CLONING

Cause: Problem in cloning the object <domainObject>. Clone method <methodName> is not
accessible. The method name specified using useCloneCopyPolicy(String cloneMethodName)
or the clone() method to create clone on the domain object is not accessible by TopLink using
Java reflection. The error is purely Java exception and TopLink only wraps the reflection
exception.

Action: Inspect the internal exception and check the Java manuals.

Error code: 15

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 4 of 77

ILLEGAL_ACCESS_WHILE_CONSTRUCTOR_INSTANTIATION

Cause: The domain class does not define a public default constructor, which is needed by
TopLink to create new instances of the domain class.

Action: Define one or use different instantiation policy.

Error code: 16

ILLEGAL_ACCESS_WHILE_EVENT_EXECUTION

Cause: The descriptor callback method <eventMethodName> with DescriptorEvent as


argument, is not accessible. This exception is thrown when TopLink tries to access the event
method using Java reflection. The error is purely Java exception and TopLink only wraps the
reflection exception.

Action: Inspect the internal exception and check the Java manuals.

Error code: 17

ILLEGAL_ACCESS_WHILE_GETTING_VALUE_THRU_ METHOD_ACCESSOR

Cause: Trying to invoke inaccessible <methodName> on the object <objectName>. The


underlying get accessor method to access an attribute in the domain object is not accessible. This
exception is thrown when TopLink tries to access an attribute through method using Java
reflection. The error is purely Java exception and TopLink only wraps the reflection exception.

Action: Inspect the internal exception and check the Java manuals.

Error code: 18

ILLEGAL_ACCESS_WHILE_INSTANTIATING_METHOD_ BASED_PROXY

Cause: The method used by the Transformation mapping using a ValueHolder is illegal. This
exception is thrown when TopLink tries to access the method using Java reflection. The problem
is caused when method base value holder is getting instantiated.

Action: Inspect the internal exception and check the Java manuals.

Error code: 19

ILLEGAL_ACCESS_WHILE_INVOKING_ATTRIBUTE_METHOD

Cause: On transformation mapping the underlying attribute method used to retrieve value from
the database row while reading transformation mapped attribute is not accessible.

Action: Inspect the internal exception and check the Java manuals.

Error code: 20

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 5 of 77

ILLEGAL_ACCESS_WHILE_INVOKING_FIELD_TO_METHOD

Cause: On transformation mapping the method <methodName> used to retrieve value from the
object while writing transformation mapped attribute is not accessible. The error is purely Java
exception and TopLink only wraps the reflection exception.

Action: Inspect the internal exception and check the Java manuals.

Error code: 21

ILLEGAL_ACCESS_WHILE_INVOKING_ROW_EXTRACTION_ METHOD

Cause: Problem in extracting class from <row>; Static method <method> with <databaseRow> as
argument, is not accessible. The method to extract class from row on the domain object is not
accessible. The error is purely Java exception and TopLink only wraps the reflection exception.

Action: Inspect the internal exception and check the Java manuals.

Error code: 22

ILLEGAL_ACCESS_WHILE_METHOD_INSTANTIATION

Cause: Problem in creating new instance; the method <methodName> to create instances on the
domain class is not accessible. The error is purely Java exception and TopLink only wraps the
reflection exception.

Action: Inspect the internal exception and check the Java manuals.

Error code: 23

ILLEGAL_ACCESS_WHILE_OBSOLETE_EVENT_EXECUTION

Cause: The descriptor callback method <eventMethodName> with Session as argument, is


inaccessible. This exception is thrown when TopLink tries to access the event method using Java
reflection. The error is purely Java exception and TopLink only wraps the reflection exception.

Action: Inspect the internal exception and check the Java manuals.

Error code: 24

ILLEGAL_ACCESS_WHILE_SETTING_VALUE_THRU_
INSTANCE_VARIABLE_ACCESSOR

Cause: The <attributeName> instance variable in the object <objectName> is not accessible
through Java reflection. The error is thrown by Java and TopLink only wraps the reflection
exception.

Action: Inspect the internal exception and check the Java manuals.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 6 of 77

Error code: 25

ILLEGAL_ACCESS_WHILE_SETTING_VALUE_THRU_ METHOD_ACCESSOR

Cause: Trying to invoke inaccessible method <setMethodName> on the object with parameter
<parameter>. The attribute's set accessor method is not accessible through Java reflection. The
error is thrown by Java and TopLink only wraps the reflection exception.

Action: Inspect the internal exception and check the Java manuals.

Error code: 26

ILLEGAL_ARGUMENT_WHILE_GETTING_VALUE_
THRU_INSTANCE_VARIABLE_ACCESSOR

Cause: Trying to get a value for an instance variable <attributeName> of type <typeName> from
the object. The specified object is not an instance of the class or interface declaring the underlying
field. An object is accessed to get the value of an instance variable that does not exist.

Action: Inspect the internal exception and check the Java manuals.

Error code: 27

ILLEGAL_ARGUMENT_WHILE_GETTING_VALUE_THRU_ METHOD_ACCESSOR

Cause: Trying to invoke method <methodName> on the object <objectName>. The get accessor
method declaration on the domain object differs from the one that is defined. The number of
actual and formal parameters differ, or an unwrapping conversion has failed.

Action: Inspect the internal exception and check the Java manuals.

Error code: 28

ILLEGAL_ARGUMENT_WHILE_INSTANTIATING_METHOD_ BASED_PROXY

Cause: The method used by the method-based proxy in a Transformation mapping is getting
illegal arguments when the value holder is getting instantiated. This exception is thrown when
TopLink tries to access the method using Java reflection.

Action: Inspect the internal exception and check the Java manuals.

Error code: 29

ILLEGAL_ARGUMENT_WHILE_INVOKING_ATTRIBUTE_ METHOD

Cause: The number of actual and formal parameters differ, or an unwrapping conversion has
failed. On transformation mapping the method used to retrieve value from the database row while
reading transformation mapped attribute is getting illegal argument.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 7 of 77

Action: Inspect the internal exception and check the Java manuals.

Error code: 30

ILLEGAL_ARGUMENT_WHILE_INVOKING_FIELD_TO_ METHOD

Cause: The number of actual and formal parameters differ for method <methodName> or an
unwrapping conversion has failed. On transformation mapping the method used to retrieve value
from the object while writing transformation mapped attribute is getting illegal argument. The
error is purely Java exception and TopLink only wraps the reflection exception.

Action: Inspect the internal exception and check the Java manuals.

Error code: 31

ILLEGAL_ARGUMENT_WHILE_OBSOLETE_EVENT_ EXECUTION

Cause: he number of actual and formal parameters for the descriptor callback method
<eventMethodName> differs, or an unwrapping conversion has failed. The callback event method
is invoked with illegal argument. This exception is thrown when TopLink tries to invoke the event
method using Java reflection. The error is a purely Java exception and TopLink only wraps the
reflection exception.

Action: Inspect the internal exception and check the Java manuals.

Error code: 32

ILLEGAL_ARGUMENT_WHILE_SETTING_VALUE_THRU_
INSTANCE_VARIABLE_ACCESSOR

Cause: Illegal value is being assigned to the attribute instance variable. Trying to set a value
<value> for an instance variable <attributeName> of type <typeName> in the object. The
specified object is not an instance of the class or interface declaring the underlying field, or an
unwrapping conversion has failed.

TopLink does the assignment of value by using Java reflection. Java throws the error and TopLink
only wraps the reflection exception.

Action: Inspect the internal exception and check the Java manuals.

Error code: 33

ILLEGAL_ARGUMENT_WHILE_SETTING_VALUE_THRU _METHOD_ACCESSOR

Cause: Illegal argument is being passed to the attribute's set accessor method. Trying to invoke
method <setMethodName> on the object. The number of actual and formal parameters differs, or
an unwrapping conversion has failed. Java throws the error and TopLink only wraps the reflection
exception.

Action: Inspect the internal exception and check the Java manuals.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 8 of 77

Error code: 34

INSTANTIATION_WHILE_CONSTRUCTOR_INSTANTIATION

Cause: he class does not define a public default constructor, or the constructor raised an
exception. The default constructor for the domain object is invoked to create new instance of the
object while building new domain objects. If this Class represents an abstract class, an interface,
an array class, a primitive type, or void; or if the instantiation fails for some other reason. Java
throws the error and TopLink only wraps the reflection exception.

Action: Inspect the internal exception and check the Java manuals.

Error code: 35

INVALID_DATA_MODIFICATION_EVENT

Cause: This is an exception that an application should never encounter. The exception can occur
at the time of developing TopLink. In cases where one writes new mapping it is possible to get
this exception. In direct collection mapping and many to many mapping the target table and
relational table are populated at the end of the commit process and if data modification event is
sent to any other mapping then this exception is thrown.

Action: Contact Technical Support.

Error code: 36

INVALID_DATA_MODIFICATION_EVENT_CODE

Cause: This is an exception that an application should never encounter. The exception can occur
at the time of developing TopLink. In cases where one writes new mapping it is possible to get
this exception. In direct collection mapping and many to many mapping the target table and
relational table are populated at the end of the commit process and if data modification event is
sent to these two mappings with wrong event code then this exception is thrown.

Action: Contact Technical Support.

Error code: 37

INVALID_DESCRIPTOR_EVENT_CODE

Cause: This is an exception that an application should never encounter. The exception can occur
at the time of developing TopLink. The exception means that descriptor event manager does not
support the event code passed in the event.

Action: Contact Technical Support.

Error code: 38

INVALID_IDENTITY_MAP

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 9 of 77

Cause: Identity map constructor failed because an invalid identity map was specified. The identity
map class given in the descriptor cannot be instantiated. The exception is Java exception thrown
by Java reflection when TopLink is instantiating the identity map class. TopLink only wraps the
Java exception.

Action: Inspect the internal exception and check the Java manuals.

Error code: 39

JAVA_CLASS_NOT_SPECIFIED

Cause: The descriptor does not define a Java class. The Java class is not specified in the
descriptor.

Action: Specify the Java Class

Error code: 40

DESCRIPTOR_FOR_INTERFACE_IS_MISSING

Cause: A descriptor for the referenced interface is not added to the session.

Action: Add that descriptor to the session.

Error code: 41

MAPPING_FOR_SEQUENCE_NUMBER_FIELD

Cause: A non-read-only mapping is not defined for the sequence number field. A mapping is
required so that TopLink can put and extract values for the primary key.

Action: Define a mapping.

Error code: 43

MISSING_CLASS_FOR_INDICATOR_FIELD_VALUE

Cause: Missing class for indicator field value <classFieldValue> of type <type>. There was no
class entry found in the inheritance policy for the indicator field value read from the database.
Probably the method addClassIndicator(Class class, Object typeValue) was not called
for the field value. The class and typeValue is stored in the hashtable and later on the class is
extracted from the hashtable by passing typeValue as a key. Remember Integer(1) is not equal to
Float(1), this is another major reason for this problem when the type of typeValue is different.

Action: Check descriptor.

Error code: 44

MISSING_CLASS_INDICATOR_FIELD

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 10 of 77

Cause: The class indicator field is missing from the database row <row> that was read from the
database. This is done in inheritance model where after reading rows from the database, child
domain objects are to be constructed depending upon the type indicator values.

Action: Check the printed row to make sure the spelling is correct.

Error code: 45

MISSING_MAPPING_FOR_FIELD

Cause: Missing mapping for field <field>; a mapping for the field is not specified.

Action: Define a mapping for the field.

Error code: 46

NO_MAPPING_FOR_PRIMARY_KEY

Cause: A mapping for the primary key is not specified. There should be one non-read-only
mapping defined for the primary key field.

Action: efine a mapping for the primary key.

Error code: 47

MULTIPLE_TABLE_PRIMARY_KEY_NOT_SPECIFIED

Cause: The multiple table primary key mapping must be specified when a custom multiple table
join is used. If multiple tables are specified in the descriptor and the join expression is customized
then the primary keys for all the tables must be specified. If the primary keys are not specified
then the exception is caused.

Action: Call method addMultipleTablePrimaryKeyFieldName(String


fieldNameInPrimaryTable, String fieldNameInSecondaryTable) on the descriptor to set
the primary keys.

Error code: 48

MULTIPLE_WRITE_MAPPINGS_FOR_FIELD

Cause: There are multiple writable mappings for the field <fieldName> in the descriptor. Exactly
one must be defined writable. The others must be specified as read-only. When multiple write
mappings are defined for the field, TopLink cannot decide on which mapping to pick up for
writing the value of the field in the database row hence the exception is thrown during the
validation process of descriptors. The most common site for this problem is that sometimes the
field has direct-to-field mapping and also one-to-one mapping. In this case if direct-to-field
mapping has to be kept then one-to-one mapping should either be read-only or it should be target
foreign key reference.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 11 of 77

Action: Make one of those mappings read only.

Error code: 49

NO_ATTRIBUTE_TRANSFORMATION_METHOD

Cause: The attribute transformation method name in the transformation mapping is not specified.
This method is invoked internally by TopLink to retrieve value to store in the domain object.

Action: Define a method and set the method name on the mapping by calling method
setAttributeTransformation(String methodName).

Error code: 50

NO_FIELD_NAME_FOR_MAPPING

Cause: No field name is specified in direct-to-field mapping.

Action: Set the field by calling setFieldName(String FieldName).

Error code: 51

NO_FOREIGN_KEYS_ARE_SPECIFIED

Cause: Neither the selection criteria nor the foreign keys were specified on one-to-one mapping.
If the selection criterion is not specified then TopLink tries to build one from the foreign keys
specified in the mapping.

Action: Specify the fields.

Error code: 52

NO_REFERENCE_KEY_IS_SPECIFIED

Cause: No query key named: <queryKey> found in: <descriptor>; no reference key from the
target table is specified on direct collection mapping.

Action: Specify the fields by calling method setReferenceKeyFieldName(String fieldName).

Error code: 53

NO_RELATION_TABLE

Cause: The relation table name is not set in this many-to-many mapping.

Action: Set relation table name by calling method setRelationTableName(String


tableName).

Error code: 54

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 12 of 77

NO_SOURCE_RELATION_KEYS_SPECIFIED

Cause: There are no source relation keys specified in this many-to-many mapping.

Action: Add source relation keys to the mapping.

Error code: 55

NO_SUCH_METHOD_ON_FIND_OBSOLETE_METHOD

Cause: The descriptor callback method <selector> on the domain class was not found. It must
take a Session or a DescriptorEvent as its argument. TopLink tries to invoke the method using
Java reflection. It is a Java exception and TopLink is only wrapping the main exception.

Action: Inspect the internal exception and check the Java manuals.

Error code: 56

NO_SUCH_METHOD_ON_INITIALIZING_ ATTRIBUTE_METHOD

Cause: The method <attributeMethodName> with parameters <databaseRow> or <databaseRow,


session> is not found. TopLink wraps the Java reflection exception that is caused when the
method is being created from the method name. This method is set by calling
setAttributeMethodName(String aMethodName).

Action: Inspect the internal exception and check the Java manuals.

Error code: 57

NO_SUCH_METHOD_WHILE_CONSTRUCTOR_ INSTANTIATION

Cause: Inaccessible constructor. TopLink wraps the Java reflection exception that is caused when
it is creating a new instance of the domain.

Action: Inspect the internal exception and check the Java manuals.

Error code: 58

NO_SUCH_METHOD_WHILE_CONVERTING_TO_METHOD

Cause: Method <methodName> not found with parameters () or (Session). TopLink wraps the
Java reflection exception that is caused when it is creating a Method type from the method names
in transformation mapping.

Action: Inspect the internal exception and check the Java manuals.

Error code: 59

NO_SUCH_FIELD_WHILE_INITIALIZING_ATTRIBUTES_

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 13 of 77

IN_INSTANCE_VARIABLE_ACCESSOR

Cause: The instance variable <attributeName> is not defined in the domain class or it is not
accessible. TopLink wraps the Java reflection exception that is caused when it is creating a Field
type from the attribute name.

Action: Inspect the internal exception and check the Java manuals.

Error code: 60

NO_SUCH_METHOD_WHILE_INITIALIZING_ ATTRIBUTES_IN_METHOD_ACCESSOR

Cause: The accessor method <setMethodName> or <getMethodName> is not defined for the
attribute in the domain class <javaClassName>, or it is not accessible. TopLink wraps the Java
reflection exception that is caused when it is creating a Method type from the method name.

Action: Inspect the internal exception and check the Java manuals.

Error code: 61

NO_SUCH_METHOD_WHILE_INITIALIZING_ CLASS_EXTRACTION_METHOD

Cause: The static class extraction method <methodName> with <databaseRow> as argument does
not exist, or is not accessible. Java reflection exception wrapped in TopLink exception is thrown
when class extraction method is being created from the method name in inheritance policy.

Action: Inspect the internal exception and check the Java manuals.

Error code: 62

NO_SUCH_METHOD_WHILE_INITIALIZING_COPY_POLICY

Cause: The clone method <methodName> with no arguments does not exist, or is not accessible.
Java reflection exception wrapped in TopLink exception is thrown when a method to create clones
is being created from the method name in copy policy.

Action: Inspect the internal exception and check the Java manuals.

Error code: 63

NO_SUCH_METHOD_WHILE_INITIALIZING_ INSTANTIATION_POLICY

Cause: The instance creation method <methodName> with no arguments does not exist, or is not
accessible. Java reflection exception wrapped in TopLink exception is thrown when a method to
create new instances is being created from the method name in instantiation policy.

Action: Inspect the internal exception and check the Java manuals.

Error code: 64

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 14 of 77

NO_TARGET_FOREIGN_KEYS_SPECIFIED

Cause: The foreign keys in the target table are not specified in one-to-many mappings. These
fields are not required if a selection criterion is given in the mapping but otherwise they must be
specified.

Action: Set target foreign keys or selection criteria.

Error code: 65

NO_TARGET_RELATION_KEYS_SPECIFIED

Cause: There are no target relation keys specified in many-to-many mappings.

Action: Call method addTargetRelationKeyFieldName(String


targetRelationKeyFieldName, String targetPrimaryKeyFieldName) to set the fields.

Error code: 66

NOT_DESERIALIZABLE

Cause: The object cannot be de-serialized from the byte array read from the database. The
exception is thrown when serialized object mapping is converting byte array into object.

Action: Inspect the internal exception and check the Java manuals.

Error code: 67

NOT_SERIALIZABLE

Cause: The object cannot be serialized into byte array. The exception is thrown when serialized
object mapping is object into byte array.

Action: Inspect the internal exception and check the Java manuals.

Error code: 68

NULL_FOR_NON_NULL_AGGREGATE

Cause: Value of aggregate in the source object <object> is null. Null values not allowed for
aggregate mappings unless allow null is specified in aggregate mapping.

Action: Call method allowNull() on the mapping.

Error code: 69

NULL_POINTER_WHILE_GETTING_VALUE_THRU_
INSTANCE_VARIABLE_ACCESSOR

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 15 of 77

Cause: An object is accessed to get the value of an instance variable through Java reflection. This
exception is thrown only on some VMs.

Action: Inspect the internal exception and check the Java manuals.

Error code: 70

NULL_POINTER_WHILE_GETTING_VALUE_THRU_ METHOD_ACCESSOR

Cause: The get accessor method is invoked to get the value of attribute through Java reflection.
This exception is thrown only on some VMs.

Action: Inspect the internal exception and check the Java manuals.

Error code: 71

NULL_POINTER_WHILE_SETTING_VALUE_THRU_ INSTANCE_VARIABLE_ACCESSOR

Cause: Null Pointer Exception is thrown while setting value of <attributeName> instance variable
in the object to value. An object is accessed to set the value of an instance variable through Java
reflection. This exception is thrown only on some VMs.

Action: Inspect the internal exception and check the Java manuals.

Error code: 72

NULL_POINTER_WHILE_SETTING_VALUE_THRU_ METHOD_ACCESSOR

Cause: Null Pointer Exception is thrown while setting value through <setMethodName> method
in the object with argument <argument>. The set accessor method is invoked to set the value of
attribute through Java reflection. This exception is thrown only on some VMs.

Action: Inspect the internal exception and check the Java manuals.

Error code: 73

PARENT_DESCRIPTOR_NOT_SPECIFIED

Cause: Cannot find descriptor for parent class. The descriptor of a subclass has no parent
descriptor.

Action: The method setParentClass(Class parentClass) on the subclass descriptor must be


called.

Error code: 74

PRIMARY_KEY_FIELDS_NOT_SPECIFIED

Cause: The primary key fields are not set for this descriptor.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 16 of 77

Action: Add primary key field names using method setPrimaryKeyFieldName(String


fieldName) or setPrimaryKeyFieldName(String fieldName).

Error code: 75

REFERENCE_CLASS_NOT_SPECIFIED

Cause: The reference class is not specified in the foreign reference mapping.

Action: Set reference class by calling method setReferenceClass(Class aClass)

Error code: 77

REFERENCE_DESCRIPTOR_IS_NOT_AGGREGATE

Cause: The referenced descriptor for <className> should be set to aggregate descriptor. An
aggregate mapping should always reference a descriptor that is aggregate.

Action: Call method descriptorIsAggregate() on the referenced descriptor.

Error code: 78

REFERENCE_KEY_FIELD_NOT_PROPERLY_SPECIFIED

Cause: The table for the reference field must be the reference table. If the reference field name
specified in the direct collection mapping is qualified with the table name then the table name
should match the reference table name.

Action: Qualify the field with the proper name or change the reference table name.

Error code: 79

REFERENCE_TABLE_NOT_SPECIFIED

Cause: The reference table name in the direct collection mapping is not specified.

Action: Use method setReferenceTableName(String tableName) on the mapping to set the


table name.

Error code: 80

RELATION_KEY_FIELD_NOT_PROPERLY_SPECIFIED

Cause: The table for the relation key field must be the relation table. If the source and target
relation fields name specified in the many to many mapping are qualified with the table name then
the table name should match the relation table name.

Action: Qualify the field with the proper name or change the relation table name.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 17 of 77

Error code: 81

RETURN_TYPE_IN_GET_ATTRIBUTE_ACCESSOR

Cause: The method <attributeMethodName> specified in the transformation mapping should


have a return type set in the attribute because this method is used to extract value from the
database row.

Action: Check the method and make appropriate changes.

Error code: 82

SECURITY_ON_FIND_METHOD

Cause: The descriptor callback method <selector> with DescriptorEvent as argument is not
accessible. Java throws security exception when a Method type is created from the method name
using Java reflection. The method is a descriptor event callback on the domain object that takes
DescriptorEvent as its parameter.

Action: Inspect the internal exception and check the Java manuals.

Error code: 83

SECURITY_ON_FIND_OBSOLETE_METHOD

Cause: The descriptor callback method <selector> with <session> as argument is not accessible.
Java throws security exception when a Method type is created from the method name using Java
reflection. The method is a descriptor event callback on the domain object which takes class and
session as its parameters.

Action: Inspect the internal exception and check the Java manuals.

Error code: 84

SECURITY_ON_INITIALIZING_ATTRIBUTE_METHOD

Cause: Access to the method <attributeMethodName> with parameters <databaseRow> or


<databaseRow, Session> has been denied. Java throws security exception when a Method type is
created from the attribute method name using Java reflection. The attribute method specified in
the transformation mapping is used to extract value from the database row and set by calling
setAttributeTransformation(String methodName).

Action: Inspect the internal exception and check the Java manuals.

Error code: 85

SECURITY_WHILE_CONVERTING_TO_METHOD

Cause: Method: <methodName> ACCESS DENIED with <> or <session> parameters. Java

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 18 of 77

throws security exception when a Method type is created from the method name using Java
reflection. These are the methods that will extract the field value from the domain object in the
transformation mapping.

Action: Inspect the internal exception and check the Java manuals.

Error code: 86

SECURITY_WHILE_INITIALIZING_ATTRIBUTES_IN_
INSTANCE_VARIABLE_ACCESSOR

Cause: Access to the instance variable, <attributeName> in the class <javaClassName> is denied.
Java throws security exception when creating Field type from the given attribute name using Java
reflection.

Action: Inspect the internal exception and check the Java manuals.

Error code: 87

SECURITY_WHILE_INITIALIZING_ATTRIBUTES_IN_ METHOD_ACCESSOR

Cause: The methods <setMethodName> and <getMethodName> in the object <javaClassName>


are inaccessible. Java throws security exception when creating Method type from the given
attribute accessor method name using Java reflection.

Action: Inspect the internal exception and check the Java manuals.

Error code: 88

SECURITY_WHILE_INITIALIZING_CLASS_ EXTRACTION_METHOD

Cause: The static class extraction method <methodName> with DatabaseRow as argument is not
accessible. Java throws security exception when creating Method type from the given class
extraction method name using Java reflection. The method is used to extract class from the
database row in inheritance policy.

Action: Inspect the internal exception and check the Java manuals.

Error code: 89

SECURITY_WHILE_INITIALIZING_COPY_POLICY

Cause: The clone method <methodName> with no arguments is not accessible. Java throws
security exception when creating Method type from the given method name using Java reflection.
This method on copy policy is used to create clones of the domain object.

Action: Inspect the internal exception and check the Java manuals.

Error code: 90

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 19 of 77

SECURITY_WHILE_INITIALIZING_INSTANTIATION_POLICY

Cause: The instance creation method <methodName> with no arguments is not accessible. Java
throws security exception when creating Method type from the given method name using Java
reflection. This method on instantiation policy is used to create new instances of the domain
object.

Action: Inspect the internal exception and check the Java manuals.

Error code: 91

SEQUENCE_NUMBER_PROPERTY_NOT_SPECIFIED

Cause: Either the sequence field name or the sequence number name is missing. To use sequence
generated ids both the sequence number name and field name properties must be set.

Action: To use sequence-generated ids, both the sequence number name and field name properties
must be set.

Error code: 92

SIZE_MISMATCH_OF_FOREIGN_KEYS

Cause: The size of the primary keys on the target table does not match the size of the foreign keys
on the source in one to one mapping.

Action: Check the mapping and the reference descriptor's primary keys.

Error code: 93

TABLE_NOT_PRESENT

Cause: The table <tableName> is not present in the descriptor.

Action: Check the qualified field names specified in the mappings and descriptor, if these fields
are qualified with the table name then those fields should have right table.

Error code: 94

TABLE_NOT_SPECIFIED

Cause: No table is specified in the descriptor. Descriptor must have a table name defined.

Action: Call method addTableName(String tableName) or setTableName(String


tableName) to set the tables on the descriptor.

Error code: 96

TARGET_FOREIGN_KEYS_SIZE_MISMATCH

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 20 of 77

Cause: The size of the foreign keys on the target table does not match the size of the source keys
on the source table in one to many mapping.

Action: Check the mapping.

Error code: 97

TARGET_INVOCATION_WHILE_CLONING

Cause: Problem in cloning the object <domainObject> clone method. <methodName> triggered
an exception. Java is throwing exception when clone method is invoked using Java reflection
while cloning object. The clone method is specified on the copy policy that is usually invoked to
create clones in unit of work.

Action: Inspect the internal exception and check the Java manuals.

Error code: 98

TARGET_INVOCATION_WHILE_EVENT_EXECUTION

Cause: The underlying descriptor callback method <eventMethodName> with DescriptorEvent as


argument, throws an exception. Java is throwing exception when descriptor event method is
invoked using Java reflection.

Action: Inspect the internal exception and check the Java manuals.

Error code: 99

TARGET_INVOCATION_WHILE_GETTING_VALUE_ THRU_METHOD_ACCESSOR

Cause: The method <methodName> on the object <objectName> is throwing an exception. Java
is throwing exception while getting an attribute value from the object through method accessor.

Action: Inspect the internal exception and check the Java manuals.

Error code: 100

TARGET_INVOCATION_WHILE_INSTANTIATING_ METHOD_BASED_PROXY

Cause: Method has thrown an exception. Java is throwing exception while instantiating method
based proxy. This happens while instantiating transformation mapping.

Action: Inspect the internal exception and check the Java manuals.

Error code: 101

TARGET_INVOCATION_WHILE_INVOKING_ ATTRIBUTE_METHOD

Cause: The underlying method throws an exception. Java is throwing exception while invoking

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 21 of 77

attribute transformation method on transformation mapping. The method is invoked to extract


value from the database row to set into the domain object.

Action: Inspect the internal exception and check the Java manuals.

Error code: 102

TARGET_INVOCATION_WHILE_INVOKING_FIELD_ TO_METHOD

Cause: The method <methodName> is throwing an exception. Java is throwing exception while
invoking field transformation method on transformation mapping. The method is invoked to
extract value from the domain object to set into the database row.

Action: Inspect the internal exception and check the Java manuals.

Error code: 103

TARGET_INVOCATION_WHILE_INVOKING_ROW_ EXTRACTION_METHOD

Cause: Problem in extracting class from row <row>, static method, <method> with
<databaseRow as argument>. An exception was triggered Java is throwing exception while
invoking class extraction method. The method is used to extract class type so that right kind of
object can be created in inheritance model.

Action: Inspect the internal exception and check the Java manuals.

Error code: 104

TARGET_INVOCATION_WHILE_METHOD_INSTANTIATION

Cause: Problem in creating new instance. Creation method <methodName> caused an exception.
Java is throwing exception while invoking instantiation method. The method is used to create new
instances of the domain objects.

Action: Inspect the internal exception and check the Java manuals.

Error code: 105

TARGET_INVOCATION_WHILE_OBSOLETE_ EVENT_EXECUTION

Cause: The underlying descriptor callback method <eventMethodName> with <session> as


argument, throws an exception. Java is throwing exception while invoking descriptor event
method that takes session as its parameter.

Action: Inspect the internal exception and check the Java manuals.

Error code: 106

TARGET_INVOCATION_WHILE_SETTING_VALUE_THRU_ METHOD_ACESSOR

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 22 of 77

Cause: The method <setMethodName> on the object is throwing an exception. Java is throwing
exception while invoking set accessor method on the domain object to set an attribute value into
the domain object.

Action: Inspect the internal exception and check the Java manuals.

Error code: 108

VALUE_NOT_FOUND_IN_CLASS_INDICATOR_MAPPING

Cause: The indicator value is not found in the class indicator mapping in the parent descriptor for
the class.

Action: Check addClassIndicator(Class childClass, Object typeValue) on the


inheritance policy.

Error code: 109

WRITE_LOCK_FIELD_IN_CHILD_DESCRIPTOR

Cause: The child descriptor should not have a write lock field defined because it gets it from the
parent descriptor.

Action: Check your child descriptor and remove the field.

Error code: 110

DESCRIPTOR_IS_MISSING

Cause: The descriptor for the reference class <className> is missing from the mapping.

Action: Check session to see if the descriptor for the reference class was added.

Error code: 111

MULTIPLE_TABLE_PRIMARY_KEY_MUST_BE_ FULLY_QUALIFIED

Cause: Multiple table primary key field names must be fully qualified. These fields names are
given on the descriptor if it has more than one table.

Action: Specify the field names with table name.

Error code: 112

ONLY_ONE_TABLE_CAN_BE_ADDED_WITH_THIS_METHOD

Cause: Only one table can be added through this method.

Action: Use addTableName(String tableName) to add multiple tables to descriptor.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 23 of 77

Error code: 113

NULL_POINTER_WHILE_CONSTRUCTOR_INSTANTIATION

Cause: Inaccessible constructor. Java is throwing this exception while invoking a default
constructor to create new instances of the domain object.

Action: Inspect the internal exception and check the Java manuals.

Error code: 114

NULL_POINTER_WHILE_METHOD_INSTANTIATION

Cause: Problem in creating new instance <methodName> creation method is not accessible. Java
is throwing an exception while calling a method to build new instance of the domain object. This
method is given by the user to override the default behavior of creating new instances through
class constructor.

Action: Inspect the internal exception and check the Java manuals.

Error code: 115

NO_ATTRBUTE_VALUE_CONVERSION_TO_FIELD_VALUE_PROVIDED

Cause: The field conversion value for the attribute value <attributeValue> was not given in the
object type mapping.

Action: Check the attribute value and provide a corresponding field value in the mapping.

Error code: 116

NO_FIELD_VALUE_CONVERSION_TO_ATTRIBUTE_ VALUE_PROVIDED

Cause: The attribute conversion value for the <fieldValue> was not given in the object type
mapping.

Action: Check the field value and provide a corresponding attribute value in the mapping.

Error code: 118

LOCK_MAPPING_CANNOT_BE_READONLY

Cause: The domain object <className> cannot have a read only mapping for the write lock
fields when the version value is stored in the object.

Action: Check the mappings on write lock fields.

Error code: 119

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 24 of 77

LOCK_MAPPING_MUST_BE_READONLY

Cause: The domain object <className> should have a read only mapping for the write lock
fields when the version value is stored in the cache.

Action: Check the mappings on write lock fields.

Error code: 120

CHILD_DOES_NOT_DEFINE_ABSTRACT_QUERY_KEY

Cause: The queryKey <queryKeyName> is defined in the parent descriptor but not in the child
descriptor. The descriptor has not defined abstract query key.

Action: Any implementors of interface descriptor must define the query key defined by abstract
query key in the interface descriptor.

Error code: 122

SET_EXISTENCE_CHECKING_NOT_UNDERSTOOD

Cause: The interface descriptor <parent> must have at least one abstract query key defined. The
string given to the method setExistenceChecking(String token) is not understood.

Action: The string passed should be one of the following:

l Check cache

l Check database

l Assume existence

l Assume non-existence

Error code: 125

VALUE_HOLDER_INSTANTIATION_MISMATCH

Cause: The mapping for the attribute <mapping.getAttributeName()> uses indirection and
must be initialized to a new ValueHolder.

Action: Ensure the mapping uses indirection and the attribute is initialized to a new
valueHolder.

Error code: 126

NO_SUB_CLASS_MATCH

Cause: No sub-class matches this class <theClass> when inheritance is in aggregate relationship

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 25 of 77

mapping.

Action: Verify the sub-class and the relationship mapping.

Error code: 127

RETURN_AND_MAPPING_WITH_INDIRECTION_MISMATCH

Cause: The get method return type for the attribute mapping.getAttributeName() is not
declared as type ValueHolderInterface, but the mapping is using indirection.

Action: Ensure the get method returns a ValueHolder or change the mapping to not use
indirection.

Error code: 128

RETURN_AND_MAPPING_WITHOUT_INDIRECTION_ MISMATCH

Cause: The get method return type for the attribute mapping.getAttributeName() is declared as
type ValueHolderInterface, but the mapping is not using indirection.

Action: Ensure the mapping is using indirection or change the return type from ValueHolder

Error code: 129

PARAMETER_AND_MAPPING_WITH_INDIRECTION_ MISMATCH

Cause: The set method parameter type for the attribute mapping.getAttributeName() is not
declared as type ValueHolderInterface, but the mapping is using indirection.

Action: Ensure the set method parameter is declared as a ValueHolder or the mapping is changed
to not use indirection.

Error code: 130

PARAMETER_AND_MAPPING_WITHOUT_INDIRECTION_ MISMATCH

Cause: The set method parameter type for the attribute mapping.getAttributeName() is
declared as type ValueHolderInterface, but the mapping is not using indirection.

Action: Ensure the mapping is changed to use indirection or the set method parameter is not
declared as a ValueHolder.

Error code: 131

GET_METHOD_RETURN_TYPE_NOT_VALID

Cause: he get method return type for the attribute mapping.getAttributeName() should be
declared as type Vector (or a type that implements Map or Collection, if using Java2).

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 26 of 77

Action: The get method return type for the attribute should be declared as type Vector (or a type
that implementsMap or Collection, if using Java2).

Error code: 133

SET_METHOD_PARAMETER_TYPE_NOT_VALID

Cause: The set method parameter type for the attribute mapping.getAttributeName() should be
declared as type Vector (or a type that implements Map or Collection, if using Java2).

Action: The set method parameter type for the attribute should be declared as type Vector (or a
type that implements Map or Collection, if using Java2).

Error code: 135

ILLEGAL_TABLE_NAME_IN_MULTIPLE_TABLE_ FOREIGN_KEY

Cause: The table in the multiple table foreign key relationship refers to an unknown table.

Action: Verify the table name.

Error code: 138

ATTRIBUTE_AND_MAPPING_WITH_TRANSPARENT_ INDIRECTION_MISMATCH

Cause: The attribute mapping.getAttributeName() is not declared as a super-type of


validTypeName, but the mapping is using transparent indirection.

Action: Verify the attribute's type and the mapping setup.

Error code: 139

RETURN_AND_MAPPING_WITH_TRANSPARENT_ INDIRECTION_MISMATCH

Cause: The get method return type for the attribute mapping.getAttributeName() is not
declared as a super-type of validTypeName, but the mapping is using transparent indirection.

Action: Verify the attribute's type and the mapping setup.

Error code: 140

PARAMETER_AND_MAPPING_WITH_TRANSPARENT_ INDIRECTION_MISMATCH

Cause: The set method parameter type for the attribute mapping.getAttributeName() is not
declared as a super-type of validTypeName, but the mapping is using transparent indirection.

Action: Verify the attribute's type and the mapping setup.

Error code: 141

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 27 of 77

FIELD_IS_NOT_PRESENT_IN_DATABASE

Cause: Field <fieldname> is not present in the table <tableName> in the database.

Action: Verify the field name for the attribute.

Error code: 142

TABLE_IS_NOT_PRESENT_IN_DATABASE

Cause: descriptor.getTableName() is not present in the database.

Action: Verify the table name for the descriptor.

Error code: 143

MULTIPLE_TABLE_INSERT_ORDER_MISMATCH

Cause: The multiple table insert order Vector specified


aDescriptor.getMultipleTableInsertOrder(), has more/fewer tables than are specified in
the descriptor aDescriptor.getTables(). All the tables must be included in the insert order
Vector.

Action: Verify that all table names for the descriptor are present and that there are no extras.

Error code: 144

INVALID_USE_OF_TRANSPARENT_INDIRECTION

Cause: Transparent Indirection can only be used with CollectionMappings.

Action: Verify the mapping. It must be a collection mapping.

Error code: 145

MISSING_INDIRECT_CONTAINER_CONSTRUCTOR

Cause: The indirect container class must implement the constructor.

Action: Implement the constructor for the container.

Error code: 146

COULD_NOT_INSTANTIATE_INDIRECT_CONTAINER_CLASS

Cause: The indirect container class could not be instantiated using the constructor.

Action: Validate the constructor for the indirect container class.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 28 of 77

Error code: 147

INVALID_CONTAINER_POLICY

Cause: This container policy should only be used in JDK1.1: containerPolicy. It was instantiated
for javaClass.

Action: Validate the container policy being used.

Error code: 148

INVALID_CONTAINER_POLICY_WITH_TRANSPARENT_ INDIRECTION

Cause: The container policy is incompatible with transparent indirection.

Action: Change the container policy to be compatible with transparent indirection or do not use
transparent indirection.

Error code: 149

INVALID_USE_OF_NO_INDIRECTION

Cause: No Indirection should not receive this message.

Action: Change to use no indirection.

Error code: 150

INDIRECT_CONTAINER_INSTANTIATION_MISMATCH

Cause: The mapping for the attribute mapping.getAttributeName() uses transparent


indirection and must be initialized to an appropriate container.

Action: Initialize the mapping to an appropriate container.

Error code: 151

INVALID_MAPPING_OPERATION

Cause: Invalid mapping operation.

Action: Check the documentation for valid mapping operations.

Error code: 152

INVALID_INDIRECTION_POLICY_OPERATION

Cause: Invalid indirection policy operation.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 29 of 77

Action: Check the documentation for valid indirection policy operations.

Error code: 153

REFERENCE_DESCRIPTOR_IS_NOT_ AGGREGATECOLLECTION

Cause: The reference descriptor for <className> should be set to aggregate collection
descriptor.

Action: Set the reference descriptor to an aggregate collection descriptor.

Error code: 154

INVALID_INDIRECTION_CONTAINER_CLASS

Cause: Invalid indirection container class.

Action: Verify the container class.

Error code: 155

MISSING_FOREIGN_KEY_TRANSLATION

Cause: The mapping does not include a foreign key field linked to the primary key field.

Action: Link the foreign key to the appropriate primary key.

Error code: 156

TRUCTURE_NAME_NOT_SET_IN_MAPPING

Cause: The structure name is not set.

Action: Set the structure name appropriately.

Error code: 157

NORMAL_DESCRIPTORS_DO_NOT_SUPPORT_ NON_RELATIONAL_EXTENSIONS

Cause: Normal descriptors do not support non-relational extensions.

Action: Contact Technical Support.

Error code: 158

PARENT_CLASS_IS_SELF

Cause: The descriptor's parent class has been set to itself.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 30 of 77

Action: Contact Technical Support.

Error code: 159

PROXY_INDIRECTION_NOT_AVAILABLE

Cause: An attempt to use proxy indirection has been made but JDK 1.3 is not being used.

Action: Proxy indirection is only supported in JDK 1.3

Error code: 160

INVALID_ATTRIBUTE_TYPE_FOR_PROXY_INDIRECTION

Cause: The attribute wasn't specified in the list of interfaces given to use Proxy Indirection.

Action: Verify the attribute

Error code: 161

INVALID_GET_RETURN_TYPE_FOR _PROXY_INDIRECTION

Cause: The return type for the indirection policy is invalid for the indirection policy.

Action: Verify that the parameter type of the attribute's get method is correct for the indirection
policy.

Error code: 162

INVALID_SET_PARAMETER_TYPE_FOR_PROXY_ INDIRECTION

Cause: The parameter for the set method is incorrect for the indirection type.

Action: Verify that the parameter type of the attribute's set method is correct for the indirection
policy.

Error code: 163

INCORRECT_COLLECTION_POLICY

Cause: The container policy is invalid for the collection type.

Action: Check that the container policy is correct for the collection type.

Error code: 164

INVALID_AMENDMENT_METHOD

Cause: The amendment method provided is invalid, not public, or cannot be found.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 31 of 77

Action: Ensure the amendment method is public, static, returns void and has a single argument:
Descriptor.

Error code: 165

ERROR_OCCURRED_IN_AMENDMENT_METHOD

Cause: The specified amendment method threw an exception.

Action: Examine the returned exception for further details.

Error code: 166

VARIABLE_ONE_TO_ONE_MAPPING_IS_NOT_DEFINED

Cause: There is no mapping for attribute.

Action: Validate the mapping and attribute.

Error code: 168

TARGET_INVOCATION_WHILE_CONSTRUCTOR_ INSTANTIATION

Cause: Constructor is missing.

Action: Make the required constructor.

Error code: 169

TARGET_INVOCATION_WHILE_CONSTRUCTOR_ INSTANTIATION_OF_FACTORY

Cause: Constructor is missing.

Action: Make the required constructor.

Error code: 170

ILLEGAL_ACCESS_WHILE_CONSTRUCTOR_ INSTANTIATION_OF_FACTORY

Cause: Permissions do not permit access to the constructor.

Action: Adjust the Java security permissions to permit access to the constructor.

Error code: 171

INSTANTIATION_WHILE_CONSTRUCTOR_ INSTANTIATION_OF_FACTORY

Cause: An instantiation failed inside the associated constructor.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 32 of 77

Action: Determine which objects are being instantiated, and ensure all are being done properly.

Error code: 172

NO_SUCH_METHOD_WHILE_CONSTRUCTOR_ INSTANTIATION_OF_FACTORY

Cause: A message send invoked from inside the constructor is invalid because the method does
not exist.

Action: Correct the message send ensuring that the message exists.

Error code: 173

NULL_POINTER_WHILE_CONSTRUCTOR_ INSTANTIATION_OF_FACTORY

Cause: A message is being sent from inside a constructor to a null object.

Action: Avoid sending a message to an object that is null.

Error code: 174

ILLEGAL_ACCESS_WHILE_METHOD_ INSTANTIATION_OF_FACTORY

Cause: A message is being sent to an object from inside a factory instantiation. Java has
determined this message to be illegal.

Action: Determine why the message send is illegal, and replace the message with the proper legal
one.

Error code: 175

TARGET_INVOCATION_WHILE_METHOD_ INSTANTIATION_OF_FACTORY

Cause: Error inside the factory associated with the invocation of a target.

Action: Determine the faulty target, and replace with the correct target, or proper message send.

Error code: 176

NULL_POINTER_WHILE_METHOD_ INSTANTIATION_OF_FACTORY

Cause: A message is being sent to null inside a factory instantiation.

Action: Avoid sending a message to null.

Builder Exceptions (1001 - 1042)


Error code: 1001

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 33 of 77

No such method

Cause: Tokens in the builder generated files are the subsets of all the tokens a Project Reader can
understand. Each token has a related public method on TopLink. The exception would mean that
the method name is incorrect.

Action: If the project files are not manually edited and corrupted then this is usually an internal
exception to TopLink and must be reported to Technical Support. But if the file was manually
edited or corrupted then the files must be generated again.

Error code: 1002

Could not find post load method <methodName> on class <aClass>

Cause: The post load method defined in descriptor properties is not defined on the related domain
class.

Action: Must define the method on the specified class.

Error code: 1003

Cannot write parameter <object> of class <type>

Cause: While creating project class the parameter tokens are read from the file and are converted
to actual types before sending them to the methods. An unknown type will cause this exception.

Action: If the project files are not manually edited and corrupted then this is usually an internal
exception to TopLink and must be reported to Technical Support. But if the file was manually
edited or corrupted then the files must be generated again.

Error code: 1004

Could not access method <method>

Cause: Java is throwing an illegal access reflection exception while invoking the method on the
object. TopLink only wraps that exception.

Action: Inspect the internal exception and check the Java manuals. If the project files are not
manually edited and corrupted then this is usually an internal exception to TopLink and must be
reported to Technical Support. But if the file was manually edited or corrupted then the files must
be generated again.

Error code: 1005

Invoking <applyResultMethod> raised exception <exception>

Cause: Java is throwing an invocation reflection exception while invoking the method on the
object. TopLink only wraps that exception.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 34 of 77

Action: Inspect the internal exception and check the Java manuals. If the project files are not
manually edited and corrupted then this is usually an internal exception to TopLink and must be
reported to Technical Support. But if the file was manually edited or corrupted then the files must
be generated again.

Error code: 1006

Invalid arguments invoking: <applyResultMethod> with <receiver>

Cause: Java is throwing an invalid argument reflection exception while invoking the method on
the object. TopLink only wraps that exception.

Action: Inspect the internal exception and check the Java manuals. If the project files are not
manually edited and corrupted then this is usually an internal exception to TopLink and must be
reported to Technical Support. But if the file was manually edited or corrupted then the files must
be generated again.

Error code: 1007

Could not access <applyResultMethod> with <receiver>

Cause: Java is throwing reflection exception while invoking the method on the object. TopLink
only wraps that exception.

Action: Inspect the internal exception and check the Java manuals. If the project files are not
manually edited and corrupted then this is usually an internal exception to TopLink and must be
reported to Technical Support. But if the file was manually edited or corrupted then the files must
be generated again.

Error code: 1008

Parameter mismatch <method>; received <size> parameters

Cause: The number of parameters for the token read from the project or descriptor file do not
match the number of parameters a related method can take.

Action: If the project files are not manually edited and corrupted then this is usually an internal
exception to TopLink and must be reported to Technical Support. But if the file was manually
edited or corrupted then the files must be generated again.

Error code: 1009

Accessing <methodName> on <className> with <parameters>

Cause: Java is throwing reflection exception while invoking the method on the object. TopLink
only wraps that exception.

Action: Inspect the internal exception and check the Java manuals. If the project files are not
manually edited and corrupted then this is usually an internal exception to TopLink and must be
reported to Technical Support. But if the file was manually edited or corrupted then the files must

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 35 of 77

be generated again.

Error code: 1010

Could not find section definition <section> when building section definitions for <target>

Cause: Invalid section name was found in the project or descriptor file.

Action: If the project files are not manually edited and corrupted then this is usually an internal
exception to TopLink and must be reported to Technical Support. But if the file was manually
edited or corrupted then the files must be generated again.

Error code: 1011

Could not convert <object> into an accessible Java class.

Cause: The parameter read from the file cannot be converted to a appropriate type.

Action: If the project files are not manually edited and corrupted then this is usually an internal
exception to TopLink and must be reported to Technical Support. But if the file was manually
edited or corrupted then the files must be generated again.

Error code: 1012

File not found

Cause: The project or descriptor file was not found.

Action: Check that the path was given correctly in a project reader and also the path is correct in
project file.

Error code: 1013

Invalid class/method name format.

Cause: No one should actually be using the URL way of reading INI files. This is untested and
undocumented feature.

Action: Use other ways of reading files.

Error code: 1015

Open failed for URL <url>

Cause: Open failed for URL.

Action: Inspect the internal exception and check the Java manuals.

Error code: 1016

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 36 of 77

Could not resolve INIFile location: <sourceString> using search paths <searchPaths>

Cause: The file was not found on the given search paths.

Action: Check your search paths.

Error code: 1017

Invoking <method> on <receiver>

Cause: Java is throwing reflection exception while invoking the method on the object. TopLink
only wraps that exception.

Action: Inspect the internal exception and check the Java manuals. If the project files are not
manually edited and corrupted then this is usually an internal exception to TopLink and must be
reported to Technical Support. But if the file was manually edited or corrupted then the files must
be generated again.

Error code: 1018

Invoking <method> on <receiver>

Cause: Java is throwing reflection exception while invoking the method on the object. TopLink
only wraps that exception.

Action: Inspect the internal exception and check the Java manuals. If the project files are not
manually edited and corrupted then this is usually an internal exception to TopLink and must be
reported to Technical Support. But if the file was manually edited or corrupted then the files must
be generated again.

Error code: 1019

Invalid character value; expecting $* format

Cause: An invalid character format was written to the file.

Action: If the project files are not manually edited and corrupted then this is usually an internal
exception to TopLink and must be reported to Technical Support. But if the file was manually
edited or corrupted then the files must be generated again.

Error code: 1020

Unexpected character: {

Cause: Unexpected character { found while reading vector values from the file.

Action: If the project files are not manually edited and corrupted then this is usually an internal
exception to TopLink and must be reported to Technical Support. But if the file was manually
edited or corrupted then the files must be generated again.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 37 of 77

Error code: 1021

Unexpected character: }

Cause: Unexpected character } found while reading vector values from the file.

Action: If the project files are not manually edited and corrupted then this is usually an internal
exception to TopLink and must be reported to Technical Support. But if the file was manually
edited or corrupted then the files must be generated again.

Error code: 1022

Expecting object, found token <nextToken>

Cause: Unexpected token found while reading from the file.

Action: If the project files are not manually edited and corrupted then this is usually an internal
exception to TopLink and must be reported to Technical Support. But if the file was manually
edited or corrupted then the files must be generated again.

Error code: 1023

Unexpected word

Cause: Unexpected token found while reading from the file.

Action: If the project files are not manually edited and corrupted then this is usually an internal
exception to TopLink and must be reported to Technical Support. But if the file was manually
edited or corrupted then the files must be generated again.

Error code: 1024

setExistenceChecking <token>; not understood

Cause: Existence checking string specified on the descriptor is not understood.

Action: If the project files are not manually edited and corrupted then this is usually an internal
exception to TopLink and must be reported to Technical Support. But if the file was manually
edited or corrupted then the files must be generated again.

Error code: 1025

Class <className> not found

Cause: Java is throwing reflection exception while invoking the method on the object. TopLink
only wraps that exception.

Action: Inspect the internal exception and check the Java manuals. If the project files are not
manually edited and corrupted then this is usually an internal exception to TopLink and must be

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 38 of 77

reported to Technical Support. But if the file was manually edited or corrupted then the files must
be generated again.

Error code: 1026

Not enough INI elements. Found <count>.

Cause: If the line in an INI file is incomplete, i.e., it does not have enough tokens.

Action: If the project files are not manually edited and corrupted then this is usually an internal
exception to TopLink and must be reported to Technical Support. But if the file was manually
edited or corrupted then the files must be generated again.

Error code: 1027

Too many INI elements. Found <count>.

Cause: If the line in an INI file has more tokens then needed.

Action: If the project files are not manually edited and corrupted then this is usually an internal
exception to TopLink and must be reported to Technical Support. But if the file was manually
edited or corrupted then the files must be generated again.

Error code: 1028

Error writing <writeString>

Cause: Could not write into the file. Perhaps / are used and file or directory structure does not
exist.

Action: Inspect the internal exception and check the Java manuals. Try using \\.

Error code: 1029

Illegal access exception

Cause: Java is throwing reflection exception while invoking the method on the object. TopLink
only wraps that exception.

Action: Inspect the internal exception and check the Java manuals.

Error code: 1030

Invocation target exception

Cause: Java is throwing reflection exception while invoking the method on the object. TopLink
only wraps that exception.

Action: Inspect the internal exception and check the Java manuals.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 39 of 77

Error code: 1031

Attempting to instantiate <className> with default constructor.

Cause: Java is throwing reflection exception while instantiating the object. TopLink only wraps
that exception.

Action: Inspect the internal exception and check the Java manuals.

Error code: 1032

Attempting to instantiate <className> with default constructor.

Cause: Java is throwing reflection exception while instantiating the object. TopLink only wraps
that exception.

Action: Inspect the internal exception and check the Java manuals.

Error code: 1033

IO Exception in next token

Cause: Java is throwing reflection. TopLink only wraps that exception.

Action: Inspect the internal exception and check the Java manuals.

Error code: 1034

IOException on close.

Cause: Java is throwing reflection. TopLink only wraps that exception.

Action: Inspect the internal exception and check the Java manuals.

Error code: 1035

Invalid INI(URL) Method: <method>. Should return a string.

Cause: No one should actually be using the URL way of reading INI files. This is untested and
undocumented feature.

Action: Use other ways of reading files.

Error code: 1036

Could not cast using <castString>.

Cause: An error occurred during an attempt to cast using the castString

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 40 of 77

Action: Validate the castString

Error code: 1037

A writer or a target file name must be specified

Cause: A writer or a target file name is not specified.

Action: A writer or a target file name must be specified.

Error code: 1039

IOException on open.

Cause: Java is throwing reflection. TopLink only wraps that exception.

Action: Inspect the internal exception and check the Java manuals.

Error code: 1040

Post Load Method Not Static

Cause: The method specified is not static.

Action: Modify the method to be static.

Error code: 1041

Project Not Found.

Cause: No projects were found in the specified directory.

Action: Verify the directory.

Error code: 1042

Multiple Projects With Name.

Cause: More than one project with the same name was found.

Action: Verify the project name.

Concurrency Exceptions (2001 - 2004)


Error code: 2001

WAIT_WAS_INTERRUPTED

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 41 of 77

Cause: In a multi threaded environment one of the waiting thread was interrupted.

Action: Usually such exceptions would mean restarting the application but it is totally dependent
on the application.

Error code: 2002

WAIT_FAILURE_SERVER

Cause: Wait failure on ServerSession. When the number of non-pooled connections reach the
threshold any more requests for such connection results in wait until some one releases the
connection resource. If this wait was interrupted then an exception is thrown.

Action: Usually such exceptions would mean restarting the application but it is totally dependent
on the application.

Error code: 2003

WAIT_FAILURE_CLIENT

Cause: Wait failure on ClientSession. When the number of pooled connections reach the
threshold any more requests for such connection results in wait until some one releases the
connection resource. If this wait was interrupted then an exception is thrown.

Action: Usually such exceptions would mean restarting the application but it is totally dependent
on the application.

Error code: 2004

SIGNAL_ATTEMPTED_BEFORE_WAIT

Cause: A signal was attempted before wait on concurrency manager. This normally means that an
attempt was made to commit or rollback a transaction before it was started, or to rollback a
transaction twice.

Action: Check transactions in the application.

Conversion Exceptions (3001 - 3007)


Error code: 3001

COULD_NOT_BE_CONVERTED

Cause: The object <object> of class <objectClass> could not be converted to <javaClass>. The
object cannot be converted to given type.

Action: Check that the object being converted is of right type or not.

Error code: 3003

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 42 of 77

INCORRECT_DATE_FORMAT

Cause: The date in <dateString> is in an incorrect format. Expected format is YYYY-MM-DD.

Action: Check the date format.

Error code: 3004

INCORRECT_TIME_FORMAT

Cause: The time in <timeString> is in an incorrect format. Expected format is HH:MM:SS.

Action: Check the time format.

Error code: 3005

INCORRECT_TIMESTAMP_FORMAT

Cause: The timestamp <timestampString> is in an incorrect format. Expected format is YYYY-


MM-DD HH:MM:SS.NNNNNNNNN.

Action: Check the timestamp format.

Error code: 3006

COULD_NOT_CONVERT_TO_BYTE_ARRAY

Cause: The String object must be of even length to be converted to a ByteArray. This object
could not be converted to a ByteArray

Action: Check the object being converted.

Error code: 3007

COULD_NOT_BE_CONVERTED_TO_CLASS

Cause: The object <object> of class <objectClass> could not be converted to <javaClass>. The
class <javaClass> is not on the CLASSPATH.

Action: Check that the class <javaClass> is on the CLASSPATH.

Database Exceptions (4001 - 4018)


Error code: 4002

SQL_EXCEPTION

Cause: An SQL exception was encountered, thrown by the underlying JDBC bridge. TopLink
only wraps that exception.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 43 of 77

Action: One must inspect the internal exception thrown.

Error code: 4003

CONFIGURATION_ERROR_CLASS_NOT_FOUND

Cause: The driver class name was not found.

Action: Check the class name given in JDBCLogin.

Error code: 4005

DATABASE_ACCESSOR_NOT_CONNECTED

Cause: Session is not connected to the database while doing reading or writing on the database.

Action: An application may have to login again because the connection to the database might
have been lost.

Error code: 4006

ERROR_READING_BLOB_DATA

Cause: Error reading blob data from the database. There are two possibilities for this exception,
first is that the blob data was not read properly from the result set or the TopLink could not
process the blob data using ByteArrayOutputStream.

Action: Check if the underlying driver support blobs properly or not and if it does then report this
problem to Technical Support.

Error code: 4007

OULD_NOT_CONVERT_OBJECT_TYPE

Cause: Could not convert object type on internal error. java.sql.TYPES = <type>. The object
from the result set cannot be converted to the type returned from the metadata information.

Action: Check if the underlying driver support the conversion type properly or not and if it does
then report this problem to Technical Support.

Error code: 4008

LOGOUT_WHILE_TRANSACTION_IN_PROGRESS

Cause: An attempt has been made to logout while the transaction is still in progress. You cannot
logout while a transaction is in progress.

Action: Wait until the transaction is over.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 44 of 77

Error code: 4009

SEQUENCE_TABLE_INFORMATION_NOT_COMPLETE

Cause: The sequence information given to TopLink is not sufficiently complete to get the set of
sequence numbers from the database. This usually happens on native sequencing on oracle
database.

Action: Check the data given specially the sequence name given in TopLink.

Error code: 4011

ERROR_PREALLOCATING_SEQUENCE_NUMBERS

Cause: Error preallocating sequence numbers on the database; the sequence table information is
not complete.

Action: Check if the sequence table was created on the database properly or not.

Error code: 4014

CANNOT_REGISTER_SYNCHRONIZATIONLISTENER_ FOR_UNITOFWORK

Cause: Cannot register Synchronization Listener: underlying_exception_string. When the


TopLink Session is configured with an ExternalTransactionController, any unit of work
requested by a client must operate within the context of a JTS external global transaction. When a
unit of work is created and the external global transaction is not in existence or if the system
cannot acquire a reference to it, this error is reported.

Action: Ensure that a JTS transaction is in progress before acquiring the unit of work.

Error code: 4015

SYNCHRONIZED_UNITOFWORK_DOES_NOT_ SUPPORT_COMMITANDRESUME

Cause: Synchronized UnitOfWork does not support the commitAndResume operation. When the
TopLink Session is configured with an ExternalTransactionController, any unit of work
requested by a client must operate within the context of a JTS external global transaction (see
Error code: 4014). The JTS specification does not support the concept of "checkpointing" a
transaction, that is, committing the work done and then continuing to work within the same
transaction context (JTS does not support nested transactions, either). Thus, if client code invokes
commitAndResume() on a "synchronized" unit of work, this error will be reported.

Action: None.

Error code: 4016

CONFIGURATION_ERROR_NEW_INSTANCE_ INSTANTIATION_EXCEPTION

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 45 of 77

Cause: Configuration error. Attempting to instantiate Driver: <javaClass>. Could not instantiate
driver.

Action: Check the driver.

Error code: 4017

CONFIGURATION_ERROR_NEW_INSTANCE_ILLEGAL_ ACCESS_EXCEPTION

Cause: A configuration error occurred while attempting to instantiate Driver: <javaClass>.


Could not instantiate driver.

Action: Check the driver.

Error code: 4018

TRANSACTION_MANAGER_NOT_SET_FOR_JTS_DRIVER

Cause: The transaction manager has not been set for the JTSSynchronizationListener.

Action: Set a transaction manager for the JTSSynchronizationListener.

Optimistic Lock Exceptions (5001 - 5007)


Error code: 5001

NO_VERSION_NUMBER_WHEN_DELETING

Cause: An attempt was made to delete the object <object> but it has no version number in the
identity map. This object either was never read or has already been deleted.

Action: Logging SQL is very helpful in understanding the reason why the exception is thrown.
The last delete will show the object we are deleting that throws an exception.

Error code: 5003

OBJECT_CHANGED_SINCE_LAST_READ_WHEN_DELETING

Cause: The object state has changed in the database. The object <object> cannot be deleted
because it has changed or been deleted since it was last read. This usually means that the row in
the table was changed by some other application.

Action: Refreshing an object will refresh the object with the new data from the database.

Error code: 5004

NO_VERSION_NUMBER_WHEN_UPDATING

Cause: An attempt has been made to update the object <object> but it has no version number in

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 46 of 77

the identity map. It may not have been read before being updated or has been deleted.

Action: Logging SQL is very helpful in understanding the reason why the exception is thrown.
The last update will show the object we are updating that throws an exception.

Error code: 5006

OBJECT_CHANGED_SINCE_LAST_READ_WHEN_UPDATING

Cause: The object state has changed in the database. The object <object> cannot be updated
because it has changed or been deleted since it was last read. This usually means that the row in
the table was changed by some other application.

Action: Refreshing an object will refresh the object with the new data from the database.

Error code: 5007

MUST_HAVE_MAPPING_WHEN_IN_OBJECT

Cause: The object <aClass> must have a non-read-only mapping corresponding to the version
lock field. The mapping was not defined for the locking field. It is needed when the lock value is
stored in the domain object than in a cache.

Action: Define a mapping for the field.

Error code: 5008

NEED_TO_MAP_JAVA_SQL_TIMESTAMP

Cause: A write lock value which is stored in a domain object is not an instance of
java.sql.Timestamp.

Action: Change the value of the attribute to be an instance of java.sql.Timestamp.

Query Exceptions (6001 - 6092)


Error code: 6001

ADDITIONAL_SIZE_QUERY_NOT_SPECIFIED

Cause: Cursored SQL queries must provide an additional query to retrieve the size of the result
set. Custom queries using cursor streams and not specifying the size query will cause this
exception. The size query is used to retrieve the size of the number of object read from the
database. This is done on JDBC 1.0 compatible drivers because it provides no way to extract the
size of the result set read. Non custom queries using cursor streams will have default queries
generated by TopLink.

Action: Specify a size query.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 47 of 77

Error code: 6002

AGGREGATE_OBJECT_CANNOT_BE_DELETED

Cause: Aggregated objects cannot be written or deleted independent of their owners. There is no
identity maintained on such objects.

Action: Application's discretion.

Error code: 6003

ARGUMENT_SIZE_MISMATCH_IN_QUERY_AND_ QUERY_DEFINITION

Cause: The number of arguments provided to the query for execution does not match the number
of arguments provided with the query definition.

Action: Check the query and query execution.

Error code: 6004

BACKUP_CLONE_IS_ORIGINAL_FROM_PARENT

Cause: The object <clone> of class <clone.getClass()> with identity hashcode


(System.identityHashCode()) <System.identityHashCode(clone)> is not from this unit of
work space but from the parent session. The object was never registered in this unit of work but
read from the parent session and related to an object registered in the unit of work.

Action: Ensure that you are correctly registering your objects. If you are still having problems,
you can use the UnitOfWork.validateObjectSpace() method to help debug where the error
occurred. Please see the manual and FAQ for more information.

Error code: 6005

BACKUP_CLONE_IS_ORIGINAL_FROM_SELF

Cause: The object clone of class <clone.getClass()> with identity hashcode


(System.identityHashCode()) <System.identityHashCode(clone)> is the original to a
registered new object. The unit of work clones registered new objects, so you must ensure that it is
registered before it is reference by another object. If you do not want the new object to be cloned,
used the UnitOfWork.registerNewObject(Object) API.

Action: Ensure that you are correctly registering your objects. If you are still having problems,
you can use the UnitOfWork.validateObjectSpace() method to help debug where the error
occurred. Please see the manual and FAQ for more information.

Error code: 6006

BATCH_READING_NOT_SUPPORTED

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 48 of 77

Cause: This mapping does not support batch reading. The optimization of batching the read of all
the target rows is not supported for the mapping.

Action: The problem is a TopLink development problem and user should never encounter this
unless the mapping is a new custom mapping. Contact Technical Support.

Error code: 6007

DESCRIPTOR_IS_MISSING

Cause: Missing descriptor for <reference Class>. The descriptor related to the class or the object
is not found in the session.

Action: Check if the related descriptor was added to the session or the query is done on the right
object or class.

Error code: 6008

DESCRIPTOR_IS_MISSING_FOR_NAMED_QUERY

Cause: Missing descriptor for <domain Class Name> for query named <queryName>. The
descriptor where named query is defined is not added to the session.

Action: Check if the related descriptor was added to the session or the query is done on the right
class.

Error code: 6013

INCORRECT_SIZE_QUERY_FOR_CURSOR_STREAM

Cause: The size query given on the queries returning cursor streams is not correct. The execution
of the size query did not return any size.

Action: If the cursor stream query was custom query than check the size query specified else
report this problem to Technical Support.

Error code: 6014

INVALID_QUERY

Cause: Objects cannot be written in unit of work using modify queries, they must be registered.

Action: Objects are registered in the unit of work and during commit unit of work will do the
required changes to the database.

Error code: 6015

INVALID_QUERY_KEY_IN_EXPRESSION

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 49 of 77

Cause: The query key <key> does not exist. Usually this happens because of mis-spelled query
key.

Action: Check the query key specified in the expression and make sure that a query key was
added to the descriptor.

Error code: 6016

INVALID_QUERY_ON_SERVER_SESSION

Cause: Objects and the database cannot be changed through the server session; all changes must
be done through a client session's unit of work. The objects cannot be changed on the server
session by modifying queries. Objects are changed in the client sessions acquired from this server
session.

Action: Use client session's unit of work to change the object.

Error code: 6020

NO_CONCRETE_CLASS_INDICATED

Cause: No concrete class indicated for the type in this row. The type indicator read from the
database row has no entry in the type indicator hashtable or if class extraction method was used, it
did not return any concrete class type. The exception is thrown when sub classes are being read.

Action: Check class extraction method if specified or check the descriptor to see if all the type
indicator values were specified or not.

Error code: 6021

NO_CURSOR_SUPPORT

Cause: No cursor support provided for abstract class multiple table descriptors using expressions.

Action: Consider using custom SQL or multiple queries. <query>

Error code: 6023

OBJECT_TO_INSERT_IS_EMPTY

Cause: There are no fields to be insert into the table. The fields to insert into the table, <table> is
empty. You must define at least one mapping for this table

Action: Must define at least one mapping for this table.

Error code: 6024

OBJECT_TO_MODIFY_NOT_SPECIFIED

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 50 of 77

Cause: An object to modify is required for a modify query.

Action: Ensure the query contains an object before executing.

Error code: 6026

QUERY_NOT_DEFINED

Cause: Query is not defined. When executing query on the session the parameter which takes
query is null.

Action: Check if the query is passed properly.

Error code: 6027

QUERY_SENT_TO_INACTIVE_UNIT_OF_WORK

Cause: The unit of work has been released and is now inactive.

Action: The unit of work, once released, cannot be reused unless commitAndResume is called.

Error code: 6028

READ_BEYOND_QUERY

Cause: An attempt has been made to read from the cursor streams beyond its limits (beyond the
end of the stream).

Action: Ensure the stream is being checked for an "end of stream" condition before attempting to
retrieve more objects.

Error code: 6029

REFERENCE_CLASS_MISSING

Cause: The reference class in the query is not specified. A reference class must be provided.

Action: Check the query.

Error code: 6030

REFRESH_NOT_POSSIBLE_WITHOUT_CACHE

Cause: Refresh is not possible if caching is not set. The read queries which skip cache to read
objects cannot be used to do refresh the object. Refreshing is not possible without identity.

Action: Check query.

Error code: 6031

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 51 of 77

SIZE_ONLY_SUPPORTED_ON_EXPRESSION_QUERIES

Cause: Did not find size query. Size only supported on expression queries, unless a size query is
given.

Action: Cursor streams on custom query should also define size query.

Error code: 6032

SQL_STATEMENT_NOT_SET_PROPERLY

Cause: The SQL statement has not been properly set. The user should never encounter this unless
queries have been customized.

Action: Contact Technical Support.

Error code: 6034

INVALID_QUERY_ITEM

Cause: Invalid query item expression.

Action: Validate the Expression being used.

Error code: 6041

SELECTION_OBJECT_CANNOT_BE_NULL

Cause: The selection object passed to a read object or refresh was null.

Action: Check setSelectionObject() on the read query.

Error code: 6042

UNNAMED_QUERY_ON_SESSION_BROKER

Cause: Data read and data modify queries is being executed without the session name. Only
object-level queries can be directly executed by the session broker, unless the query is named.

Action: Session broker has no idea about such queries about which session to execute the query
on. Specify the session name.

Error code: 6043

REPORT_RESULT_WITHOUT_PKS

Cause: ReportQuery without PKs cannot readObject. The report query result returned is without
primary key values. An object from the result can only be created only if primary keys were also
read.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 52 of 77

Action: Check documentation on retrievePriamryKeys() on report query.

Error code: 6044

NULL_PRIMARY_KEY_IN_BUILDING_OBJECT

Cause: The primary key read from the row, <databaseRow> during the execution of the query
was detected to be null; primary keys must not contain null.

Action: Check query and also the table on the database.

Error code: 6045

NO_DESCRIPTOR_FOR_SUBCLASS

Cause: The subclass has no descriptor defined for it.

Action: Check session if the descriptor was added or not or else check class extraction method.

Error code: 6046

CANNOT_DELETE_READ_ONLY_OBJECT

Cause: Cannot delete an object of read-only class. The class <className> is declared read-only
in this unit of work. Thrown in unit of work when trying to delete an object that is marked as read
only.

Action: Contact Technical Support.

Error code: 6047

INVALID_OPERATOR

Cause: The operator <data> used in the expression is not valid.

Action: Check ExpressionOperator class to see a list of all of the operators supported.

Error code: 6048

ILLEGAL_USE_OF_GETFIELD

Cause: Illegal use of getField <data> in expression. This is a TopLink development exception
that users should not encounter.

Action: Report this problem to Technical Support.

Error code: 6049

ILLEGAL_USE_OF_GETTABLE

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 53 of 77

Cause: Illegal use of getTable <data> in expression. This is a TopLink development exception
that users should not encounter.

Action: Report this problem to Technical Support.

Error code: 6050

REPORT_QUERY_RESULT_SIZE_MISMATCH

Cause: The number of attributes requested does not match the attributes returned from the
database in report query. This usually happens if one gives custom query on the report query.

Action: Check the custom query if it is specified or report this problem to Technical Support.

Error code: 6051

CANNOT_CACHE_PARTIAL_OBJECT

Cause: Partial Objects are never put in the cache. Partial object queries are not allowed to
maintain the cache or be edited. You must set dontMaintainCache().

Action: Call the dontMaintainCache() method before executing the query.

Error code: 6052

OUTER_JOIN_ONLY_VALID_FOR_ONE_TO_ONE

Cause: An outer join (getAllowingNull) is only valid for one to one mappings, and cannot be
used for the mapping.

Action: Do not attempt to use getAllowingNull for mappings other than one to one.

Error code: 6054

CANNOT_ADD_TO_CONTAINER

Cause: Cannot add <anObject> to a <containerClass> using <policy>. This is TopLink


development exception and user should never encounter this problem unless a custom container
policy has been written.

Action: Contact Technical Support.

Error code: 6055

METHOD_INVOCATION_FAILED

Cause: The method invocation of <aMethod> on the object <anObject> threw a Java reflection
exception while accessing method.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 54 of 77

Action: Check Java documentation on the internal exception.

Error code: 6056

CANNOT_CREATE_CLONE

Cause: Cannot create a clone of <anObject> using <policy>. This is a TopLink development
exception and user should never encounter this problem unless a custom container policy has been
written.

Action: Report this problem to Technical Support.

Error code: 6057

METHOD_NOT_VALID

Cause: The method <methodName> is not valid to call on object <aReceiver>. This is a TopLink
development exception and user should never encounter this problem unless a custom container
policy has been written.

Action: Contact Technical Support.

Error code: 6058

METHOD_DOES_NOT_EXIST_IN_CONTAINER_CLASS

Cause: The method named <methodName> was not found in class <aClass>. Thrown when
looking for clone method on the container class. The clone is needed to create clones of the
container in unit of work.

Action: Define clone method on the container class.

Error code: 6059

COULD_NOT_INSTANTIATE_CONTAINER_CLASS

Cause: The class <aClass> cannot be used as the container for the results of a query since it
cannot be instantiated. Thrown when new interface container policy is being created using Java
reflection.

Action: Check Java documentation on the internal exception.

Error code: 6060

MAP_KEY_NOT_COMPARABLE

Cause: Could not use object <anObject> of type <objectClass> as a key into <aContainer> which
is of type <containerClass>. Key cannot be compared with the keys currently in the map. Throws
Java reflection exception while accessing method.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 55 of 77

Action: Check Java documentation on the internal exception.

Error code: 6061

CANNOT_ACCESS_METHOD_ON_OBJECT

Cause: Cannot reflectively access the method <aMethod> for object: <anObject> of type
<anObjectClass>. Throws Java reflection exception while accessing method.

Action: Check Java documentation on the internal exception.

Error code: 6062

CALLED_METHOD_THREW_EXCEPTION

Cause: The method <aMethod> was called reflectively on object <object> of class <objectClass>
and threw an exception. Throws Java reflection exception while accessing method.

Action: Check Java documentation on the internal exception.

Error code: 6063

INVALID_OPERATION

Cause: Invalid operation <operation> on cursor. The operation is not supported.

Action: Check the class documentation and look for the corresponding method that should be
used.

Error code: 6064

CANNOT_REMOVE_FROM_CONTAINER

Cause: Cannot remove <anObject> of type <anObjectClass> from <aContainerClass> using


<policy>. This is TopLink development exception and user should never encounter this problem
unless a custom container policy has been written.

Action: Contact Technical Support.

Error code: 6065

CANNOT_ADD_ELEMENT

Cause: Cannot add element to the collection container policy (cannot add <anObject> of type
<anObjectClass> to a <aContainerClass>).

Action: Check Java documentation on the internal exception.

Error code: 6066

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 56 of 77

BACKUP_CLONE_DELETED

Cause: Deleted objects cannot have reference after being deleted. The object clone of class
<clone.getClass()> with identity hashcode (System.identityHashCode())
<System.identityHashCode(clone)> has been deleted, but still has references.

Action: Ensure that you are correctly registering your objects. If you are still having problems,
you can use the UnitOfWork.validateObjectSpace() method to help debug where the error
occurred. Please see the manual and FAQ for more information.

Error code: 6068

CANNOT_COMPARE_TABLES_IN_EXPRESSION

Cause: Cannot compare table reference to <data> in expression

Action: Check the expression

Error code: 6069

INVALID_TABLE_FOR_FIELD_IN_EXPRESSION

Cause: Field has invalid table in this context for field <data> in expression.

Action: Check the expression

Error code: 6070

INVALID_USE_OF_TO_MANY_QUERY_KEY_IN_EXPRESSION

Cause: Invalid use of a query key representing a to-many relationship <data> in expression. Use
anyOf rather than get.

Action: Use the anyOf operator instead of get.

Error code: 6071

INVALID_USE_OF_ANY_OF_IN_EXPRESSION

Cause: Invalid use of anyOf for a query key not representing a to-many relationship <data> in
expression. Use get rather than anyOf.

Action: Use the get operator instead of anyOf.

Error code: 6072

CANNOT_QUERY_ACROSS_VARIABLE_ONE_TO_ ONE_MAPPING

Cause: Querying across a variable one-to-one mapping is not supported.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 57 of 77

Action: Change the expression such that the query in not done across a variable one to one
mapping.

Error code: 6073

ILL_FORMED_EXPRESSION

Cause: Ill-formed expression in query, attempting to print an object reference into a SQL
statement for <queryKey>.

Action: Contact Technical Support.

Error code: 6074

CANNOT_CONFORM_EXPRESSION

Cause: This expression cannot determine if the object conforms in memory, you must set the
query to check the database.

Action: Change the query such that it does not attempt to conform to the results of the query.

Error code: 6075

INVALID_OPERATOR_FOR_OBJECT_EXPRESSION

Cause: Object comparisons can only use the equal or notEqual operators, other comparisons
must be done through query keys or direct attribute level comparisons.

Action: Ensure the query uses only equal and notEqual if object comparisons are being used.

Error code: 6076

UNSUPPORTED_MAPPING_FOR_OBJECT_COMPARISON

Cause: Object comparisons can only be used with 1:1 mappings; other mapping comparisons
must be done through query keys or direct attribute level comparisons.

Action: Use a query key instead of attempting to compare objects across the mapping.

Error code: 6077

OBJECT_COMPARISON_CANNOT_BE_PARAMETERIZED

Cause: Object comparisons cannot be used in parameter queries.

Action: Change the query such that it does not attempt to use object when using parameterized
queries.

Error code: 6078

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 58 of 77

INCORRECT_CLASS_FOR_OBJECT_COMPARISON

Cause: The class of the argument for the object comparison is incorrect.

Action: Ensure the class for the query is correct.

Error code: 6079

CANNOT_COMPARE_TARGET_FOREIGN_KEYS_ TO_NULL

Cause: Object comparison cannot be used for target foreign key relationships. Query on the
source primary key instead.

Action: Query on source primary key.

Error code: 6080

INVALID_DATABASE_CALL

Cause: Invalid database call - the call must be an instance of DatabaseCall: <call>.

Action: Ensure the call being used is a DatabaseCall.

Error code: 6081

INVALID_DATABASE_ACCESSOR

Cause: Invalid database accessor - the accessor must be an instance of DatabaseAccessor:


<accessor>.

Action: Ensure the accessor being used is a DatabaseAccessor.

Error code: 6082

METHOD_DOES_NOT_EXIST_ON_EXPRESSION

Cause: Method: <methodName> with argument types: <argTypes> cannot be invoked on


Expression.

Action: Ensure the method being used is a supported method.

Error code: 6083

IN_CANNOT_BE_PARAMETERIZED

Cause: Queries using IN cannot be parameterized.

Action: Either disable the query prepare or binding.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 59 of 77

Error code: 6084

REDIRECTION_CLASS_OR_METHOD_NOT_SET

Cause: The redirection query was not configured properly, the class or method name was not set.

Action: Check the configuration for the redirection class.

Error code: 6085

REDIRECTION_METHOD_NOT_DEFINED_CORRECTLY

Cause: The redirection query's method is not defined or define with the wrong arguments. It must
be public static and have arguments DatabaseQuery, DatabaseRow, Session (the interface).

Action: Check the redirection query's method as above.

Error code: 6086

REDIRECTION_METHOD_ERROR

Cause: The redirection query's method invocation threw an exception.

Action: Check the redirection method for problems.

Error code: 6087

EXAMPLE_AND_REFERENCE_OBJECT_CLASS_MISMATCH

Cause: There is a class mismatch between the example object and the reference class specified for
this query.

Action: Ensure the example and reference classes are compatible.

Error code: 6088

NO_ATTRIBUTES_FOR _REPORT_QUERY

Cause: A RepertQuery has been built with no attributes specified.

Action: Specify attribute for the query.

Error code: 6089

NO_EXPRESSION_BUILDER_CLASS_FOUND

Cause: The expression has not been initialized correctly. Only a single ExpressionBuilder should
be used for a query. For parallel expressions, the query class must be provided to the
ExpressionBuilder constructor, and the query's ExpressionBuilder must always be on the left side

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 60 of 77

of the expression.

Action: Contact Technical Support.

Error code: 6090

CANNOT_SET_REPORT_QUERY_TO_CHECK_ CACHE_ONLY

Cause: Cannot set ReportQuery to Check Cache Only.

Action: Contact Technical Support.

Error code: 6091

TYPE_MISMATCH_BETWEEN_ATTRIBUTE_AND_ CONSTANT_ ON_EXPRESSION

Cause: The type of the constant, used for comparison in the expression, does not match the type
of the attribute.

Action: Contact Technical Support.

Error code: 6092

MUST_INSTANTIATE_VALUEHOLDERS

Cause: Uninstantiated ValueHolder detected. You must instantiate the relevant Valueholders to
perform this in-memory query.

Action: Instantiate the valueholders for the collection you want to query on.

Validation Exceptions (7001 - 7097)


Error code: 7001

LOGIN_BEFORE_ALLOCATING_CLIENT_SESSIONS

Cause: You attempted to allocate client sessions before logging into the server.

Action: Ensure you have called login() on your ServerSession or DatabaseSession.

Note:

This error also appears in multithreaded environments as a result of concurrency


issues. Check that all of your threads are synchronized.

Error code: 7002

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 61 of 77

POOL_NAME_DOES_NOT_EXIST

Cause: The pool name used while acquiring client session from the server session does not exist.

Action: Check the pool name given while acquiring client session and all the existing pools on the
server session.

Error code: 7003

MAX_SIZE_LESS_THAN_MIN_SIZE

Cause: The maximum number of connections in a connection pool should be more than the
minimum number of connections.

Action: Check addConnectionPool(String poolName, JDBCLogin login, int


minNumberOfConnections, int maxNumberOfConnections) on server session.

Error code: 7004

POOLS_MUST_BE_CONFIGURED_BEFORE_LOGIN

Cause: Pools must all be added before login on the server session has been done. Once logged in
pools cannot be added.

Action: Check addConnectionPool(String poolName, JDBCLogin login, int


minNumberOfConnections, int maxNumberOfConnections) on server session. This method
should be called before login on server session.

Error code: 7008

JAVA_TYPE_IS_NOT_A_VALID_DATABASE_TYPE

Cause: The Java type <javaClass> is not a valid database type. The Java type of the field to be
written to the database has no corresponding type on the database.

Action: Check table or stored procedure definition.

Error code: 7009

MISSING_DESCRIPTOR

Cause: The descriptor <className>is not found in the session. Verify that the descriptor has been
properly registered with the session.

Action: Check if the related descriptor to the class was added to the session.

Error code: 7010

START_INDEX_OUT_OF_RANGE

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 62 of 77

Cause: This is a TopLink development exception and user should never encounter this problem. It
happens when a copy of vector is created with start and end index.

Action: Report this problem to Technical Support.

Error code: 7011

STOP_INDEX_OUT_OF_RANGE

Cause: This is a TopLink development exception and user should never encounter this problem. It
happens when a copy of vector is created with start and end index.

Action: Report this problem to Technical Support.

Error code: 7012

FATAL_ERROR_OCCURRED

Cause: This is a TopLink development exception and user should never encounter this problem. It
happens when test cases are executed.

Action: Report this problem to Technical Support. This error commonly occurs if you attempt to
commit() an invalid (or previously committed) UnitOfWork.

If ValidationException.cannotCommitUOWAgain() appears in the stack trace, ensure that call


commit() on valid UnitOfWork instances.

Error code: 7013

NO_PROPERTIES_FILE_FOUND

Cause: TopLink.properties file cannot be found on the system CLASSPATH.

Action: Ensure that there is a TopLink.properties file located on the system CLASSPATH.

Error code: 7017

CHILD_DESCRIPTORS_DO_NOT_HAVE_IDENTITY_MAP

Cause: Child descriptors do not have an identity map; they share their parent's. An Identity map is
added to the child descriptor. A child descriptor shares its parent's identity map.

Action: Check child descriptor and remove identity map from it.

Error code: 7018

FILE_ERROR

Cause: The user should never encounter this problem. It happens when test cases are executed.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 63 of 77

Action: Contact Technical Support.

Error code: 7023

INCORRECT_LOGIN_INSTANCE_PROVIDED

Cause: The login instance provided to the login() method is incorrect. A JDBCLogin must be
provided.

Action: It should be of type JDBCLogin.

Error code: 7024

INVALID_MERGE_POLICY

Cause: This is a TopLink development exception and users should never encounter it.

Action: Contact Technical Support.

Error code: 7025

ONLY_FIELDS_ARE_VALID_KEYS_FOR_ DATABASE_ROWS

Cause: The key on the database row is not either of type String or of type DatabaseField.

Action: Contact Technical Support.

Error code: 7027

SEQUENCE_SETUP_INCORRECTLY

Cause: Sequence <sequenceName> is setup incorrectly, increment does not match pre-allocation
size.

Action: Contact Technical Support.

Error code: 7028

WRITE_OBJECT_NOT_ALLOWED_IN_UNIT_OF_WORK

Cause:

Action: The objects in the unit of work are written to database by registering and committing the
unit of work.

Error code: 7030

CANNOT_SET_READ_POOL_SIZE_AFTER_LOGIN

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 64 of 77

Cause: You cannot set read pool size after the server session has already been logged in.

Action: The size should be set before login.

Error code: 7031

CANNOT_ADD_DESCRIPTORS_TO_SESSION_BROKER

Cause: You cannot add descriptors to session broker.

Action: Descriptors are added to the sessions contained in the session broker.

Error code: 7032

NO_SESSION_REGISTERED_FOR_CLASS

Cause: The descriptor related to the domain class <domainClass> was not found in any of the
sessions registered in the session broker.

Action: Check sessions.

Error code: 7033

NO_SESSION_REGISTERED_FOR_NAME

Cause: The session with the given name <sessionName> is not registered in the session broker.

Action: Check session broker.

Error code: 7038

LOG_IO_ERROR

Cause: Error while logging message to session's log.

Action: Check the internal exception.

Error code: 7039

CANNOT_REMOVE_FROM_READ_ONLY_CLASSES_ IN_NESTED_UNIT_OF_WORK

Cause: Cannot remove from the set of read-only classes in a nested unit of work. A nested unit of
work's set of read-only classes must be equal to or a superset of its parent's set of read-only
classes.

Action: Contact Technical Support.

Error code: 7040

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 65 of 77

CANNOT_MODIFY_READ_ONLY_CLASSES_SET_ AFTER_USING_UNIT_OF_WORK

Cause: Cannot change the set of read-only classes in a unit of work after that unit of work has
been used. Changes to the read-only set must be made when acquiring the unit of work or
immediately after.

Action: Contact Technical Support.

Error code: 7042

LATFORM_CLASS_NOT_FOUND

Cause: The platform class <className> was not found and a reflection exception was thrown.

Action: Check internal exception.

Error code: 7043

NO_TABLES_TO_CREATE

Cause: <project> does not have any tables to create on the database.

Action: Validate the project and tables to be created.

Error code: 7044

LLEGAL_CONTAINER_CLASS

Cause: The container class specified <className> cannot be used as the container because it does
not implement Collection or Map.

Action: The container class must implement either of these two interfaces.

Error code: 7047

ONTAINER_POLICY_DOES_NOT_USE_KEYS

Cause: Invalid Map class was specified for the container policy. The container specified (of class
<aPolicyContainerClass>) does not require keys. You tried to use <methodName>.

Action: Use map class that implements Map interface.

Error code: 7048

METHOD_NOT_DECLARED_IN_ITEM_CLASS

Cause: The key method on the map container policy is not defined. The instance method
<methodName> does not exist in the reference class <className> and therefore cannot be used to
create a key in a Map.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 66 of 77

Action:

Error code: 7051

MISSING_MAPPING

Cause: Missing attribute <attributeName> for descriptor <descriptor> called from <source>.
This is a TopLink development exception and a user should never encounter it.

Action: Contact Technical Support.

Error code: 7052

ILLEGAL_USE_OF_MAP_IN_DIRECTCOLLECTION

Cause: The method useMapClass was called on a DirectCollectionMapping. It is illegal to call


useMapClass() on a DirectCollectionMapping. TopLink cannot instantiate Java attributes
mapped using a DirectCollectionMapping with a Map. The useMapClass() API is supported
for OneToManyMappings and ManyToManyMappings. The Java2 Collection interface is supported
using the useCollectionClass() method.

Action: Do not call useMapClass() on DirectCollectionMappings. Instead, use the


useCollectionClass() API.

Error code: 7053

CANNOT_RELEASE_NON_CLIENTSESSION

Cause: Release attempted on a session that is not a client session. Only client sessions may be
released.

Action: Modify code so that the client session is not released.

Error code: 7054

CANNOT_ACQUIRE_CLIENTSESSION_FROM_SESSION

Cause: Acquire attempted on a session that is not a client session. Client sessions may only be
acquired from server sessions.

Action: Modify code so that the acquire in not attempted.

Error code: 7055

OPTIMISTIC_LOCKING_NOT_SUPPORTED

Cause: Optimistic Locking is not supported with stored procedure generation.

Action: Do not use OptimisticLocking with stored procedure generation.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 67 of 77

Error code: 7056

WRONG_OBJECT_REGISTERED

Cause: The wrong object was registered into the unit of work. It should be the object from the
parent cache.

Action: Ensure the object is from the parent cache

Error code: 7058

INVALID_CONNECTOR

Cause: The connector must be of type DefaultConnector.

Action: Ensure the connector is of type DefaultConnector.

Error code: 7059

INVALID_DATA_SOURCE_NAME

Cause: Invalid DataSource name: <name>.

Action: Verify the data source name.

Error code: 7060

CANNOT_ACQUIRE_DATA_SOURCE

Cause: Cannot acquire DataSource: <name> or an error has occurred in setting up the datasource.

Action: Verify the data source name. Check the nested SQL exception to determine the cause of
the error. Typical problems include:

l The connection pool was not configured in your config.xml.

l The driver is not on the classpath.

l The user or password is incorrect.

l The database server url or driver name is not properly specified.

Error code: 7061

JTS_EXCEPTION_RAISED

Cause: Exception occurred within JTS.

Action: Examine the JTS exception returned and consult the JTS documentation.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 68 of 77

Error code: 7062

FIELD_LEVEL_LOCKING_NOTSUPPORTED_ OUTSIDE_A_UNIT_OF_WORK

Cause: FieldLevelLocking not supported outside a unitOfWork. In order to use field level
locking, a unit of work must be used for ALL writes.

Action: Use a unit of work for writing.

Error code: 7063

EJB_CONTAINER_EXCEPTION_RAISED

Cause: Exception occurred within EJB container.

Action: Examine the EJB exception returned and consult the JTS documentation.

Error code: 7064

EJB_PRIMARY_KEY_REFLECTION_EXCEPTION

Cause: Exception occurred in reflective EJB bean primary key extraction.

Action: Ensure your primary key object is defined correctly.

Error code: 7065

EJB_CANNOT_LOAD_REMOTE_CLASS

Cause: The remote class for the bean cannot be loaded/found for the bean.

Action: Ensure the correct class loader is set correctly.

Error code: 7066

EJB_MUST_BE_IN_TRANSACTION

Cause: Cannot create or remove beans unless a JTS transaction is present, bean=<bean>.

Action: Verify that the JTS transaction is present.

Error code: 7068

EJB_INVALID_PROJECT_CLASS

Cause: The platform class <platformName> was not found for the <projectName> using default
class loader.

Action: Validate the project and platform.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 69 of 77

Error code: 7069

SESSION_AMENDMENT_EXCEPTION_OCCURED

Cause: A exception occurred looking up or invoking the session amendment method,


<amendmentMethod> on the class <amendmentClass>.

Action: Validate the amendment method and class.

Error code: 7070

EJB_TOPLINK_PROPERTIES_NOT_FOUND

Cause: A toplink.properties resource bundle must be located on the classpath in a TopLink


directory.

Action: Validate the classpath and the location of the TopLink resource bundle.

Error code: 7071

CANT_HAVE_UNBOUND_IN_OUTPUT_ARGUMENTS

Cause: You cannot use input output parameters without using binding.

Action: Use binding on the StoredProcedureCall.

Error code: 7073

ORACLE_OBJECT_TYPE_NOT_DEFINED

Cause: Oracle object type with type name <typeName> is not defined.

Action: Verify that the Oracle object type is defined.

Error code: 7074

ORACLE_OBJECT_TYPE_NAME_NOT_DEFINED

Cause: Oracle object type <typeName> is not defined.

Action: Verify that the Oracle object type is defined.

Error code: 7075

ORACLE_VARRAY_MAXIMIM_SIZE_NOT_DEFINED

Cause: Oracle VARRAY type <typeName> maximum size is not defined

Action: Verify the maximum size for the Oracle VARRAY.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 70 of 77

Error code: 7076

DESCRIPTOR_MUST_NOT_BE_INITIALIZED

Cause: When generating the project class the descriptors must not be initialized.

Action: Ensure the descriptors are not initialized before generating the project class.

Error code: 7077

EJB_INVALID_FINDER_ON_HOME

Cause: The Home Interface <homeClassName.toString()> specified during creation of


BMPWrapperPolicy does not contain a correct findByPrimaryKey method. A findByPrimaryKey
method must exist that takes the PrimaryKey class for this bean.

Action: Verify that a FindByPrimaryKey method exists and is correct.

Error code: 7078

EJB_NO_SUCH_SESSION_SPECIFIED_IN_PROPERTIES

Cause: The sessionName specified on the deployment descriptor does not match any session
specified in the TopLink properties file.

Action: Contact Technical Support.

Error code: 7079

EJB_DESCRIPTOR_NOT_FOUND_IN_SESSION

Cause: The descriptor was not found in the session.

Action: Check the project being used for this session.

Error code: 7080

EJB_FINDER_EXCEPTION

Cause: A FinderException was thrown when trying to load an object from the class with the
primary key.

Action: Contact Technical Support.

Error code: 7081

CANNOT_REGISTER_AGGREGATE_OBJECT_IN_ UNIT_OF_ WORK

Cause: The aggregate object cannot be directly registered in the unit of work. It must be

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 71 of 77

associated with the source (owner) object.

Action: Contact Technical Support.

Error code: 7082

MULTIPLE_PROJECTS_SPECIFIED_IN_PROPERTIES

Cause: The TopLink properties file specified multiple project files for the server. Only one
project file can be specified.

Action: Specify one of projectClass, projectFile, or xmlProjectFile.

Error code: 7083

O_PROJECT_SPECIFIED_IN_PROPERTIES

Cause: The TopLink properties file does not include any information on the TopLink project to
use for the server. One project file must be specified.

Action: Specify one of projectClass, projectFile, or xmlProjectFile.

Error code: 7084

INVALID_FILE_TYPE

Cause: The specified file is not a valid type for reading. ProjectReader must be given the
deployed XML Project file.

Action: Contact Technical Support.

Error code: 7085

CANNOT_CREATE_EXTERNAL_TRANSACTION_ CONTROLLER

Cause: Cannot create an instance of the external transaction controller specified in the properties
file.

Action: Contact Technical Support.

Error code 7087:

EJB_SESSION_TYPE_CLASS_NOT_FOUND

Cause: SessionManager cannot load the class corresponding to session's type class name.

Action: Verify the class name of the session's type in the Session.xml or toplink.properties
that it is fully qualified.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 72 of 77

Error code 7088:

CANNOT_CREATE_EXTERNAL_TRANSACTION_ CONTROLLER

Cause: SessionManager cannot load the class corresponding to external transaction controller's
class name.

Action: Verify the class name of the external transaction controller in Session.xml or
toplink.properties that it is valid and fully qualified.

Error code 7089:

SESSION_AMENDMENT_EXCEPTION_OCCURED

Cause: SessionManager cannot load the class corresponding to the amendment class name or it
cannot load the method on the amendment class corresponding to the amendment method name.

Action: Verify the class name of the amendment class in Session.xml or toplink.properties
that it is fully qualified and the amendment method exists in the amendment class.

Error code 7091

SET_LISTENER_CLASSES_EXCEPTION

Cause: Cannot create the listener class that implements SessionEventListener for the internal
use of SessionXMLProject.

Action: Contact Technical Support.

Error code 7092

EXISTING_QUERY_TYPE_CONFLICT

Cause: Add custom query with the same name and arguments to a session.

Action: Verify that no query is added to the session more than once or change the query name so
that the query can be distinguished.

Error code 7093

QUERY_ARGUMENT_TYPE_NOT_FOUND

Cause: Cannot create an instance of the query argument type.

Action: Verify the argument type is a fully qualified class name and the argument class is
included in the classpath environment.

Error code 7095

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 73 of 77

NO_SESSIONS_XML_FOUND

Cause: Session.XML or toplink.properties cannot be loaded.

Action: Add the path to the above file to the classpath environment.

Error code 7096

CANNOT_COMMIT_UOW_AGAIN

Cause: Invoke commit() on an inactive unit of work that was committed or released.

Action: Invoke commit() on a new unit of work or invoke commitAndResume() so that the unit
of work can be reused. See Oracle9iAS TopLink Foundation Library Guide for more details on
commitAndResume().

Error code 7097:

OPERATION_NOT_SUPPORTED

Cause: Invoke a nonsupport operation on an object.

Action: Do not use the operation indicated in the stack trace.

Error Code: 7099

PROJECT_XML_NOT_FOUND

Cause: The filename specified for the XML-based project is incorrect.

Action: Verify the name and location of the file.

Error Code: 7101

NO_TOPLINK_EJB_JAR_XML_FOUND

Cause: The toplink-ejb-jar.xml file was not found.

Action: Please refer to the TopLink examples located in <INSTALL DIR>\Examples.

EJBQL Exceptions (8001 - 8009)


Error Code: 8001

recognitionException

Cause: The TopLink EJBQL parser doesn't recognize a clause in the EJBQL string

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 74 of 77

Action: Validate the EJBQL string

Error Code: 8002

generalParsingException

Cause: TopLink has encountered a problem while parsing the EJBQL string.

Action: Check the internal exception for details on the root cause of this exception

Error Code: 8003

classNotFoundException

Cause: The class specified in the EJBQL string was not found

Action: Ensure that the class is on the appropriate classpath

Error Code: 8004

aliasResolutionException

Cause: TopLink was unable to resolve the alias used in the EJBQL string

Action: Validate the identifiers used in the EJBQL string

Error Code: 8005

resolutionClassNotFoundException

Cause: TopLink was unable to resolve the class for an alias. This means that the class specified
can not be found

Action: Ensure the class is specified properly and is on the classpath

Error Code: 8006

missingDescriptorException

Cause: The class specified in the query has no TopLink descriptor

Action: Ensure the class has been mapped and is specified correctly in the EJBQL string

Error Code: 8009

expressionNotSupported

Cause: An unsupported expression was used in the EJBQL

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 75 of 77

Action: Change the query to use only supported expressions

Synchronization Exceptions (8050 - 8070)


Error Code: 8050

DROPPING_REMOTE_CONNECTION

Cause: A communication error over the communication framework

Action: Reconnect the server to this session. If using the default discovery system restart the
session on the disconnected server

Error Code: 8051

ERROR_DOING_REMOTE_MERGE

Cause: The remote server's cache has become corrupt.

Action: Restart the session on the remote server or initialize identity maps

Error Code: 8052

ERROR_DOING_LOCAL_MERGE

Cause: The local shared cache has become corrupt.

Action: Restart the session on this server or initialize identity maps.

Error Code: 8053

ERROR_LOOKING_UP_LOCAL_HOST

Cause: Failed to get the IP address of the local machine for generating the SessionID.

Action: Contact network administrator.

Error Code: 8054

ERROR_BINDING_CONTROLLER

Cause: A Global Naming Service, such as JNDI, was unavailable at supplied URL.

Action: Check that the LocalHostURL points to the Service and verify that the Service is
available.

Error Code: 8055

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
Error Codes and Descriptions Page 76 of 77

ERROR_LOOKING_UP_CONTROLLER

Cause: Failed to find the remote connection for a remote session.

Action: Verify that the Global Naming Service, such as JNDI, is running properly.

Error Code: 8056

ERROR_UNMARSHALLING_MSG

Cause: Message from remote system could not be read by this session.

Action: None, however some servers may not be connected.

Error Code: 8057

ERROR_GETTING_SYNC_SERVICE

Cause: Failed to create the specified Synchronization Service.

Action: Verify that you have specified an available Synchronization service in the current
configuration file, or in your application code.

Error Code: 8058

ERROR_NOTIFYING_CLUSTER

Cause: Failed to send existence announcement to remote servers.

Action: Check that this machine has access to the network and restart Synchronization service.

Error Code: 8059

ERROR_JOINING_MULTICAST_GROUP

Cause: Failed to set socket to listen to the multicast group.

Action: Contact network administrator to verify that this machine has network access and can use
Multicast protocols.

Error Code: 8070

ERROR_RECEIVING_ANNOUNCEMENT

Cause: Error occurred while attempting to receive a Multicast announcement.

Action: Verify that this machine is connected to the network and is capable of sending and
receiving multicast packets.

https://docs.oracle.com/cd/A97688_16/toplink.903/b10068/errorcod.htm 23/11/2017
CS 111: Common Java Errors
List of common Java error messages:

1.  cannot find symbol
2.  class <X> is public, should be declared in a file named <X>.java
3.  class, interface, or enum expected
4.  <X> expected
5.  <identifier> expected
6.  illegal start of expression
7.  incompatible types
8.  invalid method declaration; return type required
9.  java.lang.ArrayIndexOutOfBoundsException: <X>
10.  java.lang.StringIndexOutOfBoundsException: String index out of range: <X>
11.  method <X> in class <Y> cannot be applied to given types
12.  missing return statement
13.  possible loss of precision
14.  reached end of file while parsing
15.  unreachable statement
16.  variable might not have been initialized

Encountering an error that you don't see above? Ask on Piazza ­­ using the error folder.

1.  cannot find symbol 

"Cannot find symbol" errors generally occur when you try to reference an undeclared variable in your code. Consider the following
example:

    public class Test {
        public static void main(String[] args) {
            int a = 3;
            int b = 4;
            int c = 20;
        
            average = (a + b + c)/5.0;
            System.out.println(average);
        }
    }

 
    1 error found:
    File: Test.java  [line: 7]
    Error: Test.java:7: cannot find symbol
    symbol  : variable average
    location: class Test
 

Here, the variable average has not been declared­­ you need to tell the compiler what the type of average is; for example:

    double average = (a + b + c)/5.0;

Secondly, sometimes this error occurs because you are trying to reference a method in your code, but forget to include the parentheses
that indicate a reference to a method, even when there are no parameters. For example:

    public class Test {
        public static void main(String[] args) {
            my_method;
        }
    
        public static void my_method() {
            System.out.println("Hello, world!");
        }
    }

    
    1 error found:
    File: Test.java  [line: 7]
    Error: Test.java:7: cannot find symbol
    symbol  : variable my_method
    location: class Test
 

Here, the compiler is looking for a variable called my_method in the main method; instead, you want to initiate a method call to
my_method:

    public class Test {
        public static void main(String[] args) {
            my_method();
        }
    
        public static void my_method() {
            System.out.println("Hello, world!");
        }
    }

Thirdly, this error could also occur if you forget to import a Java package that you need to use. For example, consider the following
program that reads in an integer from the user:

    public class Test {     
        public static void main(String[] args) {
            Scanner console = new Scanner(System.in);
            int n = console.nextInt();
        }
    }

    
    2 errors found:
    File: Test.java  [line: 3]
    Error: cannot find symbol
      symbol:   class Scanner
      location: class Test
    File: Test.java  [line: 3]
    Error: cannot find symbol
      symbol:   class Scanner
      location: class Test
 

The issue here is that the program must import java.util.Scanner (or, more generally, java.util.*). Otherwise, the compiler does
not know what a Scanner type is. You may encounter a similar error if you forget to import java.util.Arrays or java.io.* when
working with file input/output. To fix the code above:

    import java.util.*; // or ­­> import java.util.Scanner;    
    public class Test {     
        public static void main(String[] args) {
            Scanner console = new Scanner(System.in);
            int n = console.nextInt();
        }
    }

Finally, this error can occur if you have case­sensitive errors with variables. All identifiers in Java are case sensitive. This means that if
you declare a variable named average and try to later refer to it using Average, the compiler will complain that it cannot find a symbol
named Average.

2.  class <X> is public, should be declared in a file named <X>.java 

This error occurs when the class name and the filename of a given Java program do not match. For example, say that the following
program is saved in a file named Foo.java:

    public class Bar {     
        public static void main(String[] args) {
            System.out.println("Hello, world!");
        }
    }

 
    1 error found:
    File: Foo.java  [line: 1]
    Error: class Bar is public, should be declared in a file named Bar.java
 

Since Foo does not match with Bar, the code will not compile. To fix this error, either rename the file or change the class name.

3.  class, interface, or enum expected 

This error is another form of problems with curly braces. Typically this error arises when there are too many curly braces at the end of a
program; for example:

    public class Test {     
        public static void main(String[] args) {
            System.out.println("Hello!");
        }
    }
    }

 
    1 error found:
    File: Test.java  [line: 6]
    Error: class, interface, or enum expected
 

One way of figuring out where this error is occurring (as with all problems with curly braces) is to correctly indent the code. Again, one
way of doing this in Dr. Java is to press CTRL­A (to highlight the entire program) and then TAB (to correctly indent the highlighted code).
In our example program above, notice that the two curly braces at the end of the program are at the same indentation level, which cannot
happen in a valid program. Therefore, simply delete one of the curly braces for the code to compile:
    public class Test {     
        public static void main(String[] args) {
            System.out.println("Hello!");
        }
    }

4.  <X> expected 
Errors of the form "<X> expected" happen when the compiler detects a missing character in your code. The error message will tell you
which character is missing and on which line. Consider the following program:

    public class Test
        public static void main(String[] args) {
            my_method();
        }
    
        public static void my_method() {
            System.out.println("Hello, world!")     
        }
    }
 
    
    2 errors found:
    File: Test.java  [line: 1]
    Error: Test.java:1: '{' expected
    File:.java  [line: 7]
    Error: Test.java:7: ';' expected
 

These error messages tell you there is a missing curly brace on the first line and a missing semi­colon on the seventh line. To fix this kind
of error, simply place the missing character in the correct position in the code:

    public class Test {
        public static void main(String[] args) {
            my_method();
        }
    
        public static void my_method() {
            System.out.println("Hello, world!");   
        }
    }

5.  <identifier> expected 

This error occurs when code is written outside of a method; it is typically caused by a mistake in curly braces. Consider the following
example:
    public class Test { 
        System.out.println("Hello!");
    
        public static void main(String[] args) {
            System.out.println("World!");
        }
    }

 
    2 errors found:
    File: Test.java  [line: 2]
    Error: <identifier> expected
    File: Test.java  [line: 2]
    Error: illegal start of type
 

In this case, it is somewhat clear that the first print statement must be inside the main method for the code to compile. However, when
there is more than one method and a curly brace error, the "<identifier> expected" error can be harder to see:

    public class Test {     
        public static void main(String[] args) {
            System.out.println("Hello!");}
            System.out.println("World!");
        }
    }

 
    3 errors found:
    File: Test.java  [line: 4]
    Error: <identifier> expected
    File: Test.java  [line: 4]
    Error: illegal start of type
    File: Test.java  [line: 6]
    Error: class, interface, or enum expected
 

There is an extra curly brace in the code above, but the code is not properly indented so it is difficult to see. The effect of this is to end the
main method immediately after the line that prints "Hello!," which leaves the print statement that prints "World!" outside of any
method. To fix the error above, simply remove the curly brace at the end of the third line:

    public class Test {     
        public static void main(String[] args) {
            System.out.println("Hello!");
            System.out.println("World!");
        }
    }
6.  illegal start of expression 

An "illegal start of expression" error occurs when the compiler encounters an inappropriate statement in the code. Consider the following
example:

    public class Test {
        public static void main(String[] args) {
            my_method();
    
    
        public static void my_method() {
            System.out.println("Hello, world!");
        }
    } 

    
    5 errors found:
    File: Test.java  [line: 6]
    Error: Test.java:6: illegal start of expression
    File: Test.java  [line: 6]
    Error: Test.java:6: illegal start of expression
    File: Test.java  [line: 6]
    Error: Test.java:6: ';' expected
    File: Test.java  [line: 6]
    Error: Test.java:6: ';' expected
    File: Test.java  [line: 9]
    Error: Test.java:9: reached end of file while parsing
 

Here, there is a missing closing curly brace for the main method. Since the main method is not closed, the compiler is expecting the line
after the call to my_method to be a part of the main method's code. However, it instead encounters public static void
my_method() {, which is not a valid statement inside a method.

The "illegal start of expression" error message is not as helpful as the "... expected" error message that we encountered above. For this
error (and for many other errors), it may be necessary to look at the lines that come before the error to see where the problem is. In this
case, we simply need to add a curly brace to close the main method on the line before where the compiler issued the warning. After
recompiling, all of the errors are resolved.

    public class Test {
        public static void main(String[] args) {
            my_method();
        }   
    
        public static void my_method() {
            System.out.println("Hello, world!");
        }
    } 

For "illegal start of expression" errors, try looking at the lines preceding the error for a missing ')' or '}'.

7.  incompatible types 

This error occurs when there are type issues with your program. It is possible to convert between some kinds of types; for example, you
can freely convert a char to an int and vice versa, and you can also convert a double to an int with some typecasting. However, you
can not convert between primitive types and objects such as String. For example:

    public class Test {
        public static void main(String[] args) {
            int num = "Hello, world!";
        }
    }

    
    1 error found:
    File: Test.java  [line: 3]
    Error: Test.java:3: incompatible types
    found   : java.lang.String
    required: int
 

Typically, you cannot "fix" this error as you can for most other errors. This is not a syntax error, but rather an error in type logic. It usually
does not make sense to try to put a String into an integer type. However, there are some applications where you need to do something
like a String to int conversion, such as when the String is a representation of a number:

    public class Test {
        public static void main(String[] args) {
            int num = "500";
        }
    }
 
    
    1 error found:
    File: Test.java  [line: 3]
    Error: Test.java:3: incompatible types
    found   : java.lang.String
    required: int
 
To fix something like this, you might be able to depend on Java classes such as the Integer class, which is capable of taking a String
that represents a number and converting it to an integer type:

    public class Test {
        public static void main(String[] args) {
            int num = Integer.parseInt("500");
        }
    }

However, this kind of solution to an "incompatible types" error is the exception and not the rule, as this error usually comes from a mistake
in logic.

8.  invalid method declaration; return type required 

Every method in Java requires that you explicitly state the return type of the method. Even methods that do not return a value must
explicitly say void in the method signature, just as the main method does.

When a method declaration does not contain a return type, this error will occur:

    public class Test {
        public static void main(String[] args) {
            int x = getValue();
            System.out.println(x);
        }
    
        public static getValue() {
            return 10;
        }
    }

 
    1 error found:
    File: Test.java  [line: 7]
    Error: Test.java:7: invalid method declaration; return type required
 

To fix this, simply insert the appropriate return type in the method signature:

    public class Test {
        public static void main(String[] args) {
            int x = getValue();
            System.out.println(x);
        }
    
        public static int getValue() {
            return 10;
        }
    }

9.  java.lang.ArrayIndexOutOfBoundsException: <X> 

An ArrayIndexOutOfBoundsException is thrown when an attempt is made to access an index in an array that is not valid. The only
valid indices for an array arr are in the range [0, arr.length ­ 1]; any attempt to access an index outside of this range will result in
this error. For example:

    public class Test {
        public static void main(String[] args) {
            int[] arr = {1, 2, 3};
            for (int i = 0; i <= arr.length; i++) {
                System.out.println(arr[i]);
            }
        }
    }
 
    
    java.lang.ArrayIndexOutOfBoundsException: 3
  at Test.main(Test.java:5)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at edu.rice.cs.drjava.model.compiler.JavacCompiler.runCommand(JavacCompiler.java:272)
 

This error is quite similar to the java.lang.StringIndexOutOfBoundsException: String index out of range: <X> error that we have previously
discussed. The error message for this kind of error is similarly irrelevant toward the end of the message. However, the first line lets you
know that a problem with an array index was encountered, and the index in error was 3, in this case. The next line tells you that it
encountered this error on line 5 of Test.java, inside the main method.

In this case, the error occurred because the for loop iterates too many times; the value of the loop index, i, reaches 4 and is therefore
out of bounds. Instead, the upper bound should use the < boolean operator, or an equivalent statement.

    public class Test {
        public static void main(String[] args) {
            int[] arr = {1, 2, 3};
            for (int i = 0; i < arr.length; i++) {
                System.out.println(arr[i]);
            }
        }
    }

When dealing with an ArrayIndexOutOfBoundsException, it is usually helpful to print out the value of the index variable that is
accessing the array and try to trace through to code to find out why it is reaching that (invalid) value.

10.  java.lang.StringIndexOutOfBoundsException: String index out of range: v 

A StringIndexOutOfBoundsException is thrown when an attempt is made to access an index in the String that is not valid. The
only valid indices for a String str are in the range [0, str.length() ­ 1]; any attempt to access an index outside of this range will
result in this error. For example:
    public class Test {
        public static void main(String[] args) {
            String str = "Hello, world!";

            String a = str.substring(­1, 3);
            String b = str.charAt(str.length());
            String c = str.substring(0, 20);
        }
    }
 
    
    java.lang.StringIndexOutOfBoundsException: String index out of range: ­1
        at java.lang.String.substring(Unknown Source)
        at Test.main(Test.java:5)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at edu.rice.cs.drjava.model.compiler.JavacCompiler.runCommand(JavacCompiler.java:271)
 

The error message for this kind of error becomes less relevant towards the end. However, the first line lets you know that a problem with
a String index was encountered, and the index in error was ­1. The next line tells you that it encountered this error while trying to
perform the substring routine, which was called from the Test class on line 5. This "backtrace" of the error tells you the line numbers
of the method calls involved so that you can trace your error to the source and correct it.

Note that all of a, b, and c would have thrown this error, but the program was halted after the first occurred.

This is not a compile­time error, but rather a runtime error. In other words, the compiler will accept this kind of error because it is a logical
error. Additionally, it may not be known before the program is run that the error will occur. To fix this error, you often have to correct the
logic of your program to ensure that the program will not try to access an invalid index.

11.  method <X> in class <Y> cannot be applied to given types 

This method occurs when you try to call a method using the wrong number or wrong order of parameters. For example, consider the
following program:
    public class Test {     
        public static void main(String[] args) {
            myMethod(1.0, 2, "Hello!");
        }
    
        public static void myMethod(double d, String s, int x) {
            System.out.println(s + " " + d + " " + x);
        }
    }
    
 
    1 error found:
    File: Test.java  [line: 3]
    Error: method myMethod in class Test cannot be applied to given types;
      required: double,java.lang.String,int
      found: double,int,java.lang.String
      reason: actual argument int cannot be converted to java.lang.String by method invocation conversion
 

The error message for this error is very helpful. The line that says "required" tells you about what the method is expecting. It lists the order
of the arguments that are required. In the example above, the parameters for myMethod should be a double, then a String, and then
an int.

The next line of the error message (which says "found") tells you what you (incorrectly) tried to use to call the method. In this example, we
invoked the method using a double, then an int, and then a String­­ which is the wrong order!

We can fix this by ensuring that the number and ordering of the method parameters is correct:

    public class Test {     
        public static void main(String[] args) {
            myMethod(1.0, "Hello!", 2);
        }
    
        public static void myMethod(double d, String s, int x) {
            System.out.println(s + " " + d + " " + x);
        }
    }
12.  missing return statement 

This method happens when you declare that a method will return a value, but then fail to actually return the value. For example:

    public class Test {
        public static void main(String[] args) {
            int x = twice(5);
            System.out.println(x);
        }
    
        public static int twice(int x) {
            int value = 2 * x;
        }
    }
 
     
    1 error found:
    File: Test.java  [line: 9]
    Error: Test.java:9: missing return statement
 

We have informed the compiler that the twice method will return an int, but we are missing the return statement:

    public class Test {
        public static void main(String[] args) {
            int x = twice(5);
            System.out.println(x);
        }
    
        public static int twice(int x) {
            int value = 2 * x;
            return value;
        }
    }

Returning values in if statements can also trick the compiler into thinking that it's possible no value will be returned, as in the following
example:

    public class Test {
        public static void main(String[] args) {
            int x = absVal(­5);
            System.out.println(x);
        }
    
        public static int absVal(int x) {
            if (x < 0) {
                return ­x;
            }
     
            if (x >= 0) {
                return x;
            }
        }
    }
 
     
    1 error found:
    File: Test.java  [line: 15]
    Error: Test.java:15: missing return statement
 

To avoid this, we can either use an else statement (as we did in the Variable might not have been initialized example), or we can simply
not use the second if statement because we know that if we've reached that point in the method we can just return x:

    public class Test {
        public static void main(String[] args) {
            int x = absVal(­5);
            System.out.println(x);
        }
    
        public static int absVal(int x) {
            if (x < 0) {
                return ­x;
            }
     
            return x;
        }
    }

13.  possible loss of precision 

A "possible loss of precision" error occurs when you attempt to store more information in a variable than it can hold. The most common
example of this error is trying to assign a double to an int:

    public class Test {
        public static void main(String[] args) {
            int pi = 3.14159;
            System.out.println("The value of pi is: " + pi);
        }
    }
 
    
    1 error found:
    File: Test.java  [line: 3]
    Error: Test.java:3: possible loss of precision
    found   : double
    required: int
 

This error happens because the amount of space that a computer needs to store a double is typically twice as much as the space
needed to store an int. You're allowed to do this by acknowledging to the compiler that you know that you're going to lose precision if
you do the assignment. To acknowledge this, you can use a typecast:
    public class Test {
        public static void main(String[] args) {
            int pi = (int)3.14159;
            System.out.println("The value of pi is: " + pi);
        }
    }

Now the compiler does not complain, but the pi variable only contains the value 3 due to integer rounding.

14.  reached end of file while parsing 

This error typically happens when you are not adequately closing your program using curly braces. The error message is essentially
saying that the compiler has reached the end of the file without any acknowledgement that the file has ended. For example:
    public class Test {
        public static void main(String[] args) {
            my_method();
        }
    
        public static void my_method() {
            System.out.println("Hello, world!");
        }

 
    1 error found:
    File: Test.java  [line: 9]
    Error: Test.java:9: reached end of file while parsing
 

To fix this, all you have to do is correct your ending curly braces ('}'). Sometimes all you need is a curly brace at the end of your file;
other times you may have missed a curly brace or added an extra curly brace in the middle of your code.

One way to diagnose where the problem is occuring is to use the CTRL­A + TAB shortcut to attempt to properly indent your code. Since
we have a curly brace problem, however, the code will not be properly indented. Search for the place in the file where the indentation first
becomes incorrect. This is where your error is happening!

Once the curly braces in the program match up appropriately, the compiler will not complain:

    public class Test {
        public static void main(String[] args) {
            my_method();
        }
    
        public static void my_method() {
            System.out.println("Hello, world!");
        }
    }

15.  unreachable statement 

An "unreachable statement" error occurs when the compiler detects that it is impossible to reach a given statement during the flow of a
program. This error is often caused by placing statements after return or break. For example:

    public class Test {
        public static void main(String[] args) {
            int value = twice(5);
            System.out.println(value);
        }
    
        public static int twice(int x) {
            int twice = 2 * x;
            return twice;
            System.out.println("Returning " + twice);
        }
    }
 
    2 errors found:
    File: Test.java  [line: 10]
    Error: Test.java:10: unreachable statement
    File: Test.java  [line: 11]
    Error: Test.java:11: missing return statement
 

The compiler gives two errors: one to indicate that the line System.out.println("Returning " + twice); is an unreachable
statement, and another because it assumes that if we can get to that print statement, then we would need a return statement
somewhere after it.

We can fix this by placing the print statement before the return so it can be executed:

    public class Test {
        public static void main(String[] args) {
            int value = twice(5);
            System.out.println(value);
        }
    
        public static int twice(int x) {
            int twice = 2 * x;
            System.out.println("Returning " + twice);
            return twice;
        }
    }

16.  variable might not have been initialized 

This error occurs when the compiler believes you're trying to use a variable that has not been "initialized"­­ or given an initial value­­ yet.
In a very simple case:

    public class Test {
        public static void main(String[] args) {
            int x = 2;
            int y;
            System.out.println(x + y);
        }
    } 

    
    1 error found:
    File: Test.java  [line: 5]
    Error: Test.java:5: variable y might not have been initialized
 

Here, you have not told the compiler what the value of y is. Therefore, y cannot be printed; it needs to be initialized as x is in this
example.

In more complicated scenarios, if statements can cause this error if you are not careful about ensuring that a variable is initialized. For
example:

    public class Test {
        public static void main(String[] args) {
            int x;
            boolean setX = false;
     
            if (setX) {
                x = 10;
            }
     
            System.out.println(x);
        }
    }

    
    1 error found:
    File: Test.java  [line: 8] 
    Error: Test.java:8: variable x might not have been initialized
 

Here again it is clear that the variable x will not be initialized, and therefore an error occurs. However, cases can also arise where it is
clear to us that one of the cases has to be reached and therefore the error should not happen. However, the compiler is not always smart
enough to see cases that we as humans can see. For example:

    public class Test {
        public static void main(String[] args) {
            int x;
            boolean setToTen = false;
         
            if (setToTen) {
                x = 10;
            }
        
            if (!setToTen) {
                x = 0;
            }
        
            System.out.println(x);
        }
    }

    
    1 error found:
    File: Test.java  [line: 14]
    Error: Test.java:14: variable x might not have been initialized
 

It may appear obvious that x will get set to a value one way or another, but the compiler cannot see this. One way to fix this error is to use
an else statement. When using an else statement, the compiler is smart enough to see that in at least one case x will be initialized:

    public class Test {
        public static void main(String[] args) {
            int x;
            boolean setToTen = false;
        
            if (setToTen) {
                x = 10;
            } else {
                x = 0;
            }
        
            System.out.println(x);
        }
    }

Original document created by Cody Doucette '14.
Top Ten Errors Java Programmers Make
(How to spot them. How to fix/prevent them.)

By David Reilly

Whether you program regularly in Java, and know it like the back of your hand, or
whether you're new to the language or a casual programmer, you'll make mistakes. It's
natural, it's human, and guess what? You'll more than likely make the same mistakes that
others do, over and over again. Here's my top ten list of errors that we all seem to make at
one time or another,  how to spot them, and how to fix them.

10. Accessing non­static member variables from static methods (such as
main)

Many programmers, particularly when first introduced to Java, have problems with
accessing member variables from their main method. The method signature for main is
marked static ­ meaning that we don't need to create an instance of the class to invoke the
main method. For example, a Java Virtual Machine (JVM) could call the class
MyApplication like this :­

MyApplication.main ( command_line_args );

This means, however, that there isn't an instance of MyApplication ­ it doesn't have any
member variables to access! Take for example the following application, which will
generate a compiler error message.
public class StaticDemo
{
        public String my_member_variable = "somedata";

        public static void main (String args[])
        {
    // Access a non­static member from static method
                System.out.println ("This generates a compiler error" +
      my_member_variable );
        }
}

If you want to access its member variables from a non­static method (like main), you
must create an instance of the object. Here's a simple example of how to correctly write
code to access non­static member variables, by first creating an instance of the object.
public class NonStaticDemo
{
        public String my_member_variable = "somedata";

        public static void main (String args[])
        {
                NonStaticDemo demo = new NonStaticDemo();

    // Access member variable of demo
                System.out.println ("This WON'T generate an error" +
                        demo.my_member_variable );
        }
}
9. Mistyping the name of a method when overriding

Overriding allows programmers to replace a method's implementation with new code.
Overriding is a handy feature, and most OO programmers make heavy use of it. If you
use the AWT 1.1 event handling model, you'll often override listener implementations to
provide custom functionality. One easy trap to fall into with overriding, is to mistype the
method name. If you mistype the name, you're no longer overriding a method ­ you're
creating an entirely new method, but with the same parameter and return type.
public class MyWindowListener extends WindowAdapter {
  // This should be WindowClosed
  public void WindowClose(WindowEvent e) {
    // Exit when user closes window
    System.exit(0);
  }
});

Compilers won't pick up on this one, and the problem can be quite frustrating to detect.
In the past, I've looked at a method, believed that it was being called, and taken ages to
spot the problem. The symptom of this error will be that your code isn't being called, or
you think the method has skipped over its code. The only way to ever be certain is to add
a println statement, to record a message in a log file, or to use good trace debugger (like
Visual J++ or Borland JBuilder) and step through line by line. If your method still isn't
being called, then it's likely you've mistyped the name.

8. Comparison assignment (  = rather than == )

This is an easy error to make. If you're used other languages before, such as Pascal, you'll
realize just how poor a choice this was by the language's designers. In Pascal, for
example, we use the := operator for assignment, and leave = for comparison. This looks
like a throwback to C/C++, from which Java draws its roots.

Fortunately, even if you don't spot this one by looking at code on the screen, your
compiler will. Most commonly, it will report an error message like this : "Can't convert
xxx to boolean", where xxx is a Java type that you're assigning instead of comparing.

7. Comparing two objects ( == instead of .equals)

When we use the == operator, we are actually comparing two object references, to see if
they point to the same object. We cannot compare, for example, two strings for equality,
using the == operator. We must instead use the .equals method, which is a method
inherited by all classes from java.lang.Object.

Here's the correct way to compare two strings.
String abc = "abc"; String def = "def";

// Bad way
if ( (abc + def) == "abcdef" )
{
    ......
}

// Good way
if ( (abc + def).equals("abcdef") )
{
   .....
}

6. Confusion over passing by value, and passing by reference
This can be a frustrating problem to diagnose, because when you look at the code, you
might be sure that its passing by reference, but find that its actually being passed by
value. Java uses both, so you need to understand when you're passing by value, and
when you're passing by reference.

When you pass a primitive data type, such as a char, int, float, or double, to a function
then you are passing by value. That means that a copy of the data type is duplicated, and
passed to the function. If the function chooses to modify that value, it will be modifying
the copy only. Once the function finishes, and control is returned to the returning
function, the "real" variable will be untouched, and no changes will have been saved. If
you need to modify a primitive data type, make it a return value for a function, or wrap it
inside an object.

When you pass a Java object, such as an array, a vector, or a string, to a function then
you are passing by reference. Yes ­ a String is actually an object, not a primitive data
type.  So that means that if you pass an object to a function, you are passing a reference
to it, not a duplicate. Any changes you make to the object's member variables will be
permanent ­ which can be either good or bad, depending on whether this was what you
intended.

On a side note, since String contains no methods to modify its contents, you might as
well be passing by value.

5. Writing blank exception handlers

I know it's very tempting to write blank exception handlers, and to just ignore errors. But
if you run into problems, and haven't written any error messages, it becomes almost
impossible to find out the cause of the error. Even the simplest exception handler can be
of benefit. For example, put a try { .. } catch Exception around your code, to catch ANY
type of exception, and print out the message. You don't need to write a custom handler
for every exception (though this is still good programming practice). Don't ever leave it
blank, or you won't know what's happening.

For example
public static void main(String args[])
{
    try {
  // Your code goes here..
    }
    catch (Exception e)
    {
  System.out.println ("Err ­ " + e );
    }
}

4. Forgetting that Java is zero­indexed
If you've come from a C/C++ background, you may not find this quite as much a
problem as those who have used other languages. In Java, arrays are zero­indexed,
meaning that the first element's index is actually 0. Confused? Let's look at a quick
example.
// Create an array of three strings
String[] strArray = new String[3];

// First element's index is actually 0
strArray[0] = "First string";

// Second element's index is actually 1
strArray[1] = "Second string";

// Final element's index is actually 2
strArray[2] = "Third and final string";

In this example, we have an array of three strings, but to access elements of the array we
actually subtract one. Now, if we were to try and access strArray[3], we'd be accessing
the fourth element. This will case an ArrayOutOfBoundsException to be thrown ­ the
most obvious sign of forgetting the zero­indexing rule.

Other areas where zero­indexing can get you into trouble is with strings. Suppose you
wanted to get a character at a particular offset within a string. Using the
String.charAt(int) function you can look this information up ­ but under Java, the String
class is also zero­indexed. That means than the first character is at offset 0, and second at
offset 1. You can run into some very frustrating problems unless you are aware of this ­
particularly if you write applications with heavy string processing. You can be working
on the wrong character, and also throw exceptions at run­time. Just like the
ArrayOutOfBoundsException, there is a string equivalent. Accessing beyond the bounds
of a String will cause a StringIndexOutOfBoundsException to be thrown, as
demonstrated by this example.
public class StrDemo
{
 public static void main (String args[])
 {
        String abc = "abc";

        System.out.println ("Char at offset 0 : " + abc.charAt(0) );
        System.out.println ("Char at offset 1 : " + abc.charAt(1) );
        System.out.println ("Char at offset 2 : " + abc.charAt(2) );

  // This line should throw a StringIndexOutOfBoundsException
        System.out.println ("Char at offset 3 : " + abc.charAt(3) );
 }
}

Note too, that zero­indexing doesn't just apply to arrays, or to Strings. Other parts of Java
are also indexed, but not always consistently. The java.util.Date, and java.util.Calendar
classes start their months with 0, but days start normally with 1. This problem is
demonstrated by the following application.
import java.util.Date;
import java.util.Calendar;

public class ZeroIndexedDate
{
        public static void main (String args[])
        {
                // Get today's date
                Date today = new Date();
 
    // Print return value of getMonth
    System.out.println ("Date.getMonth() returns : " +
       today.getMonth());

    // Get today's date using a Calendar
    Calendar rightNow = Calendar.getInstance();

    // Print return value of get ( Calendar.MONTH )
    System.out.println ("Calendar.get (month) returns : " +
      rightNow.get ( Calendar.MONTH ));

        }
}

Zero­indexing is only a problem if you don't realize that its occurring. If you think you're
running into a problem, always consult your API documentation.

3. Preventing concurrent access to shared variables by threads
When writing multi­threaded applications, many programmers (myself included) often
cut corners, and leave their applications and applets vulnerable to thread conflicts. When
two or more threads access the same data concurrently, there exists the possibility (and
Murphy's law holding, the probability) that two threads will access or modify the same
data at the same time. Don't be fooled into thinking that such problems won't occur on
single­threaded processors. While accessing some data (performing a read), your thread
may be suspended, and another thread scheduled. It writes its data, which is then
overwritten when the first thread makes its changes.

Such problems are not just limited to multi­threaded applications or applets. If you write
Java APIs, or JavaBeans, then your code may not be thread­safe. Even if you never write
a single application that uses threads, people that use your code WILL. For the sanity of
others, if not yourself, you should always take precautions to prevent concurrent access
to shared data.

How can this problem be solved? The simplest method is to make your variables private
(but you do that already,  right?) and to use synchronized accessor methods. Accessor
methods allow access to private member variables, but in a controlled manner. Take the
following accessor methods, which provide a safe way to change the value of a counter.
public class MyCounter
{
  private int count = 0; // count starts at zero

  public synchronized void setCount(int amount)
  { 
    count = amount;
  }
 
  public synchronized int getCount()
  {
    return count;
  }
}

2. Capitalization errors

This is one of the most frequent errors that we all make. It's so simple to do, and
sometimes one can look at an uncapitalized variable or method and still not spot the
problem. I myself have often been puzzled by these errors, because I recognize that the
method or variable does exist, but don't spot the lack of capitalization.

While there's no silver bullet for detecting this error, you can easily train yourself to
make less of them. There's a very simple trick you can learn :­

all methods and member variables in the Java API begin with lowercase letters
all methods and member variables use capitalization where a new word begins e.g ­
getDoubleValue()

If you use this pattern for all of your member variables and classes, and then make a
conscious effort to get it right, you can gradually reduce the number of mistakes you'll
make. It may take a while, but it can save some serious head scratching in the future.

(drum roll)
And the number one error that Java programmers
make !!!!!
 

1. Null pointers!
Null pointers are one of the most common errors that Java programmers make. Compilers
can't check this one for you ­ it will only surface at runtime, and if you don't discover it,
your users certainly will.

When an attempt to access an object is made, and the reference to that object is null, a
NullPointerException will be thrown. The cause of null pointers can be varied, but
generally it means that either you haven't initialized an object, or you haven't checked the
return value of a function.

Many functions return null to indicate an error condition ­ but unless you check your
return values, you'll never know what's happening. Since the cause is an error condition,
normal testing may not pick it up ­ which means that your users will end up discovering
the problem for you. If the API function indicates that null may be returned, be sure to
check this before using the object reference!

Another cause is where your initialization has been sloppy, or where it is conditional. For
example, examine the following code, and see if you can spot the problem.
public static void main(String args[])
{
  // Accept up to 3 parameters
  String[] list = new String[3];

  int index = 0;

  while ( (index < args.length) && ( index < 3 ) )
  {
    list[index++] = args[index];
  }

  // Check all the parameters 
  for (int i = 0; i < list.length; i++)
  {
    if (list[i].equals "­help")
    {
      // .........
    }
    else
    if (list[i].equals "­cp")
    {
      // .........
    }
    // else .....
  } 
}

This code (while a contrived example), shows a common mistake. Under some
circumstances, where the user enters three or more parameters, the code will run fine. If
no parameters are entered, you'll get a NullPointerException at runtime. Sometimes your
variables (the array of strings) will be initialized, and other times they won't. One easy
solution is to check BEFORE you attempt to access a variable in an array that it is not
equal to null.

Summary
These errors represent but some of the many that we all make. Though it is impossible to
completely eliminate errors from the coding process, with care and practice you can
avoid repeating the same ones. Rest assured, however, that all Java programmers
encounter the same sorts of problems. It's comforting to know, that while you work late
into the night tracking down an error, someone, somewhere, sometime, will make the
same mistake!

We'd like to thank the readers of the comp.lang.java.programmer
newsgroup for their suggestions for the top ten. Regrettably, due to the
number of submissions, not every error could be featured ­ but we
think this "Top Ten" list represents the most popular and frequent
errors people make.

Back to main
Capitalisation of key words
Since you get into the habit of writing class names in capital letters you will occasionally find yourself
writing keywords such as class andint with a capital beginning letter. The compiler will object to
this and will issue an error message which depends on which keyword was capitalised. The compiler
will issue an error message such as:
Line nn: class or interface declaration expected

when, for example, you capitalise the keyword class.

Writing a string over a new line

Sometimes you will need to write a long string. A common error is to have a new line embedded in
the string. The compiler will object to this and will issue an error message such as:
Line nn: ';' expected

When this happens the solution is to split the string into two, making sure that neither string has a new
line in it, and concatenate them with +. Thus you might replace:
String s = "A very long string which just happens to go over the end of a 
line and causes a problem with the compiler";

with:
String s = "A very long string which just happens to go over the end "+
"of a line and causes a problem with the compiler"

Missing brackets in a no­argument message
When you use a method which has no arguments you should place brackets after the name of the
method. For example, if you have declared a method carryOut with no arguments and you want to
send a message corresponding to the method to the object objSend then you should code this as:
objSend.carryOut()

rather than:
objSend.carryOut 

The compiler will usually emit an error message of the form:
Line nn: Invalid expression statement
Forgetting to import a package

This one of the most common errors that inexperienced Java programmers make. If you forget to put
the required import statement at the beginning of a program, then the compiler will respond with a
message such as:
Line nn: Class xxxx not found in type declaration

Don't forget, though, that java.lang is imported automatically and, hence, does not need an import
statement.

Treating a static method as if it were an instance method

Static methods are associated with messages sent to classes rather than objects. A common error is to
send static method messages to objects. For example, in order to calculate the absolute value of an int
value and place it into the int variable you should write:
int result = Math.abs(value);

rather than:
int result = value.abs();

This gives rise to a variety of syntax errors. The most common one is of the form:
Line nn: Method yyyy not found in class xxxx.

where yyyy is the name of the method and xxxx is the name of the class within which it is called.

Case­sensitive errors with classes

This is another category of error which is very common. Java is case sensitive so, for example, it will
not recognise string as a valid type in the language as you should have written String. It will
generate an error message of the form:
Line nn: Class xxxx not found in type declaration.

where xxxx is the name of the class which has not been given the correct capitalisation.

Case­sensitive errors with variables

It is also quite easy to miss the fact that variables are case sensitive. For example, you may have
declared the variable linkEdit as an int and then tried to refer to linkEdit within a class. This gives
rise to error messages of the form
Line nn: Undefined variable: xxxx

where xxxx is the name of the variable which has been mistyped.

Missing } brackets
This is a common programming error in any programming language and can be eradicated by means
of a proper indentation scheme.

Missing class brackets
A common bracketing error that you will often make is to omit the final } bracket that delimits the end
of a class.

Writing the wrong format for a class method
Class methods have the form:
ClassName.MethodName(Argument(s))

A common error is to forget the class name. If you do, then you will get an error message of the form:
Line nn: '}' expected

Specifying method arguments wrongly

When you define classes you should prefix each argument with the name of a scalar type or the name
of an existing class. For example:
public void tryIt(int a, int b, URL c)

A common error that programmers from other languages make is to forget to prefix every argument
with its type. For example, an erroneous version of the definition above would be:
public void tryIt(int a, b URL c)

This type of error will give rise to error messages of the form:
Line nn: Identifier expected

Forgetting the fact you should send messages to objects
This is a common error committed by programmers who have only recently changed to object­
oriented programming. As an example of this consider the method tryIt, which has two int
arguments and which delivers an int value. Assume that this method is involved in sending a
message to an object destination. This should be written as:
int newVal = destination. tryIt(arg1, arg2)

where the arguments are ints which have been declared somewhere. A common mistake is to write
this as:
int newVal = tryIt(destination, arg1,arg2)

This gives rise to error messages of the form:
Line nn: ')' expected

Assuming that == stands for value equality

== is used with scalars as a means of comparing values. However, when it is applied to objects then it
compares addresses. For example, the if statement:
if(newObj1 == newObj2){
...
}
will execute the code denoted by the three dots only if the first object occupies the same address as the
second object. If the objects occupied different addresses, but still had the same values for their
instance variables, then it would evaluate to false. Unfortunately this does not give rise to any syntax
errors, but will show up when any program containing the error is executed.

Omitting void in methods
When a method returns no result, but just carries out some action, you need to use the keyword void
in front of the name of the method. If you do not use this keyword, then it will give rise to error
messages of the form:
Line nn: Invalid method declaration; return type required

Omitting break from case statements

This is an error which is committed in both object­oriented and procedural languages. If you want the
branch of a case statement to just finish and exit to the end of the case statement, then don't forget to
include the break statement as the last statement in the branch. If you do not do this, then execution
will continue with the next branch underneath the one in which the break statement was omitted.

Omitting the return in a method
When a method returns a value, then the body of the method should include at least one return
statement which returns the right type of value. Failing to do this will generate an error message of the
form:
Line nn: Return required at end of xxxx

where xxxx is the method which does not contain the return.

Making an instance variable private and then referring to it by name in another
class

When you tag an instance variable as private you are not allowed to access it by name outside its
class. The only way that you can access such instance variables is through methods which are
declared in the class in which the instance variables are defined. This gives rise to error messages of
the form:
Line nn: Variable xx in class xxxx not accessible from class yyyy

where xx is the private variable, xxxx is the class in which it is defined and class yyyy is the class in
which it is referred to.

Using a variable before it is given a value

Again this is a common error found in both object­oriented and procedural languages. In Java, scalars
are intialised to zero or some default value so there will be no error indication and any problems that
arise will be signaled by erroneous results or some side effect such as an array going over its bounds.
Objects will be initalised to null and any attempt to reference an uninitialised object will be caught at
run time.

Assuming the wrong type of value is generated by a message
This is a common error to make when using the Java packages. A typical example is using a method
which delivers a string that contains digits and treating it like an integer. For example, the method
getInteger within java.lang.Integer delivers an Integer and any attempt to use that value as, say,
an int will give rise to an error message of the form:
Line nn: Incompatible type for declaration can't convert xxxx to yyyy

Confusing prefix operators with postfix operators
This is an error that comes with any C­like language. Postfix operators such as ++ and ­­ deliver the
old value of the variable to which they are applied, while prefix operators deliver the new value. Thus,
if x is 45 and the statement:
y = ++x 

is executed, then y and x both become 46. If the statement
y = x++

is executed, then y becomes 45, while x becomes 46. These errors will not be signalled at compile
time, but will emerge during run time.

Forgetting that arguments are passed by reference to methods if they are objects

When an object is used as an argument to a method, then its address is passed over and not a value.
This means that you can assign values to such arguments. If you treat them as values this will not
strictly be an error, but will not be making use of the full facilities of an object­oriented programming
language.

Forgetting that scalars are passed by value to methods
You cannot treat an argument which is a scalar as if it can be assigned to. This will not be signalled as
a syntax error. However, it will show up as a run­time error when you write code which assumes that
the scalar has been given a value by a method.

Misusing size when applied to strings and arrays

size is an instance variable associated with arrays and a method when associated with strings. If you
mix them up by, for example writing:
arrayVariable.size()  

or
stringVariable.size

then the first would generate an error message of the form:
Line nn: Method size() not found in class java.lang.Object 

and the second would generate an error message of the form:
Line nn: No variable size defined in java.lang.String

Using a constructor which does not exist
You may use a constructor which has not been defined. For example, you may have a class X which
has a one int constructor, a two int constructor and a threeint constructor and yet you may have
used a four int constructor. This would be picked up at compile time and an error of the form:
Line nn: No constructor matching xxxx found in class yyyy

would be generated, where xxxx is the signature of the constructor that you have tried using and yyyy
is the name of the class which it should have been defined in.

Calling a constructor in a constructor with the same name
For example, you may have defined a class X with a two int constructor and a one int constructor
and inside the two int constructor there is a reference to X(argument). This will be flagged as an
error and will generate an error message of the form:
Line nn: Method xxxx not found in yyyy

where xxxx is the name of the constructor and its arguments and yyyy is the name of the class which it
is defined in. The solution is to use the this keyword.

Assuming that two­dimensional arrays are directly implemented in Java

This gives rise to erroneous code such as:
int [,] arrayVariable = new [10,20] int

This is illegal and will give rise to an errors of the form:
Line nn: Missing term

and:
Line nn: ']' expected

You can implement many­dimensional arrays in Java, but they are treated like single­dimension
arrays which contain single­dimensional arrays which contain single dimension arrays, etc.

Treating a scalar like an object
Scalars such as int and float are not objects. However, sometimes you want to treat them as such,
for example when you want to deposit them in a Vector, as in the code:
Vector vec = new Vector();
vec.addElement(12);

If you write code such as that shown above then it will give rise to syntax errors of the form:
Line nn: No method matching xxxx found in yyyy

where xxxx is the name of the method which is used and yyyy is the name of the class which expects
an Object. The solution is to use the object wrapper classes found in java.lang to convert them to
objects.

Confusing scalars and their corresponding object types

When you have scalars such as int it is easy to write code which assumes that they can be treated as
if they were objects. For example, the code:
int y = 22;
Integer x = y; 

will give rise to an error message of the form:
Line nn: Incompatible type for declaration. Can't convert xxxx to yyyy

where xxxx and yyyy are the classes involved.

Mistyping the header for the main method
When you want to execute a Java application you need to declare a method which starts with:
public static void main (String []args){

If you mistype any part of this line or miss out a keyword, then a run­time error will be generated. For
example, if you miss out the keyword static then an error message of the form:
Exception in thread main.....

will be generated at run time.
yet another insignificant programming notes... | HOME

TABLE OF CONTENTS ﴾HIDE﴿


1. JDK Common Errors

Common Error Messages


1.1 JDK Installation Errors
1.2 Java Native Library ﴾JNI﴿ Errors
2. MySQL Installation Common Errors

JDK, MySQL, Tomcat, JDBC, 2.1 Starting the MySQL Server after Installation
2.2 Starting the "mysql" Client

Servlet ... 2.3 Using the "mysql" Client


3. Tomcat Installation Common Errors
3.1 Starting Tomcat after Installation
3.2 Accessing Tomcat Server
4. JDBC Programming Common Errors
Murphy's Law states that:
4.1 JDBC on MySQL
"Anything that can possibly go wrong, does." 4.2 JDBC on MS Access
"Everything that can possibly go wrong will go wrong." 5. Java Servlet Common Errors
"If anything can go wrong, it will." 6. NetBeans Common Errors
"If there is any way to do it wrong, he will." 7. C++ with GCC Compiler

When software goes wrong, the MOST IMPORTANT thing to do is to FIND the ERROR
MESSAGE, which can give you clues of what went wrong. If things were running fine until the
lightning strikes, ask yourself what have you CHANGED!

Search this document with your Error Message; or simple google your error message.

Stack Trace
Most of the times, the error message consists of tens of lines of so‐called stack trace of method invocation. That is, method A called
method B, which called method C, and so on, until method Z encountered an error and threw an Exception or an Error. It is important
to:
1. Get to the first line of the error message to read the description, and
2. Look for the line number of YOUR PROGEAM that triggered the error.

For example, this error message ﴾stack trace﴿ has 40 over lines:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure  <== First line with error description
The last packet sent successfully to the server was 0 milliseconds ago.
The driver has not received any packets from the server.
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
        at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
        at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:344)
        at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2333)
        at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2370)
        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2154)
        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792)
        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
        at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
        at java.sql.DriverManager.getConnection(DriverManager.java:579)
        at java.sql.DriverManager.getConnection(DriverManager.java:221)
        at MySQLJdbcTestJDK7.main(MySQLJdbcTestJDK7.java:7)         <== Your program's line number here (line 7)
Caused by: java.net.ConnectException: Connection refused: connect   <== First line of another related error
        at java.net.DualStackPlainSocketImpl.connect0(Native Method)
        at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:337)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:198)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
        at java.net.Socket.connect(Socket.java:579)
        at java.net.Socket.connect(Socket.java:528)
        at java.net.Socket.<init>(Socket.java:425)
        at java.net.Socket.<init>(Socket.java:241)
        at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:257)
        at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:294)
        ... 15 more

1. JDK Common Errors

1.1 JDK Installation Errors

SYMPTOM: Cannot compile Java program from the CMD shell (e.g., "javac Hello.java" does not work!)
ERROR MESSAGE: 'javac' is not recognized as an internal or external command, operable program or batch file.
PROBABLE CAUSES: The PATH environment variable, which maintains a list of search paths for executable
   programs (including "javac.exe"), does not include JDK's bin directory.
POSSIBLE SOLUTIONS:
   1) Start a CMD shell (click "Start" button ⇒ "run..." ⇒ enter "cmd") and issue a path command:
         prompt> path
         PATH=.......
   2) Check if it includes your JDK's "bin" directory. For example, suppose that your JDK is installed 
      in "c:\program files\java\jdk1.7.0", then PATH should include "c:\program files\java\jdk1.7.0\bin".

      Otherwise, include JDK's bin directory in the PATH environment variable.
      Read "Step 3 of How to install JDK".

SYMPTOM: Can compile but cannot run Java program from the CMD shell (e.g., "java Hello" does not work!)
ERROR MESSAGE (JDK 1.7): Error: Could not find or load main class Hello
ERROR MESSAGE (Pre JDK 1.7): Exception in thread "main" java.lang.NoClassDefFoundError: Hello
PROBABLE CAUSES:
   1) The Java class (in this example, Hello.class) is NOT in the current directory.
   2) The CLASSPATH environment variable is set, but does not include the current directory ".".
POSSIBLE SOLUTIONS:
   1) Issue a "dir" command to list the contents of the current directory. 
      Check that it contains the Java class to be run (e.g., Hello.class). 
      You need to compile the source program (".java") to get the class file (".class").
   2) If the Java class is present in the current directory, issue a "set classpath" command
      to check its settings:
            prompt> set classpath
            CLASSPATH=.......
      If you receive the message "Environment variable CLASSPATH not defined" and 
        your program is correct, I can't help you here.
      Otherwise, if the CLASSPATH is defined, for beginner, I suggest that you remove
        the CLASSPATH environment variable. 
        From "Control Panel"
        ⇒ System
        ⇒ (Vista only) Advanced system settings 
        ⇒ Switch to "Advanced" tab 
        ⇒ Environment Variables 
        ⇒ System variables (and also User variables) 
        ⇒ Select variable "CLASSPATH" 
        ⇒ Delete (Delete from both the System variables and User variables)
   3) (For Advanced Users Only) If CLASSPATH is not set, it is defaulted to the current directory.
      However, if CLASSPATH is set, the current  directory is NOT implicitly included.
      You can include the current  directory (denoted by a single dot ".") in front of the 
      existing class‐paths. 
      Read "Java Applications and Environment Variable" for more discussion on CLASSPATH.

SYMPTOM: Can compile but cannot run the Hello‐world program (e.g., "java Hello" does not work!)
ERROR MESSAGE (JDK 1.7): Error: Main method not found in class Hello.
POSSIBLE SOLUTIONS: Check whether there is a main() method in your program, and the signature of your main()
  as shown in the error message.

SYMPTOM: Cannot compile Java program
ERROR MESSAGE (JDK 1.7): Could not find or load main class com.sun.tools.javac.Main
POSSIBLE SOLUTIONS:
  You did not install JDK and JRE correctly.
  If you are a novice, re‐install JDK (Read "How to install JDK" again)
    1. Un‐install JDK and JRE (via control panel ⇒ "Program and Features"...)
    2. Download the JDK (with JRE) and re‐install. Use the default directories for JDK and JRE.
       That is, simply click Simply click "next"..."next"... 
       to install JDK in "C:\Program Files\java\jdk1.7.0_0x" and
       JRE in "C:\Program Files\java\jre7".
       DO NOT change the installed directories!
    3. Update the PATH environment variable.

SYMPTOM: Cannot run the downloaded JDK Installer. Double‐click the installer but nothing happens!
POSSIBLE SOLUTIONS:
  There seems to be a bug in JDK 1.7 u2 onwards, that affects only some computers.
  Download and install JDK 1.7 u1 or below.

1.2 Java Native Library ﴾JNI﴿ Errors


ERROR MESSAGE: SEVERE: java.lang.UnsatisfiedLinkError: no xxx in java.library.path
PROBABLE CAUSES: Your program uses a native library from a 3rd‐party API (such as JOGL), 
   which cannot be located in the native library search paths.
POSSIBLE SOLUTION:
A Java Native Library (JNI) contains non‐Java library codes (in filetype of ".dll" in Windows, ".so" in Linux, 
   ".jnilib" in MacOS). For example, JOGL's "jogl_xxx.dll", "gluegen‐rt.dll".
   These dll's are needed for proper operations.
The directory path of native libraries must be included in Java system's property "java.library.path".
The "java.library.path" usually mirrors the Envrionment Variable PATH. You can list the entries by issuing:
   System.out.println(System.getProperty("java.library.path"));

To include a directory in "java.library.path", you can use VM command‐line option ‐Djava.library.path=pathname
For JRE:
   > java ‐Djava.library.path=d:\bin\jogl2.0\lib myjoglapp
 
For Eclipse, the VM command‐line option can be set in "Run Configuration..." ⇒ "Arguments" ⇒ "VM Arguments".
Alternatively, you can create a User library and specifying the native library (Refer to "Eclipse How‐To")
 
For NetBeans, the VM command‐line option can be set in "Set Configuration" ⇒ "Customize..." ⇒ "Run" ⇒ "VM options".
2. MySQL Installation Common Errors

2.1 Starting the MySQL Server after Installation


First of all, check if you have already started an instance of MySQL Server:
For Windows, start the "Task Manager", select "Processes" and look for "mysqld" processes. "End" all the "mysqld" processes.
For Mac, start the "Activity Monitor", select "All Processes" and look for "mysqld" processes. "Kill" all the "mysqld" processes.
For Ubuntu, start the "System Monitor" and look for "mysqld" processes. "Kill" all the "mysqld" processes.

SYMPTOM: Cannot start MySQL server after installation
ERROR MESSAGE: [ERROR] Can't find message file 'x:\xxxxx\share\english\errmsg.sys'
PROBABLE CAUSES: Error in "basedir" option in the configuration file "my.ini".
POSSIBLE SOLUTIONS:
  1. Take note of your MySQL installed directory, e.g., d:\myproject\mysql.
  2. Goto the MySQL installed directory, and check if "my.ini" (for Windows) or "my.cnf" (for Mac and Ubuntu) exists.
  3. For Windows, if you use NotePad, ensure that you save the configuration file as "my.ini", instead of "my.ini.txt".
     "my.ini.txt" has file type of "Text Document". "my.ini" has file type of "Configuration Settings".
     "Save As..." the file again by enclosing the filename "my.ini" with a pair of double quotes.
  4. Check the "basedir" and "datadir" options in "my.ini". Make sure that that path corresponds to your 
     MySQL installed directory. Use Unix‐style forward slash '/' as the directory separator, instead of 
     Windows‐style back slash '\'.

SYMPTOM: Cannot start MySQL server after installation
ERROR MESSAGE:
  [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
  .........
  [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
PROBABLE CAUSES: Error in "datadir" option in the configuration file "my.ini".
POSSIBLE SOLUTIONS: Check that "datadir" selects the "data" sub‐directory of your MySQL installed directory, 
  e.g., datadir=d:/myproject/mysql/data

SYMPTOM: MySQL Server runs on TCP port 3306 (the MySQL default port number) instead of 8888 that was configured.
PROBABLE CAUSES: MySQL Server was not started with your customized "my.ini".
POSSIBLE SOLUTIONS:
  1. Take note of your MySQL installed directory, e.g., d:\myproject\mysql.
  2. Goto the MySQL installed directory, and check if "my.ini" exists.

SYMPTOM: Cannot start MySQL server.
ERROR MESSAGE:
  InnoDB: Operating system error number 32 in a file operation.
  InnoDB: The error means that another program is using InnoDB's files.
  InnoDB: This might be a backup or antivirus software or another instance of MySQL. 
  InnoDB: Please close it to get rid of this error.
PROBABLE CAUSES: You have already started an instance of MySQL.
POSSIBLE SOLUTIONS: Shutdown the previously‐started MySQL.
  You may use "Task Manager" to cancel the "process" called "mysqld".
  [The proper way is to use "mysqladmin" to do a normal shutdown.]

2.2 Starting the "mysql" Client


SYMPTOM: Cannot start mysql client
ERROR MESSAGE: ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
PROBABLE CAUSES: 
  1. MySQL Server is NOT started, or
  2. The client was connecting to the wrong port number
POSSIBLE SOLUTIONS: 
  1. Check to make sure that the MySQL server has been started. 
     Note down the server's port number from the server's console.
  2. Check "my.ini", make sure that you have a [client] section with port=xxxx.
  3. Run a client with command "mysql ‐u root ‐‐port=xxxx" to specify the server's port number manually.

SYMPTOM: Cannot start mysql client
ERROR MESSAGE: error 2005 (hy000) unknown mysql server host  'localhost' (2)
PROBABLE CAUSES: 
  Somehow your localhost is not bind to 127.0.0.1
POSSIBLE SOLUTIONS:
  1. Try "ping localhost" to check if "localhost" exists.
  2. If not, check "C:\Windows\System32\drivers\etc\hosts" file. There should be an entry:
     127.0.0.1       localhost
     Remove all the other localhost entries, if any.

2.3 Using the "mysql" Client


ERROR MESSAGE: ERROR 1046 (3D000): No database selected
PROBABLE CAUSES: The default database is not set
POSSIBLE SOLUTIONS: 
  1) Issue command "use database" to set the default database, or
  2) Use the fully‐qualified name in the form of "databaseName.tableName".
  
ERROR MESSAGE: ERROR 1005 (HY000): Can't create table '....' (errno: 150)
PROBABLE CAUSES:
A foreign key references a parent table's column which is not indexed. Create index for that column in the parent table.

3. Tomcat Installation Common Errors

3.1 Starting Tomcat after Installation


SYMPTOM: Cannot start Tomcat after installation. The Tomcat console flashed and disappeared.
POSSIBLE SOLUTIONS: 
  1. Run the script "configtest.bat" (for Windows) or "./configtest.sh" (for Mac/Linux) to check
     configuration files ("server.xml", "web.xml", "content.xml").
  2. Check the Tomcat's log files, located at "<TOMCAT_HOME>\logs".
     The "catalina.{yyyy‐mm‐dd}.log" shows the Tomcat's startup messages.
  3. Start the tomcat in the debugging mode by running "catalina debug" (or ./catalina.sh debug) and 
     type "run" in the "jdb" prompt. Look for the error messages.
  4. Check if you have already started a copy of Tomcat.
     For Windows, start Task Manager, Tomcat run as a "process" named "java.exe". Kill it.
     For Mac/Linux, issue "ps ‐ef | grep tomcat" to locate the Tomcat process.
       Note the process ID (pid), and kill the process via "kill ‐9 pid".
  5. Check the JDK Extension directory, remove the out‐dated "servlet‐api.jar", if any.

SYMPTOM: Cannot start Tomcat
ERROR MESSAGE: 
  SEVERE: StandardServer.await: create[localhost:8005]
  java.net.BindException: Address already in use: JVM_Bind
POSSIBLE SOLUTIONS:
  1. Another Tomcat instance has been started. Kill it.
     For Windows, start Task Manager, Tomcat run as a "process" named "java.exe". Kill it.
     For Mac/Linux, issue "ps ‐ef | grep tomcat" to locate the Tomcat process.
        Note the process ID (pid), and kill the process via "kill ‐9 pid".
  2. Another application is running on the Tomcat's port number.
     Change the Tomcat's port number in "server.xml".
     You can issue command "netstat ‐an" to check the status of all the ports.

SYMPTOM: Cannot start Tomcat after installation
ERROR MESSAGE: 
  1. Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
     At least one of these environment variable is needed to run this program
  2. JRE_HOME environment variable is not defined
POSSIBLE SOLUTIONS:
  1. Check if JAVA_HOME is properly defined, via command "set JAVA_HOME" (for Windows)
     or "echo $JAVA_HOME" (for Mac/Linux).
     Check the spelling carefully.
  2. Define environment variable JAVA_HOME according to "Step 2: Create an Environment Variable JAVA_HOME".

SYMPTOM: Cannoat start Tomcat start after installation
ERROR MESSAGE: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getSessionCookieConfig()
    Ljavax/servlet/SessionCookieConfig;
PROBABLE CAUSES: This is a new method in Servlets 3.0 (which Tomcat 7 supports).
    There is a Servlets 2.x API is your CLASSPATH or JDK's extension directory.
POSSIBLE SOLUTIONS: Check your CLASSPATH. Remove servlet‐api.jar from JDK's extension directory if any.
3.2 Accessing Tomcat Server
Common Error Messages:
﴾Firefox﴿ Unable to Connect; ﴾IE﴿ Internet Explorer cannot display the webpage; ﴾Chrome﴿ Oops! Google Chrome could not connect to
xxxx.
Error 404 File Not Found.
Error 500 Internal Server Error.
Error 505: GET ﴾or POST﴿ method not supported: Check you servlet to make sure that you have defined a doGet() ﴾or doPost()﴿
method.

Read "How to debug" section of "How to install Tomcat".

4. JDBC Programming Common Errors

4.1 JDBC on MySQL


SYMPTOM: Can compile the JDBC program but Runtime Error
ERROR MESSAGE: 
   (Windows) No suitable driver found
   (Mac/Linux) NullPointerException
PROBABLE CAUSES: MySQL JDBC Driver Connector/J was NOT (properly) installed.
POSSIBLE SOLUTION:
   1. Read "Install  MySQL  JDBC Driver" again, again and again... 
   2. Make sure that you copy the driver to the JDK's Extension directory.
   3. You may the following command to run your JDBC program:
      > java ‐cp .;path‐to\mysql‐connector‐java‐5.1.xx‐bin.jar JdbcClassName
   4. For Tomcat, you may place the driver JAR‐file in Tomcat's "lib" directory.

SYMPTOM: Can compile the JDBC program but Runtime Error
ERROR MESSAGE: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: 
   Communications link failure
PROBABLE CAUSES: 
   1. MySQL Server is NOT started, or
   2. The program was connecting to a wrong TCP port number or wrong hostname (or IP address)
      in your database‐URL jdbc:mysql://localhost:port/studentdb.
POSSIBLE SOLUTION:
   1. Make sure that server has been started. Note down the server's port number 
      from the server's console.
   2. Check the database‐URL's hostname and port number: jdbc:mysql://localhost:port/studentdb
   3. Run a MySQL client, issue command "status" to confirm the server's TCP port number.
   4. Run a mysql client, use "mysql ‐u root ‐p ‐‐port=xxxx" to specify the port number to
      confirm the server's port number.

SYMPTOM: Can compile the JDBC program but Runtime Error
ERROR MESSAGE: java.sql.SQLException: Access denied for user 'username'@'localhost' 
   (using password: YES)
PROBABLE CAUSES: Wrong username or password in statement:
   DriverManager.getConnection(databaseURL, username, password).
POSSIBLE SOLUTION: Obvious!

SYMPTOM: Can compile the JDBC program but Runtime Error
ERROR MESSAGE: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 
   Unknown database 'xxxx'
PROBABLE CAUSES: DriverManager.getConnection("jdbc:mysql://localhost:8888/xxxx", user, password) 
   specifies a database that does not exist in the server.
POSSIBLE SOLUTION: Create the database using a client, before running the Java program.

SYMPTOM: Can compile the JDBC program but Runtime Error
ERROR MESSAGE: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 
   Table 'xxxx.xxxx' doesn't exist
PROBABLE CAUSES: The SQL statement references a non‐existence table.
POSSIBLE SOLUTION: Check your SQL statement and the database tables.
SYMPTOM: Can compile the JDBC program but Runtime Error
ERROR MESSAGE: java.sql.SQLException: Column 'xxx' not found.
PROBABLE CAUSES: The method ResultSet.getXxx(columnName) cannot locate 
   the requested columnName in the ResultSet.
POSSIBLE SOLUTION: Make sure that the column 'xxx' is included in the SELECT statement,
   so that it is included in the ResultSet.

SYMPTOM: Can compile the JDBC program but Runtime Error
ERROR MESSAGE: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 
   You have an error in your SQL syntax; check the manual that corresponds to 
   your MySQL server version for the right syntax to use near .... at line x
PROBABLE CAUSES: Syntax error in your SQL statement.
POSSIBLE SOLUTION: Obvious!

SYMPTOM: Logical error in comparing floating point numbers for equality. 
   For example, "SELECT * FROM class101 WHERE gpa = 4.4" 
   yields empty set although there is a record with gpa=4.4.
PROBABLE CAUSES: 
   "gpa" has the type of FLOAT.
   Floating point numbers are not stored "accurately".
POSSIBLE SOLUTION: 
   Do not compare two floating point number for equality. 
   Instead, specify a range, e.g., "gpa > 3.9 AND gpa < 4.1"

SYMPTOM (NetBeans): I got this strange error running JDBC program on NetBeans.
ERROR MESSAGE: 
   The DriverManager.getConnection() method throws:
   com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error 
      in your SQL syntax; check the manual that corresponds to your MySQL server 
      version for the right syntax to use near '??' at line 1
POSSIBLE SOLUTION:
   The NetBeans project was using "UTF‐16" as the default charset. Hence, it communicates
      with MySQL server using "UTF‐16" character set.
   The problem solved by setting the default charset to an ASCII compatible charset
      such as "Latin‐1" or "UTF‐8" (Right‐click on the project ⇒ Properties ⇒ Encoding)

4.2 JDBC on MS Access


SYMPTOM (Access 2007): Can compile the JDBC program but Runtime Error
ERROR MESSAGE: java.sql.SQLException: [Microsoft][ODBC Driver Manager] 
   Data source name not found and no default driver specified.
PROBABLE CAUSES: No such Data Source (ODBC) name in method 
   DriverManager.getConnection("jdbc:odbc:ODBCName");
POSSIBLE SOLUTION: Check your ODBC configuration (under control panel ⇒ ODBC).

SYMPTOM (Access 2007): Can compile the JDBC program but Runtime Error
ERROR MESSAGE: java.sql.SQLException: [Microsoft][ODBC Driver Manager] No data found
PROBABLE CAUSES: The ODBCName in method DriverManager.getConnection("jdbc:odbc:ODBCName") 
   does not SELECT a database.
POSSIBLE SOLUTION: Check your ODBC configuration (under control panel ⇒ ODBC).

SYMPTOM (Access 2007): Can compile the JDBC program but Runtime Error
ERROR MESSAGE: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] 
   The Microsoft Office Access database engine cannot find the input table or query 'xxx'.  
   Make sure it exists and that its name is spelled correctly.
PROBABLE CAUSES: The SQL statement references a non‐existence table.
POSSIBLE SOLUTION: Check your SQL statement and the database tables.

SYMPTOM (Access 2007): Can compile the JDBC program but Runtime Error
ERROR MESSAGE: java.sql.SQLException: Column not found.
PROBABLE CAUSES: The method ResultSet.getXxx(columnName) cannot locate 
   the requested columnName in the ResultSet.
POSSIBLE SOLUTION: Make sure that the column is included in the SELECT statement, 
   so that it is included in the ResultSet.
SYMPTOM (Access 2007): Can compile the JDBC program but Runtime Error
ERROR MESSAGE: 
  [Microsoft][ODBC Microsoft Access Driver] Syntax error in FROM clause.
  [Microsoft][ODBC Microsoft Access Driver] Too few parameters.
  ....
PROBABLE CAUSES: Syntax error in the SQL statement.
POSSIBLE SOLUTION: Obvious!

SYMPTOM (Access 2007): Can compile the JDBC program but Runtime Error
ERROR MESSAGE: 
  [Microsoft][ODBC Microsoft Access Driver] SQL General Error.
PROBABLE CAUSES: This message is not clear, but most likly caused by inserting a record
  with duplicate primary key.

SYMPTOM (Access 2007): Can compile the JDBC program but Runtime Error
ERROR MESSAGE: 
  [Microsoft][ODBC Microsoft Access Driver] The number of fields are not the same as the ....
PROBABLE CAUSES: In the INSERT INTO tableName VALUES (...), you should have the same number
  of values as the number of columns.

5. Java Servlet Common Errors


SYMPTOM: Cannot compile Java Servlet
ERROR MESSAGE: 
  class xxxx is public, should be declared in a file named xxxx.java
CAUSES/SOLUTION:
  In Java, the filename must be the same as the classname with extension of ".java".
  For example, the class "HelloServlet" must be saved as "HelloServlet.java" ‐ case‐sensitive!

SYMPTOM: Cannot compile Java Servlet
ERROR MESSAGE: package javax.servlet does not exist
CAUSES/SOLUTION:
  The Java Servlet library is missing. Read "Step 6(a) Install Servlet API Library" 
  again, again and again....

6. NetBeans Common Errors


SYMPTOM: Cannot display chinese characters and other Unicode characters in the NetBeans editor
ERROR MESSAGE: Chinese characters displayed as boxes or question marks in the NetBeans editor
CAUSES/SOLUTION:
  1. Check the character set. Right‐click on the project ⇒ Property ⇒ "Source" node 
     ⇒ "Encoding" ⇒ Choose "UTF‐8" or the desired Unicode charater sets.
  2. You also need to choose a font type that displays chinese or Unicode characters,
     such as "Monospace".
     In "Tools" menu ⇒ Options ⇒ Fonts & Colors ⇒ Syntax ⇒ default.
     If one font does not work, try another.

7. C++ with GCC Compiler


SYMPTOM: Cannot compile
ERROR MESSAGE: error: 'string' does not name a type
CAUSES/SOLUTION: missing "using namespace std;"
 
SYMPTOM: Cannot compile
ERROR MESSAGE: error: iostream: No such file or directory
CAUSES/SOLUTION: The file is incorrectly saved as ".c" instead of ".cpp"

Latest version tested: JDK 1.7.0_17, MySQL 5.6.10, Tomcat 7.0.39, JDBC 4.0
Last modified: April, 2013
Feedback, comments, corrections, and errata can be sent to Chua Hock­Chuan (ehchua@ntu.edu.sg) | HOME
Seleccionar idioma ​

compile time error messages : Java Glossary
            Guardar  
* 0­9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (all)

You are here :
home
Java Glossary
C words
compile time error messages
 

©1996­2017 2008­08­30 Roedy Green of Canadian Mind Products

  compile time error messages
This table contains errors detected at compile time. If you don’t find your error listed here, send me an email at 
 containing the complete source code so I too can compile it and I will figure out what it
means and add it to this list.

  run time error messages
error messages

Index To Compile Time Error Messages
menu
( expected class should be declared in file not a statement
. expected class, enum or interface expected not abstract
.class expected classname not enclosing class not accessible
; expected Comparable cannot be inherited not found in import
; missing constructor calls overridden method not initialised
= expected constructor used as method operator +
[ expected duplicate class operator ||
already defined duplicate methods package does not exist
ambiguous class enum as identifier permission denied
array not initialised error while writing possible loss of precision
attempt to reference Exception never thrown public class should be in file
attempt to rename final parameter may not be assigned reached end of file while parsing
bad class file generic array creation recompile with ­Xlint:unchecked
blank final identifier expected redefined method
boolean dereferenced illegal character reference ambiguous
bound mismatch illegal escape repeated modifier
cannot find symbol illegal forward reference return in constructor
cannot override,
illegal reference to static return outside method
attempting weaker access
cannot override,
illegal start return required
does not throw
cannot override,
impotent setters serialVersionUID required
incompatible return type
cannot resolve constructor incompatible type should be declared in file
cannot resolve symbol instance not accessible statement expected
cannot resolve symbol constructor invalid declaration static field should be accessed in a static
Thread way
cannot resolve symbol this invalid flag static not valid on constructor
cannot use operator new invalid label superclass not found
can’t access class invalid method suspicious shadowing
can’t be applied invalid type Tag @see: not found
can’t be dereferenced javac is not a … command type can’t be private
can’t be instantiated; main must be static void type can’t be widened
can’t convert from Object to X method cannot hide type expected
can’t delete jar file method clone not visible type safety
can’t determine application home method matches constructor name type safety: type erased
can’t instantiate abstract class method not found unable to resolve class
can’t make static reference misplaced construct unchecked cast
capitalisation errors misplaced package unchecked conversion
case fallthru missing init unclosed character literal
char cannot be dereferenced missing method body unclosed String literal
clashes with package missing public undefined reference to main
class expected missing return statement undefined variable
class has wrong version missing variable initialiser unexpected symbols
class must be defined in a file modifierr synchronized not allowed unqualified enumeration required
class names only accepted for
name of constructor mismatch unreachable statement
annotation
class names unchecked only accepted no field unsorted switch
class not found no method found void type
class not found in import no method matching weaker access
class not found in type declaration non­final variable { expected
class or interface declaration expected non­static can’t be referenced } expected

Compiler Error Messages
Compiler Error Messages
Compiler Error Messages
Key What Compiler Says
Real Error / Possible Causes
( expected ( expected instead of {.
// oops missing [] in attempt to define an array literal
new String { "x", "y" };

instead 
// how to create string array literal
new String[] { "x", "y" };

See balancing.
. expected '.' expected. Usually pointing to an import statement.
You must import either a packagename.* or packagename. Classname. You can’t just import packagename or import
Classname. You don’t import classes in the same package as the current class. In other words, the thing you import will
always contain at least one .. You don’t use import for code not in any package. You have to put such classes on the
classpath. Whenever you have more than one class, it is a good idea to assign every class to an explicit package with a
package statement. In summary, you import fully qualified classes, with package and classname separated by a dot. You
don’t import classes without packages.
.class expected '.class’ expected
you wrote int i where you meant just plain i.
; expected semicolon expected.

Usually this is just a missing semicolon,
sometimes it can be caused by unbalanced () on the previous line.
sometimes it can be cause by junk on the previous line. This junk might be far to the right off the screen.
Sometimes it is caused by spelling the keyword if incorrectly nearby.
Sometimes it is a missing + concatenation operator. C programmers often make this one on multi­line Strings since the
concatenation operator is implied in C.
; missing ';' expected. 'else' without if. statement expected. invalid expression.
missing semicolon. See ; expected.
= expected = expected.
Look for a stray } just before where it is complaining.
[ expected Missing [
Likely you wrote [i,j] instead of [i][j].
already defined Variable 'x' is already defined in this method.
duplicate variable declaration
ambiguous class x.y.SomeClass and a.b.SomeClass,
ambiguous class reference to Object is ambiguous, both class org.omg.CORBA.Object in org.omg.CORBA and
class java.lang.Object in java.lang match.

// Ambiguous Class import.
// If you were to use SomeClass, which one did you mean?
import x.y.SomeClass;
import a.b.SomeClass;

can 
// Ambiguous Class import for x.y.SomeClass and a.b.SomeClass
// but the compiler won't mind unless you actually use SomeClass.
import x.y.*;
import a.b.*;

Some compilers may complain about the clash in SomeClass, even if you never reference it. And, of course, all references to
SomeClass should be disambiguated to either x.y.SomeClass or a.b.SomeClass. Alternatively, you can throw out all the
imports and fully qualify all classes in x.y and a.b. This approach makes code easier to maintain because it is easier to find
the code that implements the class when it is fully qualified. In your own classes, try to use globally unique class names.
Even if the computer understands the ambiguity, humans often become confused.
import
array not initialised Array a may not have been initialized.
You forgot to initialise an array with new int[5].
attempt to reference Attempt to reference method xxx in class XXX as an instance variable.
missing dummy pair of parentheses after the 0­argument method name.
attempt to rename jarsigner: attempt to rename xxx.jar to xxx.jar.orig failed.
Your jar is in use by some running Applet or application. Shut it down to build and sign the jar.
bad class file: XXX.java file does not contain class XXX. Please remove or make sure it appears in
bad class file
the correct subdirectory of the classpath.
Check that the package statement and the class statement have names that are precisely correct including case and that this
file is in a directory that precisely matches the package name and the source file name that precisely matches the class name
followed by .java.

Blank final variable 'xxx' may not have been initialized. It must be assigned a value in an initialiser,
blank final
or in every constructor.
Check that your final variable is indeed so initialised. If it is, remove the final, to bypass a bug in the Javac 1.1 compiler.
Boolean dereferenced Boolean cannot be dereferenced.
You need extra layers of parentheses around your casting.
Eclipse error: Bound mismatch: The generic method sort(List<T>) of type Collections is not
Bound mismatch applicable for the arguments (ArrayList<X>). The inferred type X is not a valid substitute for the
bounded parameter <T extends Comparable<? super T>>
You forget to implement Comparable on the class X you are sorting.
Can’t access com.mindprod.mypackage.MyClass. Only classes and interfaces in other packages can
can’t access class
be accessed.

You forgot to make the class public.
In JBuilder, check the properties for your project. Your root directories should be plain C:\ not
J:\com\mindprod\thepackage\

can’t be applied setVisible(Boolean) in java.awt. Component cannot be applied to ()
You wrote x.setVisible() instead of x. setVisible( true ), or similar parameter mismatch. Check the types of parameters and
arguments for an exact match. Whenever you see cannot be applied check the Javadoc to make sure the signature of the
method you are calling matches the types of the arguments. The problem often is you are sure a method must logically have
to exist that does not.

It ain’t what you don’t know that gets you into trouble. It’s what you know for sure that just ain’t so.
~ Mark Twain (1835­11­30 1910­04­21 age:74)
can’t be dereferenced int cannot be dereferenced.
You need extra layers of parentheses around your casting. or perhaps you may have written something like i.toString() where
i is an int rather than an object with methods. You need to write something like  Integer.toString( i) instead. ints can’t have
any instance methods. They can be parameters to either static or instance methods though.
load: com.mindprod.mypackage.MyApplet.class can’t be instantiated.
can’t be instantiated;
java.lang.InstantiationException: com/mindprod/mypackage/MyApplet
You are missing the default constructor for your Applet. See The Case of the Disappearing Constructors.
can’t convert from
Type mismatch: cannot convert from Object to X.
Object to X
This error often comes up in the context of the clone method which, without covariance, returns an Object reference not the
specific type of the Object cloned as you might naïvely expect. You tried to use a general Object reference in a context that
requires something more specific. Sometimes all you need is a cast.
can’t determine
Can’t determine application home.
application home
Uninstall all Java JDKs (Java Development Kits) and JREs (Java Runtime Environments) with the Control Panel. Use
Microsoft’s RegClean. Tidy up the registry with regedit. Reinstall just the latest JDK (Java Development Kit).
cannot find symbol Cannot find symbol
You used a variable name you did not define. Perhaps you forgot the declaration. Perhaps you declared it inside a block/loop
and you tried to use it outside the block/loop. You must move the declaration to an encompassing outer block that encloses
all the references. Perhaps you spelled the variable slightly differently in declaration and reference. Watch your caps and
double letters carefully. Perhaps you left out or mistyped the corresponding import or static import.

Cannot find symbol constructor XXX, means you likely you did an explicit XXX() to call the superclass constructor first thing
in your constructor instead of using super().

Cannot find symbol method XXX, where XXX is your class’s superclass constructor means you likely you did an explicit
XXX() to call the superclass constructor first thing in your constructor instead of using super().

Possible causes of the error for constructors and methods:

Wrong syntax for calling: constructor: new X(), instance: x. someMethod(), static: SomeClass.someMethod ().
The method you want is protected or private.
You left out a parm.
You added an extra parm.
You have the parms in the wrong order.
You have the type of a parm wrong, e.g. it wants a File, but you gave it a String.
Symbols are case­sensitive. You have a mismatch.
Confused package. Javac.exe is looking in the wrong package or class, e.g. java.util.List vs java.awt.Listawt.List. Use
fully qualified references to rule that out.
The referenced class did not compile because it has a syntax error.
The needed class/jar files are not on the classpath.
Cannot find symbol method sort(java.util.ArrayList<Xxx>) could mean you have not implemented Comparator on the
class you are trying to sort.
There is some other syntax error, than the compiler interprets its strange way as an undefined symbol.

Using the ­verbose option on javac.exe will give you hints to help resolve this error. Cannot Resolve Symbol
can’t instantiate
Error: MyClass is an abstract class. It can’t be instantiated.
abstract class
missing method to fulfill an interface implementation
can’t make static
Can’t make a static reference to non­static (instance) variable x in MyClass.
reference
using an instance variable in a static method
toString() in xxx cannot override toString() in java.lang.Object; attempting to assign weaker access
cannot override
privileges; was public.
You can override a default or protected method with a public one, but not the reverse.
toString() in xxx cannot override toString() in java.lang.Object; overridden method does not throw
cannot override
java.io.IOException
Overridden methods cannot add any throws clauses not in the base method they are overriding.
cannot override cannot override xxx() in java.lang.Object; attempting to use incompatible return type.
When you override an existing method, you must use exactly the same method signature including return type. Perhaps you
did not realise you were overriding a method. In Java version 1.5 or later, you may return a subclass of the base return type.
cannot resolve Cannot resolve constructor xxx().
constructor
If a subclasses constructor does not call one of the constructors of the superclass as the very first thing, java inserts a call to
the default constructor for you super(). If you have not defined that null constructor, you will get an error. The usual way to
fix it is by inserting some sort of super( parm ); as the first statement of your subclass constructor. See also hints on resolving
symbols.
cannot resolve symbol Cannot resolve symbol

No such variable or method. Perhaps it exists, but not in the current scope, e.g. you are trying to use a variable defined
inside a loop outside that loop.
Possibly you are trying to use a constructor without new as if it were an ordinary method.
You left off the () on your method call.
If the error message is pointing to code that uses the standard classes, chances are you either misspelled it, or forgot to
import the class, or misspelled the import. If it is pointing to one of your methods or variables chances are you
misspelled it either in the definition or reference. Java is picky. You must get upper­lower case precisely correct too.
If the code is pointing to one of your classes that is clearly there, perhaps you forgot to put C:\ on the classpath — the
mother of all packages where com is in com.mindprod.thispackage lives. If you are not using packages, perhaps you
forgot to put. on your classpath. A symptom of this is you can compile successfully if you rebuild everything, but not
if you just recompile the changed modules.
You are using a method of the object when the reference is to an interface that does not contain that method. Either
cast to specific object, or change the reference to a specific object reference, e. g. 
// Using subclass methods.
// In this case, MultiFilter.addNever() is implemented
// in MultiFilter but not in the base FileNameFilter.

// oops. f. has no addNever method.
FileNameFilter f = new MultiFilter();
f.addNever( never );

// should read
FileNameFilter f = new MultiFilter();
((MultiFilter)f).addNever( never );

// or more efficiently
MultiFilter f = new MultiFilter();
f.addNever( never );

 addNever is a method of
MultiFilter, but not of FileNameFilter.
Watch for subtle spelling differences between declaration and reference, e.g. Hashtable and HashTable. Copy/paste the
definition on top of the reference to be sure they are absolutely identical. Your eyes can fool you.
In an implements clause, you may have used a period where you should have used a comma.
If is complaining about the superclass of your constructor, the problem is you must either explicitly call super(), or
there must be a superclass constructor with a matching signature.
Cannot Find Symbol
cannot resolve symbol
cannot resolve symbol constructor Thread( YourRunnable )
constructor Thread
You forgot to write implements Runnable on the class with the run method.
cannot resolve symbol
Cannot resolve symbol this.xxx
this
You are inside an anonymous inner class and xxx is a member or method of the enclosing class. You must use Outer. this.
xxx instead of this.xxx.
cannot use operator
Cannot use operator new for this type
new
You can’t instantiate references, class names as Strings, interfaces or abstract classes, only concrete class names. Perhaps
there is no suitable constructor. Perhaps you inadvertently wrote methods instead of constructors by specifying a return type
on them.
can’t delete jar file Ant complains it cannot delete the jar file during a build
You are running the application from the old jar. Shut it down before rebuilding.
char cannot be
char cannot be dereferenced
dereferenced
You have tried to use a String or other Object method on a char or char[] which have no instance methods.
clashes with package XXX clashes with package of same name
Rename your class or rename your package so they don’t have the same name. Usually this is not a problem since package
names normally have dots in them.
class has wrong
class file has wrong version 49.0, should be 48.0
version
You are compiling with the Java version 1.4 compiler, referencing class files compiled with the newer  Java version 1.5
compiler. The referenced class files must be recompiled with 1.4 to make them compatible with the old Java. Alternatively,
you must use JDK 1.5 for everything.
class must be defined
Warning: ublic MyClass must be defined in a file called 'MyClass.java'.
in a file

class name does not match source filename.
Putting more than one public class per file.
Getting the capitalisation wrong in the filename on the javac command line or in the filename itself.

class names only
accepted for Error: Class names, 'XXX', are only accepted if annotation processing is explicitly requested
annotation processing

There is nothing wrong with the text of your program; the problem is in how you tried to compile it. You left off the *.java
extension when compiling with javac.exe, e.g. at the command line you typed:

javac.exe MyClass

instead of:

javac.exe MyClass.java
This is one of the most maliciously misleading of all error messages.
class names unchecked
only accepted for error: Class names, "unchecked", are only accepted if annotation processing is explicitly requested
annotation processing
For Netbeans, uncheck the project’s property entitled Enable Annotation Processing in Editor, leaving all others checked on
that page and clean and build the project.
class not found Class not found
This can occur at compile or run time.

You are using Internet Explorer which has a defective or missing Java.
Some other syntax error ahead of the class declaration is preventing the compiler from seeing the class declaration.
The class is not in the proper file in the proper directory.
The class is not public.
The class does not have the correct case, either in the class name or the file name.
The corresponding class or java file is not on the CLASSPATH (considering the package name.)

class not found in
class com.mindprod.mypackage.Myclass not found in an import
import
All class files and packages you reference in import statements must be accessible via the CLASSPATH, or be part of the
project or live in the ext directory. You must import a class, not a package, e.g. import java.io.File ; not import java.io; You
can import all the classes in a package with: import java.io. *; It is easiest to use an IDE (Integrated Development
Environment) like IntelliJ that inserts and prunes the imports for you. Also remember that package and class names are case­
sensitive.
class not found in type
Class WindowAdapter not found in type declaration.
declaration
You forgot to import java.awt.event.* or to fully qualify java.awt.event.WindowAdapter. I’m sure you can generalise for
other classes.
class expected class expected.
It is not expecting the keyword class, but rather the name of a class. You might have written something like
long.MAX_VALUE instead of Long.MAX_VALUE.
class or interface (or
enum) declaration class or interface (or enum) declaration expected.
expected

Put your package statement before all the imports. The imports come before your class declarations.
Make your class public, not protected.
You may have too many } so that you have finished off your class before you intended too. Using a source code
beautifier that aligns code block and {} will help make these sorts of errors obvious.

class, enum or
class, enum or interface expected
interface expected
There is a missing { somewhere much earlier in the code. class and interface must be all lower case. Another way of looking
at it, you method and variable definitions come after class, not package.
class should be
class XXX is public, should be declared in a file named XXX.java
declared in file
The name of the *.java file must precisely match the name of the public class it defines. The name is case­sensitive.
classname not
classname is not an enclosing class
enclosing class

You are attempting to instantiate a non­static named inner class without an instantiated the outer class. Solution:
declare the named inner class as static or instantiate your inner class like this as described under nested classes.
You used an expression like JApplet.this in an inner class. You must specify the precise name of the enclosing class,
e.g. MyApplet. this not one of its superclasses. If you wanted a superclass reference you would have to use (JApplet)
MyApplet. this.

Comparable cannot be
Comparable cannot be inherited with different arguments
inherited
// base class
class SalesTaxItem implements Comparable<SalesTaxItem>
{
...
}

// subclass
class DatedSalesTaxItem extends SalesTaxItem implements Comparable<DatedSalesTa
{
...
}

The best way I know of to bypass the problem is to write both classes without the implements Comparable. Then write two
Comparators instead.

duplicate class Duplicate class
You misspelled the package name on the package statement. It must match the name of the directory containing the Java
source.
duplicate methods duplicate method declaration
You have two methods with the same name and the same signature i.e. number and types of parameters. You can’t have two
methods that differ only in return type.
enum as identifier try ­source 1.4 or lower to use 'enum' as an identifier.
Starting with Java version 1.5, enum became a reserved keyword. Older programs may have used the word enum as a
variable, method or package name. You will have to globally rename enum to some other identifier, or convert the code to
use the new built­in enum features.
error while writing error while writing <classname>. The system cannot find the path specified.
You used the javac.exe ­d option. The compiler is trying to write the generated class files to this directory, but it cannot,
probably because it does not exist. The compiler wants to create a tree of package names in that directory. You may have it
blocked by files of the same name as the packages. Use lower case for all package names and directories.
Exception never
Exception IOException is never thrown in the body of the corresponding try statement.
thrown
You are trying to catch an exception that could never happen. Just remove the try/catch. Java does not like you trying to
catch an exception that could never happen, but oddly it does not mind you declaring a throws that could never happen.
final parameter xxx
Attempt to assign to a variable declared as final
may not be assigned
The wording is ambiguous. You might think it means the parameter might, under some circumstances, escape being
assigned. That is not what it means.
generic array creation Attempt to create an array of generic objects

You might have written new ArrayList <String>[ 100] instead of new ArrayList< String>( 100);

To be charitable, Java’s generics are Mickey Mouse. One of the side effects of the el­cheapo implementation is that you
can’t have arrays of generic collections, e. g. the following is illegal

// You cannot use "new" to allocate an array of T where T is a generic type, e.g
// Recall that even if it did, it would still allocate an array of Objects at ru
T[] things = new T[10];

// Illegal attempt to create an array of generic collections.
ArrayList<String>[] stuff = new ArrayList<String>[ 10 ];

identifier expected identifier expected
Look for a missing { slightly before of where it is complaining. It may also be a } before the code that should appear after. It
can also be caused by attempting to define a constructor in an interface. Perhaps you wrote some initialisation code without
enclosing it in static {} or plain {}. Method calls must be inside methods or init blocks, not just lying loose in amongst the
field declarations.
illegal character illegal character: \8220 or \8221
You used Unicode 8220 (aka \u291c, 0x291c, “, left quote) or 8821 (aka \u291d, 0x291d, ”, right quote) instead of a simple
34 (aka \u0022, 0x22, ") that Java requires. This probably resulted from using a word processor like MS Word instead of a
text processor or IDE to compose your Java source which converts "s into and .

illegal escape illegal escape character
Mostly likely you forget to double each \ in a filename String, e. g. you should write C:\\temp\\somefile.txt not
C:\temp\somefile.txt. Backslash \ has special meaning inside Strings, e. g. \n means newline, \t means tab, \" means
embedded ". \\ means a single \. If you used \ followed by a letter without special meaning, you will get this error message.
literals
illegal forward
Probable forward enum reference
reference

Java computes its static initialisation in a simplistic top to bottom way. It is not clever, in using natural order like a
spreadsheet. Any value you reference must be defined lexically earlier in the class. This holds both for the order of
initialisations and for the order of assignments in a static init or instance init block.

You may not reference an enum constant that has not yet been defined. e.g. you cannot reference other enum constants
in an enum constructor call.
You must declare static finals before you define them in a static init block. Put your static init blocks after all your
static final variables.
You must define the value of a static final before you can use it in defining the value of another static final.
illegal reference to
illegal reference to static field from initialiser
static
enum constructors cannot access the enum static fields. However, they can invoke the enum’s static methods that access the
static fields, but they won’t get the right values. The easiest way out is to convert your static constants to instance constants.
Strange as it seems, they are initialised before the constructor code. Constructors may, however, directly access static final
in­lineable constants known at compile time.
The problem is static initialisation has not been done at the time the enum constructor constant constructors are invoked, so
static methods called from your constructors will just see zeros/nulls. Why this screwy rule? You’d think statics would be
initialised first, the way they are with any other classes. The JLS (Java Language Specification) justifies it this way:

The direct superclass of an enum type named E is Enum<E>. In addition to the members it inherits from
Enum<E<, for each declared enum constant with the name n the enum type has an implicitly declared public
static final field named n of type E. These fields are considered to be declared in the same order as the
corresponding enum constants, before any static fields explicitly declared in the enum type. Each such field is
initialized to the enum constant that corresponds to it. Each such field is also considered to be annotated by the
same annotations as the corresponding enum constant. The enum constant is said to be created when the
corresponding field is initialized. The direct superclass of an enum type named E is Enum<E<. In addition to the
members it inherits from Enum<E<, for each declared enum constant with the name n the enum type has an
implicitly declared public static final field named n of type E. These fields are considered to be declared in the
same order as the corresponding enum constants, before any static fields explicitly declared in the enum type.
Each such field is initialized to the enum constant that corresponds to it. Each such field is also considered to be
annotated by the same annotations as the corresponding enum constant. The enum constant is said to be created
when the corresponding field is initialized.
~ Java Language Spec

In other words, the gotchas is a side effect of the kludgy way enums are implemented.
illegal start illegal start of expression

The error message will point to perfectly good code. Look just ahead of it for a missing } or ;
static int x = 0; Static variables have to be defined outside all methods inside a class.
you wrote x + = 2; instead of x += 2; You also may have used an ) when you meant a }.
you wrote case: STRAWBERRY instead of case STRAWBERRY :
You nested a method inside another method.

incompatible type Incompatible type for =. Explicit cast needed to convert int to byte.
missing a cast such as (byte)
Error: An instance of XXX.this is not accessible here because it would have to cross a static region
instance not accessible
in the intervening type XXX.
Something is wrong with the parameters to an inner class.
invalid declaration Invalid declaration
Most likely the name you are trying to declare is invalid. It must not contain dots. It must not start with a digit.
invalid label invalid label
You used a semicolon instead of a colon after a label.
invalid flag javac: invalid flag: MyClass
writing javac.exe MyClass or javac.exe MyClass.class instead of javac.exe MyClass.java.
invalid method Invalid method declaration; return type required.
forgetting void return type on a method declaration. Possibly your constructor and its class name do not match exactly,
including case.
invalid type Invalid type expression.
You forgot the semicolon.
javac is not a …
javac is not an internal or external command operable statement or batch file
command
J:\Program Files\java\jdk1.8.0_131\ \bin\javac.exe must be on the path. See JDK for details on polishing and testing your
JDK installation.

main must be static
main must be static and void
void
An application’s main class must have a method public static void main (String[] args).
The static method XXX declared in class AAA cannot hide the instance method of the same
method cannot hide
signature declared in class BBB (Better Business Bureau). It is illegal to hide an instance method.
You can’t use the same name for a static and instance method in a subclass. Either you have to give them different names, or
make them both static or make them both instance, or change the signature (parameter types) to make them different.
method clone not The method clone() from the type Object is not visible
visible
If the class containing clone is one of yours, you must implement a public clone method, that will probably use the protected
version in its implementation. If the class is built­in, unfortunately, it does not have a public clone method, just a protected
clone, which you may not use, unless you write a class extending the built­in class. See clone for details.
method matches The name of this method XXX matches the name of the containing class. However, the method is
constructor name not a constructor since its declarator is qualified with a type.
You can’t put void on a constructor, or put any other return type for that matter.
method not found Method MyClass() not found in MyClass

undefined (missing) method.
You wrote MyClass x = MyClass(); instead of MyClass x = new MyClass();

misplaced construct misplaced construct

You wrote doSomething( String[] choices ) rather than doSomething( choices )
There is a stray } just before of where it is complaining.

misplaced package Error: com/sun/java/swing/xxx is either a misplaced package name or a non­existent entity.
Sun renamed com.sun.java.swing to javax.swing but your code is still using the old name. Use a global search and replace on
all your *.java files.
missing method body missing method body, or declare abstract
You inserted a semicolon just before the first { of a method.
missing return
missing return statement
statement
No matter how control flows through your method, it must end with a return statement, unless the method has a void return.
The most common failing is when you catch an exception. The return in the try body conceptually might never be executed
because of an exception potentially being triggered. You need a return in the catch block or after the catch block too. Javac is
not as clever as you. You may be sure the exception will never dodge the return in the try block, but javac can’t be so sure.
modifier synchronized
modifier synchronized not allowed here
not allowed

synchronized applies to methods and blocks of code. transient applies to variables.
name of constructor
The name of the constructor main does not match name of class MyClass
mismatch
You forgot your return type, e.g. void, on a method.
no field No field named length was found in type java/lang/String
You said s.length rather than s.length() to get the length of a String. The a.length form without the () is only used for arrays.
Whereas Lists (e.g. ArrayList) use java.util.List.length(). Collections use Collection.size() just to keep you on your toes. You
will even see getLength() every once in a while. The designers of Java must hate newbies to put such stumbling blocks in
front of them. It is either laziness of a subtle form of one upmanship.
no method found No method xxx found in class yyy.
You have the wrong number of parameters or the wrong parameter types for the method. It can also mean you defined a
method with the wrong visibility modifier, e.g. none, private or protected when you meant public. Perhaps you called it as if
it were static and defined it as instance, or vice versa. Perhaps you were calling a constructor without new.
no method matching No method matching myMethod() found in MyClass
You have the wrong number of parameters or the wrong parameter types for the method. It can also mean you defined a
method with the wrong visibility modifier, e.g. none, private or protected when you meant public. Perhaps you called it as if
it were static and defined it as instance, or vice versa. Perhaps you were calling a constructor without new.
cap missing no warning. caps missing.

missing caps on a class name declaration.
Caps on a variable/method declaration

impotent setters no warning. impotent setters.

this.x = x; Effectively you wrote this.x = this.x; because there is no x parameter.
// This method does nothing,
// just sets this.brush to itself.
// Note misspelling brash for brush.
// No warning!
// Eclipse compiler will warn you though.
public voidsetBrush ( int brash )
   {
   this.brush = brush;
   }

missing public no warning. missing public.
In debug mode, if you forget to make your main method public, you will not be warned. You won’t discover the problem
until later. main must be public static void.
case fallthru no warning. Case fall through is the default.
missing break. In Java version 1.4 or later you can use the javac.exe ­Xswitchcheck to get this error detected.
missing initialisation no warning. Missing initialisation.

The array is automatically initialised to null. This will likely soon lead to a java.lang.NullPointerException when you
try to apply some method to one of the elements of the array. Note Null PointerException, not
NullReferenceException. You forgot to initialise an array of strings or objects to some value.
You forgot to initialise an int array to some value or populate it with objects.

missing variable
missing variable initialiser
initialiser
Don’t put () around the dot­separated parts of a name.
constructor treated as
no warning. Constructor treated as a method.
method
specifying a void return type on a constructor. Method with the same name as the class.
suspicious shadowing no warning. reusing instance variable as local.
You accidentally declared a local variable with the same name as an instance or class variable when you intended to use the
instance or local variable. This is my most common error that the compiler does not detect.
JPCC
The Jikes compiler will warn you of this.
calling overridden
methods in no warning. calling overridden methods in constructors
constructor
Be very careful calling any methods inside your constructors. If subclasses override them, you will be invoking the
subclass’s version, which may be attempting to use fields that have not been initialised yet. You won’t get a warning
message! The problem usually shows up as puzzling NullPointerExceptions. The way out is to move code out of the
constructor, often to the addNotify method. However, addNotify can get in analogous problem to the constructor since it too
is overridden and it may use overridden methods.
local variable xxx is accessed from within inner class; needs to be declared final or cannot refer to a
non­final variable
non­final variable xxx inside an inner class defined in a different method.
Inside anonymous classes, you can’t use local variables of the enclosing method unless they are final. I don’t mean instance
or static variables. I don’t mean passing locals as parameters to the anonymous constructor. I mean directly accessing local
method stack variables directly from anonymous inner class methods. When you do that, they variables have to be final.
more details.
non­static can’t be
non­static method xxx cannot be referenced from a static context
referenced

In a static method, you used an instance method without an object, e.g. MyClass.xxx(). You must first create an object
with MyClass o = new MyClass();, then use o.xxx(); to invoke the method.
You used an instance variable (one without the static attribute) inside a static method. static methods don’t have access
to any particular object, so can’t use any of the instance (per object) fields. You may have used a reference to an inner
class inside a static method. Make that inner class an ordinary separate class. Inner classes are always linked to an
instance of the main class. You may have tried to instantiate an inner class in some static code. You need to make the
inner class static to be able to use it without a mother object.
You tried to access an instance variable or method of the outer class from static nested class.
You tried to instantiate/reference a non­static inner class from a static method of the outer class. Either make the inner
class static, or make it an independent class, or make the invoking method an instance method.
This sounds bizarre, but you were using an enum with some enum private methods. Remove the private keyword and
magically all will work. Use an IDE like IntelliJ Idea to show you will methods can be private. This is a side effect of
the way enums are implemented. enum constants with a body of their own methods are implemented as anonymous
inner classes defined in a static init block. They can’t access the private methods of the mother class. The error
message is misleading. The problem is one of scope, not context.

not abstract SomeClass is not abstract and does not override abstract method someMethod.
You defined a class that extended an abstract class, but you forgot to provide a concrete implementation for one of the
abstract methods.
Check out all the abstract methods in the base abstract class and make sure you have provided implementations for all of
them of them.
not a statement Not a statement
The compiler was expecting a statement and you gave it something else, e. g. you wrote if (i > 7) 42;. You might have
used a variable name beginning with a digit or punctuation or some other improper character.
Perhaps you used == instead of = in an assignment statement, turning it into an expression instead of a statement.
you wrote x + = 2; instead of x += 2;
Perhaps you had a stray semicolon in a statement made of dozen of concatenations.

not accessible xxx.this is not accessible here because it would have to cross a static region in the intervening type.
Move your named inner class definition outside a static method. Keep in mind, instances of inner classes must be associated
with an instance of the main class. As a corollary of this, you can’t create anonymous inner classes except inside instance
methods.
not found in import not found in import.
The package you mentioned is not available on the classpath. Make sure you spell it with proper case. Make sure you
understand the limitations of import wildcards. See import, classpath.
Local variable x may not have been initialized. There is some execution path from the declaration
not initialised
of x to where you used its value, that avoids setting its value. It often involves an exception.
missing initialisation for a temporary variable. If you initialise it in a try block, you need also to initialise it in the catch or
before the try in case you get an exception.
operator + operator + cannot be applied java.lang.String
Irritatingly, Java does not allow unary + in front of a String, only between Strings so you can’t write  
// oops, lead + not allowed even though it would be nice for alignment and consi
result =
 + "cow "
 + "rabbit "
 + "horse ";

operator || operator || cannot be applied to int,int
you wrote if ( x1 = x2 || y1 = y2 ) instead of if ( x1 == x2 || y1 == y2 )
package does not exist Package Java.Applet does not exist.

Java is case­sensitive. The package is called java.applet, not Java.Applet. Package names are supposed to be pure
lower case.
Check that the package is available on the classpath or in some jar in the appropriate ext directory. You can use winzip
to examine the jar file directories to find out which classes they contain. To help discover which jar does contain your
class use Google on the package name + jar. Then get that jar on the classpath or in the ext directory.
This error can so come up when you try to allocate an inner class object, e.g.
import java.awt.geom.Ellipse2D;

...

// allocate an inner class Float object of the Ellipse2D class
return new Ellipse2D.Float( x,  y,  w,  h );

You should use an import for the outer class. You don’t need to import the inner, though you may optionally do so.
Don’t try to use * notation to import the inner class..

Permission denied error while writing XXX: XXX.class (Permission denied)
This will happen in Linux/Unix systems, particularly if you use the Javac.exe ­d targetdir option. You are trying to write
your generated class files to a directory where you don’t have permission, or the *.class files that you are overwriting may
have been generated with a different owner.
possible loss of
possible loss of precision
precision
You did something like i = d; where i is an int and d is a double. Narrowing will throw away high order bits or the fraction.
You need an explicit cast to acknowledge this loss, e.g. i = (int)d;

public class should be
public class Xxx should be in a file named Xxx.java.
in file
Javadoc.exe is particularly picky about case. Make sure the name of the class exactly matches the name of the file and that
the name of the package exactly matches the name of the directory tree, e.g. com.mindprod.mypackage.MyClass should be
in a file called com\mindprod\mypackage\MyClass.java or com/mindprod/mypackage/MyClass.java, exactly including case
of the directory names.
reached end of file reached end of file while parsing
This is usually a brace balancing problem. You are missing a closing brace, so the parser got to the end while it figured it
was still inside the class. The problems can also be caused by unbalanced " and unclosed comments. IDEs (Integrated
Development Environments) often have tools to help you balance braces. Code tidiers make unbalanced braces more
obvious. For tough case try the BraceBalancer applet/utility.
method already
valueOf(java.lang.String) is already defined
defined
There are two causes, one is you simply defined the same method with identical signatures, or signatures differing only in
return type in the same class. The other you tried to override the valueOf method in an enum class. There is already a
generated hidden implementation in your class, so you can’t override it. Use some other name. The same applies to the
automatically constructed methods, compareTo, ordinal and equals.
Recompile with ­
XXX uses unchecked or unsafe operations. Recompile with ­Xlint:unchecked for details
Xlint:unchecked
You used a Collection without generifying it. If it is not obvious what the problem is, recompile with javac.exe ­
Xlint:unchecked *.java
reference to xxx is ambiguous, both method xxx(java.lang.String) method xxx(java.lang.Object)
match xxx(null). You have two methods with similar signatures. When you call a method with null,
reference ambiguous
there is no type information to help the compiler decide which version to use. Use a typed constant
whose value is null.
repeated modifier repeated modifier
You specified a modifying keyword more than once e.g. final or public.
return in constructor 'return' with value from constructor: MyClass(..).
specifying a return this in a constructor
return outside method return outside method
you have a return dangling between classes. Perhaps you left the ; before the method {body} in when you converted from
abstract method to a real one.
return required Return required at end of MyClass Myclass(..).
specifying a MyClass return type on a constructor
serialVersionUID
serializable class XXX has no definition of serialVersionUID
required
Assign your class a serialVersionUID
/**
 * Defining a layout version for a class.
 * Watch the spelling and keywords!
 */
public static final long serialVersionUID = 3L;

should be declared in
Could not find the main class. Program will exit.
file
There is a problem with the Main­Class entry of manifest in the jar file. Possibly you got the package name wrong or the
case of the name off. The Main­Class must exist in an element of the jar filed under the package name as the folder. Possible
the Class you specified is missing a public static void main(Strings[] args) method. Check the gotchas in setting up the
manifest.
statement expected Statement expected.
missing } in a method
static not valid on
static is not a valid constructor modifier
constructor
You forgot your return type e.g. void, on a method.
static field should be
accessed in a static The static field Calendar.HOUR_OF_DAY should be accessed in a static way.
way.

You specified c.HOUR_OF_DAY where c is a Calendar instance reference. You should get at the static constant with
Calendar. HOUR_OF_DAY.
Tag @see : reference
Must have a class or method signature
not found
You should have something of the form @see java.lang.String or java.lang.String#indexOf(char). Most commonly you have
left off the parameters on a method. The target must be in the standard System Javadoc or in the Javadoc bundle. You can’t
point to a class whose Javadoc is not in the bundle.
superclass not found Superclass YYY of class XXX not found.
Did you remember to import the YYY class?
The type MyClass can’t be private. Package members are always accessible within the current
type can’t be private
package.
Top level classes can’t be private, only classes nested inside others.
type cannot be the type of this expression, 'double', cannot be promoted to 'int' by widening conversion.
widened
Java cannot automatically convert a double to an int. There are many options. See Converter Amanuensis for the code you
need.
type expected Type expected. identifier expected.

extra }, or literally a missing type, especially in constant declarations like: public static final SOMETHING=3; instead
of public static final int SOMETHING=3;
Executable code has to be inside some method, in a static initialiser block or in an instance initialiser block. It can’t be
just dangling inside a class or outside any class. Check that your {} are balanced. Code you think is in a method may
actually be outside because of an extra unbalanced }.

Eclipse error: Type safety: Unchecked invocation sort(List<X>) of the generic method
type safety
sort(List<X>) of type Collections X
You forgot to generify your X implements Comparable<X> and similar differences for generics documented under
Comparable.
type safety: erased Type safety: The cast from Object to ArrayList<String> is actually checking against the erased type
type ArrayList.
The compiler is warning you that the cast you are doing is only ensuring the Object is an ArrayList. It can’t tell if it truly is
an ArrayList< String>. If it isn’t, on your head be it. If it is not really an ArrayList< String> expect a ClassCastException as
soon as you do a get, even though there are no explicit casts near the get in your code. The problem in essence is that
serialized objects contain no record of their generic type. Many think that design decision was a big mistake.
unable to resolve class anable to resolve class: xxxx
This happens when genjar is building a jar. It can be caused by a missing class file that is needed for the jar, but more
frequently is just happens for no apparent reason. You can try rebooting is case the problem is some other application has the
needed class file locked. Earlier versions of genjar did not even tell you which class file it was having trouble with.
unchecked cast warning: [unchecked] unchecked cast
This is a subtle problem. The root cause of it is type erasure. All information the compiler has about generics is erased from
the run time. You did a run­time cast that would require the run time to have knowledge of the generic information. In Java
version 1.5 or later, you can use a @SuppressWarnings to pat the compiler on the head and say There there. I know what I
am doing. Not to worry.

unchecked conversion Warning: [unchecked] unchecked conversion
You used a Collection without generifying it. If it is not obvious what the problem is, recompile with javac.exe ­
Xlint:unchecked *.java
unclosed character
unclosed character literal
literal
Single char literals are enclosed in ’s. Strings, including empty and 1­character Strings are enclosed in "s. You may have
used an invalid representation for a char literal. You may have tried to put a string of more than one character between the 's.
char literals that need quoting include: '\"', '\'', '\n' and '\\'.
unclosed string literal unclosed string literal
String literals are enclosed in " characters. Check the lead and trail character to make sure it is indeed a " not something
similar looking. Check for awkward characters (e.g. " ' \ ) embedded in the string and make sure they are preceded by a \. For
a string made up of pieces, make sure there is a + between each pair.
undefined reference to
undefined reference to main with gcj.
main
If you are using the gcj Java compiler, you left off the ­­main command line option or you screwed it up in some way. It
needs the fully qualified name of your main class, which will necessarily have a public static void main method.
Undefined variable x; or Variable x in SomeOtherClass not accessible from MyClass Incompatible
undefined variable
type for =.

caps on a variable reference
missing variable declaration

unexpected symbols Unexpected symbols ignored.
You just coded a snippet. All code has to live inside a method and all methods have to live inside a class. The only exception
are static and instance initialisers, which must be contained in {} inside a class.
unqualified
unqualified enumeration constant name required
enumeration required

This is the Java version 1.5 or later enum type checking catching you. Your enum constant on a case is not of the same type
as the variable in the switch.
unreachable statement statement unreachable
You have written some code that could never be executed, e.g. you put some code immediately after a throw or return
statement.
unreported exception Unreported exception java.text.ParseException; must be caught or declared to be thrown.
The code potentially throws an exception. You must either wrap it in a
try {…}
catch (ParseException e) {…}
or put a throws declaration on the method to let the caller deal with it.
unsorted switch Unsorted lookup switch
Java won’t let you have two different symbolic constants as case labels if they have the same numeric value, even if they
label the same block of code.
void type 'void' type not allowed here
You are using a method that does not return a value in a place where a value is required such as the right side of an equal
sign or a parameter to another method.
weaker access Attempting to assign weaker access privileges; was public.
The original method you are overriding was public. Your overriding method must be public too. This often happens when
you implement a method in an interface. All methods in an interface are implicitly public abstract. However, when you
implement them, you must explicitly specify the public.

{ expected Syntax: { expected after this token

Look for a missing { slightly before where it is complaining.
Usually it means you put a semicolon where one was not supposed to be ahead of a {, such as at the end of an
implements or extends clause. There are many errors of this type the compiler cannot catch because Java slavishly
copied C syntax. For example, getting your semicolons wrong in a for loop will generally not generate an error, just
give surprising results.

} expected } expected. Type expected. Identifier expected.

Missing } at the end of a class.
Missing } is on a line containing // before the }.
Failure to enclose initialiser code in {} or static {}.
Code has to live inside some method, or inside some initialiser. It can’t just be left lying out in the middle of the class
declarations.
forgetting static { } around class init code.
Perhaps 
// Oops, interfaces extend other interfaces,
// only classes can implement them.
interface X implements Y
   {
   // ...
   }

instead 
// Correct. An interface extends another interface,
// it cannot implement it.
// A class extends another class or implements an interface.
// An interface cannot extend or implement a class.
interface X extends Y
   {
   // ...
   }

balancing
CheckStyle
error messages
run time error messages

standard footer

This page is posted
http://mindprod.com/jgloss/compileerrormessages.html
on the web at:

Optional Replicator mirror 
of mindprod.com  J:\mindprod\jgloss\compileerrormessages.html
on local hard disk J:
Please read the feedback from other visitors, or send your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.

Canadian Mind Products 
IP:[65.110.21.43] 
Your face IP:[201.230.158.83]
You are visitor number
Feedback

Carnegie’s Values
In the 1800s rich people like
Carnegie felt obligated to
fund public works. His
libraries serve many
American and Canadian
Seleccionar idioma ​

run time error messages : Java Glossary
            Guardar  
* 0­9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (all)

You are here :
home
Java Glossary
R words
run time error messages
 

©1996­2017 2008­04­08 Roedy Green of Canadian Mind Products

  run time error messages
This table contains errors detected at run time.

  compile time error messages
error messages
exception

Index To Run Time Error Messages
menu
AbstractMethodError Handshake Alert NullPointerException
AccessControlException HeadlessException NumberFormatException
Applet not inited Identifier Expected OptionalDataException
Application Failed To Start illegal nonvirtual OutOfMemoryError
ArithmeticException: IllegalAccessError Pong
ArrayIndexOutOfBoundsException IllegalBlockSizeException security violation
ArrayStoreException IllegalMonitorStateException signal 10 error
bad configuration Image won’t paint StackOverflowError
bad magic number Incompatible types Start Service Failed
bad major IncompatibleClassChangeError StreamCorruptedException
blank Applet intern overflow StringIndexOutOfBoundsException
BoxLayout Can’t be Shared InvalidArgumentException Text does not display
Broken Pipe InvalidClassException TrustProxy
can’t create virtual machine InvocationTargetException unable to find certification path
CertificateException IOException unable to load for debugging
class file contains wrong class Jars Not Signed With Same Certificate Unable to locate tools.jar
class has wrong version JavaMail obsolete Unable to open file xxx.exe
ClassCastException JRE not installed unable to run
ClassFormatError Links UnavailableServiceException
ClassNotFoundException load: class not found UnmarshalException
ClientClientTransportException Method Not found UnrecoverableKeyException
ConcurrentModificationException MissingResourceException UnsatisfiedLinkError
ConnectException NoClassDefFoundError UnsupportedClassVersionError
Could not find main­class NoInitialContextException UnsupportedDataTypeException
Could not find or load the main class NoSuchElementException VerifyError
Could not reserve enough space for object
NoSuchFieldError wrong name
heap
does not contain expected NoSuchMethodError wrong version
EOFException in ZIP NoSuchProviderException ZipException
Exception in thread NotSerializableException

ExceptionInInitializerError NTLDR missing
Whenever you ask for help about an exception on a newsgroup make sure you include the following:

The complete error message and complete stack trace.
The source code for at least the lowest level class you wrote mentioned in the stack trace with the relevant lines in the stack trace
marked in the source listing.

Runtime Error Messages
Runtime Error Messages
Runtime Error Messages
Key What Runtime Says
Real Error / Possible Causes
AbstractMethodError AbstractMethodError
Thrown when an application tries to call an abstract method. Normally, this error is caught by the compiler. It could occur at run time only
if the callee were modified to make the method or enclosing class abstract without recompiling both caller and callee.
AccessControlException AccessControlException

This usually happens in unsigned Applets when you attempt to do something Applets are not allowed to do, such as read a file or
talk to a server other than the one you were loaded from. You are getting slapped down by the security sandbox. However, they also
occur in other contexts you would not think would be related to security, e.g. in RMI (Remote Method Invocation) when you have a
mangled serialised object, or if you try to register a duplicate RMI service name.
Oracle bug number 4809366 : The Bea JVM fails to give permission for getClassLoader even when you ask for AllPermissions.
One common way to get in trouble is to use absolute URL (Uniform Resource Locator) s in your unsigned Applet. The Applet will
then work on one website only, or locally only. Instead, use a relative URL and convert it to an 
import java.net.URL;

// ...

URL url = new URL( absoluteOrRelativeUrlString );

if ( url.getProtocol().length() == 0 )
   {
   // convert relative URL to absolute
   url = new URL ( getDocumentBase(), url.getPath() );
   }

Watch out for this one. Sometime when you test your Applets locally they work, but when you use them on the web they fail with
AccessControlException. Remember, Applets are not supposed to read files, though you can do an AppletContext. showDocument.
You can however, read resources in the jar file.

Applet not inited Applet not inited

You are using Internet Explorer which has a defective or missing Java.
Missing package statement.
These erroneous Applets will often work with the Java Plug­in, or when run locally, but will fail with native Javas when run on the
web.
There can also be problems with your jar file having too much or too little qualification of class names. Your <APPLET CODE=
must have nothing but the class name, without the .class.
Make sure the case and name exactly match the name of the *.java file, *.class file and class name. For a class in a package this
would have dots in it, e.g. com.mindprod.mypackage.Myclass, but it would not have any directory qualification.
Your CODEBASE= parameters must have an absolute http://­style reference to the base directory where the code is stored.
For a local hard disk, the only thing I could get to work reliably on NT with all browsers and AppletViewers is leaving the
CODEBASE out entirely. You may find for your platform you have to code it something like this: ///C|//MyDir/ or C:\MyDir\.
Your ARCHIVE= parameter must have a list of the jar files, separated by commas. If you have too little or too much qualification,
or if you fail to use the file naming conventions of your server, you will be in trouble.
You tried to do something in an unsigned Applet only signed Applets are allowed to do such as reading restricted system properties,
perhaps indirectly via Color. getColor.

Application Failed To Start The application has failed to start because its side­by­side configuration is incorrect.
Most likely you are using the Microsoft Express C++ compiler to create your JNI (Java Native Interface). It links to a run time library
which is not present. You need to put the necessary redistribution support DLLs (Dynamic Link Libraries) on the path, or install the entire
C++ run time library on all client machines. The catch is other vendors may do the same thing and you can have versioning problems,
more commonly known as DLL (Dynamic Link Library) hell. Some compilers allow /MT or /LD static linking to create a standalone DLL
that does not require a run time, but Express 2008 will not.
ArithmeticException: ArithmeticException: / by zero
You divided by 0. If it occurred in a paint method, likely this occurred as a result of creating a Font with zero height.
ArrayIndexOutOfBoundsException ArrayIndexOutOfBoundsException
You have used an array index outside the allowable range. There may be several array references x[i] in the same line. Don’t leap to
conclusions about which one caused the trouble. Arrays are indexed from 0 to x.length­1, not 1 to x.length the way FØRTRAN
programmers are used to. When you allocate the array you specify the length something like this:
// assigning ram to hold an array of ints
int[] x = new int[ 10 ];

array initialisation
ArrayStoreException ArrayStoreException
The rules of casting arrays and casting the elements of arrays are subtle. See the gotchas.
bad configuration Bad installation. No jre found in the configuration file.
If you got that error message while trying to launch a JWS (Java Web Start) application, it means your deployment files are corrupt. This
is easy to fix. At the command line, type javaws.exe ­viewer. Then delete all the applications. Then launch your apps again.
bad magic number Bad magic number

The first four bytes of a class file are supposed to say CAFEBABE in hex. They don’t.
Most likely the problem is you uploaded your class file to your Web server using FTP (File Transfer Protocol) ASCII (American
Standard Code for Information Interchange) mode instead of BINARY mode which mangled the class file.
Oracle bug number 4151665 : Sometimes when a class is not found it gets reported as corrupt instead.
Novices get this error when they try to run a program without compiling it first e.g
rem oops, javac.exe takes *.java
rem java.exe takes *.class without the .class extension.
java.exe MyClass.java

If the class file seems ok, consider the possibility some other class file on the classpath is the one the ClassLoader is looking at.
See ClassFormatError

java.exe
javac.exe
bad major Bad major version number
Most likely your class files use a more recent version of Java than the Java runtime you are using. This most commonly happens with
Applets in Internet Explorer which supports only an ancient version of Java.
Applet works fine run as application, but shows a blank screen without any error message when run
blank Applet
as an Applet. There is not even an Applet loading message.
Check the <applet code=com.mindprod.mypackage.Myclass.class tag. It is spelled code not class.
BoxLayout can’t be shared. BoxLayout can’t be shared.
You wrote something like: 
JFrame.this. setLayout ( new BoxLayout( this, BoxLayout. PAGE_AXIS ) ); 
instead of: 
JFrame.contentPane.setLayout ( new BoxLayout( contentPane, BoxLayout. PAGE_AXIS ) );
Broken Pipe Caused by: java.lang.RuntimeException: Broken Pipe!
Your pipe connection stopped working. You may have run out of scratch disk space. You may have clogged RAM (Random Access
Memory) by failing to release resources. Your compressed datastream may be corrupt. The process reading a pipe may have closed it, so
you can’t write more data to it.
can’t create virtual machine Could not create the Java virtual machine
You wrote java ­xxxx.jar instead of java ­jar xxxx.jar
java.security.cert.CertificateException: No subject alternative DNS (Domain Name Service) name
CertificateException
matching xxx.com
You are trying to connect to some site on the web with SSL (Secure Sockets Layer). Its certificate is defective. Use the Comodo SSL
Analyser to examine the suspicious certificate. One of the alternative names should exactly match the hostname. (The analyser will not tell
you about the certificate chain. However, the Chrome browser will if you click the green lock to the left of the URL.) If there is no match,
suggest to that website they rename the host or get an amended certificate.
CharConversionException CharConversionException
Typically you are reading a UTF­8 stream and encounter an illegal binary pattern that has no meaning.
class has wrong version class file has wrong version 49.0, should be 48.0
You trying to run class files compiled with JDK (Java Development Kit) version 1.5 on an older JRE (Java Runtime Environment) version
1.4.

class file contains wrong class. Please remove or make sure it appears in the correct subdirectory of
class file contains wrong class the classpath.
If the name of your class is HelloWorld then the name of the source file must be HelloWorld.java and case matters. You also get this error
if you have the wrong or missing package statement. You could also have the source file in the wrong directory if you have a complex
package structure. If your package is called com.mindprod.com.mindprod.mypackage and your class MyClass, then you had better be in
the root directory and the class file for MyClass hand better be called MyClass.class and better live in com/mindprod/mypackage, with
matching case!
ClassCastException ClassCastException
You have cast a Class object to a Class that is not the same class or a super class of the Class object. This exception happens when
you cast a generic reference to an Object to an invalid class. You must cast it to the class of the Object or one of its superclasses.
You can find out what class the Object actually is with getClass().toString().
You can cast null into anything without raising a ClassCastException. Generally, this is a Good Thing™. Otherwise every cast
would need an if to specially handle the null case. You might be tempted to count on ClassCastExceptions to filter out nulls for you.
The following code will not raise a java.lang. ClassCastException:
Cat c = null;
Object o = c;
Dalmatian d = (Dalmatian)o;

In other words, there is one universal representation for null, not a special one for each class. For more detail see gotchas.

If the error message complains you have tried to cast class X to class X, it is complaining that the two different class Xes belong to
different class loaders. Even though they have the same name, they are treated like logically separate classes.
If the ClassCastException occurs during a sort, chances are you forgot the implements Comparable. See the gotchas for details.
If you write a factory method like this:
// typical factory method, that overrides a similar method in the base class
protected CameraButton cameraButtonFactory ( int buttonNumber )
   {
   return new LabelledCameraButton ( buttonNumber, this );
   }

and it seems to be producing the wrong kind of objects — ones from the base class’s version of the method, check the precise
spelling and signature of the method. It had better exactly match the one in the base class. If it does not exactly match, it will not
override. To guard against this error Bali proposes an explicit overrides keyword.

ClassFormatError ClassFormatError

You mangled the class file FTP upload by doing it as ASCII instead of binary.
Further, your web server must be configured to send *.class files as binary rather than ASCII. It needs a MIME (Multipurpose
Internet Mail Extensions) configuration entry to define *.class files. See MIME for details.
Sometimes it is actually a CLASSPATH problem. It can’t find the class.
ClassFormatError: class already loaded. You have a class file twice on the classpath. It has nothing to do with the DLL already
being loaded. Thankfully, having a DLL still loaded from the last time you ran is not considered an error.
ClassFormatError: bad major version. Your ancient 1.1 Java runtime does not know what to do with a program compiled under JDK
1.4..

ClassNotFoundException ClassNotFoundException
Thrown when an application tries to load a class through its string name using Class.forName, ClassLoader. findSystemClass or
ClassLoader. loadClass. It is similar to NoClassDefFoundError.

this occurs only at run time. Usually it means a class that was present during compilation has disappeared, or the classpath has
changed so it is no longer accessible. It could also happen if you dynamically load a class and the class is not on the classpath.
Are you spelling the fully qualified class name correctly on your Applet tag. Case matters. Double check the case of every letter.
The class itself references another class that can’t be found. Are you using APIs (Application Programming Interfaces) from
versions of Java that aren’t supported by your browser?
Try specifying CODEBASE=. as an Applet parameter, to ensure that the browser is looking in the right place.
Are there packages involved? If so, the Applet class needs to be in a package­appropriate subdirectory, or better still in a jar, not in
the same directory as the HTML (Hypertext Markup Language) file. If not, you ought to look into putting every class in a some
package before you deploy code; the default (nameless) package is intended only for test code that won’t be distributed.
Look at your jar with WinZip. Are all the classes and package names correct with the correct case? Make sure all the case
information is perfect on your jar­building line.
Class.forName(String) is short hand for Class.forName ( String, initaliseTrue, currentClassLoader). If the class you are looking for
was loaded by a different ClassLoader you won’t find the class.
If you are deploying with FStart, make sure you have included all the jars used in your JNLP (Java Network Launching Protocol).
You may have forgotten some that were on the classpath or in the ext directory that the app needs. Make sure you spelled all the jar
names correctly and they actually exist on the download site in the directory you expected.
In the Java control panel ⇒ advanced ⇒ Java plug­in, trying unticking the option enable the next generation Java plug­in.
If you have been playing games with class loaders, the problem can be that you are using the wrong classloader to load some
particular class. You might have meant: ClassLoader. getSystemClassLoader, or Thread.currentThread (). getContextClassLoader()
or some other. Keep in mind that the same class loaded in different classloaders are effectively different classes.
See bad magic number

ClientClientTransportException com.sun.xml.internal.ws.clientClientTransportException
You were using JAX to access AWS (Amazon Web Services) or something similar. A request failed. You can catch the more general
javax.xml.ws.WebServiceException instead.
ConcurrentModificationException ConcurrentModificationException
You tried to delete or add to a Collection while you were in the middle of running an Iterator over it. To get around this, you must remove
elements via the Iterator object using Iterator.remove rather than the usual Collection. remove. You can add elements if you use
ListIterator.add. See sample code. The problem also shows up if you remove elements on one thread while another thread is iterating.
Oddly you also get it with
// this fails with a ConcurrentModificationException
for ( String s: SomeStringSet )
To fix that, export to an array and iterate over that.

ConnectException java.net.ConnectException
You were probing a server on the net. A request timed out. You can catch the more general java.net.SocketException or
java.io.IOException instead.
Could not find or load the main
Could not find or load the main class in com.mindprod.setclock.SetClock
class
Your main method must look exactly like this: public static void main(final String[] args) You can leave out the final. Do not add any
throws clauses!
Could not find main­class com.mindprod.setclock.SetClock in
Could not find main­class
http://www.mindprod.com/setclock.jar
Check that you have the correct package name and class name in the Java source, in the *.mft file and the *.jnlp file line <application­desc
main­class=com.mindprod.setclock.SetClock />
Could not reserve enough space for Error occurred during initialization of VM. Could not reserve enough space for object heap. Could
object heap. not create the Java virtual machine.
You asked for too much RAM on java.exe ­Xmx parameter.
myClass.class does not contain myClass as expected, but MyClass. Please remove the file. Class
does not contain expected
myClass not found in new.

missing caps on new MyClass() reference.
missing caps on MyClass() obj declaration.

EOFException in ZIP java.io.EOFException: Unexpected end of ZLIB input stream
Try using ZipFile instead of ZipInputStream to read a zip created by ZipOutputStream. See Zip for why.
ExceptionInInitializerError ExceptionInInitializerError

You wrote some code like this:
// one way to trigger an ExceptionInInitializerError
private static final int a;

static {
 // someMethod throws some sort of Exception
 a = someMethod();
}

If the class you are loading throws an Exception during the static initialisation, it will show up as a ExceptionInInitializerError rather
than the original Exception, which your code may not be prepared to handle. When your code later goes to use the class, you will get
a NoClassDefFoundError.
If you get this error when you run in Netscape, but not when debugging, check that all your class files are being included in the jar
file.
Catch the Exception in the init code and do an e.printStackTrace( err ) to get more detail on what is going wrong.

Exception in thread main java.lang.IllegalArgumentException: Comparison method violates its
Exception in thread
general contract!
You have written a Comparator that violates transitivity. If A > B and B > C then it must be that A > C
Handshake Alert handshake alert: unrecognized_name
Thrown when Java tries to connect with an improperly configured SSL server. Fix by turning off check with system property
jsse.enableSNIExtension=false. Get more info with ­Djavax.net.debug=all
HeadlessException HeadlessException
Thrown when code that is dependent on a keyboard, display, or mouse is called in an environment that does not support a keyboard,
display, or mouse. Check the java.awt.headless=true Java System property. If you are using X11, check that the DISPLAY environment
variable points to the X11 server.
IllegalAccessError IllegalAccessError

In Netscape, inner classes can’t seem to access private variables of the enclosing class. You don’t discover this until run time.
Failing to use both the <APPLET ARCHIVE= parameter to specify a comma­delimited list of jar file names and the CODEBASE=
parameter in the form of an absolute http://­style reference to where the jar file is.
Generally problems with CLASSPATH, CODEBASE and ARCHIVE.
Classes in jar have the wrong amount of qualification stored with them.
Classes in packages are not stored in the correspondingly named directories. See CLASSPATH and java.exe in the Java glossary for
a fuller discussion.
Using an old library with new code. In the old library a method might be private where in the new it might be public.

javax.crypto.IllegalBlockSizeException : Input length must be multiple of 8 when decrypting with
IllegalBlockSizeException
padded cipher.
Literally, the problem is the message to be decrypted is not a multiple of 8 bytes, when the encryption padding algorithm should have
made it a multiple of 8 bytes. Possible causes:

The message was truncated or garbled in the process of storing, armouring or transmitting it. Dump it out in hex immediately after
encrypting and immediately before decrypting to make sure it is identical.
You specified different encryption and decryption algorithm options.
For good measure, make sure both the encryption and decryption were done with the same version of the JCE (Java Cryptography
Extension).

An IllegalMonitorStateException thrown when an object’s wait(), notify(), or notifyAll() method is
called from a thread that does not own the object’s monitor. In other words, the Thread using these
IllegalMonitorStateException
methods must be executing inside a synchronised block locking on the object whose wait etc.
method you are calling.
illegal nonvirtual Illegal use of nonvirtual function call
An inner class is not permitted to call private methods of the enclosing outer class. It is permitted to call protected methods. This error
message appears in the old Symantec 2.5a Java only when you have debugging turned off. Normally the compiler should catch this error,
but if it doesn’t it will show up at run time with this strange error message.
Image won’t paint Your app uses drawImage, paintComponent or simply Container.add. Yet nothing appears.
See the list of possible causes.
Identifier Expected When generating Javadoc, you get Identifier Expected
You are using old version of javadoc.exe that does not understand the newer Java syntax, or perhaps you are trying to generate Javadoc
before you have a clean compile.
Incompatible types Incompatible types, found : java.lang.Object, required: java.io.File: for ( File file : wantedFiles )
Make sure you declare your File collection class with implements Iterable< File> and its iterator method with public Iterator< File>
iterator()
IncompatibleClassChangeError IncompatibleClassChangeError

You forgot the static on your main method.
Any illegal use of a legal class.
You have made a change to a class and are still referencing it from an another class by its old signatures. Try deleting all class files
and recompiling everything.

intern overflow OutOfMemoryError: string intern table overflow
You have too many interned strings. Some older JVM (Java Virtual Machine) ’s may limit you to 64K Strings, which leaves perhaps
50,000 for your application.

InvalidAlgorithmParameterException: Prime size must be multiple of 64 and can only range from
InvalidArgumentException
512 to 1024 (inclusive).

In the Diffie­Hellman handshake for SSL/TLS you need a prime. Neither 512 nor 1024 are primes, so they are using some imprecise
vocabulary. The other end is insisting on using a prime not in the range. You can bump it up to either 1024 or 2048 with:
// increase limit of Diffie­Hellman key size to 1024 or 2048
System.setProperty( "jdk.tls.ephemeralDHKeySize", "2048" );

This is the problem with SSL. It is implemented as a Chinese menu. You can’t count on universal connection. All you can do is try a third
party SSL implementation (e.g. BouncyCastle) in your Java. RFC 3526 defines primes up to 8192 Java is a bit behind the curve. IBM
(International Business Machines) says 1024 bit primes are too weak. In other words, Java only supports keys considered too weak. Diffie­
Hellman has two key sizes: the discrete log key size, and the discrete log group size. These map onto q and p respectively. Reasonable
sizes for them, as of 2016, are 256 bits for q and 2048 bits for p. If you want security for a decade into the future, you should look for 3072
bit keys.
java.io.InvalidClassException: local class incompatible: stream classdesc serialVersionUID =
InvalidClassException
­3714695503693357733.

You serialised some objects, then modified the class source code a tad, say by adding another convenience constructor. Java
panicked and decided the old objects were no longer compatible when you tried to read them back in. You can soothe it by manually
assigning your objects class version numbers with 
// manually assigning a serialVersionUID, usually just 1, 2, 3 ...
// It marks class files that are nearly the same with a unique number to identify the
static final long serialVersionUID = 99999999999999L;

It is up to you to change that number any time the class changes in a way that would affect the old object’s ability to be read back
with the new class definition. Java has some flexibility for the old and new objects not to have a perfect match. serialVersionUID is
a magic variable name. Spell it exactly like that. If you have used a serialVersionUID, perhaps you have actually changed the layout
of the class fields without a new serialVersionUID. Finally, perhaps you failed to provide a no­arg constructor.
You serialised some objects, then changed the format of the objects, rightly changed the serialVersionUID, then tried to read the old
object back with the new class definition.

Oracle’s Java 1.8 documentation on : InvalidClassException

InvocationTargetException java.lang.relfect.InvocationTargetException
This is a wrapper exception. You will get one if a method or constructor you invoke with reflection throws an exception. Because the
compiler cannot analyse methods called through reflection, the reflection runtime wraps any errors thrown in the called routines in a
predictable exception called the InvocationTargetException which you can catch. Use InvocationTargetException. getCause and
InvocationTargetException. getTargetException to find more details. One way to trigger one is to initialise variables in an Applet rather
than setting their initial values in the init method.
IOException IOException: invalid header field

Something went wrong with I/O, usually you got the filename wrong or presumed the wrong default directory.
If you get it in jar.exe, your manifest is malformed.
Main­Class: com.mindprod.canadiantax.CanadianTaxCalculator
Note, there is no space before the colon and exactly one afterwards. There must be a line feed at the end of the line. There is no
.class on the end.

Jar Not Signed With Same
Your JAR­resources in JNLP­File are not signed from the same certificate.
Certificate
You will have to resign all jars mentioned in the JNLP file with the same certificate.
JavaMail obsolete You have an obsolete JavaMail or Java Activation Framework jar.
Make sure you don’t have more that one mail.jar or jmf.jar on the classpath/ext directory.
The application has requested a version of the JRE (version 1.5+) that currently is not locally
JRE not installed
installed.
If the JRE is not installed, install it. Normally, you only need the latest version,1.8.0_131, none of the older ones. This is a common Java
Web Start problem. The JRE is indeed installed and works fine for non Java Web Start apps. Java Web Start apps sometimes work fine
launched from a browser, but fail when launched from a desktop shortcut. My theory is somehow the registry or the Java Web Start
development cache gets corrupted in a way that causes Java to use a version of javaws.exe with the wrong matching directory. There will
be at least three copies on your machine C:\Program Files\java\jre1.8.0_131\\bin\javaws.exe, J:\Program Files\java\jdk1.8.0_131\
\bin\javaws.exe and C:\Windows\System32\javaws.exe.

Kludges around the bug include:

Always launch Java Web Start apps inside a browser.
Create your own desktop shortcuts with an explicit link to a local copy of the *.jnlp file and possibly
C:\Program Files\java\jre1.8.0_131\ \bin\javaws.exe if you are unsure associations are set to use that version of javaws.exe.
Explicitly launch the JRE javaws.exe with C:\Program Files\java\jre1.8.0_131\ \bin\javaws.exe ­viewer and use it to launch your
apps or create your shortcuts.

Here is how to fix the problem permanently. Unfortunately, this is a difficult, time­consuming procedure and does not always work:

1.  Uninstall any JREs and JDKs including the SQL (Standard Query Language) database.
2.  Manually strip out any remaining JRE/JDK files, including those in C:\Windows\System32 and C:\Users\
user\AppData\Roaming\Sun\Java\Deployment\cache.
3.  Manually delete any references to the JRE/JDK from the registry.
4.  Remove any Java Web Start desktop shortcuts or menu items.
5.  run a registry cleaner.
6.  run NTRegOpt.
7.  Reboot.
8.  Reinstall the JDK with associated JRE, making sure you select a drive explicitly for each of the three pieces, the JDK, the database
and the JRE.
9.  Fix up the set environment and the ext directories.

load: class not found load: class X not found
Likely you are using Microsoft’s ancient old JVM in Internet Explorer that supports only up to Java 1.1.4. Check which version of Java
you are using with Wassup. Make sure you are using the most recent JRE in C:\Program Files\java\jre1.8.0_131\.

method not found method X not found
This is caused by using obsolete jar files. The version of the class in the jar is missing the method, but at compile time, the java file had the
method. The way to avoid this is to do a clean compile periodically deleting all class and jar files and rebuilding them.
MissingResourceException MissingResourceException: Can’t find bundle base name …
The resources you need are missing from the main jar or the jar they live in is not on the classpath. Keep in mind that jars have an internal
manifest classpath and Java Web Start using the JNLP file to locate the jars.
 NoClassDefFoundError NoClassDefFoundError
 
Detail from The Scream, by Edvard Munch

java.lang.NoClassDefFoundError: mypackage/ MyClass 
This one is a bitch to track down. It has so many causes. Java is so picky! A misplaced comma, quote, semicolon, extraneous extension or
even the wrong upper/lower case can derail the whole program. I hope some will implement the NoClassDefFoundError Amanuensis to
make the problem easier to track down.

Sun explains that it is thrown when Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a
normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found. The
searched­for class definition existed when the currently executing class was compiled, but the definition can no longer be found. It is
similar to a ClassNotFoundException. This gives you the hint that a NoClassDefFoundError problem was not with caused by a 
Class.forName.

1.  Essentially the problem is the place and name where you put the class file, free­standing on disk or inside a jar, does match the place
and name it should have, based on the classpath, the package name and the class name. Everything is case­sensitive and sensitive to
the tiniest typo. Unfortunately, there is currently no tool to tell you where the class should be placed (usually there are several
possibilities) or where it is now.
2.  You got the class name wrong on the java.exe command line. It must include the full package name and class separated by dots,
without the *.class e.g.
java.exe com.mindprod.converter.Convert
not just the class:
java.exe Convert
Newbies often get in trouble by adding a *.java or *.class suffix. In contrast, javac.exe demands the *.java extension.
3.  You get an error message like this: Exception in thread main java.lang.NoClassDefFoundError: XXX/java. When attempting to
compile, you keyed java.exe XXX.java instead of javac.exe XXX.java.
4.  Java can’t find the class mentioned. It is missing from the jar or classpath. Java may need it because it occurs as a class or superclass
in a serialised ObjectStream or because you called a method of that class. You don’t find out about the problem at compile time or
even load time. You only find out when you actually go to use that missing class. The missing class was present when the class
referencing it was compiled (perhaps on somebody else’s machine) but the missing class is no longer accessible. To fix a vanilla
NoClassDefFoundError, search the all the jar files on your machine for the missing class. Funduc Search and Replace will do that. If
you can’t find it, scour the web for a download. When you find it, make sure its jar is on the general classpath, the project classpath,
the command line classpath or in the ext directories of the various JREs (Java Runtime Environments) you have installed. There will
be at least two ext directories.
classpath
5.  Three diagnostic tools you may find helpful:
1.  To dump the classpath that you are actually using at some point in your code insert: You must first determine if the classpath
is correct with: 
// discovering system properties relevant to the classpath
import java.util.Properties;
//...

// the classpath
out.println( System.getProperty( "java.class.path" ) );

// extension directories whose jars are included on the classpath
out.println( System.getProperty( "java.ext.dirs" ) );

// low level classpath, includes system jars
out.println( System.getProperty( "java.library.path" ) );

// character to separate (not terminate!) entries on the classpath, ; for Windows
out.println( System.getProperty( "path.separator" ) );

// To discover the default values for these properties, run Wassup either
// as an Applet or standalone (You will get quite different results each way.)
// See http://mindprod.com/applets/wassup.html

2.  If you have a jar or more than one class, assign each class to a package! Package­less classes are for one­shot, single­class
throw­away experiments only.
3.  Then when you are sure the jar or directory you want is truly on the classpath (it is not sufficient for the directory that the jar
is in be on the classpath), then check the contents of the jar with jarlook to make sure your package/class is in there, spelled
precisely, including case. You can download jarlook with source.
4.  download jarcheck as well. It will help you detect problems with unexpected target versions of class files in your jars.
6.  Recall that reconstitution of serialized files uses Class. forName to instantiate all the classes buried in the files. Genjar or equivalent
does not know to include these classes in your jar. It is up to you to include all the classes you need manually. You will keep getting
the dreaded NoClassDefFoundError until you have nailed them all.
7.  Look for a typo in spelling the class file name in the file or in the command line invoking its main method. Copy/paste to make sure
they are absolutely identical including case.
8.  Check your classpath. Make sure you used semicolons or colons as appropriate. Don’t specify null fields in your classpath, e.g. two
semicolons in a row.
9.  The problem is essentially either the class is not on the classpath or the classpath is wrong. You must first determine if the classpath
is correct with: 
// discovering system properties relevant to the classpath
import java.util.Properties;
//...

// the classpath
out.println( System.getProperty( "java.class.path" ) );

// extension directories whose jars are included on the classpath
out.println( System.getProperty( "java.ext.dirs" ) );

// low level classpath, includes system jars
out.println( System.getProperty( "java.library.path" ) );

// character to separate (not terminate!) entries on the classpath, ; for Windows : f
out.println( System.getProperty( "path.separator" ) );

// To discover the default values for these properties, run Wassup either
// as an Applet or standalone (You will get quite different results each way.)
// See http://mindprod.com/applets/wassup.html

10.  If your program used to work and it suddenly stopped working, did you upgrade your JDK/JRE? If so, you likely forgot to copy over
the jars to the C:\Program Files\java\jre1.8.0_131\\lib\ext and C:\Program Files\java\jre1.8.0_131\ \jre\lib\ext\ directories.
11.  You wrote some code like this:
// one way to trigger an ExceptionInInitializerError
private static final int a;

static {
 // someMethod throws some sort of Exception
 a = someMethod();
}

If the class you are loading throws an Exception during the static initialisation, it will show up as a ExceptionInInitializerError rather
than the original Exception, which your code may not be prepared to handle. When your code later goes to use the class, you will get
a NoClassDefFoundException.
12.  If you see the phrase wrong name in the error message, it means you are not consistently naming the packagename. ClassName
everywhere. Perhaps you left off the packagename, or got the case wrong, or made a typo in either the package or class name.
13.  If you have two packages that use classes from each other, each jar must have all the classes of the other package that it uses, or that
it uses indirectly uses.
dependencies
14.  You must put the ­classpath option before the class name on the java command line. To remember the order, you can think of it like
this. Java.exe needs to know the classpath before it can search for the class.
15.  You got package name wrong at the top of the source file, or left it out entirely. It does not match the one when you built the jar. It is
case­sensitive.
16.  If this is an Applet, you got the <applet code=com.mindprod.mypackage.MyClass.class wrong. Perhaps you forgot the package part
of the name or you forgot the .class. The package names in the jar may not be right. The <applet archive=myjar.jar may not match a
jar file containing the needed class.
.jar
Applet
17.  If you use java.exe ­jar, it ignores your classpath environment variable and any ­classpath option without comment! All your classes
must be in the jar.
rem Vainly attempting to add an auxiliary mail.jar.
rem It has to go in the bulk.jar manifest Class­Path entry instead.
java.exe ­cp C:\javamail­1.3.3_01\mail.jar ­jar bulk.jar

won’t be able to find any of the classes in mail.jar. You must copy mail.jar to the ext directory or mention the mail.jar in the
manifest Class­Path: entry.
18.  Did you remember to include. on your classpath?
19.  If you got the exception trying to execute a class in a jar, check with WinZip that the pathnames inside the jar on that class exactly
match the package structure, including case. If you don’t know what I am talking about, see jar for details. Make sure the class you
are trying to call has the expected package statement. Check the manifest to make sure the fully qualified name of the main­class is
properly specified.
20.  You are trying to use a program compiled under Java version 1.4 or later with an old Java 1.1.5 runtime, often the one in Internet
Explorer. The old class library is missing many of the new methods. Any other version mismatch where you run new code on old
runtimes can cause the similar problems. Check the runtime version
rem getting version of java.exe
java.exe ­version

java.lang.StringBuilder is one of the most likely candidates for a method from 1.5+ not available under earlier JVMs (Java Virtual
Machines).
21.  Have you got a simple HelloWorld working yet? If not, your problem may be in the way you installed the JDK or JRE. If you have
trouble, read up on Getting Started, javac.exe, java.exe and classpath.
22.  Java is case­sensitive. Have you got the name of the class spelled exactly the same way everywhere it is used, including the name of
the *.java file, with class names always starting with a capital letter and package names pure lower case?
23.  One of your static initialisers invokes a function that uses a static field not yet initialised.
24.  Did you remember to make your kickoff class, the one you mentioned in the java command line, public?
25.  Does your main method have signature exactly like this?
// what a main method declaration must precisely look like
public static void main( String[] args )
   {
   }

26.  Somehow your runtime is having trouble finding classes it could find at compile time. Check your CLASSPATH. Make sure all the
classes are available.
27.  Check your java.exe command line. Your current directory is crucial. You must specify fully qualified class names, without the
.class extension.
28.  Consider combining class files into a single jar file. Jars cause far less trouble than individual class files, especially when you export
them to a server or someone else’s machine.
29.  Check that your browser supports jar files. Fortunately, all the modern ones mentioned under browsers do.
30.  You can get this error if you try to run an Applet on an old browser since it will not have the needed classes.
31.  Watch \ and /. In string literals \ appears as \\.
32.  Make sure when developing classes for an extension i.e. class or jar files that live in the lib/ext/ folder, make sure you do not have
duplicate classes. Classes from extension folders will always be loaded before any other classpath, therefore making it impossible to
test other development versions not in the extensions folder. Make sure extensions *.jar’s are complete (i.e., not reliant any
additional classes). Make sure the *.jar in the extensions folder is up to date. Basically only thoroughly­tested, stable code should
live in the extensions folder.
33.  Have you accidentally used a system package name for your own classes?
34.  If every program gives NoClassDefFoundErrors, try uninstalling all Java tools and JDK s, clean out the registry and then reinstall.
Make sure you have only the latest Java on your machine.
JDK
35.  If your NoClassDefFoundError occurs only sporadically, here is a possible cause: You are running some classes in a jar file which is
stored on a network mapped drive in MS Windows. Sun keeps the jar files open in order to re­load classes which haven’t been used
in a while and occasional network problems will force the jar to close. The JVM doesn’t know to re­open the jar when the network
mapped drive reconnects and simply reports that various classes (different each time) no longer exist. The solution is either make
sure the network is reliable, use a network file system which doesn’t close if drives are temporarily unavailable, or locate all jar files
on local drives.
36.  If you change the jars used by your JSP (Java Server Pages) code, make sure you manually delete the generated class files (classes in
the WEB­INF tree for Caucho Resin). The womb won’t be smart enough to do that on its own and you will get all manner of
NoClassDefFoundErrors.
37.  If you have classes included in your project that don’t live in the same directory as the project, in Café you must also do a Project ⇒
Options ⇒ Directory ⇒ Classes to include their directories in the invisible CLASSPATH for the project. Simply including the java
or class files in the project is not sufficient. Other IDEs (Integrated Development Environments) may have similar gotchas.
38.  If your code works then suddenly stops working, chances are you have uninstalled a JRE/JDK or installed a new one and the current
JDK/JRE does not have the full complement of jars in the ext directory.

Sooner or later you will have to reinstall the JDK/JRE and you will lose your ext directories. You can quickly rebuild them if you
maintain a bat file like this and run it after every JRE/JDK install. Adjust the file to account for where your ext dirs are and where
the jars are you need.

@echo on
rem fixext.btm fix the ext directories for Java  2017‐03‐01 (MUST BE RUN AS ADMINISTR
rem Propagated as a snippet.
rem this file must be tailored before each use.
rem propagate changes to killanextfile.btm
pushd

echo building environment sets...

rem fix system copies of the environment, and local environment.

rem F:\Program Files (x86)\VC\bin\vcvars32.bat sets C++ sets up

set /E /S antVersion=1.10.1
set /E /S ANT_HOME=F:\Program Files (x86)\apache‐ant‐%antVersion%
rem ANT_HOME\bin must be on the path
set /E /S ANT_OPTS=‐Xms256m ‐Xmx3000m ‐XX:ReservedCodeCacheSize=192m ‐ea ‐Dsun.io

rem configure browser
set /E /S BROWSER="F:\Program Files (x86)\Mozilla Firefox\firefox.exe"
rem set /E /S BROWSER="F:\Program Files (x86)\Opera\launcher.exe"
rem set /E /S BROWSER="C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"

set /E /S CATALINA_HOME=F:\Program Files\apache‐tomcat‐%TomcatVersion%
set /E /S CLASSPATH=.;E:\;E:\exper

39.  Sometimes the problem is with your build. Try using ant and a script based on one of my examples. Ant has a better chance of
getting it right that some ad hoc build script.
40.  You overrode JPanel.getParent or perhaps some other crucial piece of Oracle’s code without reproducing its functionality typically
by calling super.xxx().
41.  Check the integrity of all jars. Some may have been truncated during upload. Verify with jarsigner.exe or winzip.exe.
42.  An the app works fine locally but fails when you deploy it on a server because you failed to upload all the class files needed to the
server (usually in jar form).
NoInitialContextException NoInitialContextException
You did a new javax.naming.InitialContext () when your program was not running inside a servlet womb which provides the default Initial
context factory. You can provide a factory class by naming it is a SET environment parameter, or a Java system property
java.naming.factory.initial. Here is some typical code: 
import java.sql.Connection;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.Datasource;

...

// These two calls are not normally needed. They are handled
// for you by the servlet womb.
System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
    "com.sun.jndi.fscontext.RefFSContextFactory");
System.setProperty(Context.PROVIDER_URL, "file:///tmp");

// accessing a database in TomCat using a Datasource.

// Obtain environment naming context
Context initalContext = new InitialContext();
Context envContext = (Context) initialContext.lookup("java:comp/env");

// Look up the data source, which knows the user/password/url/jdbc drivers etc.
DataSource ds = (DataSource)envContext.lookup( "jdbc/Mammals" );

// Allocate and use a connection from the pool
Connection conn = ds.getConnection();

// Get a statement from the connection
NoSuchElementException NoSuchElementException
You called Iterator.next when there were no more elements. You must either call isNext first, or use the for ( Thing: thing : thingCollection
) syntax which handles it all for you automatically.
NoSuchFieldError NoSuchFieldError
Likely you are mixing an old library with new code or vice versa. The definitions and references to a class differ in whether they include
some field. If you have source for the libraries, recompile everything to discover the precise error. If not, check to make sure you are using
the most up­to­date libraries (or ones of the appropriate vintage) and clean compile all your code making sure the libraries you run with are
also on the classpath at compile time. Compilation may clear up the problem or at least make it more specific.
NoSuchMethodError or
NoSuchMethodError
NoSuchMethodException

A method is missing, often main. If it is complaining about the main method, it must have
// what a main method declaration must precisely look like
public static void main( String[] args )
   {
   }

Did you forget the []?
Did you remember to compile? use javac.exe *.java to compile and java.exe com.mydomain.mypackage.MyClass to run. Try
del *.class 
javac *.java
Did you use a Java version 1.5 method with a Java version 1.1 runtime?
Did you run with a different version of a library jar than you compiled against? Perhaps the run time version of a class is missing a
method that was present in the compile time version. Perhaps a class was public at compile time, but package local at run time.
Check for duplicates of the jar. You might be accessing the wrong one.

NoSuchProviderException javax.mail.NoSuchProviderException
Use Transport.sendMessage not Transport.send.
NotSerializableException NotSerializableException
You forgot to put implements Serializable on the class you are doing a writeObject on. Since writeObject also writes out all the objects
pointed to by that object, by the objects those objects point to, ad infinitum, all those classes too must be marked implements Serializable.
Any references to non­serializable classes must be marked transient. While you are at it, give each of those classes 
// manually assigning a serialVersionUID, usually just 1, 2, 3 ...
// It marks class files that are nearly the same with a unique number to identify the pre
static final long serialVersionUID = 99999999999999L;

Oracle’s Java 1.8 documentation on : NotSerializableException

serialization
NTLDR missing NTLDR is missing

You are trying to boot from a non­system diskette (or disk) in Windows 95/98/ME/NT/W2K/XP/W2K3.
The crucial loader program used in booting has been deleted from your hard disk.

NullPointerException NullPointerException
If you try to execute a piece of code like this when s is null you will get a NullPointerException.
s.someMethod();

To learn about exceptions in general and try/catch to recover from them, see exceptions. Here are some of the possible causes:

A reference variable is null, when you used it to access a field or method.
Autounboxing can make NullPointerExceptions hard to track down. Innocent looking code like int result = getResult(); can throw a
NullPointerException if autounboxing is hiding what is really happening, namely int result = getResult().intValue(); It will fail if
getResult returns null instead of an Integer object.
Examine the stack trace to figure out where in the code it happening and how you got there. The stack trace shows the exact line the
problem was detected (not necessarily the line at fault though). That gives you a clue to get started. You can put some code of the
form:
// simple debugging code to check for null variables before
// they trigger a NullPointerException
if ( p == null )
   {
   out.println( "p was null" );
   }

// alternatively
assert p != null : "p was null";

Narrow it down to the precise variable giving the trouble. Then you have to sit and think about why that variable is null. The real
problem could be much earlier in the code and the problem propagated through to the point where it eventually surfaced as an
exception. You must figure out where it was supposed to be set and have a look at that code and why it is failing. Most of the time
you simply forgot to initialise. The easiest way to track the causes down is using a source­level debugger such as Intellij Idea or
Eclipse You can trace the flow of execution, or examine the state of the universe at the time of failure.
If you don’t want to use a debugger, pepper your code with assertions to track down just what is
// typical debugging code that prints a message if thing is null.
ensureNotNull( thing, "thing" );

// in JDK 1.4+ you can also do that with an assert.
assert thing != null : "thing is null";

Your ensureNotNull( Object toTest ) method might print an error message if toTest is null, then throw a new NullPointerException.
By making ensureNotNull final and using an if (DEBUG) inside ensureNotNull, the inline expansions will have no overhead in
production and you can leave the debugging assertions in place to be reactivated later if ever needed.
Most commonly you forgot statements of the form: myArray = new int[10]; or myThing = new Thing(); See the array initialisation
gotchas. These are the most common of runtime errors.
You may not call getParameter in the Applet constructor. Move that code to init.
Sometimes the problem is redeclaring a local variable with the same name as an instance variable. You might have initialised one
but not the other. Beware having two variables with the same name, one local and one instance, It is very easy to do inadvertently
and Javac will not warn you, though Jikes will e.g.
ArrayList thelist = new ArrayList( 149 );

instead
thelist = new ArrayList( 149 );
You work with the local variable thinking you are working with the instance variable and poof, your values are lost as soon as the
local goes out of scope, leaving the instance version null. This is the way I most commonly create NullPointerExceptions for myself,
when I convert a local variable to an instance one when I have to break a method up that uses the variable and forget to take out the
local declaration.
Be very careful calling any methods inside your constructors. If subclasses override them, you will be invoking the subclass’s
version, which may be attempting to use fields that have not been initialised yet. You won’t get a warning message! The problem
usually shows up as puzzling NullPointerExceptions. The way out is to move code out of the constructor, often to the addNotify
method. However, addNotify can get in analogous problem to the constructor since it too is overridden and it may use overridden
methods.
If the problem is in Oracle’s code that you call or indirectly call, (i.e. no source code line number) look at the place in your code
where you trigger the chain of calls. Insert some debug code there to examine the parameters and the fields in any objects you pass.
If you can’t track it from that, use a source code debugger like Eclipse that lets you follow program flow inside Oracle’s code. For
example, your code creates an event, asking it to operate on some null component and the problem does not show up until later when
the event is dispatched and handled by Oracle’s code.
The Nice language manages to detect NullPointerExceptions at compile time instead of run time the way Java does.

NumberFormatException NumberFormatException
In converting a String to internal int/ long etc. with parseInt or brethren, the number was not a valid string of digits. The usual problem is
leading or trailing spaces on your number. The sign must come ahead of the number, no commas. Localisation may have an effect on what
constitutes a valid number. Sometimes it can be the number is too big to fit in the int, long etc.
OptionalDataException OptionalDataException
Attempting to use readObject on a stream that does not contain objects, or attempting to read past the end of file.
OutOfMemoryError OutOfMemoryError
You have run out of memory. You have filled up virtual RAM with objects and the garbage collector can’t free any more RAM. You can
expand the effective size of virtual ram by putting options on the java.exe command line. See the­Xss64k ­Xoss300k ­Xms4m and ­
Xmx10m options described under java.exe. Perhaps you have read some ridiculously large number from a DataInputStream to use as the
size of an array. Perhaps you have used a method recursively without terminating at reasonable depth and filled memory that way.
profiler

Pong Pong sound
IBM Visual Age sometimes makes a noise like an elevator arriving every time you click anything. No error message is visible anywhere. It
means you are debugging a multi­thread program and a higher priority thread is blocking the one you want to debug.
security violation No error while developing. Security Violation in production.
Applets can only access the server they were loaded from.
signal 10 error Unexpected Signal : 10
Signal 10 is a bus error. It’s generally caused by attempting to perform an unaligned bus operation (for example, reading a long from an
odd address), so it isn’t something that will normally occur in a pure java application unless there is a bug in the JVM. If you have native
code in your application though, that could be the cause. On some platforms, an application will get a bus error if its executable file or one
of its shared libraries are replaced while the application is running.
StackOverflowError StackOverflowError Stack size too small Use java ­Xss to increase default stacksize.
These usually happen when you have recursion, a method that calls itself, perhaps indirectly via a second method. You have simply nested
to deeply. Another source of the problem is calling method x() or this.x() when you meant to call super. x(), usually when inside method x.
If you legitimately overflowed the stack, you may rescue yourself by getting the runtime to allocate more memory for the stack for each
thread with java.exe ­Xss128
recursion
Start Service Failed StartService FAILED 1056: Instance of the service is already running.
Just ignore this spurious error message. There is nothing the matter. Window is being prissy and chastising you for asking it to start a
service, when it already did so earlier.
StreamCorruptedException StreamCorruptedException
The object stream is scrambled. Perhaps you are trying to read human­readable data, e.g. something that was not prepared with
writeObject. Perhaps you have classes missing or the classes used in the stream are obsolete. Perhaps you tried to use append mode to tack
more onto the end of your stream file after it was closed and later reopened in append mode. That does not work.

Learning More
Oracle’s Java 1.8 documentation on : StreamCorruptedException
StringIndexOutOfBoundsException java.lang.StringIndexOutOfBoundsException: String index out of range

The parameters you gave to the substring, charAt, index or related String method were outside the range of the base String, or the start
point was after the end point. See substring gotchas. To track it down, dump the base String and the indexing parameters with System. out.
println.
SunCertPathBuilderException path.SunCertPathBuilderException: unable to find valid certification path to requested target
You are missing the root or intermediate certificates for the SSL website you are trying to connect to. They need to be imported into
cacerts..
Text Does Not display. In Java or HTML text you painted does not appear.
Check that you painted the foreground text in a contrasting colour to the background.
TrustProxy TrustProxy
Applets behind a firewall may not have access to DNS. You must encode your CODEBASE as an IP (Internet Protocol) instead of a DNS
name.
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path
Unable to find certification path
to requested target
You are trying to connect to some site on the web with SSL. You don’t have all the certificates you need in your cacerts. file. Normally, all
the certificates you need are built­in to cacerts.. Happily, you don’t need the site’s certificate, just the intermediate all the ones back to the
root. Click details ⇒ view certificate ⇒ Certification Path. Use google or look at the certificate roots page to find out where these root
certificates are posted. Then you can download and import them into cacerts. with keytool.exe.
unable to load for debugging Unable to load MyClass.class for debugging.

Symantec support suggests copying all the DLLs in VCP\JAVA\BIN to VCP\BIN to correct stability problems. If you do this, all
debugging will cease to function. Delete any DLL in VCP\BIN that also exists is VCP\JAVA\BIN.
Check that you fully qualified the name of your class with its package name, e.g. com.mindprod.business.TestDate in the Project
section of Visual Cafe, no trailing .class and that the upper and lower case is precisely correct. Read the section in the glossary on
CLASSPATH and under java.exe on how packages, classnames, the directory structure and the CLASSPATH all interact. If that
does not solve it, I have bad news.
Windows 95 has the most incredibly inept scheme for dealing with DLLs from different vendors that just happen to have the same
8+3 name, (even when they are stored in totally different directories). Whichever application starts first gets its DLLs installed and
every other app that comes afterward has to use them. If you start some app before VC, it may load incompatible DLLs. To avoid
this, load VC first. Then the other apps may stop working. Phttt! Mr. Gates has guaranteed himself a seat in hell for this (and for the
confounded registry where all configuration information for all applications is lumped in one unrestorable basket). There should be
separate system DLLs and application DLLs with no possibility of DLLs provided by one vendor being foisted on some other. Try
starting Visual Cafe before any other app and keep it running. It stands a better chance then of getting its own DLLs loaded.

Unable to locate tools.jar Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre1.6.0\lib\tools.jar
It seems to be looking for tools.jar in the JRE instead of the JDK. Make sure all the JDK directories contain the expected files, including
tools.jar. I found that uninstalling the JRE and JDK and reinstalling them cleared this up. Especially for beta software you are safer to
uninstall and reinstall rather than install over top.
Unable to open file xxx.exe Fatal error (0): Unable to open file xxx.exe
In JET (Just Enough Time) when compiling, you forgot to terminate execution of your app before redoing the compile.
Unable to run MyClass.class: Check that you have properly specified name of the class containing
unable to run
main in your project settings.
Your SlickEdit vep project file is not in the same directory with the *.java and *.class files that compose the class containing Main.
UnavailableServiceException javax.jnlp.UnavailableServiceException: Running a JWS app without JWS.
If you run a Java Web Start apps and try to use the JWS service library, you will get this exception. You can only use that library in the
context of Java Web Start.
UnmarshalException java.rmi.UnmarshalException: invalid method hash.
Some possibilities:

the receiver does not have the needed class file.
the receiver and sender have different versions of the class file.
your stubs are out of date.
you screwed up something doing RMI. Try a very simple case and get that going, then gradually add complexity. When it stops
working you have a much better idea where to look for the problem.

UnrecoverableKeyException java.security.UnrecoverableKeyException : Cannot recover key
You gave the wrong password when you accessed the keystore with KeyStore. getKey.
 UnsatisfiedLinkError UnsatisfiedLinkError
This means you had some trouble loading a library containing native class implementations.

Use Wassup to determine the java.library.path system property. It is restricted, so make sure you flip the Wassup display from safe
to restricted. Your DLL must live either on that path, or in your jar without any package name. In Windows, look under System
Tools ⇒ Event Viewer ⇒ Application to see the event log of DLL problems for additional clues.
All your DLLs and all the DLLs they indirectly invoke must live on the java.library.path.
You must do a System.loadLibrary ( mylib ) [or System. load( C:\\libs\\mylib.dll ) for Windows] [or System.load ( lib/mylib.so ) for
Linux] before you can use any native methods of a class.
If you get the error after the class containing the native method is safely loaded, when you invoke a native method, make sure you
generated your *.h file with the fully qualified
rem preparing .h file for native methods for class
rem com.mindprod.mouse.Mouse
javah.exe ­jni ­o mouse.h com.mindprod.mouse.Mouse

not simply:
javah Mouse
If you get the error after the class containing the native method is safely loaded, when you invoke a native method, check that the
*.cpp method signatures exactly match those in the *.h file. You should see method names like this:
Java_com_mindprod_mouse_Mouse_GetMousePosition that start with the word Java and contain the package, class and method
name all strung together. Make sure you remembered to implement all the methods.
Put all your classes is a package. Package­less classes are just for tiny toy programs.
If you get the error on your System.loadLibrary ( mylib ) or System. loadLibrary( C:\\libs\\mylib.dll ) you may be missing the
missing native class/dll.
You have given your library the wrong name or specified the wrong name in the System.loadLibrary( mylib ). Details.
If you are getting the Exception on a System.loadLibrary( mylib ) try using System.load(C:\\libs\\mylib.dll) instead of the
System.loadLibrary(mylib).
Class name not properly qualified.
At least for debugging, move your loadLibrary call out of static init so you can catch the Exception and see the stack trace more
easily and debug trace more easily.
You need to regenerate the *.h and recompile the *.c file if you change the package name.
In order to execute JNI methods from a Netscape Applet, the class containing the native methods must be in the client’s system class
path for Netscape ( X:\Program Files\Netscape\Communicator\program\java\classes\). The DLL must be in the client’s DLL
classpath for Netscape ( X:\Program Files\Netscape\Communicator\program\java\bin\). If this is not done, you will be able to load
the library, but not execute methods on it. I suspect there is something broken in Netscape and System.loadLibrary. I have fooled
around with it for months and still cannot get it to behave reliably. See notes under JNI

UnsupportedClassVersionError java.lang.UnsupportedClassVersionError: Unsupported major.minor SomeClass version (nn.n).
You used a method that your JVM does not support. This most commonly happens when you target for Java version 1.6 but inadvertently
use a Java version 1.7 method. The compiler will not warn you at compile time. I run into it most commonly when I run jet whose run time
is Java version 1.6. The problem goes away when I use a Java version 1.7 JVM. Look at the since comments in the Javadoc to make sure
you are not using any too new methods. If you use the ­bootpath option to provide Java version 1.6 jars, then the compiler can warn you
about using a Java version 1.7 method. Try upgrading or reverting your JVM. This is likely a bug — some native method not prepared to
function under the current version. Try uninstalling all your java, purging the files, then reinstall your JDKs (Java Development Kits) and
JRE s, working from oldest to newest. The problem is caused by some sort of clash with code from one version interacting with code from
another. Watch your classpath. You could have no classes on it for a more advanced JVM than you are using. Check which version you are
using with:
java.exe ­version
or use Wassup for more detail.
UnsupportedDataTypeException javax.activation.UnsupportedDataTypeException: no object DCH for MIME type text/plain.
You have an obsolete JavaMail or Java Activation Framework jar.
VerifyError Exception in thread xxx java.lang.VerifyError: Accessing value from universalised register 2.

This was a compiler bug. It comes from redefining a local variable. Just use two different names. Could come from other compiler bugs.
Try using a the current JDK compiler. It can also come from using Outer.this from a non­inner class. In JDK 1.4.2+, the compiler should
detect the problem rather than runtime.
This is a NoClassDefFoundError where you got package name wrong at the top of the source file. It
wrong name
does not match the one when you built the jar. It is case­sensitive.
wrong version class file has wrong version 48.0, should be 47.0
You have partly a Java version 1.4 and partly an earlier version of Java installed. Check out each copy of java.exe and with the ­version
option. If necessary uninstall all JDKs and JRE s, prune the registry of references to Java, prune the hard disk of java directories and
reinstall from scratch. Watch out for any JDKs that came embedded with an IDE (Integrated Development Environment). Watch out
specially for the C:\WINNT\system32\java.exe. It too should be 1.4. You may have the rt.jar file from a different version.
ZipException java.util.zip.ZipException: The system cannot find the file specified.
Usually the zip file in question is the distribution jar containing your class files and resources. For some reason it can’t be found. You may
have misspelled it or used the wrong syntax to specify it.
Applet Tags
java.exe

CheckStyle
compile time error messages
error messages
Exceptions

standard footer

This page is posted
http://mindprod.com/jgloss/runerrormessages.html
on the web at:

Optional Replicator mirror 
of mindprod.com  J:\mindprod\jgloss\runerrormessages.html
on local hard disk J:

Please read the feedback from other visitors, or send your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.

Canadian Mind Products 
IP:[65.110.21.43] 
Your face IP:[201.230.158.83]
You are visitor number
Feedback
Great Ideas
Appear Absurd
If at first, the idea is not
absurd, then there is no hope
for it.
Errors
Don't take errors personally. Even experts spend much of their time finding errors in their programs.

This page only tells you what your error message means­­not how to fix it. That will depend on what you
intended your code to do. Don't attempt to fix your code until you understand why it's broken. 

Compile­Time Errors (Syntax Errors)

Don't pay any attention to the number of errors. Just read the first error message and work on fixing that
error. (Every now and then, the second error message will help you fix the first error.)

These errors are often caused by very small mistakes that are easy to miss, so there's no shame in having
someone else help you find the mistake. 

Error Message What It Usually Means
The parser was surprised by a symbol you wrote at or just before this
something expected
point.
Make sure that file is saved in the same folder as the file that refers to
cannot find symbol ­­ class
it.
You got the method name wrong, or you called it on the wrong
cannot find symbol ­­ method
file/class.
class, interface, or enum
You have too many closing braces.
expected
class is public, should be
Your class name and file name must match exactly.
declared in a file named
illegal start of expression You're missing a closing brace for the previous method declaration.
illegal start of type You wrote a statement that does not appear inside a method body.
incompatible types ­­ expected Make sure you understand why it found what it did, and why it
type expected what it did.
missing method body Your method declaration line has a semicolon.
The compiler found a pathway through your non­void method that
missing return statement
does not reach a return statement.
non­static method cannot be You called a method on a class name, instead of on a specific instance
referenced from a static context of that class.
possible loss of precision You assigned a double value to an int variable.
reached end of file while
You're missing a closing brace at the end of the file.
parsing
unexpected type ­­ required
You used = instead of ==.
variable
You wrote this statement after a return statement. Remember that
unreachable statement
return statements return from the method immediately.
variable might not have been The compiler found a pathway through your method where you access
initialized the value of a variable before you've assigned anything to it.

Run­Time Errors (Crashes)
Error Message What It Usually Means
My program freezes. You have a loop that never reaches its stopping condition.
ArrayIndexOutOfBoundsException
You tried to access an array element with an index that was too
high or too low.
Look for every period (.) or open bracket ([) on the line of code
NullPointerException
that caused the error. Something immediately to the left of one of
these periods/brackets must have been the null value (instead of
being the object or array you thought you had).
OutOfMemoryError You are constructing new objects inside an infinite loop.
StackOverflowError
You have an infinite recursion. In other words, your method calls
itself, which then calls itself, without ever stopping.
StringIndexOutOfBoundsException
You tried to access a character in a String with an index that was
too high or too low.

How To Read A Run­Time Error
Suppose our program crashes with the following error message:
java.lang.RuntimeException: Attempt to move robot from (4, 2) to occupied location (4, 3)
          at Robot.move(Robot.java:80)
          at Lesson.climbOneStair(Lesson.java:13)
          at Lesson.climbAllStairs(Lesson.java:7)

Clearly, this error message is telling us that we told the robot to move into a wall (and it even tells us
where the robot and the wall are), but there's a lot more we can learn from reading the rest of the message.
Run­time error messages should be read from the bottom up. According to this error message, we called
the climbAllStairs method, which, on line 7 of Lesson.java, called the climbOneStair method, which,
on line 13 of Lesson.java, called the move method, which crashed on line 80 of Robot.java, when the robot
tried to move into a wall.

Now, we might guess that the bug is in move, since that's where the program crashed. But we probably
trust that the move method has been carefully tested, so we must have called move in an inappropriate
manner. Specifically, we must have violated the move method's precondition, by calling move when the
front of the robot was blocked. So, we back up to line 13 of Lesson.java, where we called the move
method. Now we need to step back and think. Was climbOneStair correct in calling move? If not, we
should fix the bug in climbOneStair But if climbOneStair was correct, maybe we called climbOneStair
when we shouldn't have, and the bug is in climbAllStairs ... 

Help! My Error Doesn't Appear On This Page!

Copy and paste the complete error message into an email and send it to me, along with a copy of the
offending code, and a description of what you were doing when you got this error. That way, I can add the
error message to this page.

You might also like