Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nested exception is java.lang.NullPointerException] with root cause while running application on remote machine #10

Open
jamshaid120 opened this issue Mar 16, 2020 · 28 comments

Comments

@jamshaid120
Copy link
Contributor

I've installed the application on a remote linux machine. After I run the app with gradle bootrun, it throws the below error while running the rules. It works fine when I run in the local machine.

`2020-03-16 03:27:57.282 ERROR 24422 --- [nio-8080-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause

java.lang.NullPointerException: null
at com.NadiaRS.InferenceEngine.ruleParser.RuleSetParser.handleChild(RuleSetParser.java:347) ~[main/:na]
at com.NadiaRS.InferenceEngine.ruleParser.RuleSetScanner.scanRuleSet(RuleSetScanner.java:99) ~[main/:na]
at com.NadiaRS.controller.InferenceController.setInferenceEngine(InferenceController.java:202) ~[main/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97) ~[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) ~[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) ~[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967) ~[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901) ~[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) ~[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) ~[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687) ~[javax.servlet-api-3.1.0.jar:3.1.0]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) ~[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) ~[javax.servlet-api-3.1.0.jar:3.1.0]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.5.23.jar:8.5.23]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:108) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]

`

@DeanLee77
Copy link
Collaborator

can you send me a rule set you used in the server? it seems that there was an issue with rules.

@jamshaid120
Copy link
Contributor Author

jamshaid120 commented Mar 16, 2020

I am using Testing for ALL Node Lines and features.txt from https://github.com/DeanLee77/Nadia/tree/master/bin/testingPackage/testing10.
It works fine on the localhost on my machine but when I run it on a remote machine, it causes the issue. It reads the rule correctly. I've tested printing parentText in the method
` @OverRide
public void handleParent(String parentText, int lineNumber) {

	Node data = nodeSet.getNodeMap().get(parentText);
	System.out.println("parentText "+ parentText);

`
It gives the same output on both local and remote machine

@jamshaid120
Copy link
Contributor Author

There's a difference in the output of the above method on both local and remote machines.
Local Machine produces indexOfRuleToBeAsked : 1 after the ouput of System.out.println("parentText "+ parentText); ends but remote machine doesn't print it.

@DeanLee77
Copy link
Collaborator

it is .RuleSetParser.handleChild(RuleSetParser.java:347) issue in com.NadiaRS/InferenceEngine/ruleParser
it might be a reason that Node object was not created or there was no NodeSet object created. but still it does NOT make sense to me. can you put a log to print 'data' instance of Node class or NodeSet instance named nodeSet?

@jamshaid120
Copy link
Contributor Author

datanull datanull datanull datanull datanull datanull datanull datanull datanull datanull datanull datanull datacom.NadiaRS.InferenceEngine.nodePackage.ValueConclusionLine@2d8f9195 datanull datanull datanull datanull datanull datacom.NadiaRS.InferenceEngine.nodePackage.ValueConclusionLine@46a20799 datacom.NadiaRS.InferenceEngine.nodePackage.ValueConclusionLine@5a90b0b2 datacom.NadiaRS.InferenceEngine.nodePackage.ValueConclusionLine@1ade2363 datacom.NadiaRS.InferenceEngine.nodePackage.ValueConclusionLine@135c5d6e
While printing node object from
Node data = nodeSet.getNodeMap().get(parentText);, it gives the above output

@jamshaid120
Copy link
Contributor Author

