简体   繁体   中英

My webapplication works fine when testing it in IDE, but doesnt work on webserver (tomcat)

I`ve created my first webapplication. I set up my webserver (tomcat+apache2) and tried to deploy the app on it. When I tested the app it worked fine with my test environment, but when created the war and deployed it the following error (exception) showed up:

HTTP Status 500 -

type Exception report

message

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: 14 in the generated java file Only a type can be imported. bitcoin.BitcoinHandler resolves to a package

An error occurred at line: 16 in the jsp file: /Balance.jsp BitcoinHandler cannot be resolved 13: double yourcoins=0.0; 14: Random rand=new Random(); 15:
16: balance=new Double(BitcoinHandler.getBalance("give")); 17:
18:
19: if(balance>2.5)

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:469) 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:722)

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.27 logs. Apache Tomcat/7.0.27

The application just cant find my classes which are inside the WEB-INF/classes folder. I dont know why!?? Could someone please help me?

Code provided in comment

<%@page import="bitcoinmonitor.BitcoinHandler"%>
<%@page import="java.util.Random"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<% 
double balance=0.0;
double yourcoins=0.0;
Random rand=new Random();
balance=new Double(BitcoinHandler.getBalance("give"));

Actually you have some information in exception report, look carefully here line: 16 in the jsp file: /Balance.jsp also you may place here code from this file to give us more information. As far as i can see you have a problem with BitcoinHandler object, may be you don't imported this class to your Balance.jsp

This tells me that your test and production environments are not the same. There's a dependency or assumption that you're making that isn't addressed properly in the environment that's failing.

You're using scriptlet code in your JSPs, which is asking for trouble. I'd recommend learning JSTL and writing servlets to validate and bind requests, fulfill use cases, and pass the information needed by the JSP to display. Your design was proven to scale poorly and be a maintenance nightmare back in the 90s.

问题是JSP子目录..我现在把JSP放到根目录中,它最终像魅力一样工作。

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