Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to compile class for JSPerror

 
Shuai Liu
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am writing a JSP (struts) application on tomcat.
Strangely, I receive an "unable to compile class" error every time I try to access the JSP page after restarting TOMCAT.
The error msg is something like:
org.apache.jasper.JasperException: Unable to compile class for JSPerror: Can't write: C:\apachetomcat\webapps\ROOT\WEB-INF\classes\CurrentMonth.class
(In this case, CurrentMonth is a java bean class)
That error occurs only at the first time access. The normal page will show up after I click the "refresh" button on the browser, and the error normally won't show up since then.
Can someone please tell me what's wrong and how to solve it? Thank you!!
 
Sreenivasa Majji
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Clear the browser cache. You will be fine.
 
Shuai Liu
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the reply.
Can you tell me what the reason that causes this problem?
Also, how can I ask the users to clear their cache every time they access my app? Is there another way to prevent it from happening?
Thx
 
Sreenivasa Majji
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's browser thing, I don't think you application should do any thing different. More over they will see only HTML output, not your exceptions. The users will see only the HTML (all jsp/servlet code will be executed on your web server, not on user's machines).
 
Shuai Liu
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the problem is at client side, how come it happens every time I re-start my server? Also, I believe the servlet engine/app server will display exceptions in html format. Is that right?
Thanks.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know this sounds weird, but put CurrentMonth in a package. Classes that are not in packages just plain cause trouble in servlet engines.
Bill
 
Shuai Liu
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William,
I did put every class in a package and I packaged them in a Jar file. Any thoughts?
Thanks a lot!
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you continue to get this error:

Why do you suppose it doesn't look for CurrentMonth in a package???
 
Shuai Liu
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by William Brogden:
Do you continue to get this error:

Why do you suppose it doesn't look for CurrentMonth in a package???

Sorry, what do you mean?
Yes, I still get this same error.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic