当我在eclipse gwt项目中运行我的代码时,无法为JSP错误编译类

Sre*_*ree 8 java eclipse gwt jsp gxt

嗨我正在尝试访问我的gwt项目中的jsp页面时遇到以下错误.其他不是jsp页面的页面正在进行中.

奇怪的是,当GWT SDK在构建路径顺序中移动到底部时,我能够看到JSP文件,这给出了另一个未安装GWT SDK的错误

有人能帮帮我吗?

org.apache.jasper.JasperException: Unable to compile class for JSP
Generated servlet error:
2016/01/07 14:30:51:128 IST [ERROR] Compiler - Javac exception  <Compile failed; see the compiler error output for details.>Compile failed; see the compiler error output for details.
at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:933)
at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:757)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:379)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:686)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1494)
at com.rapapp.gwt.server.common.util.CompressionFilter.doFilter(CompressionFilter.java:113)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1482)
at com.rapapp.gwt.server.common.util.CacheFilter.doFilter(CacheFilter.java:69)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1474)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:499)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:68)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:370)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:949)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1011)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:668)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Unknown Source)



Generated servlet error:
2016/01/07 14:30:51:129 IST [ERROR] Compiler - Env: Compile:  javaFileName=/C:/Users/USER/AppData/Local/Temp/jetty-127.0.0.1-8888-war-_-any-//org/apache/jsp\login_jsp.java
Run Code Online (Sandbox Code Playgroud)

Sky*_*ker 3

As you are not providing login.jsp file, So I want to share couple of suggestions to solve this issue.

  1. Use latest tomcat - http://www.howopensource.com/2015/07/unable-to-compile-class-for-jsp-the-type-java-util-mapentry-cannot-be-resolved/

  2. The jsp-api is provided by your Servlet container. Use at least 2.1 version. Change the dependency in your pom.xml

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jsp-api</artifactId>
    <version>2.1</version>
    <scope>provided</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
  1. Use your bean where class name will be written with package name. As an example,
<%@ page import="com.Test.Person" %> 
<html> 
<head></head> 
<body> 
<jsp:useBean id="person" class="com.Test.Person" scope="request" /> 
<jsp:setProperty name="person" property="name" value="Tripti" /> 
This JSP Page is created by:<jsp:getProperty name="person" property="name" /> 

</body> 
</html>
Run Code Online (Sandbox Code Playgroud)
  1. 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

  • Delete the contents of the <JIRA_INSTALL>/work folder if using standalone JIRA or <CATALINA_BASE>/work if using EAR/WAR installation.
  • Verify the user running the JIRA application process has Read/Write permission to the<JIRA_INSTALL|CATALINA_BASE>/work directory.
  • Restart the JIRA application container to rebuild the files.

There are also some other ways--

  1. Classes not within a package are discouraged in modern Java, to the point where they don't work in a number of cases. Put your classes into packages (use a package statement at the top of the .java file)--all of them.

  2. This problem is generated by the default values used by JspServlet, which compiles using 1.4 for source/target values.

You can configure this servlet by adding

<servlet>
    <servlet-name>jsp</servlet-name>
    <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
    <init-param>
        <param-name>compilerSourceVM</param-name>
        <param-value>1.5</param-value>
    </init-param>
    <init-param>
        <param-name>compilerTargetVM</param-name>
        <param-value>1.5</param-value>
    </init-param>
    <load-on-startup>3</load-on-startup>
</servlet>
Run Code Online (Sandbox Code Playgroud)
  1. There is one more issue as you can't configure JspServlet with the current jasper-compiler-5.0.28. You should download jasper-compiler-5.0.30 and make sure is in your classpath before gwt. There are other latest jasper compiler jars out-there but i'm not sore of how compatible are with jakarta-tomcat-5.0.28

  2. https://code.google.com/archive/p/raisercostin/wikis/GwtEclipsePluginDebug.wiki

  3. This maybe caused by jar conflict. Remove the servlet-api.jar in your servlet/WEB-INF/ directory, %Tomcat home%/lib already have this lib.

  4. Every time I have seen those errors the reason was jasper could not find the java compiler. Try and put tools.jar in your common/lib and see if the service works then..