Calling java function in jsp page - java

I am having a java file named FaceDetection.java that has a function named FaceDetectionMain and that take two arguments .The java file dont have any main function.Now i call this java class file function in my jsp page like this :
FaceDetection.FaceDetectionMain(imagepath,imagename);
But am getting an exception as follow :
Apr 21, 2014 10:44:23 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jsp] in context with path [/SharedCrpto1] threw exception [Unable to compile class for JSP:
An error occurred at line: 90 in the jsp file: /uploadwebcamimage.jsp
FaceDetection cannot be resolved
87: fos.write(imageData);
88: String imagepath=filesstore+"\\"+imagename+".png";
89:
90: Boolean flag=FaceDetection.FaceDetectionMain(imagepath,imagename);
91: %>
92: </body>
93: </html>
Stacktrace:] with root cause
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 90 in the jsp file: /uploadwebcamimage.jsp
FaceDetection cannot be resolved
87: fos.write(imageData);
88: String imagepath=filesstore+"\\"+imagename+".png";
89:
90: Boolean flag=FaceDetection.FaceDetectionMain(imagepath,imagename);
91: %>
92: </body>
93: </html>
Please help me remove this exception.
Full stackTrace for exception is :
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:97)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:457)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:374)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:352)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:339)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:594)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:344)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:399)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:317)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:204)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:182)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:311)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)

Using the default package isn't a good practice, and often causes problems such as the one you are having (you can't import the default package, so no need to try the page import directives) Try putting your class in a package and import it, you should find that it works properly.

Related

javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/mysql/jdbc/Driver

I am trying to run simple code to connect with mysql. I m using eclipse and tomcat.
I have added mysql-connector-java-8.0.1.9.jar in Libraries:
Libraries-->mysql-->mysql-connector-java-8.0.1.9.jar
I have been at it for several hours adding and removing mysql-connector-java-8.0.1.9.jar to build path cannot get it running. Please help. Do I need to add any thing in run configuration??
This is the error on eclipse browser:
HTTP Status 500 – Internal Server Error
Type Exception Report
Message javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/mysql/jdbc/Driver
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/mysql/jdbc/Driver
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:599)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:500)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Root Cause
javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/mysql/jdbc/Driver
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:917)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:846)
org.apache.jsp.regCheck_jsp._jspService(regCheck_jsp.java:129)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:71)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Root Cause
java.lang.NoClassDefFoundError: com/mysql/jdbc/Driver
compute.DB.con(DB.java:21)
org.apache.jsp.regCheck_jsp._jspService(regCheck_jsp.java:100)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:71)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Root Cause
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1951)
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1794)
compute.DB.con(DB.java:21)
org.apache.jsp.regCheck_jsp._jspService(regCheck_jsp.java:100)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:71)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
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.
This is the output in console:
> Mar 16, 2020 4:57:27 PM org.apache.catalina.core.StandardContext reload
INFO: Reloading Context with name [/Mysql] has started
Mar 16, 2020 4:57:27 PM org.apache.catalina.core.StandardContext reload
INFO: Reloading Context with name [/Mysql] is completed
Mar 16, 2020 4:57:41 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jsp] in context with path [/Mysql] threw exception [javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/mysql/jdbc/Driver] with root cause
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1951)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1794)
at compute.DB.con(DB.java:21)
at org.apache.jsp.regCheck_jsp._jspService(regCheck_jsp.java:100)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:71)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:492)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:165)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:1025)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1195)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:654)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:319)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)
Try - 05 Trying to establish con in regCheck.jsp
Con method called Try 5A
Try 05a - Trying to connect
This is DB.java:
package compute;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.*;
public class DB {
final static String DB_URL = "jdbc:mysql://localhost:3306/new";
final static String USER = "admin";
final static String PASS = "admin";
public static Connection con() {
System.out.println("Con method called Try 5A");
Connection con;
try {
System.out.println("Try 05a - Trying to connect");
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
con = DriverManager.getConnection(DB_URL, USER, PASS);
System.out.println("Try 05a- con established ");
return con;
}catch(Exception e) {
System.out.println(e);
return null;
}
}
public static Statement st() {
Statement stmt;
try {
stmt=DB.con().createStatement();
return null;
}catch(Exception e) {
System.out.println(e);
return null;
}
}
}
This is regCheck.jsp:
<%#page import="java.sql.Connection" %>
<%#page import="compute.DB" %>
<%#page import="java.sql.PreparedStatement" %>
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
String user = request.getParameter("username");
System.out.println("Try - 05 Trying to establish con in regCheck.jsp");
Connection con = DB.con();
System.out.println("Preparing Statement in regCheck.jsp");
PreparedStatement p = con.prepareStatement("Insert into register(username)values(?)");
p.setString(1,user);
System.out.println("user::" +user);
int R = p.executeUpdate();
if(R!=0)
response.sendRedirect("index.html");
else
response.sendRedirect("register.jsp");
%>
</body>
</html>
The JDBC driver library is missing from your runtime CLASSPATH i.e. the CLASSPATH where Tomcat looks for the required classes in order to execute your compiled code.
I added mysql-connector-java-8.0.19.jar to Tomcat 7.0/Lib and now it's working find.
I removed it from Library and everywhere and it works.
I created new project with the same code and without adding mysql-connector-java-8.0.19.jar to any library or build path, it's running fine.
I found the instruction to add to tomcat somewhere on youtube.

Call Java method from JSP file

I have a problem with calling Java method from .jsp file. I converted my project into Maven but still have the same problem.
My .jsp file is in /db-reagencii/WebContent/reagents/reagents.jsp
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%#page import="cz.dbReagents.web.reagentsWeb.ReagentsWeb"%>
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Reagencie</title>
</head>
<body>
<jsp:include page="../WEB-INF/menu/menu.jsp"/>
Reagents
<jsp:useBean id="podnikyWeb" class="cz.dbReagents.web.reagentsWeb.ReagentsWeb" scope="request"/>
</body>
</html>
and i want call method from this class
package cz.dbReagents.web.reagentsWeb;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import cz.dbReagents.dto.reagents.Reagents;
public class ReagentsWeb implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
public Collection<Reagents> getReagents(){
ArrayList<Reagents> result = new ArrayList<Reagents>();
result.add(new Reagents("testovaci reagencie",11));
System.out.print(result.get(0).getName());
return result;
}
}
and this class
package cz.dbReagents.dto.reagents;
import java.io.Serializable;
public class Reagents implements Serializable{
private static final long serialVersionUID = 1L;
private String name;
private int sum;
public Reagents(){
}
public Reagents(String name, int sum){
this.name = name;
this.sum = sum;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getSum() {
return sum;
}
public void setSum(int sum) {
this.sum = sum;
}
}
but when I tried to load page a got this error
VI 11, 2015 8:47:28 ODP. org.apache.catalina.core.StandardWrapperValve
invoke SEVERE: Servlet.service() for servlet [jsp] in context with
path [/db-reagencii] threw exception [/reagents/reagents.jsp (line:
17, column: 1) The value for the useBean class attribute
cz.dbReagents.web.reagentsWeb.ReagentsWeb is invalid.] with root cause
org.apache.jasper.JasperException: /reagents/reagents.jsp (line: 17,
column: 1) The value for the useBean class attribute
cz.dbReagents.web.reagentsWeb.ReagentsWeb is invalid. at
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
at
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:443)
at
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:149)
at
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1242)
at org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1196) at
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2392) at
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2444) at
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2450) at
org.apache.jasper.compiler.Node$Root.accept(Node.java:474) at
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2392) at
org.apache.jasper.compiler.Generator.generate(Generator.java:3529) at
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:251)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:374) at
org.apache.jasper.compiler.Compiler.compile(Compiler.java:354) at
org.apache.jasper.compiler.Compiler.compile(Compiler.java:341) at
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:662)
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Is there a chance that I have bad configured server?
I have web.xml in /db-reagencii/WebContent/WEB-INF/web.xml and contains this:
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>Databáze Reagencií</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
I am using Tomcat 7.0.
This is my first web application in Java so I am sure that there is some stupid mistake but I can't find it.
Thanks for any advice :)
My error with scriplet.
VI 11, 2015 11:09:00 ODP.
org.apache.catalina.core.StandardWrapperValve invoke SEVERE:
Servlet.service() for servlet [jsp] in context with path
[/db-reagencii] threw exception [Unable to compile class for JSP:
An error occurred at line: [14] in the generated java file:
[/home/michal/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/work/Catalina/localhost/db-reagencii/org/apache/jsp/reagents/reagents_jsp.java]
Only a type can be imported.
cz.dbReagents.web.reagentsWeb.ReagentsWebHandler resolves to a package
An error occurred at line: [15] in the generated java file:
[/home/michal/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/work/Catalina/localhost/db-reagencii/org/apache/jsp/reagents/reagents_jsp.java]
Only a type can be imported. cz.dbReagents.dto.reagents.Reagents
resolves to a package
An error occurred at line: 18 in the jsp file: /reagents/reagents.jsp
ReagentsWebHandler cannot be resolved to a type 15: 16: Reagents 17: 18: <%
ReagentsWebHandler r = new ReagentsWebHandler(); %> 19: 20:
21:
An error occurred at line: 18 in the jsp file: /reagents/reagents.jsp
ReagentsWebHandler cannot be resolved to a type 15: 16: Reagents 17: 18: <%
ReagentsWebHandler r = new ReagentsWebHandler(); %> 19: 20:
21:
Stacktrace:] with root cause org.apache.jasper.JasperException: Unable
to compile class for JSP:
An error occurred at line: [14] in the generated java file:
[/home/michal/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/work/Catalina/localhost/db-reagencii/org/apache/jsp/reagents/reagents_jsp.java]
Only a type can be imported.
cz.dbReagents.web.reagentsWeb.ReagentsWebHandler resolves to a package
An error occurred at line: [15] in the generated java file:
[/home/michal/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/work/Catalina/localhost/db-reagencii/org/apache/jsp/reagents/reagents_jsp.java]
Only a type can be imported. cz.dbReagents.dto.reagents.Reagents
resolves to a package
An error occurred at line: 18 in the jsp file: /reagents/reagents.jsp
ReagentsWebHandler cannot be resolved to a type 15: 16: Reagents 17: 18: <%
ReagentsWebHandler r = new ReagentsWebHandler(); %> 19: 20:
21:
An error occurred at line: 18 in the jsp file: /reagents/reagents.jsp
ReagentsWebHandler cannot be resolved to a type 15: 16: Reagents 17: 18: <%
ReagentsWebHandler r = new ReagentsWebHandler(); %> 19: 20:
21:
Stacktrace: at
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
at
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:366)
at
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:485)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:379) at
org.apache.jasper.compiler.Compiler.compile(Compiler.java:354) at
org.apache.jasper.compiler.Compiler.compile(Compiler.java:341) at
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:662)
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
I got this error when I put only this lines into ragents.jsp
<%# page import="cz.dbReagents.web.reagentsWeb.ReagentsWebHandler " %> <h1>Hello World</h1>
VI 11, 2015 11:14:05 ODP.
org.apache.catalina.core.StandardWrapperValve invoke SEVERE:
Servlet.service() for servlet [jsp] in context with path
[/db-reagencii] threw exception [Unable to compile class for JSP:
An error occurred at line: [14] in the generated java file:
[/home/michal/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/work/Catalina/localhost/db-reagencii/org/apache/jsp/reagents/reagents_jsp.java]
Only a type can be imported.
cz.dbReagents.web.reagentsWeb.ReagentsWebHandler resolves to a package
Stacktrace:] with root cause org.apache.jasper.JasperException: Unable
to compile class for JSP:
An error occurred at line: [14] in the generated java file:
[/home/michal/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/work/Catalina/localhost/db-reagencii/org/apache/jsp/reagents/reagents_jsp.java]
Only a type can be imported.
cz.dbReagents.web.reagentsWeb.ReagentsWebHandler resolves to a package
Stacktrace: at
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
at
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:366)
at
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:485)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:379) at
org.apache.jasper.compiler.Compiler.compile(Compiler.java:354) at
org.apache.jasper.compiler.Compiler.compile(Compiler.java:341) at
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:662)
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
When I deploy war files into tomcat i got this error
VI 11, 2015 11:50:18 ODP. org.apache.catalina.core.ApplicationContext
log INFO: ContextListener: contextInitialized() VI 11, 2015 11:50:18
ODP. org.apache.catalina.core.ApplicationContext log INFO:
SessionListener: contextInitialized() VI 11, 2015 11:50:18 ODP.
org.apache.catalina.core.ApplicationContext log INFO: ContextListener:
attributeAdded('org.apache.jasper.compiler.TldLocationsCache',
'org.apache.jasper.compiler.TldLocationsCache#68ccc170') VI 11, 2015
11:50:45 ODP. org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jsp] in context with path
[/db-reagencii] threw exception [Unable to compile class for JSP:
An error occurred at line: [14] in the generated java file:
[/home/michal/apps/apache-tomcat-7.0.62/work/Catalina/localhost/db-reagencii/org/apache/jsp/reagents/reagents_jsp.java]
Only a type can be imported.
cz.dbReagents.web.reagentsWeb.ReagentsWebHandler resolves to a package
Stacktrace:] with root cause org.apache.jasper.JasperException: Unable
to compile class for JSP:
An error occurred at line: [14] in the generated java file:
[/home/michal/apps/apache-tomcat-7.0.62/work/Catalina/localhost/db-reagencii/org/apache/jsp/reagents/reagents_jsp.java]
Only a type can be imported.
cz.dbReagents.web.reagentsWeb.ReagentsWebHandler resolves to a package
Stacktrace: at
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
at
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:366)
at
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:485)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:379) at
org.apache.jasper.compiler.Compiler.compile(Compiler.java:354) at
org.apache.jasper.compiler.Compiler.compile(Compiler.java:341) at
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:662)
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
you have an extra space before "page" in the JSP Import directive:
<%#page import="cz.dbReagents.web.reagentsWeb.ReagentsWeb"%>
It should be:
<%# page import="cz.dbReagents.web.reagentsWeb.ReagentsWeb"%>
I really hate using java sentences in JSP but if you want to do it this way, just modify your ReagentsWeb this way:
public class ReagentsWeb {
public Collection<Reagents> reagents;
public ReagentsWeb(){
reagents = this.getReagents();
}
public Collection<Reagents> getReagents(){
ArrayList<Reagents> result = new ArrayList<Reagents>();
result.add(new Reagents("testovaci reagencie",11));
return result;
}
}
In your JSP do this:
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%#page import="cz.dbReagents.web.reagentsWeb.ReagentsWeb"%>
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Reagencie</title>
</head>
<body>
<jsp:include page="../WEB-INF/menu/menu.jsp"/>
Reagents
<%
for(Reagent r : reagents){
out.println(r.getName());
}
%>
</body>
</html>