for nodeSet object, when I run System.out.println("nodeSet ",nodeSet);
nodeset com.NadiaRS.InferenceEngine.nodePackage.NodeSet@51bb83ee nodeset com.NadiaRS.InferenceEngine.nodePackage.NodeSet@51bb83ee nodeset com.NadiaRS.InferenceEngine.nodePackage.NodeSet@51bb83ee nodeset com.NadiaRS.InferenceEngine.nodePackage.NodeSet@51bb83ee nodeset com.NadiaRS.InferenceEngine.nodePackage.NodeSet@51bb83ee nodeset com.NadiaRS.InferenceEngine.nodePackage.NodeSet@51bb83ee nodeset com.NadiaRS.InferenceEngine.nodePackage.NodeSet@51bb83ee nodeset com.NadiaRS.InferenceEngine.nodePackage.NodeSet@51bb83ee nodeset com.NadiaRS.InferenceEngine.nodePackage.NodeSet@51bb83ee nodeset com.NadiaRS.InferenceEngine.nodePackage.NodeSet@51bb83ee nodeset com.NadiaRS.InferenceEngine.nodePackage.NodeSet@51bb83ee nodeset com.NadiaRS.InferenceEngine.nodePackage.NodeSet@51bb83ee nodeset com.NadiaRS.InferenceEngine.nodePackage.NodeSet@51bb83ee nodeset com.NadiaRS.InferenceEngine.nodePackage.NodeSet@51bb83ee nodeset com.NadiaRS.InferenceEngine.nodePackage.NodeSet@51bb83ee nodeset com.NadiaRS.InferenceEngine.nodePackage.NodeSet@51bb83ee nodeset com.NadiaRS.InferenceEngine.nodePackage.NodeSet@51bb83ee nodeset com.NadiaRS.InferenceEngine.nodePackage.NodeSet@51bb83ee nodeset com.NadiaRS.InferenceEngine.nodePackage.NodeSet@51bb83ee nodeset com.NadiaRS.InferenceEngine.nodePackage.NodeSet@51bb83ee nodeset com.NadiaRS.InferenceEngine.nodePackage.NodeSet@51bb83ee nodeset com.NadiaRS.InferenceEngine.nodePackage.NodeSet@51bb83ee

@DeanLee77
Copy link
Collaborator

it seems that you printed Node object in a 'handleParent(String parentText, int lineNumber)'.
Can you put ' System.out.println("line number: " + lineNumber); System.out.println("data : "+data.getNodeName()); ' at line:345 in RuleSetParser class, which is inside of 'handleChild()' method?

@jamshaid120
Copy link
Contributor Author

jamshaid120 commented Mar 16, 2020

output.txt
Here is the output. It doesn't print line 118 to 120 which I am getting on my local machine

@DeanLee77
Copy link
Collaborator

hum... I have looked at the output file, and was wondering if the NADIA crushed after attempt to read line 118 of the rule file or not.
I found that it only printed upto line 117 even there is a number of lines after that, and strangely a line number of 118 should be printed if there was an issue on parsing the line but the line number was not printed.

@jamshaid120
Copy link
Contributor Author

Yeah. Some issue occurs after 117 and it crashes. I've tested other files as well but when the last 3 or 4 lines are left, it throws the exception. On the local machine, it doesn't behave like that

@jamshaid120
Copy link
Contributor Author

I cloned the repository to a new folder. and started it again. It is working fine this time. I don't know what was the issue behind it

@DeanLee77
Copy link
Collaborator

Glad to hear that it is working now. sometimes Java works funny. Anyhow, when you need help, let me know. by the way, what is the entire project about, may I ask?

@jamshaid120
Copy link
Contributor Author

I tried running https://github.com/DeanLee77/Nadia/tree/master/bin/testingPackage/testing10 but it throws the same error. For https://github.com/DeanLee77/Nadia/blob/master/bin/testingPackage/testing2/Wedding%20Planner.txt
this test, it is working fine on the remote machine. I don't know what might be causing the issue.

@jamshaid120
Copy link
Contributor Author

They are working on deploying a system that works like your application. I didn't ask for many details. The UI for this app is kinda difficult for a user.

@DeanLee77
Copy link
Collaborator

so the application in the server does NOT work for a file, https://github.com/DeanLee77/Nadia/blob/master/bin/testingPackage/testing10/Testing for ALL Node Lines and features.txt?

but works with the file, 'https://github.com/DeanLee77/Nadia/blob/master/bin/testingPackage/testing2/Wedding Planner.txt '.

Do I understand correctly?

