Error while using stanford core nlp - stanford-nlp

I m having problem in using the stanford nlp. i am having issues where I'm getting various errors when trying to use the Stanford Core NLP tools.I want to know the sentiment of the sentence passed. But I've not been able to get nlp tools to work when running the code from eclipse with the needed jars added to the classpath,
This is the code i want to execute.
import java.util.Properties;
import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.ling.CoreAnnotations.TokensAnnotation;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.SentimentAnnotator;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import edu.stanford.nlp.rnn.RNNCoreAnnotations;
import edu.stanford.nlp.sentiment.SentimentCoreAnnotations;
import edu.stanford.nlp.trees.Tree;
import edu.stanford.nlp.util.CoreMap;
import edu.stanford.nlp.util.TypesafeMap.Key;
public class sentiment_demo {
public static void sentiment_analysis(String line)
{
//Uses Stanford NLP sentimnet analysis
//found in latest model released from stanford
// ver 3.3.1
//applies sentiment analysis to text
Properties props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, parse, sentiment");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
int mainSentiment = 0;
if (line != null && line.length() > 0) {
int longest = 0;
Annotation annotation = pipeline.process(line);
for (CoreMap sentence : annotation.get(CoreAnnotations.SentencesAnnotation.class)) {
System.out.println(sentence);
for (Tree token: sentence.get(SentimentCoreAnnotations.AnnotatedTree.class))
{
//System.out.println(token);
}
Tree tree = sentence.get(SentimentCoreAnnotations.AnnotatedTree.class);
int sentiment = RNNCoreAnnotations.getPredictedClass(tree);
System.out.println(sentiment);
String partText = sentence.toString();
//System.out.println(partText);
if (partText.length() > longest) {
mainSentiment = sentiment;
longest = partText.length();
}
}
}
if(mainSentiment==2)
{
System.out.println("Average");
}
else if(mainSentiment>2)
{
System.out.println("Positive");
}
else if(mainSentiment<2)
{
System.out.println("Negative ");
}
if (mainSentiment == 2 || mainSentiment > 4 || mainSentiment < 0) {
//return null;
}
}
public static void main(String[] args)
{
sentiment_analysis("Cristiano Ronaldo, is a Portuguese professional footballer who plays for Spanish club Real Madrid and the Portugal national team. He is a forward and serves as captain for Portugal.Often ranked as the best player in the world and rated by some in the sport as the greatest of all time");
}
}
Here are the libraries i have set
I m using eclipse mars. At first it was showing error for ejml library.but then i imported ejml jar file so that error was resolved but it gave rise to this errors now...
Adding annotator tokenize
Adding annotator ssplit
Adding annotator parse
Loading parser from serialized file edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz ... done [1.6 sec].
Adding annotator sentiment
Exception in thread "main" edu.stanford.nlp.io.RuntimeIOException: java.lang.ClassNotFoundException: edu.stanford.nlp.neural.SimpleTensor
at edu.stanford.nlp.sentiment.SentimentModel.loadSerialized(SentimentModel.java:470)
at edu.stanford.nlp.pipeline.SentimentAnnotator.<init>(SentimentAnnotator.java:45)
at edu.stanford.nlp.pipeline.StanfordCoreNLP$14.create(StanfordCoreNLP.java:845)
at edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:81)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(StanfordCoreNLP.java:260)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:127)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:123)
at sentiment_demo.sentiment_analysis(sentiment_demo.java:28)
at sentiment_demo.main(sentiment_demo.java:70)
Caused by: java.lang.ClassNotFoundException: edu.stanford.nlp.neural.SimpleTensor
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at java.io.ObjectInputStream.resolveClass(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at java.util.TreeMap.buildFromSorted(Unknown Source)
at java.util.TreeMap.buildFromSorted(Unknown Source)
at java.util.TreeMap.readObject(Unknown Source)
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 java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at java.util.TreeMap.buildFromSorted(Unknown Source)
at java.util.TreeMap.buildFromSorted(Unknown Source)
at java.util.TreeMap.readObject(Unknown Source)
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 java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at edu.stanford.nlp.io.IOUtils.readObjectFromURLOrClasspathOrFileSystem(IOUtils.java:298)
at edu.stanford.nlp.sentiment.SentimentModel.loadSerialized(SentimentModel.java:466)
i m stuck at it.If someone have any idea of this then please do suggest,it will be of great help.I have searched other similar questions on stackoverflow but still not getting the solution to resolve this.

Actually the problem was with different version used.some of the jar files like xom,ejml where missing.I fixed it by downloading the complete jar files from here stanford core NLP site with version 3.6.0. And one of the import statements was changed to
import edu.stanford.nlp.neural.rnn.RNNCoreAnnotations;
SentimentCoreAnnotations.AnnotatedTree.class needs to be changed to
SentimentCoreAnnotations.SentimentAnnotatedTree.class
this changes have resolved my all errors.

You appear to be using an old version of CoreNLP (3.3.0) alongside the new models. Try downloading the 3.6.0 code + models.

Related

Change spring-shell.log location

I'm having some trouble with my spring-shell.log. Not a big problem but really annoying. Once I run my application from outside of my workspace, spring shell tries to save the spring-shell.log in a directory which is protected by windows. This results in not having a shelö history. Now I simply like to save the file somewhere else
My favorite way would be to change the location via application.properties. But I don't know if there is a properties for this. I'd be fine with changing the logback-spring.xml as well.
java.nio.file.AccessDeniedException: C:\Windows\spring-shell.log
at sun.nio.fs.WindowsException.translateToIOException(Unknown Source) ~[na:1.8.0_191]
at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source) ~[na:1.8.0_191]
at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source) ~[na:1.8.0_191]
at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(Unknown Source) ~[na:1.8.0_191]
at java.nio.file.spi.FileSystemProvider.newOutputStream(Unknown Source) ~[na:1.8.0_191]
at java.nio.file.Files.newOutputStream(Unknown Source) ~[na:1.8.0_191]
at java.nio.file.Files.newBufferedWriter(Unknown Source) ~[na:1.8.0_191]
at java.nio.file.Files.newBufferedWriter(Unknown Source) ~[na:1.8.0_191]
at org.jline.reader.impl.history.DefaultHistory.save(DefaultHistory.java:121) ~[jline-3.4.0.jar!/:na]
at org.jline.reader.impl.history.DefaultHistory.add(DefaultHistory.java:248) ~[jline-3.4.0.jar!/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_191]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_191]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_191]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_191]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) [spring-aop-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205) [spring-aop-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
at com.sun.proxy.$Proxy52.add(Unknown Source) [na:na]
at org.jline.reader.impl.LineReaderImpl.finishBuffer(LineReaderImpl.java:864) [jline-3.4.0.jar!/:na]
at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:557) [jline-3.4.0.jar!/:na]
at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:390) [jline-3.4.0.jar!/:na]
at org.springframework.shell.jline.InteractiveShellApplicationRunner$JLineInputProvider.readInput(InteractiveShellApplicationRunner.java:115) [spring-shell-core-2.0.1.RELEASE.jar!/:2.0.1.RELEASE]
at org.springframework.shell.Shell.run(Shell.java:129) [spring-shell-core-2.0.1.RELEASE.jar!/:2.0.1.RELEASE]
at org.springframework.shell.jline.InteractiveShellApplicationRunner.run(InteractiveShellApplicationRunner.java:84) [spring-shell-core-2.0.1.RELEASE.jar!/:2.0.1.RELEASE]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:770) [spring-boot-2.1.6.RELEASE.jar!/:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:760) [spring-boot-2.1.6.RELEASE.jar!/:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:318) [spring-boot-2.1.6.RELEASE.jar!/:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213) [spring-boot-2.1.6.RELEASE.jar!/:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202) [spring-boot-2.1.6.RELEASE.jar!/:2.1.6.RELEASE]
at com.provinzial.convenience.tools.Application.main(Application.java:12) [classes!/:0.0.1-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_191]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_191]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_191]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_191]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:47) [convenience-tools-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:86) [convenience-tools-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [convenience-tools-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [convenience-tools-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
I'm grateful for any hint. Thanks guys. Best regards, Sebastian
In your Spring project, just create a new class like this:
package com.example.shell.demo.config;
import org.jline.reader.History;
import org.jline.reader.LineReader;
import org.jline.reader.impl.history.DefaultHistory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.context.event.EventListener;
import java.io.IOException;
import java.nio.file.Paths;
#Configuration
public class HistoryConfiguration {
#Autowired
private History history;
#Bean
public History history(LineReader lineReader, #Value("${app.history.file}") String historyPath) {
lineReader.setVariable(LineReader.HISTORY_FILE, Paths.get(historyPath));
return new DefaultHistory(lineReader);
}
#EventListener
public void onContextClosedEvent(ContextClosedEvent event) throws IOException {
history.save();
}
}
Then, in your application.properties file, create a key / value pair like this
app.history.file=<path to your log file>
The original solution was posted here: https://github.com/spring-projects/spring-shell/issues/220. I have tested it with Spring Shell 2.0.0-RELEASE and it works well.
Hope that helps.

NullPointerException when compile_fmu used for simulation of Dymola *.mo file from library

The libraray I‘m using is based on the MSL and the Modelica Buildings Library. The model can be simulated by Dymola without any error messages or warnings.
The MODELICAPATH is set in the bashrc and the PYTHONPATH too. I use JModelica 2.1, Python 2.7 and Ubuntu 16.04.
Obviously library and model are found, so I assume the path is not the actual problem.
When I use compile_fmu for simulating a model that is not part of a library everything works perfectly. So to me it seems that pymodelica has problems with the library structure or something like that. Do you have any idea what is happening here?
from pymodelica import compile_fmu
...
fmu=compile_fmu('BuildingModel.Examples.ExampleBuilding','ExampleBuilding.mo')
Error message:
File 'ExampleBuilding.mo' is part of library at '/home/debs/Schreibtisch/BuildingModel', using library instead.
Unknown program error, java.lang.NullPointerException
Traceback (most recent call last):
File "Building_Simulation.py", line 239, in <module>
fmu=compile_fmu('BuildingModel.Examples.ExampleBuilding','ExampleBuilding.mo')
File "/home/debs/Downloads/JModelica/JModelica/Python/pymodelica/compiler.py", line 141, in compile_fmu
separate_process, jvm_args)
File "/home/debs/Downloads/JModelica/JModelica/Python/pymodelica/compiler.py", line 248, in _compile_unit
compiler_options, compile_to, compiler_log_level, jvm_args)
File "/home/debs/Downloads/JModelica/JModelica/Python/pymodelica/compiler.py", line 362, in compile_separate_process
return log.end();
File "/home/debs/Downloads/JModelica/JModelica/Python/pymodelica/compiler_logging.py", line 334, in end
raise JError("%s\n%s" % (exception.message, exception.stacktrace))
pymodelica.compiler_exceptions.JError:
java.lang.NullPointerException
at org.jmodelica.modelica.compiler.CommonForIndex.addReplacementEntry(Unknown Source)
at org.jmodelica.modelica.compiler.FIterExp.splitArrayExp(Unknown Source)
at org.jmodelica.modelica.compiler.FArray.splitArrayExp(Unknown Source)
at org.jmodelica.modelica.compiler.InstArrayComponentDecl.Define_splitBindingFExp(Unknown Source)
at org.jmodelica.modelica.compiler.ASTNode.Define_splitBindingFExp(Unknown Source)
at org.jmodelica.modelica.compiler.InstNode.splitBindingFExp(Unknown Source)
at org.jmodelica.modelica.compiler.InstNode.Define_splitBindingFExp(Unknown Source)
at org.jmodelica.modelica.compiler.ASTNode.Define_splitBindingFExp(Unknown Source)
at org.jmodelica.modelica.compiler.InstNode.splitBindingFExp(Unknown Source)
at org.jmodelica.modelica.compiler.InstNode.Define_splitBindingFExp(Unknown Source)
at org.jmodelica.modelica.compiler.ASTNode.Define_splitBindingFExp(Unknown Source)
at org.jmodelica.modelica.compiler.InstNode.splitBindingFExp(Unknown Source)
at org.jmodelica.modelica.compiler.InstAssignable.getBindingFExp_compute(Unknown Source)
at org.jmodelica.modelica.compiler.InstAssignable.getBindingFExp(Unknown Source)
at org.jmodelica.modelica.compiler.InstAssignable.hasBindingFExp(Unknown Source)
at org.jmodelica.modelica.compiler.InstAssignable.isCircular_compute(Unknown Source)
at org.jmodelica.modelica.compiler.InstAssignable.isCircular(Unknown Source)
at org.jmodelica.modelica.compiler.FIdUseInstAccess.isCircular(Unknown Source)
at org.jmodelica.modelica.compiler.FIdUseExp.isCircularCalc(Unknown Source)
at org.jmodelica.modelica.compiler.FAbstractExp.isCircular_compute(Unknown Source)
at org.jmodelica.modelica.compiler.FAbstractExp.isCircular(Unknown Source)
at org.jmodelica.modelica.compiler.FExp.ceval(Unknown Source)
at org.jmodelica.modelica.compiler.FExp.ceval(Unknown Source)
at org.jmodelica.modelica.compiler.MutableSize.evaluate(Unknown Source)
at org.jmodelica.modelica.compiler.MutableSize.get(Unknown Source)
at org.jmodelica.modelica.compiler.InstComponentDecl.childDimensionLength(Unknown Source)
at org.jmodelica.modelica.compiler.InstComponentDecl.getInstComponentDeclList_compute(Unknown Source)
at org.jmodelica.modelica.compiler.InstComponentDecl.getInstComponentDeclList(Unknown Source)
at org.jmodelica.modelica.compiler.InstComposite.getInstComponentDecls(Unknown Source)
at org.jmodelica.modelica.compiler.InstNode.compareCompositeTypes(Unknown Source)
at org.jmodelica.modelica.compiler.InstComposite.subType(Unknown Source)
at org.jmodelica.modelica.compiler.InstNode.compareCompositeTypes(Unknown Source)
at org.jmodelica.modelica.compiler.InstArrayComponentDecl.subType(Unknown Source)
at org.jmodelica.modelica.compiler.InstNode.compareCompositeTypes(Unknown Source)
at org.jmodelica.modelica.compiler.InstComposite.subType(Unknown Source)
at org.jmodelica.modelica.compiler.InstNode.compareCompositeTypes(Unknown Source)
at org.jmodelica.modelica.compiler.InstComposite.subType(Unknown Source)
at org.jmodelica.modelica.compiler.InstNode.compareCompositeTypes(Unknown Source)
at org.jmodelica.modelica.compiler.InstComposite.subType(Unknown Source)
at org.jmodelica.modelica.compiler.InstNode.subType(Unknown Source)
at org.jmodelica.modelica.compiler.InstComponentDecl.typeCheckReplacingComponent(Unknown Source)
at org.jmodelica.modelica.compiler.InstReplacingComposite.typeCheck(Unknown Source)
at org.jmodelica.modelica.compiler.ErrorChecker$TypeChecker.check(Unknown Source)
at org.jmodelica.modelica.compiler.ASTNode.allChecks(Unknown Source)
at org.jmodelica.modelica.compiler.InstNode.collectErrors(Unknown Source)
at org.jmodelica.modelica.compiler.InstComponentDecl.collectErrors(Unknown Source)
at org.jmodelica.modelica.compiler.InstNode.collectErrors(Unknown Source)
at org.jmodelica.modelica.compiler.InstExtends.collectErrors(Unknown Source)
at org.jmodelica.modelica.compiler.InstNode.collectErrors(Unknown Source)
at org.jmodelica.modelica.compiler.InstComponentDecl.collectErrors(Unknown Source)
at org.jmodelica.modelica.compiler.InstNode.collectErrors(Unknown Source)
at org.jmodelica.modelica.compiler.InstBaseClassDecl.collectErrors(Unknown Source)
at org.jmodelica.modelica.compiler.InstFullClassDecl.collectErrors(Unknown Source)
at org.jmodelica.modelica.compiler.InstLibNode.collectErrors(Unknown Source)
at org.jmodelica.modelica.compiler.ASTNode.errorCheck(Unknown Source)
at org.jmodelica.modelica.compiler.InstClassDecl.checkErrorsInModelInstance(Unknown Source)
at org.jmodelica.modelica.compiler.ModelicaCompiler.doInstantiateModel(Unknown Source)
at org.jmodelica.modelica.compiler.ModelicaCompiler.instantiateModel(Unknown Source)
at org.jmodelica.modelica.compiler.ModelicaCompiler.instantiateModel(Unknown Source)
at org.jmodelica.modelica.compiler.ModelicaCompiler.doCompileModel(Unknown Source)
at org.jmodelica.modelica.compiler.ModelicaCompiler.compileModel(Unknown Source)
at org.jmodelica.modelica.compiler.ModelicaCompiler.doCompileUnit(Unknown Source)
at org.jmodelica.modelica.compiler.ModelicaCompiler.compileUnit(Unknown Source)
at org.jmodelica.modelica.compiler.ModelicaCompiler.compileUnit(Unknown Source)
at org.jmodelica.modelica.compiler.ModelicaCompiler.compileModelFromCommandLine(Unknown Source)
at org.jmodelica.modelica.compiler.ModelicaCompiler.main(Unknown Source)
JModelica.org handles structured libraries with no particular problems. You can see from the first line of the log that it detected that the file you referred to is inside a library. The problem looks to be a bug that triggers on some expression used in a modification on an array of components somewhere in the model. I'd suggest trying the latest version (currently 2.4).
I'd also recommend using a working directory that is outside the library, so that generated files do not wind up in the library.

How to add Richfx in a layout

I have been trying to add an InlineStyleTextArea and a CodeArea in anylayout both in the main method in javafx and in a fxml file. I receive a thread error. Please if possible with examples how can i add these components to a javafx layout? If possible with a tutorial link.
This is a simple code
public class Main extends Application {
#Override
public void start(Stage primaryStage) {
TextField myTextField = new TextField();
InlineCssTextArea TextArea = new InlineCssTextArea();
HBox hbox = new HBox();
hbox.getChildren().add(myTextField);
hbox.getChildren().add(TextArea);
HBox.setHgrow(myTextField, Priority.ALWAYS);
HBox.setHgrow(TextArea, Priority.ALWAYS);
Scene scene = new Scene(hbox);
primaryStage.setScene(scene);
primaryStage.show();}
public static void main(String[] args) {
launch(args);
}
}
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
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 sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$152(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: org/reactfx/value/SuspendableVal
at application.Main.start(Main.java:20)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$159(Unknown Source)
at com.sun.javafx.application.LauncherImpl$$Lambda$53/19776028.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$45/18503843.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$170(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$48/3799573.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$46/2180324.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$145(Unknown Source)
at com.sun.glass.ui.win.WinApplication$$Lambda$36/3326003.run(Unknown Source)
... 1 more
Caused by: java.lang.ClassNotFoundException: org.reactfx.value.SuspendableVal
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 15 more
Exception running application application.Main
at com.sun.javafx.application.LauncherImpl$$Lambda$50/14845382.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
From the stack trace, it looks like the Java Runtime can't find (at least one class in) the ReactFX library, which is a dependency of RichTextFX. Since it gets as far as looking for that, it must have found InlineCssTextArea, so the RichTextFX library must be installed.
If you are using some kind of dependency management (Gradle or Maven, for example), that tool should manage all the dependencies for you.
If you are managing the dependencies by hand (i.e. downloading jar files and adding them to the classpath), you need to make sure you either download all the dependent jar files as well, or use the "Fat jar file".

Access hive remotely

I am working on Hive. I want to access Hive table via Hive JDBC. The code I'm using is below :
public class HiveJdbcClient {
private static String driverName = "org.apache.hadoop.hive.jdbc.HiveDriver";
public static void main(String[] args) throws SQLException {
try {
Class.forName(driverName);
}catch(ClassNotFoundException e){
e.printStackTrace();
System.exit(1);
}
Connection connection = DriverManager.getConnection("jdbc:hive2://aaaa:10000", "" , "");
Statement statement = connection.createStatement();
String tableName = "tmp_ext_h;
/**
* SELECT* QUERY
* */
String sql = "select * from " + tableName;
System.out.println("Running: " + sql);
ResultSet result = statement.executeQuery(sql);
while (result.next()){
System.out.println(String.valueOf(result.getInt(1)) + "\t" + result.getString(2));
}
/**
* REGULAR HIVE QUERY
* */
sql = "select count(1) from " + tableName;
System.out.println("Running: " + sql);
result = statement.executeQuery(sql);
while (result.next()){
System.out.println(result.getString(1));
}
}
}
and my Libraries are :
hive-jdbc.jar"
hive-exec.jar"
hive-metastore.jar"
hive-service.jar"
libthrift-0.9.0.jar"
mysql-connector-java.jar"
While running this, I get the ERROR :
Exception in thread "main" java.lang.NoClassDefFoundError: com/facebook/fb303/FacebookService$Iface
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.apache.hadoop.hive.jdbc.HiveDriver.connect(HiveDriver.java:106)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at hadoop_HiveConnector.HiveJdbcClient.main(HiveJdbcClient.java:28)
enter code here
Does anybody know what is the problem? I'm new on Hive
Thanks.
According to this http://docs.aws.amazon.com/ElasticMapReduce/latest/DeveloperGuide/HiveJDBCDriver.html
You need the following jars for Hive 0.13:
hive_metastore.jar
hive_service.jar
HiveJDBC3.jar
libfb303-0.9.0.jar
libthrift-0.9.0.jar
log4j-1.2.14.jar
ql.jar
slf4j-api-1.5.8.jar
slf4j-log4j12-1.5.8.jar
TCLIServiceClient.jar
However it changes by environment and version. In your case at the least you're missing libfb303-*.jar

How to debug a beanshell script?

I have troubles to debug a beanshell script all I get all the time is:
Exception invoking imported object method. : at Line: 194 : in file: inline evaluation of: ``import java.lang.reflect.InvocationTargetException; import java.util.Arrays; i . . . '' : migrateModels ( models , apiManager , isSAPRetailImportCondition , isSAPAFSCondition )
Called from method: initMissingImportSources : at Line: -1 : in file: :
Target exception: java.lang.reflect.InvocationTargetException
at bsh.BshMethod.invoke(Unknown Source)
at bsh.BshMethod.invoke(Unknown Source)
at bsh.Name.invokeLocalMethod(Unknown Source)
at bsh.Name.invokeMethod(Unknown Source)
at bsh.BSHMethodInvocation.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHBlock.evalBlock(Unknown Source)
at bsh.BSHBlock.eval(Unknown Source)
at bsh.BshMethod.invokeImpl(Unknown Source)
at bsh.BshMethod.invoke(Unknown Source)
at bsh.BshMethod.invoke(Unknown Source)
at bsh.This.invokeMethod(Unknown Source)
at ImportSourceMigration.initMissingImportSources(BeanShell Generated via ASM (www.objectweb.org))
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at bsh.Reflect.invokeMethod(Unknown Source)
at bsh.Reflect.invokeObjectMethod(Unknown Source)
at bsh.Name.invokeMethod(Unknown Source)
at bsh.BSHMethodInvocation.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHBlock.evalBlock(Unknown Source)
at bsh.BSHBlock.eval(Unknown Source)
at bsh.BSHBlock.eval(Unknown Source)
at bsh.BSHTryStatement.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.servlet.BshServlet.evalScript(Unknown Source)
at bsh.servlet.BshServlet.doGet(Unknown Source)
I am trying to retrieve the full stack trace with this code
try {
migration.initMissingImportSources();
} catch (java.lang.Throwable e) {
print(ExceptionUtils.getFullStackTrace(e));
}
Is there a possibility to retrieve the causing exception?
Thanks a lot.
What is you "ExceptionUtils.getFullStackTrace()" really doing? Are you sure it's printing the nested exception?
Thanks a lot for the reply. Yes the getFullStackTrace is from apache commons and should work. I found the problem. The point is here that I didnt have the complete script in one method call. This is important, only then you are able to surround it with a try catch and see the exception. Hope that will helpful for the others in the future too. I see the exception now. I had several methods calling each other.

Resources