PHP JavaBridge ClassNotFoundException - works on my machine, but not on server

Linux server with Apache2, Tomcat7, PHP 5.5.10 are all up and running
Got this project where we have a JavaBridge installed for report generation, I have this working like a charm on my windows pc in an xampp environment, but on the server I am getting a ClassNotFoundException.
I can access the JavaBridge directly from the site by:
http://mysite:8080/JavaBridge/java/Java.inc
However from the PHP I keep getting this error of ClassNotFoundException
//getting Java.inc
//acquired Java.incdisplay
//java propertiesIn Java.inc
[[o:Exception]:"java.lang.Exception: CreateInstance failed: new com.nlrt.reportgenerator.ReportGenerator([o:PhpParserString], [o:PhpParserString], [o:PhpParserString]).
Cause: java.lang.ClassNotFoundException: com.nlrt.reportgenerator.ReportGenerator VM: 1.6.0_27#http://java.sun.com/" at:
#-32 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
#-31 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
#-30 java.lang.Class.forName0(Native Method)
#-29 java.lang.Class.forName(Class.java:266)
#-28 php.java.bridge.Util.classForName(Util.java:1518)
#-27 php.java.bridge.JavaBridge.CreateObject(JavaBridge.java:445)
#-26 php.java.bridge.Request.handleRequest(Request.java:458)
#-25 php.java.bridge.Request.handleOneRequest(Request.java:510)
#-24 php.java.servlet.PhpJavaServlet.handleLocalConnection(PhpJavaServlet.java:202)
#-23 php.java.servlet.PhpJavaServlet.handlePut(PhpJavaServlet.java:250)
#-22 php.java.servlet.PhpJavaServlet.doPut(PhpJavaServlet.java:261)
#-21 javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
#-20 javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
#-19 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
#-18 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
#-17 php.java.servlet.PhpCGIFilter.doFilter(PhpCGIFilter.java:126)
#-16 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
#-15 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
#-14 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
#-13 org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
#-12 org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
#-11 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) #-10 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) #-9 org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927) #-8 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) #-7 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) #-6 org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
#-5 org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
#-4 org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
#-3 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
#-2 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
#-1 java.lang.Thread.run(Thread.java:679)
#0 /home/dev/public/sanome.com/public/java/Java.inc(232): java_ThrowExceptionProxyFactory->getProxy(1, NULL, 'T', false)
#1 /home/dev/public/sanome.com/public/java/Java.inc(360): java_Arg->getResult(false)
#2 /home/dev/public/sanome.com/public/java/Java.inc(363): java_Client->getWrappedResult(false)
#3 /home/dev/public/sanome.com/public/java/Java.inc(535): java_Client->getInternalResult()
#4 /home/dev/public/sanome.com/public/java/Java.inc(1930): java_Client->createObject('com.nlrt.report...', Array)
#5 /home/dev/public/sanome.com/public/devicePorts/FileManager.class.php(139): Java->Java('com.nlrt.report...', '372', '/home/dev/publi...', '{"result_id":"4...')
#6 /home/dev/public/sanome.com/public/devicePorts/FileManager.class.php(65): FileManager->generateAndStreamPDF('1', '372')
#7 /home/dev/public/sanome.com/public/devicePorts/FileManager.class.php(43): FileManager->handleGenerateAndStreamPDF()
#8 /home/dev/public/sanome.com/public/report_generation/download_pdf.php(76): FileManager->__construct(Array, '1')
#9 {main}]
//500 Encountered exception while trying to create ReportGenerator
The PHP code that is accessing the required resources is as follows:
try
{
// we'll be using JavaBridge
echo "getting Java.inc";
require_once('../java/Java.inc');// http://sanome.com:8080/JavaBridge/java/Java.inc
echo "acquired Java.inc";
echo "display java properties";
//echo java("java.lang.System")->getProperties();
$reportGenerator = new java("com.nlrt.reportgenerator.ReportGenerator", $st_usage_id, $report_generator_directory, json_encode($results_array));
echo "created reportGenerator";
}
catch(Exception $exception)
{
var_dump($exception) ;//$exception;
}
The required JAR has been packaged and added to the WEB-INF/lib directory of the JavaBridge.
Also the php.ini file has the config
allow_url_include=On
I have even followed these steps but I am having no luck.
javabridge setup/installation issue
From what I have provided can anyone please help me?
Please don't criticize the solution for it was not my design. I am just trying to get it working, while adding to it.
Thank you.

Exception with ClassPathXmlApplicationContext

I'm working with servlet + spring. The servlet shows this exception in
ApplicationContext context = new ClassPathXmlApplicationContext("my_config.xml");
This is ecxeption text:
28.08.2013 16:27:36 org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [my_spring2] in context
with path [/test_spring2] threw exception [Servlet execution threw an
exception] with root cause java.lang.ClassNotFoundException:
org.springframework.context.support.ClassPathXmlApplicationContext at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
at main_package.my_spring.doGet(my_spring.java:34) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
Source) at java.lang.Thread.run(Unknown Source)
28.08.2013 16:27:59 org.apache.catalina.core.StandardContext reload INFO: Reloading Context with name [/test_spring2] has started
28.08.2013 16:28:00 org.apache.catalina.core.StandardContext reload INFO: Reloading Context with name [/test_spring2] is completed
I see that the exception you got is java.lang.ClassNotFoundException
Unless you are involved in dynamic class loading and using the Java Reflection API, chances are that the ClassNotFoundException error you are getting is not from your application code but from a referencing API. Another common problem pattern is a wrong packaging of your application code.
Check to see if all the jars are added to your classpath.
Also some jars depend on other jars for their working. In that case you will have to add those jars too !
look at the line 34 in main_package.my_spring.doGet(my_spring.java:34) and see if it is referenced from local class or from an API?
If project-> build automatically is on on your eclipse if using eclipse, then you must be having class file, else you might see errors in the explorer.
most probably the class that you are referencing is from an API, if not try add jars from your project build path.

How do I parse/read this XML file in JSP

I have following XML files below which I am trying to read from JSP using the tutorial on http://www.easywayserver.com/blog/java-read-xml-file/:
XML FILE 1:
<root>
<data v="1.0">
<cellimage counter="0" cash_filename="C:\Temp\_TempFolder\39d437f08cc302876a70a0f91b137991_h.jpg" width="94" height="141" />
<cellimage counter="1" cash_filename="C:\Temp\_TempFolder\39d437f08cc302876a70a0f91b137991_h.jpg" width="94" height="141" />
</data>
</root>
XML FILE 2
<people>
<person>
<name>Joe</name>
<age>30</age>
</person>
<person>
<name>Rob</name>
<age>29</age>
</person>
</people>
XML file 1 above throws an error on following line but 2nd XML file works just fine. Can someone please tell me how I can make the XML file 1 to work?
String dateTagValue=dateElements.getChildNodes().item(0).getNodeValue();
Error stacktrace:
Caused by: org.apache.jasper.JasperException: An exception occurred processing JSP page /html/archivedetails/view.jsp at line 33
30: for (int i = 0; i < nl.getLength(); i++) {
31: NodeList nameNlc = doc.getElementsByTagName("counter");
32: Element nameElements = (Element) nameNlc.item(i);
33: String nameTagValue = nameElements.getChildNodes().item(0).getNodeValue();
34:
35: out.println("name :" + nameTagValue + "<br>");
36: }
Stacktrace:
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:73)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:593)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:530)
at com.liferay.portlet.PortletRequestDispatcherImpl.dispatch(PortletRequestDispatcherImpl.java:323)
at com.liferay.portlet.PortletRequestDispatcherImpl.include(PortletRequestDispatcherImpl.java:105)
... 167 more
Caused by: java.lang.NullPointerException
at org.apache.jsp.html.archivedetails.view_jsp._jspService(view_jsp.java:152)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
... 182 more
The exception is in
String nameTagValue = nameElements.getChildNodes().item(0).getNodeValue();
So either nameElements is null or it has no child nodes (getChildNodes() returns null).
The code is highly suspicious because you are looping over nl, but then using the index to access elements of nameNlc which may or may not have the same number of elements. Also, you're looking for elements named <counter>, which don't appear in either sample.
There's a serious disconnect between the error message and what you're showing, and I suspect you need to take a close look at what you're doing. There are probably other inconsistencies as well.
I realize this is borderline as an answer (may have been better as a comment) but it's too long for a comment and, given the inconsistencies in your post, is probably the best you can hope for.

Categories