483
votes
26answers
393k views

Dealing with “java.lang.OutOfMemoryError: PermGen space” error

Recently I ran into this error in my web application: java.lang.OutOfMemoryError: PermGen space It's a typical Hibernate/JPA + IceFaces/JSF application running on Tomcat 6 and JDK 1.6. Apparently ...
404
votes
14answers
17k views

Uncatchable ChuckNorrisException

Is it possible to construct a snippet of code in Java that would make a hypothetical java.lang.ChuckNorrisException uncatchable? Thoughts that came to mind are using for example interceptors or ...
171
votes
3answers
36k views

Is there anything like .NET's NotImplementedException in Java?

Is there anything like .NET's NotImplementedException in Java?
157
votes
26answers
10k views

The case against checked exceptions

For a number of years now I have been unable to get a decent answer to the following question: why are some developers so against checked exceptions. I have had numerous conversations, read things on ...
151
votes
24answers
32k views

IllegalArgumentException or NullPointerException for a null parameter?

I have a simple setter method for a property and null is not appropriate for this particular property. I have always been torn in this situation: should I throw an IllegalArgumentException, or a ...
83
votes
6answers
38k views

Rethrowing exceptions in Java

In C#, I can use the throw; statement to rethrow an exception while preserving the stack trace: try { ... } catch (Exception e) { if (e is FooException) throw; } Is there something like ...
80
votes
17answers
3k views

True-way solution in Java: parse 2 numbers from 2 strings and then return their sum

Quite a stupid question. Given the code: public static int sum(String a, String b) /* throws? WHAT? */ { int x = Integer.parseInt(a); // throws NumberFormatException int y = Integer.parseInt(b); ...
72
votes
7answers
29k views

Java: checked vs unchecked exception explanation

I have read multiple posts on StackOverFlow about checked vs unchecked exceptions. I'm honestly still not quite sure how to use them properly. Joshua Bloch in "Effective Java" said that Use ...
68
votes
16answers
15k views

Best practices for exception management in Java or C#

I'm stuck deciding how to handle exceptions in my application. Much if my issues with exceptions comes from 1) accessing data via a remote service or 2) deserializing a JSON object. Unfortunately I ...
67
votes
27answers
19k views

Why aren't variables declared in “try” in scope in “catch” or “finally”?

In C# and in Java (and possibly other languages as well), variables declared in a "try" block are not in scope in the corresponding "catch" or "finally" blocks. For example, the following code does ...
66
votes
14answers
9k views

In Java, when should I create a checked exception, and when should it be a runtime exception? [duplicate]

Possible Duplicate: When to choose checked and unchecked exceptions When should I create a checked exception, and when should I make a runtime exception? For example, suppose I created the ...
60
votes
2answers
2k views

Why do Double.parseDouble(null) and Integer.parseInt(null) throw different exceptions?

Why do Double.parseDouble(null) and Integer.parseInt(null) throw different exceptions? Is this a historical accident or intentional? The documentation clearly states two types of exceptions for ...
59
votes
6answers
31k views

Can I catch multiple Java exceptions in the same catch clause?

In Java, I want to do something like this: try { ... } catch (IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException e) { someCode(); } ...
57
votes
5answers
26k views

Can constructors throw exceptions in Java?

Are constructors allowed to throw exceptions?
56
votes
3answers
30k views

Exception NoClassDefFoundError for CacheProvider

I'm kind of new in Spring and hibernate so I'm trying to implement some simple web application based on Spring 3 + hibernate 4 while I start tomcat I have this exception: ...

1 2 3 4 5 243
15 30 50 per page