com.sun.jdi.InvocationException이 메서드를 호출하는 동안 발생했습니다.
클래스 개체를 만들고 싶지만 디버깅 할 때이 오류가 발생했습니다. 아무도 문제가 무엇인지 말해 줄 수 있습니까? 이 코드의 위치는 Spring (2.5) Service 클래스에 있습니다.
비슷한 문제가 있습니다. OJB 참조 설명자 1 : 0 관계? 자동 검색을 false로 설정해야합니까?
고마워 ~
근본 원인은 자바 디버그 인터페이스를 디버깅 할 때 클래스의 toString ()을 호출하여 팝업 상자에 클래스 정보를 표시하므로 toString 메소드가 올바르게 정의되지 않은 경우 이런 일이 발생할 수 있다는 것입니다.
Eclipse에서 디버깅 할 때도 비슷한 예외가 발생했습니다. 개체 위로 마우스를 가져 가면 팝업 상자에 com.sun.jdi.InvocationException메시지가 표시됩니다 . 저의 근본 원인 toString()은 제 수업 방식이 아니라 hashCode()방식이었습니다. 그것은 원인이 된 NullPointerException(가) 발생하는 com.sun.jdi.InvocationException디버깅하는 동안 나타납니다. 널 포인터를 처리하면 모든 것이 예상대로 작동했습니다.
글쎄요, 그 전후에 다른 사람들이 언급 한 여러 가지 때문일 수 있습니다. 제 경우에는 문제가 같았지만 이유는 다른 것입니다.
클래스 (A)에는 여러 개체가 있었고 개체 중 하나는 다른 개체가있는 다른 클래스 (B)였습니다. 이 과정에서 B 클래스의 개체 (String) 중 하나가 null 인 다음 부모 클래스 (A)를 통해 해당 개체에 액세스하려고했습니다.
따라서 콘솔은 null 포인트 예외 를 throw 하지만 Eclipse 디버거는 위에서 언급 한 오류를 표시합니다.
나머지는 할 수 있기를 바랍니다.
나를 위해 toString이 다음과 같이 정의되었을 때 동일한 예외가 발생했습니다.
@Override
public String toString() {
return "ListElem [next=" + next + ", data=" + data + "]";
}
ListElem연결된 목록 요소는 어디에 있으며 다음과 같이 만들었습니다 ListElem.
private ListElem<Integer> cyclicLinkedList = new ListElem<>(3);
ListElem<Integer> cyclicObj = new ListElem<>(4);
...
cyclicLinkedList.setNext(new ListElem<Integer>(2)).setNext(cyclicObj)
.setNext(new ListElem<Integer>(6)).setNext(new ListElem<Integer>(2)).setNext(cyclicObj);
이로 인해 인쇄 할 수없는 순환 연결 목록이 효과적으로 발생했습니다. 포인터 주셔서 감사합니다.
나는 한 번 같은 문제가 있었다. 제 경우에는 toString () 메서드가 잘못 생성되었습니다. 정확히 말하면 우리 팀의 개발자가 코드 정리 작업을 할당하고 가능한 경우 도메인 개체에 toString (), hashCode () 코드 및 equals () 메서드를 추가 할 때 toString 메서드에 정적 최종 변수가 포함되었습니다. 그러나 그것을 지나치게 쳐다 보았 기 때문에 클래스에서 "com.sun.jdi.InvocationException"을 유발하는 최종 정적 변수를 포함 시켰습니다.이 예외는 예외가있는 객체 위로 마우스를 가져 갔을 때만 디버깅에서 볼 수있었습니다.
이클립스 디버거에서 변수 창의 오른쪽 상단 모서리에있는 '논리적 구조 표시'버튼 / 아이콘을 비활성화하면 제 경우에는 문제가 해결되었습니다.
그래서 여기에도 같은 문제가있었습니다. 내 도메인 인스턴스가 최대 절전 세션에서 분리되는 것을 알았습니다. 나는 사용 isAttached()하여 도메인을 확인하고 연결했습니다.d.attach()
이것은 내 경우였다
다른 엔티티 클래스 (그가 공부 한 클래스) 와 다 대일 관계 를 갖는 엔티티 학생 이있었습니다 .
데이터를 Student 와 Classes 모두의 외래 키 가 있는 다른 테이블에 저장하고 싶었습니다 . 실행의 어떤 인스턴스에서 나는 어떤 조건에서 학생 목록 을 가져오고 있었고 각 학생 은 수업 수업에 대한 참조를 갖게 될 것 입니다.
샘플 코드 :-
Iterator<Student> itr = studentId.iterator();
while (itr.hasNext())
{
Student student = (Student) itr.next();
MarksCardSiNoGen bo = new MarksCardSiNoGen();
bo.setStudentId(student);
Classes classBo = student.getClasses();
bo.setClassId(classBo);
}
여기 에서 저장하려는 BO에 대한 학생 및 클래스 참조를 모두 설정 하고 있음을 알 수 있습니다. 그러나 내가 검사했을 때 디버깅하는 동안 이 예외 ( ) 가 표시되었습니다 .student.getClasses()com.sun.jdi.InvocationException
내가 찾은 문제는 HQL 쿼리를 사용하여 학생 목록을 가져온 후 세션을 플러시 하고 닫는다 는 것 입니다. 그 진술을 제거했을 때 문제가 해결되었습니다.session.close();
마침내 모든 데이터를 테이블 ( MarksCardSiNoGen )에 저장했을 때 세션이 종료되었습니다 .
도움이 되었기를 바랍니다.
요소가 존재하지 않는 데는 두 가지 이유가있을 수 있습니다.
- 잘못된 xpath (// * [@ id'forgotQuote])
- Correct xpath but no element (//*[contains(text(),'This text is not in the page')])
Would you get com.sun.jdi.InvocationException in either case when you are running Debug and you hover your mouse over a reference to the WeBElement (this with Selenium and Java)???
We use the following, but can't distinguish if it returns false due to bad xpath or non-existent element (valid xpath syntax):
public static boolean isElementDisplayed(WebElement element) {
boolean isDisplayed = false;
try {
isDisplayed = element.isDisplayed();
} catch (NoSuchElementException e) {
;// No Worries
}
return isDisplayed;
}
I got similar exception in Eclipse. This was due to java.lang.StackOverflowError error. I had overriden toString() method in child class, having JoinColumn, which was returning string using object of parentclass, resulting in circular dependency. Try to remove that object from toString(), and it will work.
I have received com.sun.jdi.InvocationException occurred invoking method when I lazy loaded entity field which used secondary database config (Spring Boot with 2 database configs - lazy loading with second config does not work). Temporary solution was to add FetchType.EAGER.
Removing hashCode() and equals() solved my issue. In my case, I used Apache's commons-lang hash code and equals builders for creating non-static classes manually, so the compiler didn't throw any exception. But at runtime it caused the invocation exception.
In my case it was due to the object reference getting stale. I was automating my application using selenium webdriver, so i type something into a text box and then it navigates to another page, so while i come back on the previous page , that object gets stale. So this was causing the exception, I handled it by again initialising the elements - PageFactory.initElements(driver, Test.class;
I was facing the same issue because I was using Lombok @Data annotation that was creating toString and hashcode methods in class files, so I removed @Data annotation and used specific @Gettter @Setter annotation that fixed my issue.
we should use @Data only when we need all @ToString, @EqualsAndHashCode, @Getter on all fields, and @Setter on all non-final fields, and @RequiredArgsConstructor.
I also faced the same problem. In my case I was hitting a java.util.UnknownFormatConversionException. I figured this out only after putting a printStackTrace call. I resolved it by changing my code as shown below.
from:
StringBuilder sb = new StringBuilder();
sb.append("***** Test Details *****\n");
String.format("[Test: %1]", sb.toString());
to:
String.format("[Test: %s]", sb.toString());
I faced the same problem once. In my case it was because of overridden equals method. One values was coming null.
참고URL : https://stackoverflow.com/questions/4123628/com-sun-jdi-invocationexception-occurred-invoking-method
'Program Club' 카테고리의 다른 글
| .NET의 StringBuilder 내용을 지우는 가장 좋은 방법 (0) | 2020.11.07 |
|---|---|
| 라디오 버튼 그룹의 값 가져 오기 (0) | 2020.11.07 |
| 다중 조각 활동에서 onContextItemSelected를 처리하는 방법은 무엇입니까? (0) | 2020.11.07 |
| PowerShell을 사용하여 .sql 파일을 실행하는 방법은 무엇입니까? (0) | 2020.11.07 |
| ToString ( "X2")의 의미는 무엇입니까? (0) | 2020.11.07 |