question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java.lang.NullPointerException issue while calling PerceptronApproach().setCorpus()

See original GitHub issue

Hi,

can anyone tell me why this issue is coming ?

while setting corpus after done with pos-tag this issue is coming. specifically in this line. .setCorpus("file:///" + os.getcwd() + "/../../../src/test/resources/anc-pos-corpus-small/","|")

is it permission issue ? i don’t think so, bcs other files are able to be created.

python - 2.7 spark - 2.4.0 spark-nlp - latest version

more on issue details :

---------------------------------------------------------------------------
Py4JJavaError                             Traceback (most recent call last)
<ipython-input-53-d0ecfbd07161> in <module>()
      2 #import pdb;pdb.set_trace()
      3 print("Start fitting")
----> 4 model = pipeline.fit(data)
      5 print("Fitting is ended")
      6 print (time.time() - start)

/spark/python/pyspark/ml/base.pyc in fit(self, dataset, params)
    130                 return self.copy(params)._fit(dataset)
    131             else:
--> 132                 return self._fit(dataset)
    133         else:
    134             raise ValueError("Params must be either a param map or a list/tuple of param maps, "

/spark/python/pyspark/ml/pipeline.pyc in _fit(self, dataset)
    107                     dataset = stage.transform(dataset)
    108                 else:  # must be an Estimator
--> 109                     model = stage.fit(dataset)
    110                     transformers.append(model)
    111                     if i < indexOfLastEstimator:

/spark/python/pyspark/ml/base.pyc in fit(self, dataset, params)
    130                 return self.copy(params)._fit(dataset)
    131             else:
--> 132                 return self._fit(dataset)
    133         else:
    134             raise ValueError("Params must be either a param map or a list/tuple of param maps, "

/spark/python/pyspark/ml/wrapper.pyc in _fit(self, dataset)
    293 
    294     def _fit(self, dataset):
--> 295         java_model = self._fit_java(dataset)
    296         model = self._create_model(java_model)
    297         return self._copyValues(model)

/spark/python/pyspark/ml/wrapper.pyc in _fit_java(self, dataset)
    290         """
    291         self._transfer_params_to_java()
--> 292         return self._java_obj.fit(dataset._jdf)
    293 
    294     def _fit(self, dataset):

/spark/python/lib/py4j-0.10.7-src.zip/py4j/java_gateway.py in __call__(self, *args)
   1255         answer = self.gateway_client.send_command(command)
   1256         return_value = get_return_value(
-> 1257             answer, self.gateway_client, self.target_id, self.name)
   1258 
   1259         for temp_arg in temp_args:

/spark/python/pyspark/sql/utils.pyc in deco(*a, **kw)
     61     def deco(*a, **kw):
     62         try:
---> 63             return f(*a, **kw)
     64         except py4j.protocol.Py4JJavaError as e:
     65             s = e.java_exception.toString()

/spark/python/lib/py4j-0.10.7-src.zip/py4j/protocol.py in get_return_value(answer, gateway_client, target_id, name)
    326                 raise Py4JJavaError(
    327                     "An error occurred while calling {0}{1}{2}.\n".
--> 328                     format(target_id, ".", name), value)
    329             else:
    330                 raise Py4JError(

Py4JJavaError: An error occurred while calling o1085.fit.
: java.lang.NullPointerException
	at com.johnsnowlabs.nlp.util.io.ResourceHelper$.parseTupleSentences(ResourceHelper.scala:229)
	at com.johnsnowlabs.nlp.annotators.pos.perceptron.PerceptronApproach.train(PerceptronApproach.scala:110)
	at com.johnsnowlabs.nlp.annotators.pos.perceptron.PerceptronApproach.train(PerceptronApproach.scala:20)
	at com.johnsnowlabs.nlp.AnnotatorApproach.fit(AnnotatorApproach.scala:33)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
	at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
	at py4j.Gateway.invoke(Gateway.java:282)
	at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
	at py4j.commands.CallCommand.execute(CallCommand.java:79)
	at py4j.GatewayConnection.run(GatewayConnection.java:238)
	at java.lang.Thread.run(Thread.java:748)

Thanks.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
saif-ellaficommented, Nov 20, 2018

The error going on here is somewhere related between Spark and py4j.

Spark 2.4.x is very recently out, I haven’t tried that version myself yet. Any chance you can try back 2.3.1? Also, please make sure your SPARK_HOME variable is properly set to whatever spark directory you are running against in jupyter.

This issue seems to be pointing out to a corrupted environment setting somewhere. Maybe different Spark installations or environment variables pointing to different roots. Taking a look…

0reactions
maziyarpanahicommented, Mar 27, 2019

This has been fixed in new releases of spark-nlp against Spark 2.4.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix and Avoid NullPointerException in Java - Rollbar
NullPointerException in Java occurs when a variable is accessed which is not pointing to any object and refers to nothing or null.
Read more >
java - What is a NullPointerException, and how do I fix it?
We find out that s is null, and calling the length method on it throws the exception. We can see that the program...
Read more >
Java NullPointerException - Detect, Fix, and Best Practices
This is one of the most common occurrences of java.lang.NullPointerException because it's the caller who is passing the null argument.
Read more >
How to deal with NullPointerException in Java with Examples
1) When you call the instance method on a null object. you won't get a null pointer exception if you call a static...
Read more >
Null Pointer Exception while calling store procedure from rule
When executed, it throws the following error: success: false error: "java.lang.NullPointerException at com.appiancorp.ps.function.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found