현상 : 

QueryDSL 을 위해 Entity에 대한 Query Class 생성 후,

junit 테스트를 돌렸으나 생성한 Query Class 를 찾지 못한다는 NoDefClassFoundError 발생

※ NoDefClassFoundError : compile 시엔 문제없으나, runtime 시 class를 찾지 못하는 현상 (참고)

 

해결 :
1. compile 은 성공적으로 되었으며, compile 한 jar 파일을 실행하여 해당 메소드 호출할 경우 문제가 없는 것으로 보아

build.gradle 혹은 코드문제가 아닌 eclipse 설정이 문제라고 판단.

2. project property > Java Build Path > Source 탭 확인 : 이상없음

3. project property > Deployment Assembly 확인 : 상대경로로 지정된 패키징 경로가 존재.. 해당 부분 제거 후 문제 해결

 

 

 

 

 

 

반응형

 

 

[ Error vs Exception ]

Error: An Error indicates serious problem that a reasonable application should not try to catch.

> 애플리케이션이 잡지 말아야 할 심각한 에러(핸들링이 어려운 에러)

 

Exception: Exception indicates conditions that a reasonable application might try to catch.

> 애플리케이션이 잡을 수 있는 에러(핸들링이 할 수 있는 에러)

 

 

[ ClassNotFoundError vs NoDefClassFoundError ]

ClassNotFoundException is an exception that occurs when you try to load a class at run time using Class.forName() or loadClass() methods and mentioned classes are not found in the classpath.

> 런타임에 Class.forName() 혹은 loadClass() 메소드를 사용했고 refrection에 사용된 class가 classpath에 없는 경우 발생

 

NoClassDefFoundError is an error that occurs when a particular class is present at compile time, but was missing at run time.

> 특정 클래스가 컴파일시엔 존재했으나 런타임 때 찾을 수 없는 경우

위와 관련된 경험: https://developyo.tistory.com/241?category=747217

 

 

[Checked Exception vs Unchecked Exception ]

Checked Exception : Java forces you to handle these error scenarios in some manner in your application code. 

> java 가 핸들링을 강요하는 exception (ex: sqlException, IOException)

 

Unchecked Exception : A method is not forced by compiler to declare the unchecked exceptions thrown by its implementation. Generally, such methods almost always do not declare them, as well.

Spring Transaction only supervise Unchecked Exceptions.

> 핸들링을 강요하지 않는 exception (ex: NullPointerException)

 

 

참고)

error vs exception

https://www.geeksforgeeks.org/exceptions-in-java/

ClassNotFoundError vs NoDefClassFoundError

https://dzone.com/articles/java-classnotfoundexception-vs-noclassdeffounderro

CheckedException vs Unchecked Exception

https://www.geeksforgeeks.org/checked-vs-unchecked-exceptions-in-java/

 

반응형

+ Recent posts