简体   繁体   中英

eclipse, maven, tomcat: http status 500 unable to compile

So I know that there are a lot of other questions that have been asked on nearly the same thing, but I have not been able to fix my problem with the information provided in them.

I have a maven project in eclipse that gives this error when it tries to redirect me to my program processForm.jsp, after pressing submit on my .jsp form. It seems to have an issue with importing the class I created called parseForm.

Here are snippets of processForm.jsp where the errors take place and where I import according to the stack trace:

Import statements:

 <!-- java import statements -->
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page import="myPackage.ParseForm" %>

Spot of error:

//implement ParseForm.java
ParseForm pf = new ParseForm(f);
System.out.println(pf.getInfo());
%>

Here is a screenshot of the error message given in tomcat: part 1 part 2

Here is the full error message given in the console:

An error occurred at line: [16] in the generated java file: [/Users/speedofast4749/Documents/Eclipse Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/work/Catalina/localhost/ARForm/org/apache/jsp/processForm_jsp.java]
Only a type can be imported. myPackage.ParseForm resolves to a package

An error occurred at line: 58 in the jsp file: /processForm.jsp
ParseForm cannot be resolved to a type
55: }
56: 
57: //implement ParseForm.java
58: ParseForm pf = new ParseForm(f);
59: System.out.println(pf.getInfo());
60: %>
61: 


An error occurred at line: 58 in the jsp file: /processForm.jsp
ParseForm cannot be resolved to a type
55: }
56: 
57: //implement ParseForm.java
58: ParseForm pf = new ParseForm(f);
59: System.out.println(pf.getInfo());
60: %>
61: 


Stacktrace:] with root cause
org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: [16] in the generated java file: [/Users/speedofast4749/Documents/Eclipse Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/work/Catalina/localhost/ARForm/org/apache/jsp/processForm_jsp.java]
Only a type can be imported. myPackage.ParseForm resolves to a package

An error occurred at line: 58 in the jsp file: /processForm.jsp
ParseForm cannot be resolved to a type
55: }
56: 
57: //implement ParseForm.java
58: ParseForm pf = new ParseForm(f);
59: System.out.println(pf.getInfo());
60: %>
61: 


An error occurred at line: 58 in the jsp file: /processForm.jsp
ParseForm cannot be resolved to a type
55: }
56: 
57: //implement ParseForm.java
58: ParseForm pf = new ParseForm(f);
59: System.out.println(pf.getInfo());
60: %>
61: 


Stacktrace:
    at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
    at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:198)
    at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:457)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:361)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:585)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:363)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:509)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1104)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)

Thank you in advance!

UPDATE: At some point in trying to solve this problem, I'm not exactly sure when, the error message changed to HTTP Status 500 - An exception occurred processing JSP page /processForm.jsp at line 58

add a semicolon at the end of last import statement.

<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page import="myPackage.ParseForm"; %>

OK so this is going to sound really weird but I've been continuing to play around with my programs and at some point I made a change that I don't even know which fixed it, because now it works! Really strange but I guess you can't complain about a working program. I read over my code like 4 times now and still can't find what is different than before so I don't even know what to think :( Thanks for all the help everyone! :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM