Following is my code which runs pigrunner and pigstats:
String[] args = {"abc.pig"};
PigStats stats = PigRunner.run(args,null);
System.out.println("Stats : " + stats.getReturnCode());
OutputStats os = stats.result("B");
Iterator<Tuple> it = os.iterator();
while(it.hasNext()){
Tuple t = it.next();
System.out.println(t.getAll());
}
Contents of abc.pig
A = load 'Courses' using PigStorage(' ');
B = foreach A generate $0 as id;
dump B;
I get the correct output but it is followed by this exception Stacktrace with root cause
org.apache.hadoop.mapreduce.lib.input.InvalidInputException: Input path does not exist: hdfs://localhost:54310/tmp/temp-221133443/tmp1478461116
at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.listStatus(FileInputFormat.java:235)
at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigFileInputFormat.listStatus(PigFileInputFormat.java:37)
at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.getSplits(FileInputFormat.java:252)
at org.apache.pig.impl.io.ReadToEndLoader.init(ReadToEndLoader.java:154)
at org.apache.pig.impl.io.ReadToEndLoader.<init>(ReadToEndLoader.java:116)
at org.apache.pig.tools.pigstats.OutputStats.iterator(OutputStats.java:148)
at org.apache.jsp.result_jsp._jspService(result_jsp.java:86)
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:419)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
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:304)
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:562)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
Now the same code works without an error if I replace the DUMP with a STORE.
Can some please explain me what is going on ?
Thanks
Ravi
In case of dump Pig stores the output at a temporary location, e.g: hdfs://localhost/tmp/temp797130848/tmp1101984728
(have a look pig.map.output.dirs in your job's config.xml)
PigRunner.run() calls GruntParser.processDump(String alias) at some point of the process which iterates through the result tuples and prints them out to the console:
Iterator<Tuple> result = mPigServer.openIterator(alias);
while (result.hasNext())
{
Tuple t = result.next();
System.out.println(TupleFormat.format(t));
}
After this, but before returning, it also calls FileLocalizer.deleteTempFiles() which deletes this temporary directory.
Now you want to return the result of alias B.
OutputStats's iterator tries to open the temporary file again to loop over the tuples as PigRunner.run() did it before.
But the problem is that this file doesn't exist anymore, therefore your get the exception.
So I'd suggest you to remove the code after System.out.println("Stats : " + stats.getReturnCode()); since you already have the dump printed out.
Related
I'm receiving the following error in the Apache logs when starting my application
I've found BCrypt.checkpw() Invalid salt version exception
But this is not a match as the passwords stored in the DB for my users are hashed and this error appears on start up and I've no issues logging in 99.99% of the time.
29-Oct-2017 22:12:32.242 SEVERE [http-nio-8084-exec-1] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [UserController] in context with path [/medsched] threw exception
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:658)
at org.mindrot.jbcrypt.BCrypt.hashpw(BCrypt.java:658)
at org.mindrot.jbcrypt.BCrypt.checkpw(BCrypt.java:764)
at medsched.data.UserDB.loginUser(UserDB.java:216)
at medsched.controllers.UserController.logInToSite(UserController.java:165)
at medsched.controllers.UserController.doPost(UserController.java:41)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:213)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at medsched.filters.SecPageFilter.doFilter(SecPageFilter.java:61)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
It does not seem to affect the application as nearly most of the time as I can log in or if I present a password mismatch I am returned to a login error jsp defined in my application. I do some times, however receive a 500 error page with
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:658)
at org.mindrot.jbcrypt.BCrypt.hashpw(BCrypt.java:658)
at org.mindrot.jbcrypt.BCrypt.checkpw(BCrypt.java:764)
at medsched.data.UserDB.loginUser(UserDB.java:216)
at medsched.controllers.UserController.logInToSite(UserController.java:165)
at medsched.controllers.UserController.doPost(UserController.java:41)
Could it be the way I'm using BCrypt.checkpw ?? I'd understand the error appearing if I was attempting to log in, but not on starting the application in Netbeans.
public static User loginUser(String phnum,String passw) {
ConnectionPool pool = ConnectionPool.getInstance();
Connection connection = pool.getConnection();
PreparedStatement ps = null;
ResultSet rs = null;
String hpwd="";
//Get the key
String key=confUtil.encDeckey();
String query = "SELECT userid,fName,pwd FROM users "
+ "WHERE phone = AES_ENCRYPT(?,?) AND active=1";
try {
ps = connection.prepareStatement(query);
ps.setString(1, phnum);
ps.setString(2, key);
rs = ps.executeQuery();
User user = null;
if (rs.next()) {
user = new User();
user.setUserID(rs.getLong("userid"));
user.setFName(rs.getString("fName"));
user.setPwd(rs.getString("pwd"));
hpwd=user.getPwd();
}
if(hpwd!=null || !hpwd.isEmpty()){
if(!BCrypt.checkpw(passw,hpwd)){
user=null;
}
}
} catch (SQLException e) {
//System.err.println(e);
log.error("Exception when trying to log in",e);
return null;
} finally {
DBUtil.closeResultSet(rs);
DBUtil.closePreparedStatement(ps);
pool.freeConnection(connection);
}
}
Issue occurred again today, posting the 500 error that I'm getting
HTTP Status 500 - String index out of range: 0
type Exception report
message String index out of range: 0
description The server encountered an internal error that prevented it from fulfilling this request.
exception
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
java.lang.String.charAt(String.java:658)
org.mindrot.jbcrypt.BCrypt.hashpw(BCrypt.java:658)
org.mindrot.jbcrypt.BCrypt.checkpw(BCrypt.java:764)
medsched.data.UserDB.loginUser(UserDB.java:190)
medsched.controllers.UserController.logInToSite(UserController.java:169)
medsched.controllers.UserController.doPost(UserController.java:41)
javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:213)
medsched.filters.SecPageFilter.doFilter(SecPageFilter.java:61)
org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.27 logs.
I just ran into a similar issue:
Bcrypt throws java.lang.StringIndexOutOfBoundsException: String index out of range: 0.
In my case I found out that the hashed password was empty.
I can't tell why this error is appearing at app start without seeing more code.
I have a JSP page with two tabs and I am trying to run some Java code in the second tab but I keep getting a null pointer exception. I swear my Java Code is correct but the second tab wont show up either.
<%
String fn = request.getParameter("fn9");
String ln = request.getParameter("ln9");
String primaryEmail = request.getParameter("primaryemail9");
CreatingTheProviderFile ctpf = new CreatingTheProviderFile();
char[] c = fn.toCharArray();
if(fn != null){
System.out.println("it is blank");
}else{
System.out.println("it is something else");
}
if(fn != ''){
ctpf.FillNameArray(fn, ln, primaryEmail);
}
%>
JSP for some reason doesnt like the char statement nor does it like the if statement. This is my stacktrace
Dec 18, 2013 11:37:33 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jsp] in context with path [/TwoWayPortal] threw exception [An exception occurred processing JSP page /patient_discharge.jsp at line 800
797:
798: // CreatingTheProviderFile ctpf = new CreatingTheProviderFile();
799:
800: char[] c = fn.toCharArray();
801:
802: System.out.println(c[0]);
803: // System.out.println(String.valueOf(fn.charAt(0)));
Stacktrace:] with root cause
java.lang.NullPointerException
at org.apache.jsp.patient_005fdischarge_jsp._jspService(patient_005fdischarge_jsp.java:999)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
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:728)
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:205)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
I appreciate any help,
Thank You
The line that throws the NullPointerException is the line with fn.toCharArray(); This implies that fn is null.
Try
if(fn != null){
//do stuff here
}
Yes. fn is null.
// test for null, init to null if fn is null.
char[] c = (fn != null) ? fn.toCharArray() : null;
if (fn != null) {
System.out.println("it is not null");
if (fn.length() > 0) { // fn != '' is illegal, could have used !fn.equals("") -
// note double quotes (not single).
ctpf.FillNameArray(fn, ln, primaryEmail);
}
} else {
System.out.println("it is something else");
}
Before doing fn.toCharArray() check whether fn is null or not. You are checking it later. But if fn is null, you will get exception on fn.toCharArray() only and rest of the code wont execute.
When you change tabs, you may be losing data in request scope (just a guess). As an experiment, you can consider putting data in session scope instead. If it works, you may conider weather or not its of value to leave it as session scope.
I'm new to drools and what I'm trying to do is to get a value from the rules
I used the code from the project sample of drools which is:
Reading the DRL file:
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newClassPathResource( "path.drl", getClass() ), ResourceType.DRL );
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if( errors.size() > 0 )
{
for( KnowledgeBuilderError error : errors )
{
System.err.println( error );
}
throw new IllegalArgumentException( "Could not parse knowledge." );
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
return kbase;
Inserting object and firing the rules
Bean bean = new Bean();
StatefulKnowledgeSession ksession = aKnowledgeBase.newStatefulKnowledgeSession();
// planning to insert a double
ksession.insert( bean );
ksession.fireAllRules();
What I want to do is to get a value from the rules, What I tried so far is using query which is I'm not sure if it is the proper way of doing it:
global String $test;
rule "Excellent"
when
// I'm planning to replace the bean with just a double is that possible?
$m: bean ( listeningScore > 85 )
$p: bean ( listeningScore < 101 )
then
$test = "Excellent";
System.out.println( $test );
end
query "Knowledge"
$result : $test
end
Also this produce an error which I really don't know how to fix. Here is the stacktrace:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[24,0]: [ERR 102] Line 24:0 mismatched input 'end' in query
[0,0]: Parser returned a null Package
java.lang.IllegalArgumentException: Could not parse knowledge.
at com.neu.als.thesis.units.InferenceEngine.readKnowledgeBase(InferenceEngine.java:61)
at com.neu.als.thesis.units.EvaluationUnit.evaluateConceptKnowledgeLevel(EvaluationUnit.java:187)
at com.neu.als.thesis.web.controllers.FLTController.evaluateFLT(FLTController.java:108)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:444)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:432)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:946)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:848)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:822)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
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:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Firstly, that exception means that the DRL code won't compile. I suspect this is because your query is referencing a bound variable from another rule, but it could be something else. Check out the docs on syntax for queries.
However, I tend to use one of two mechanisms for getting rule responses into the Java code.
In a stateless session have rules modify the inserted fact(s). After rules execution, just look at the fact that you inserted.
In a stateful session you can additionally use session.getObjects() or session.getObjects(ObjectFilter) to get references to the facts that are in the working memory after rules execution.
Here's an example of the first pattern, modifying the inserted fact:
rule "Reject a request"
when
$req: PaymentValidationRequest()
then
$req.setValid(false);
update($req);
end
PaymentValidationRequest request = new PaymentValidationRequest(payment);
request.setPayment(payment);
List<Object> facts = new ArrayList<Object>();
facts.add(request);
ksession.execute(facts);
...
boolean isValid = request.isValid()
List<ValidationAnnotation> annotations = request.getAnnotations();
Here's an example of the second pattern, when your rules have inserted or modified facts:
ObjectFilter filter = new ObjectFilter() {
#Override
public boolean accept(Object object) {
return object.getClass().getSimpleName().equals("MyFact");
}
};
for (FactHandle handle : session.getFactHandles(filter)) {
Object fact = session.getObject(handle);
// Do something with the fact you just found in working memory.
// ...
}
I am building a web application for feature extraction and comparing the feature of images, using JSP, Java, and PostgreSQL.
My feature extraction is extracting some features from images, so that then I can compare them (some features are about color, some on the histogram of the image and so. I have special methods that extract them using specific libraries (jars that I add into lib) as you can see in the following example!
Those features are then successfully being added into my PostgreSQL database.
public void GetImageProperties(String targetPath, ImageProperties imagesProperties) throws Exception
{
// load image
FileInputStream imageStream;
imageStream = new FileInputStream(targetPath);
BufferedImage bimg = ImageIO.read(imageStream);
// get properties
imagesProperties.cl = new ColorLayoutImpl(bimg);
imagesProperties.eh = new EdgeHistogramImplementation(bimg);
imagesProperties.sc = new ScalableColorImpl(bimg);
}
Then I add them into a postgresql database(only the features, not the images)
String query = "CREATE TABLE Images (" +
" imageid SERIAL PRIMARY KEY," +
" fname VARCHAR(128)," +
" colorlayout VARCHAR(512), " +
" edgehist VARCHAR(512), " +
" scalablecolor VARCHAR(512) " +
")";
I get this error every time I had loaded an image and want to compare it with all the other images in a directory.
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: An exception occurred processing JSP page /query.jsp at line 124
121: if (bSearch) {
122: // get form params
123: query.setTopK(new Integer(request.getParameter("frm_topk")));
124: query.setColorHistogramWeight(new Integer(request.getParameter("frm_weight_c1")));
125: query.setColorDistributionWeight(new Integer(request.getParameter("frm_weight_c2")));
126: query.setTextureWeight(new Integer(request.getParameter("frm_weight_c3")));
127: }
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
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)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
root cause:
java.lang.NumberFormatException: For input string: "1.0"
java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
java.lang.Integer.parseInt(Integer.java:492) java.lang.Integer.<init>
(Integer.java:677) org.apache.jsp.query_jsp._jspService(query_jsp.java:256)
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)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.27 logs.
Your problem is here
query.setTopK(new Integer(request.getParameter("frm_topk")));
should be
String parFrm_topk = request.getParameter("frm_topk");
Integer frm_topk = null;
if (parFrm_topk != null && parFrm_topk.length() > 0 && !parFrm_topk.equals("null"))
try {
frm_topk = Integer.valueOf(parFrm_topk);
} catch (NumberFormatException nfe){
throw nfe;
}
if (frm_topk ! = null) {
query.setTopK(frm_topk);
this code is trying to check the parameter that could be empty, why it is empty depends on how flow the app and how parameters are passed through url.
i get this error when i calculate the string value : Double.toString(Double.parseDouble(suggestionSortScore) - 6)
17:47:19,983 INFO [STDOUT] [EDS ALL LIST] NOC BLACK LIST : Sugeng
Hindarjo
17:47:19,984 ERROR [[jsp]] Servlet.service() for servlet jsp threw
exception java.lang.NumberFormatException: empty String
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:994)
at java.lang.Double.parseDouble(Double.java:510)
at org.apache.jsp.WEB_002dINF.jsp.n51Alist_jsp.getTransactionsFromIpg(n51Alist_jsp.java:380)
at org.apache.jsp.WEB_002dINF.jsp.n51Alist_jsp._jspService(n51Alist_jsp.java:581)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
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.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
at nsia.owasp.util.Controller.doPost(Controller.java:166)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
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.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
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.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:437)
at org.apache.coyote.ajp.AjpProtocol$AjpConnectionHandler.process(AjpProtocol.java:366)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Thread.java:662) 17:47:19,984 INFO [STDOUT] Exception => org.apache.jasper.JasperException: An exception
occurred processing JSP page /WEB-INF/jsp/n51Alist.jsp at line 370
367: if(cekBlackListByNoc==true){
368: System.out.println("[EDS ALL LIST] NOC BLACK
LIST : " + nameOnCardDecrypt);
369: data[0] = "yellow";
370: data[17] =
Double.toString(Double.parseDouble(suggestionSortScore) - 6);
371: if (Double.parseDouble(data[17]) < 3.0) {
372: data[17] = "3.1";
373: }
why the stacktrace said emptystring? the suggestionsortscore is filled with value "5.0".
Double.toString(Double.parseDouble(suggestionSortScore) - 6) -- will through an exception only when string suggestionSortScore does not contain a parsable double
The exception is launched by Double.parseDouble(suggestionSortScore) and says that suggestionSortScore is empty, I'll check that again.
Anyway you can check the documentation on: parseDouble