This is my first time using Hibernate and I am able to run everything on my local machine just fine, but when I deploy my website to my professor's tomcat web server I get the error message below. All I do in the UsersHelper constructor is get the session from SessionFactory in HibernateUtils.
Here are HibernateUtil: http://www.copypastecode.com/173998/
and UsersHelper: http://www.copypastecode.com/174002/
org.apache.jasper.JasperException: An exception occurred processing JSP page /users.jsp at line 35
32: try{
33:
34:
35: UsersHelper u = new UsersHelper();
36:
37: List<Users> userList = u.getAllUsers();
38:
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:401)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class org.myworkspace.hbconnect.HibernateUtil
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.users_jsp._jspService(users_jsp.java:281)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
java.lang.NoClassDefFoundError: Could not initialize class org.myworkspace.hbconnect.HibernateUtil
org.myworkspace.hbconnect.UsersHelper.<init>(UsersHelper.java:19)
org.apache.jsp.users_jsp._jspService(users_jsp.java:241)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
java.lang.NoClassDefFoundError: Could not initialize class org.myworkspace.hbconnect.HibernateUtil
The mentioned class is missing in the runtime classpath. It must be in the runtime classpath as a standalone class file (.class) or packaged in a JAR file (.jar).
By default the webapp's myWebapp/WEB-INF/lib and myWebapp/WEB-INF/classes folders are covered by the runtime classpath.
Any 3rd party webapp-specific JAR files ought to be placed in myWebapp/WEB-INF/lib. Any webapp-specific classes (servlets, etc..) ought to be placed in myWebapp/WEB-INF/classes.
Check if you have place proper .class files and .jar when deploying.
Hope this helps.
Related
I created a new web module in IntelliJ. The java classes in my src folder make calls to classes in another module, which is causing some java.lang.NoClassDefFoundError errors at runtime (everything is compiling correctly though). Is there a way to add a dependency such that the jsp files in my web app are properly able to access these java classes in this separate module?
Here's the error:
Type Exception Report
Message java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
"Exception
org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:176)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:380)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Root Cause
java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
java.net.URLClassLoader.findClass(URLClassLoader.java:381)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:129)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:60)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:171)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:380)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Note The full stack trace of the root cause is available in the server logs."
I get the error java.lang.NoSuchMethodError: javax.el.ExpressionFactory.getStreamELResolver()Ljavax/el/ELResolver; while using jstl in tomcat 8.0.33. I've checked the WEB-INF/lib of my application and it doesn't contain anything that is conflicting.
Also I checked the source code of javax.el.ExpressionFactory class from el-api.jar file present in tomcat 8's lib folder. The method signature is public ELResolver getStreamELResolver().
This issue occurred after I migrated an application from tomcat 6.0.35 to tomcat 8.0.33. The application was written using jstl-1.2
The complete stacktrace is
16-May-2016 19:14:54.119 SEVERE [ajp-nio-11009-exec-4] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [spring] in context with path [/app] threw exception [Request processing failed; nested exception is org.apache.tiles.impl.CannotRenderException: org.apache.tiles.util.TilesIOException: JSPException including path '/WEB-INF/JSP/APP/display.jsp'.] with root cause
java.lang.NoSuchMethodError: javax.el.ExpressionFactory.getStreamELResolver()Ljavax/el/ELResolver;
at org.apache.jasper.el.ELContextImpl.<clinit>(ELContextImpl.java:87)
at org.apache.jasper.compiler.Validator$ValidateVisitor.prepareExpression(Validator.java:1617)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:750)
at org.apache.jasper.compiler.Node$ELExpression.accept(Node.java:950)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:464)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
at org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1853)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:217)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
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.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:720)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:584)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:523)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:935)
at org.apache.jasper.runtime.PageContextImpl.doInclude(PageContextImpl.java:679)
at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:673)
at org.apache.tiles.jsp.context.JspTilesRequestContext.include(JspTilesRequestContext.java:103)
at org.apache.tiles.jsp.context.JspTilesRequestContext.dispatch(JspTilesRequestContext.java:96)
at org.apache.tiles.renderer.impl.TemplateAttributeRenderer.write(TemplateAttributeRenderer.java:44)
at org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
at org.apache.tiles.renderer.impl.ChainedDelegateAttributeRenderer.write(ChainedDelegateAttributeRenderer.java:76)
at org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:670)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:336)
at org.apache.tiles.template.InsertAttributeModel.renderAttribute(InsertAttributeModel.java:210)
at org.apache.tiles.template.InsertAttributeModel.end(InsertAttributeModel.java:126)
at org.apache.tiles.jsp.taglib.InsertAttributeTag.doTag(InsertAttributeTag.java:311)
... (truncated)
How to resolve this issue?
To tackle such problems of different versions of same class present on the classpath - the best way is to enable verbose class loading and see whether the class is actually being loaded from the intended jar file.
From command line we can run java -verbose:class MyClassWithMain. This will output all the classes loaded in the JVM and the name of the jar or any class on the classpath from which it was loaded. Once you find the source of the problem, you can remove it.
To enable verbose:class in tomcat, see this answer.
I'm new to JSP. I'm trying to do a basic program of JSP & MySQL connectivity using ADT Eclipse. On running the index.jsp page, I get the following:
HTTP Status 500 - An exception occurred processing JSP page /index.jsp at line 24
type Exception report
message An exception occurred processing JSP page /index.jsp at line 24
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 24
21: String sql = "select usertype from userdetail";
22:
23: try {
24: Class.forName("com.mysql.jdbc.Driver");
25: con = DriverManager.getConnection(url, user, password);
26: ps = con.prepareStatement(sql);
27: rs = ps.executeQuery();
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
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)
root cause
javax.servlet.ServletException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:912)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:841)
org.apache.jsp.index_jsp._jspService(index_jsp.java:141)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
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)
root cause
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:126)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:63)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:190)
org.apache.jsp.index_jsp._jspService(index_jsp.java:85)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
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.30 logs.
Apache Tomcat/7.0.30
I downloaded MySQL Connector J jar and included it in the project
Thanks in advance...
Don't add the external jar. Download it and copy in project.
COPY it in WEB-INF--->lib(folder).
The error ,
javax.servlet.ServletException: java.lang.ClassNotFoundException:
com.mysql.jdbc.Driver
says that it couldn't find the class file .
So you should check for the mysql jar to the the project using ,
Project properties-> add jar
before that place the jar in folder somewhere inside the project or add through external jar option.
If you already added . trying remove and adding the jar file again
see how-to-add-mysql-driver-jar-file-in-eclipse and how-to-add-external-jar-without-eclipse for addtional reference
I am running a server application and accessing the database for operations, and I am getting the error as even though I have configured the javax.comm.properties in my project
javax.comm: Can't find javax.comm.properties!
java.io.IOException: javax.comm: platform driver class name = null
(Check 'driver' property in javax.comm.properties)
at javax.comm.CommPortIdentifier.loadDriver(CommPortIdentifier.java:244)
at javax.comm.CommPortIdentifier.<clinit>(CommPortIdentifier.java:109)
at com.rtc.actions.downloads.MySerialPort.openMyPort(MySerialPort.java:88)
at com.rtc.actions.downloads.Downloads.<init>(Downloads.java:70)
at com.rtc.actions.downloads.MasterDownloadAction.execute(MasterDownloadAction.java:37)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
javax.comm.properties should be placed in the JAVA_HOME/jre/lib/ext see details.
The first step for using this package is placing the proper files in
respective JAVA_HOME’s directory folders.
1) win32com.dll : keep it in JAVA_HOME’s bin directory. In my case I
placed it here C:\Program Files\Java\jdk1.6.0_05\jre\bin
2)comm.jar : place it in JAVA_HOME’s lib\ext directory. Mine was in
C:\Program Files\Java\jdk1.6.0_05\jre\lib\ext
3)javax.comm.properties : same as above. So this file goes in
C:\Program Files\Java\jdk1.6.0_05\jre\lib\ext
I am getting the following error when I am trying to run my J2EE project. The same project was working before and I started getting this exception now. I am sure that all class are there along with their mapping files.
If I remove mapping of jobtitle from my hibernate.cfg.xml in the project, it is running.
java.lang.ExceptionInInitializerError
hrm.dao.HibernateUtil.<clinit>(HibernateUtil.java:28)
hrm.dao.AbstractDAO.<init>(AbstractDAO.java:29)
hrm.dao.JobSpecificationDAO.<init>(JobSpecificationDAO.java:22)
hrm.actions.JobSpecificationAction.execute(JobSpecificationAction.java:53)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
java.lang.ClassNotFoundException: hrm.dao.Jobtitle
java.lang.ClassNotFoundException: hrm.dao.Jobtitle
means you do indicate a mapping in your hibernate.cfg.xml, but a mapping to a class which is not in the classpath of the j2ee project.