Program Tip

JSP 용 클래스를 컴파일 할 수 없음 : java.util.Map $ Entry 유형을 분석 할 수 없습니다.

programtip 2020. 11. 11. 20:33
반응형

JSP 용 클래스를 컴파일 할 수 없음 : java.util.Map $ Entry 유형을 분석 할 수 없습니다. 필수 .class 파일에서 간접적으로 참조됩니다.


jsps를 컴파일하기 위해 tomcat7을 얻을 수 없습니다. 예제 서블릿을 제대로 실행할 때까지 서비스가 실행되고 있습니다. Oracle Java 8을 실행하고 있습니다.

누구든지 올바른 방향으로 나를 가리킬 수 있습니까?

다음은 스택 추적입니다.

type Exception report

message Unable to compile class for JSP:

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 1 in the generated java file
The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files

Stacktrace:
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331)
    org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:468)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.35 logs.

코드는 다음과 같으며 tomcat7의 샘플 코드이므로 정확하다고 생각합니다.

<%@ taglib prefix="mytag" uri="/WEB-INF/jsp2/jsp2-example-taglib.tld" %>
<html>
<head>
  <title>JSP 2.0 Examples - Hello World SimpleTag Handler</title>
</head>
<body>
<h1>JSP 2.0 Examples - Hello World SimpleTag Handler</h1>
<hr>
<p>This tag handler simply echos "Hello, World!"  It's an example of
a very basic SimpleTag handler with no body.</p>
<br>
<b><u>Result:</u></b>
<mytag:helloWorld/>
</body>
</html>

JDK 8을 지원하는 최신 버전의 tomcat을 사용해야합니다.

apache-tomcat-7.0.35가 JDK8을 지원하지 않음을 확인할 수 있으며, apache-tomcat-7.0.50이 JDK8을 지원하는지 확인할 수도 있습니다.


JDK8의 클래스 형식이 변경 되었기 때문에 Tomcat이 JSP를 컴파일 할 수 없습니다. 최신 버전의 Tomcat을 얻으십시오.

나는 최근에 같은 문제가 있었다. 이것은 Tomcat의 버그이거나 오히려 JDK 8은 이전 JDK8 버전과 약간 다른 클래스 파일 형식을 가지고 있습니다. 이로 인해 불일치가 발생하고 Tomcat은 JDK8에서 JSP를 컴파일 할 수 없습니다.

다음 참조를 참조하십시오.


Ubuntu 12.04 LTS에서 실행 중이고 최신 공식 지원 tomcat7 패키지가 7.0.26이기 때문에 전체 tomcat을 쉽게 업데이트 할 수 없습니다.

jdk8로 테스트하기 위해 최신 7.0. * 버전에 대해 일부 jar를 변경하여이 문제를 해결할 수있었습니다.

jasper.jar, jasper-el 및 tomcat-util을 버전 7.0.53으로 전환하고 ecj-4.3.1.jar을 추가했습니다. 그러면 애플리케이션이 다시 온라인 상태가됩니다.

그러나 ... 또한 나는 이것으로 패키지 내용을 변경했기 때문에 전체 바람둥이를 다운로드하고 자체 설치하여 패키지를 엉망으로 사용하는 것이 더 낫습니다. 따라서 이것은 매우 더러운 빠른 해킹 또는 해결 방법으로 만 참조하십시오.


maven을 사용하는 경우 tomcat7-maven-plugin을 pom.xml에 추가하면 정상적으로 실행됩니다. 이 플러그인은 JDK 1.8을 지원하는 Tomcat 서블릿 컨테이너 버전 7.0.47에서 프로젝트를 실행합니다.

    <plugins>
    <plugin>
     <groupId>org.apache.tomcat.maven</groupId>
     <artifactId>tomcat7-maven-plugin</artifactId>
     <version>2.2</version>
     <configuration>
<!-- Include context file for Datasource configuration -->
     <contextFile>./src/main/webapp/META-INF/context.xml</contextFile>
    <port>8080</port>
     </configuration>
     <dependencies>
<!-- Include jdbc driver dependency if using datasource (in my case oracle) -->
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>11.2.0.4.0</version>
    </dependency>
  </dependencies>
    </plugin>
    </plugins>

이것이 유용하기를 바랍니다! 감사


로부터 JIRA 기술 자료 :

Symptoms

워크 플로 작업에 액세스 할 수 없습니다.

  1. JIRA는 화면에 예외를 던질 수 있습니다.
  2. 다음 조건 중 하나 또는 둘 모두가 존재할 수 있습니다.

atlassian-jira.log에 다음이 표시됩니다.

     2007-12-06 10:55:05,327 http-8080-Processor20 ERROR [500ErrorPage] 
     Exception caught in500 page Unable to compile class for JSP
    org.apache.jasper.JasperException: Unable to compile class for JSP
   at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:572)
   at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)

_

Cause:

The Tomcat container caches .java and .class files generated by the JSP parser they are used by the web application. Sometimes these get corrupted or cannot be found. This may occur after a patch or upgrade that contains modifications to JSPs.

Resolution

1.Delete the contents of the /work folder if using standalone JIRA or /work if using EAR/WAR installation . 2. Verify the user running the JIRA application process has Read/Write permission to the /work directory. 3. Restart the JIRA application container to rebuild the files.


Add this import <%@page import="java.util.Map" %>

This worked for me, but I also needed to add <%@ page import="java.util.HashMap" %>. It seems that the above answer is true, that if you have the newer tomcat you might not need to add these lines, but as I could not change my whole system, this worked.
Thank you


Faced exactly the same issue while upgrading my application from java 6 to java 8 on tomcat 7.0.19. After upgrading the tomcat to 7.0.59, this issue is resolved.


Try and add <%@page import="java.util.Map.Entry"%> to your jsp file


There are a lot of correct/same answers, but for future references:

Same stands for Tomcat 7. Be aware that updating only your used frameworks' versions (as proposed in other similar questions) isn't enough.

You also have to update Tomcat plugin's version. What worked for me, using Java 7, was upgrading to version 2.2 of tomcat7-maven-plugin (= Tomcat 7.0.47).


I recently get across the same issue. I was using IntelliJx64 with Tomcat7.0.32 with jdk.8.0.102. There was no issue then. I was able to directly access my deployment localhost:[port] without adding [mywebapp] or /ROOT.

When I tried to migrate to eclipse neon, I came across the same bug that is discussed when I tried to set the path as empty string. When I enforced execution environment to Java7 and set modules to empty it did not solve toe issue. However, when I changed my tomcat installation to 7.072 and manually changed context path configuration to path="" the problem was solved in eclipse. (You can manipulate the path via double click server and switching to module tab too.)

My wonder is how come IntelliJ was not giving any issues with the same bug which was supposed to be related to tomcat installation version?

There also seems to be a relation with the IDE in use.


I ran into this before, as others said: just upgrade jetty plugin

if you are using maven

go to jetty plugin in pom.xml and update it to

<plugin>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>9.3.0.v20150612</version>
    <configuration>
        <scanIntervalSeconds>3</scanIntervalSeconds>
        <httpConnector>
            <port>${jetty.port}</port>
            <idleTimeout>60000</idleTimeout>
        </httpConnector>
        <stopKey>foo</stopKey>
        <stopPort>${jetty.stop.port}</stopPort>
    </configuration>
</plugin>

hope this help you

참고URL : https://stackoverflow.com/questions/19243458/unable-to-compile-class-for-jsp-the-type-java-util-mapentry-cannot-be-resolved

반응형