@jamshaid120
Copy link
Contributor Author

Yeah. That's right. I am now testing for other files as well and will let you know the result

@jamshaid120
Copy link
Contributor Author

It causes the issues with the server on test 6,7,8 and 10. With rest of the files, it is working fine

@DeanLee77
Copy link
Collaborator

I Kind of have an idea what caused the error. the text file you tested contains a symbolic quotation mark at line: 118(“Steam force”), 11(“Australian”), 11(“Australian”), 10(“Australian”) of 10, 8, 7, 6 files respectively. Even though, handing such symbolic quotation mark has been handled during regex of Tokenizer class, it seems that the regex works funny in your environment.

Anyhow, I believe once you changed the symbolic quotation mark from ( “ ” ) to ( " " ) then it will work. If it does not then need to put another log where appropriate.

Please let me know how it goes.

@jamshaid120
Copy link
Contributor Author

Yeah. It was exactly the same issue. I wonder why it was doing so. I've noticed one thing which is if I save the file with (“ ”) and then retrieve it from the database, the sign “ ” is replaced with ? ?. Here is the retrieved value for test 6 and same happens for test 10.

FIXED name list AS LIST
	ITEM John Smith
	ITEM Dean Tudir
	ITEM Agness Huge
	ITEM Sugar Sweet
	ITEM Tim Armond
	ITEM Lolly T.Sweet
INPUT person's dob AS DATE
	//this line contained “Australian“ and is now in this format after retriving from the database
person's nationality IS ?Australian?
	AND citizenship testing of person's parents
		OR one of person's parents is Australian
		OR both of person's parents are Australian
		OR MANDATORY all grand parents of the person were Australian
	AND the person was born in Australia
	AND we have person's name and dob
		AND KNOWN person's name
		AND KNOWN person's dob  
	AND we have the person's passport
	AND person's name IS IN LIST: name list
	AND person made it to Las Vegas
		AND NOT the person missed the flight  	

Maybe the database doesn't accept those characters and change it to some unknown value

@DeanLee77
Copy link
Collaborator

which database are you currently using?

@jamshaid120
Copy link
Contributor Author

I am using PostgreSQL. The version is from 12.x series.

@jamshaid120
Copy link
Contributor Author

There's another thing which I just tested. I wrote final Pattern a=Pattern.compile("\""); and tested both “ and " and the result is different for both characters. It accepts " but doesn't accept “. The regex written in the code doesn't support “ as well. I've tested it on all of those but all returned false.

@DeanLee77
Copy link
Collaborator

I would try to use double quotation mark in ascii or unicode, and avoid the symbolic mark from MS word.

In addition, regex to handle the mark in Tokenizer class is ' Pattern quotedPattern = Pattern.compile("^(["\“])(.)(["\”])(\.)");'

@DeanLee77
Copy link
Collaborator

further more, it is not about regex at this point of time, the quotation mark is translated into something else in the database. I believe that the mistranslation is what caused the issue.

@jamshaid120
Copy link
Contributor Author

It would be great if you update that. The regex you just mentioned produces a syntax error. I will try to update it.
Yeah, I am thinking the same as well. The database might not support that character on the remote system which I am currently working on.

@DeanLee77
Copy link
Collaborator

if you look at the 'Tokenizer' class, the regex is already there.
And when I copied and pasted the pattern string it was printed like that in the github page. Please have a look at the class.

@jamshaid120
Copy link
Contributor Author

Yeah. I Just tested it. The regex works fine. There might be a problem in the database or in that system. Thanks for guiding me with this.

@DeanLee77
Copy link
Collaborator

I am using Postgre 10.xxx version, and in my database the double quotation symbol, which is extracted from file 10, is translated as below.

AND service type = \342\200\234Steam force\342\200\235

this '\342\200\234' code can be found at a link : 'http://www.ltg.ed.ac.uk/~richard/utf-8.cgi?input=8220&mode=decimal', and the value is in a row labelled as 'Octal UTF-8 bytes'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants