3

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"));
heiningair
  • 441
  • 1
  • 6
  • 23

3 Answers3

0

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

Timur Samkharadze
  • 1,737
  • 1
  • 17
  • 33
  • <%@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")); – heiningair May 06 '12 at 12:36
  • did you create instance of BitcoinHandler? – Timur Samkharadze May 06 '12 at 12:38
  • This is the only necessary code inside that JSP file.. after that balance is returned.. – heiningair May 06 '12 at 12:38
  • what about use ´balance = BitcoinHandler.getBalance("give");´ in stead of balance=new Double(BitcoinHandler.getBalance("give")); ? – Timur Samkharadze May 06 '12 at 12:47
  • @muenchnair: please update your question next time and do not add the code just in a comment (I added the code). – home May 06 '12 at 12:50
  • I`ll try it.. but I think it is not a code problem.. It already works fine in my test environment. – heiningair May 06 '12 at 12:55
  • it works on GlassfiSh without errors, when i use your construction i get the same error. – Timur Samkharadze May 06 '12 at 12:55
  • same for me.. it works fine with glassfish! but what is different then? – heiningair May 06 '12 at 13:00
  • I just tried something.. when i delete the lines within "bitcoinhandler" then the app loads, but then it hangs again when the next class is called that uses http!! – heiningair May 06 '12 at 13:12
  • but there is something strange.. every first try after I deployed the warfile again it works!But not a second time.. – heiningair May 06 '12 at 13:18
0

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.

duffymo
  • 305,152
  • 44
  • 369
  • 561
0

The problem was the JSP subdirectory.. I put the JSPs into the root directory now and it finally works like charm..

Kai
  • 38,985
  • 14
  • 88
  • 103
heiningair
  • 441
  • 1
  • 6
  • 23