0

That's the problem.

I developed a web app with NetBeans 7, Tomcat 7 and hsqldb; on my desktop all is Ok.

When I upload my java files (.class, .jsp and .jar packages) to my site and try to load a jsp page which imports a class contained in a package (class FunzioniSessione in package it.swlab.util), I get the following error:

org.apache.jasper.JasperException: Unable to compile class for JSP:  
An error occurred at line: 6 in the generated java file 
Only a type can be imported. it.swlab.util.FunzioniSessione resolves to a package 

An error occurred at line: 7 in the jsp file: /index.jsp 
FunzioniSessione cannot be resolved to a type 
4: <% 
5: synchronized(this) 
6: { 
7: FunzioniSessione funzioniSessione = new FunzioniSessione(); 
8: String percorso = config.getServletContext().getRealPath("/"); 
9: funzioniSessione.inizializza(session,request,response,percorso,"infocar"); 
10: boolean connesso = session.getAttribute("utenteConnesso") != null; 

An error occurred at line: 7 in the jsp file: /index.jsp 
FunzioniSessione cannot be resolved to a type 
4: <% 
5: synchronized(this) 
6: { 
7: FunzioniSessione funzioniSessione = new FunzioniSessione(); 
8: String percorso = config.getServletContext().getRealPath("/"); 
9: funzioniSessione.inizializza(session,request,response,percorso,"infocar"); 
10: boolean connesso = session.getAttribute("utenteConnesso") != null; 

Stacktrace: 
 org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:93) 
 org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330) 
 org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:451) 
 org.apache.jasper.compiler.Compiler.compile(Compiler.java:328) 
 org.apache.jasper.compiler.Compiler.compile(Compiler.java:307) 
 org.apache.jasper.compiler.Compiler.compile(Compiler.java:295) 
 org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:565) 
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:309) 
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308) 
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259) 
 javax.servlet.http.HttpServlet.service(HttpServlet.java:729) 

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

To prevent some obvious answers, I add some more information:

  1. The package containing the class FunzioniSessione (named funzioniComuni.jar) is in the WEB-INF\lib folder
  2. I can't look at the logs as the note in the stacktrace suggests, because I have no access to the logs folder of my provider's Tomcat server. 3 The directive for the import is <%@page import="it.swlab.util.FunzioniSessione"%> I tried also with a ";" at the end (<%@page import="it.swlab.util.FunzioniSessione;"%>) but with no success.

I wait for some suggestions.

Thank you

KV Prajapati
  • 93,659
  • 19
  • 148
  • 186
FPe
  • 3
  • 2
  • The error means that the class is missing in the runtime classpath. It's basically the same as `NoClassDefFoundError` in normal Java code (if you were writing Java code in Java servlet classes instead of in JSP files, that would have been more clear). What kind of host are you using? How are you deploying the webapp? As a single WAR file or as a bunch of loose files which represent the WAR's expanded content? – BalusC Sep 25 '11 at 05:57

1 Answers1

0

Is the FunzioniSessione on you classpath ? Generally we keep the classes in web-inf\classes which is already onclasspth. Can you ensure the deployment directory has this structure with you class in expected package ?

cs95
  • 379,657
  • 97
  • 704
  • 746
Nrj
  • 6,723
  • 7
  • 46
  • 58
  • Read the opening post - The package containing the class FunzioniSessione (named funzioniComuni.jar) is in the WEB-INF\lib folder – KV Prajapati Sep 24 '11 at 06:56
  • thats why - is the lib folder in classpath ? – Nrj Sep 24 '11 at 07:10
  • Usually Tomcat WEB-INF\lib folder is by default in the classpath, I don't know if for my ISP is so. I hope so. Which other could be the problem? – FPe Sep 28 '11 at 19:38
  • yes some on some conatiners (including tomcat old versions), this is not on classpath, which can cause the problem. – Nrj Sep 30 '11 at 04:38
  • I don't think Tomcat 7 is an old version of Tomcat. Any other suggestions? – FPe Oct 14 '11 at 20:58