I found when all values are the same, the lm function throws errors. But it worked on GNU R. I am using the latest renjin-script-engine-0.8.1593.jar.
Any exception is thrown:
Caused by: org.renjin.eval.EvalException: contrasts can be applied only to factors with 2 or more levels
at org.renjin.primitives.Conditions.stop(Conditions.java:193)
at org.renjin.primitives.R$primitive$stop.doApply(R$primitive$stop.java:72)"
when I called RenjinScriptEngine.eval(..) with this script:
fit<-lm("formula"=vals~index,"data"=data)
The data of input is
"2015-36",9
"2015-37",9
"2015-41",9.
Renjin's goal is to be compatible with the latest version of GNU R. If you find a difference or encounter error like that above, please file a bug report at https://github.com/bedatadriven/renjin/issues. We're happy to have the test cases!
Related
I am completely at a loss over this - updated my Java (to version 8, build 91) and now my Groovy project, in an early development stage, simply will not run. (See answer The update was a co-incidence)
BUG! exception in phase 'semantic analysis' in source unit 'Simul.groovy' unexpected NullpointerException
Caused by: java.lang.NullPointerException
Here is an example piece of code:
package simul
class Simulation {
def globalMemory
def signalNetwork
def processors
def blueTree
def coreArray
def outputDevice
def endian
def coreCount
static CORE_COUNT = 256
static TOTAL_MEM_SIZE = 0x100000000
static DEFAULT_ENDIAN = 0
static LOCAL_MEM_SIZE = 16
static LOCAL_MEM_START = 0xA0000000
Simulation(def cores = this.CORE_COUNT, def memSize = this.TOTAL_MEM_SIZE,
def endianess = this.DEFAULT_ENDIAN)
{
//0 for little endian, 1 for big endian
endian = endianess
globalMemory = new MemoryArray(this, memSize, 0)
coreCount = cores
}
}
def stuff = new Simulation()
stuff.coreArray = []
for (coreNumb in 1..stuff.coreCount) {
stuff.coreArray << new Core(stuff, coreNumb - 1)
}
Eclipse merely flags an error on the package line (and does the same for other class files).
I assume this is a problem caused by the Java update but I can find nobody else referencing this issue online (and unfortunately the Groovy email lists seem to be unavailable due to a DNS problem).
Any clues?
Update
If I try to run one of the files on its own eg groovyConsole Simul.groovy it will execute but then complain it cannot see other files in the package. In fact I can do the same inside the IDE (and this error is repeated in ggts also) if I change the package name for the Simul.groovy file. But if I try to compile/run the code with the package names properly specified it fails with this BUG! error.
(This means the problem is similar - in terms of symptoms - to this: https://answers.atlassian.com/questions/327479/scriptrunner-bug-exception-in-phase-semantic-analysis-in-source-unit-script40-groovy-bundle-is-uninstalled)
This is the stack trace:
BUG! exception in phase 'semantic analysis' in source unit '/Users/adrian/groovy_stuff/simul/src/simul/Simul.groovy' unexpected NullpointerException
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1226)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:651)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:629)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:606)
at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.processToPhase(GroovyCompilationUnitDeclaration.java:201)
at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.resolve(GroovyCompilationUnitDeclaration.java:2206)
at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:1084)
at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:1129)
at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:215)
at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:281)
at org.codehaus.jdt.groovy.model.GroovyReconcileWorkingCopyOperation.makeConsistent(GroovyReconcileWorkingCopyOperation.java:80)
at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:90)
at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:729)
at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:789)
at org.codehaus.jdt.groovy.model.GroovyCompilationUnit.reconcile(GroovyCompilationUnit.java:440)
at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:126)
at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.access$0(JavaReconcilingStrategy.java:108)
at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:89)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:87)
at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:151)
at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:86)
at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:104)
at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:77)
at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:206)
Caused by: java.lang.NullPointerException
at org.codehaus.groovy.control.StaticVerifier$1.visitVariableExpression(StaticVerifier.java:84)
at org.codehaus.groovy.ast.expr.VariableExpression.visit(VariableExpression.java:70)
at org.codehaus.groovy.ast.CodeVisitorSupport.visitPropertyExpression(CodeVisitorSupport.java:251)
at org.codehaus.groovy.ast.expr.PropertyExpression.visit(PropertyExpression.java:55)
at org.codehaus.groovy.control.StaticVerifier.visitConstructorOrMethod(StaticVerifier.java:79)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructor(ClassCodeVisitorSupport.java:121)
at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1214)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52)
at org.codehaus.groovy.control.StaticVerifier.visitClass(StaticVerifier.java:42)
at org.codehaus.groovy.control.CompilationUnit$13.call(CompilationUnit.java:235)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1221)
... 24 more
Well, the answer is I was referring to static members of the class Simulation in the form of this.STATIC_MEMBER as parameters to the class constructor.
As this doesn't exist at this point (and is superfluous in any case) this does raise a NullPointerException though it is highly confusing that it's flagged at the point of the package command.
I think everybody who has to work with Maven and Java8 knows of this bug that release builds suddenly fail for spelling mistakes in JavaDoc. As a company we decided to let some poor sap (aka me) work all of them out. Now I'm stuck with the following "error":
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.10.1:javadoc (default-cli) on project org.acme.project.demo: An error has occurred in JavaDocs report generation:
[ERROR] Exit code: 1 - C:\jenkins\workspace\Project 2.0\org.acme.project.demo\src\main\java\org\acme\project\demo\SomeClass.java:36: error: cannot access OtherClass
[ERROR] import org.acme.project.OtherClass;
[ERROR] ^
[ERROR] bad class file: C:\jenkins\workspace\Project 2.0\org.acme.project\target\org.acme.project-2.0.0-SNAPSHOT-v20150128-1503.jar(org/acme/project/OtherClass.class)
[ERROR] undeclared type variable: N
[ERROR] Please remove or make sure it appears in the correct subdirectory of the classpath.
I tried to clean it up a bit, but to summarize: Project B throws the exception when it tries to resolve a method call to Project A (yes, while generating JavaDoc!). The method in question looks like that:
public static <N extends Bean> void hookContinousImageFunction(final OtherClass<N> dialog,
final ImageGroup imageGroup, N model, final BiFunction<Image, N, ? extends Image> imageFunction) {
final Image original = imageGroup.getImage();
dialog.setOnCancelClick((notUsed) -> imageGroup.setImage(original));
model.addPropertyChangeListener(new ContinousImageFunctionListener<>(dialog, imageGroup, imageFunction));
dialog.setInitialModel(model);
}
It doesn't even have JavaDoc (not that any of this should matter when the generation of Project A's JavaDoc is already finished, and Maven is trying to generate JavaDoc for Project B).
As of now, we have this bug in multiple projects, about 1 out of 5. Project A (the one with a typed method / class like above) is more often than not in an entirely different build reactor and sometimes completely out of our control.
How do I fix this bug inside a bug?
(As a as a side note, the error occurs on the Jenkin's running with Java 1.8.0_31 and jdk1.8.0_40 or locally with 1.8.0_45, 1.8.0_60, but not locally with 1.8.0_20, but JavaDoc generation hasn't been that reliable, so I can't say for sure it has something to do with the Java version.)
I got the same kind of error message using a central build while having no problems in my local build. (Unfortunately I have no details about the central build environment.)
Adding a '#param ' explanation in the JavaDoc comment for the static method in question solved the issue. Adapted to the given example I did something like this:
/**
* #param <N> This is the class that ...
*/
public static <N extends Bean> void hookContinuousImageFunction(...)
Okay the answer is to a) downgrade Java to 1.8.0_20, or - if that is not possible - b) to use this code in the pom.xml to disable JavaDoc of the project until the Java people feel the need to fix the bug:
<properties>
<maven.javadoc.skip>true</maven.javadoc.skip>
</properties>
I have been using Apache CXF 2.7.0 for quite a while now, but recently I had to restructure my project in Eclipse. After I did that, for some reason, I cannot add a "WSAddressingFeature" Feature to the endpoint.
What am I missing??
endpoint.getFeatures().add(new org.apache.cxf.ws.addressing.WSAddressingFeature());
Eclipse is reporting that:
"The method add(Feature) in the type List<Feature> is not applicable for the arguments (WSAddressingFeature)"
This is my full implementation:
String url = "http://localhost:" + m_Port + "/infoburst/handler";
Object implementor = new HandlerImpl();
org.apache.cxf.jaxws.EndpointImpl endpoint = new org.apache.cxf.jaxws.EndpointImpl(implementor);
endpoint.getFeatures().add(new org.apache.cxf.ws.addressing.WSAddressingFeature());
endpoint.publish(url);
org.apache.cxf.endpoint.Server server = endpoint.getServer();
org.apache.cxf.jaxws.JaxWsServerFactoryBean serverFB = endpoint.getServerFactory();
If I remove the line of code that adds the feature, the following error occurs:
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.cxf.common.util.ReflectionUtil.getDeclaredMethod(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.bindOperation(JaxWsServiceFactoryBean.java:276)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.createOperation(ReflectionServiceFactoryBean.java:1045)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.createOperation(JaxWsServiceFactoryBean.java:642)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.createInterface(ReflectionServiceFactoryBean.java:990)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:481)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:704)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:550)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:265)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:215)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)
at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:159)
at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)
at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:456)
at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:334)
at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:251)
at org.apache.cxf.jaxws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:155)
at javax.xml.ws.Endpoint.publish(Unknown Source)
at com.infosol.infoburst.XI4Service.HandlerService.publish(HandlerService.java:106)
at com.infosol.infoburst.XI4Service.HandlerService.main(HandlerService.java:42)
This is why I really don't enjoy working in the Java environment...
To fix the ""The method add(Feature) in the type List is not applicable for the arguments (WSAddressingFeature)" error:
Go into "Configure Build Path"
Go to "Order and Export"
Move the "cfx-2.7.0.jar" file to a higher priority, this may take a little trial and error.
Once the CFX file is moved up in priority, the error will go away.
20:15:43 [INFO] macintosh264 issued server command: /sell hand
20:15:43 [INFO] [XYZShop] MacCommand sell executed
20:15:43 [SEVERE] null
org.bukkit.command.CommandException: Unhandled exception executing command 'sell' in plugin XYZShop v0.1.3
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46)
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:186)
at org.bukkit.craftbukkit.v1_4_6.CraftServer.dispatchCommand(CraftServer.java:510)
at net.minecraft.server.v1_4_6.PlayerConnection.handleCommand(PlayerConnection.java:979)
at net.minecraft.server.v1_4_6.PlayerConnection.chat(PlayerConnection.java:897)
at net.minecraft.server.v1_4_6.PlayerConnection.a(PlayerConnection.java:852)
at net.minecraft.server.v1_4_6.Packet3Chat.handle(Packet3Chat.java:44)
at net.minecraft.server.v1_4_6.NetworkManager.b(NetworkManager.java:290)
at net.minecraft.server.v1_4_6.PlayerConnection.d(PlayerConnection.java:112)
at net.minecraft.server.v1_4_6.ServerConnection.b(SourceFile:39)
at net.minecraft.server.v1_4_6.DedicatedServerConnection.b(SourceFile:30)
at net.minecraft.server.v1_4_6.MinecraftServer.r(MinecraftServer.java:598)
at net.minecraft.server.v1_4_6.DedicatedServer.r(DedicatedServer.java:224)
at net.minecraft.server.v1_4_6.MinecraftServer.q(MinecraftServer.java:494)
at net.minecraft.server.v1_4_6.MinecraftServer.run(MinecraftServer.java:427)
at net.minecraft.server.v1_4_6.ThreadServerApplication.run(SourceFile:849)
Caused by: java.lang.NoSuchMethodError: dev.xyzcraft.net.database.DatabaseHandler.getItem(IS)Ldev/xyzcraft/net/xyzshop/dataObject/MSItem;
at dev.xyzcraft.net.xyzshop.commands.SellCommand.onCommand(SellCommand.java:63)
at dev.xyzcraft.net.xyzshop.util.MacCommand.onCommand(MacCommand.java:44)
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
... 15 more
I get that exception
here's the code:
https://github.com/macintosh264/XYZShop
Lastly, I'm using a Mod API for a popular video game, Minecraft, entitled Bukkit. Here's the JavaDoc, and library
http://dl.bukkit.org/downloads/bukkit/
http://jd.bukkit.org
"I also have this problem with another project that uses MySQL, and the stack trace occurs WHENEVER the mysql class is used. "
Macintosh264
It seems like whatever your trying to execute (i.e.the method that holds the command) isn't reading it properly. Try re-packaging your project, it's happened to me many times and that is usually an easy fix.
EDITED
Thanks to Alvas' answer. I just learned that the following problem is caused by the 'not-so-up-to-date' NLTK since the latest 15-12-09 StanfordNLP requires more dependencies than previous versions. The exact solution to this problem is within this link https://github.com/nltk/nltk/issues/1239 as Alvas suggested.
StackOverflow identify my problem similar to this post Stanford Parser and NLTK. I still believe the two problems are different since the original one addresses more discussions on the overall proper setup of Standfordnlp while my question is focusing on the error itself. And after all, that doesn't solve my problem.
Follows is my post before I added these comments.
I've read almost all relative topics and possible solutions posted on Stackoverflow and tried them all on my computer. However, no positive result has been achieved. It is becoming frustrating everyday for an amature learning nlp and rookie in java because this problem prevents me from getting to know nltk at the very start. I would like to share the problem again and thanks again for all who tried to solve in advance.
Basically, I intend to parse Chinese characters but start from the English language. Here is the code I used (You probably have seen it because I copied it elsewhere to test):
import os
from nltk.parse import stanford
ini_path = 'C:/Users/qubo/jars/stanford-parser/'
os.environ['STANFORD_PARSER'] = ini_path + 'stanford-parser.jar'
os.environ['STANFORD_MODELS'] = ini_path + 'stanford-parser-3.6.0-models.jar'
os.environ['JAVAHOME'] = 'C:/Program Files/Java/jdk1.8.0_73/'
parser = stanford.StanfordParser(ini_path + 'stanford-parser.jar', ini_path + 'stanford-parser-3.6.0-models.jar')
sentences = parser.raw_parse_sents(("Python is fun. We should all date Python in this case."))
print (sentences)
for line in sentences:
for sentence in line:
sentence.draw()
And now I got this error msg when running parser.raw_parse_sents:
java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at edu.stanford.nlp.parser.common.ParserGrammar.<clinit>(ParserGrammar.java:46)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
Exception in thread "main"
Traceback (most recent call last):
File "C:\Users\qubo\Desktop\nltkexample.py", line 33, in <module>
sentences = parser.raw_parse_sents(("Python is fun. We should all date Python in this case."))
File "C:\Users\qubo\Miniconda2\lib\site-packages\nltk\parse\stanford.py", line 146, in raw_parse_sents
return self._parse_trees_output(self._execute(cmd, '\n'.join(sentences), verbose))
File "C:\Users\qubo\Miniconda2\lib\site-packages\nltk\parse\stanford.py", line 212, in _execute
stdout=PIPE, stderr=PIPE)
File "C:\Users\qubo\Miniconda2\lib\site-packages\nltk\internals.py", line 134, in java
raise OSError('Java command failed : ' + str(cmd))
OSError: Java command failed : ['C:/Program Files/Java/jdk1.8.0_73/bin\\java.exe', u'-mx1000m', '-cp', 'C:/Users/qubo/jars/stanford-parser/stanford-parser.jar;C:/Users/qubo/jars/stanford-parser/stanford-parser-3.6.0-models.jar', u'edu.stanford.nlp.parser.lexparser.LexicalizedParser', u'-model', u'edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz', u'-sentences', u'newline', u'-outputFormat', u'penn', u'-encoding', u'utf8', 'c:\\users\\qubo\\appdata\\local\\temp\\tmppz8u6r']
[Finished in 0.7s]
I'm using windows 64, Python 2.7.11 and all modules supporting nltk and stanford parser are updated. I've installed the jdk and jre as well. In fact, I've tried different versions and jdk (old or latest, 86 or 64), none was working.
I've tried to set java path directly in internals.py or commenting raise error lines in standford.py, still not working.
I've tried to add JAVAHOME environment variable, no use. In fact, it serves the exact same purpose as this line (as some may claim to be slightly different):
os.environ['JAVAHOME'] = 'C:/Program Files/Java/jdk1.8.0_73/'
Any thoughts? Thanks again!!!
After spending too long on this problem, I finally found the answer buried in one of the comments of this question. I think it's worth posting as a proper answer since other people might look for it here and not find it (I know I missed it at first).
The answer is in this gist, which also contains instructions on how to solve this problem for all Stanford NLTK interfaces (i.e. NER tagger, POS tagger, and all Stanford parsers).
Basically, you need to change the Parser object's classpath property with this function:
from nltk.internals import find_jars_within_path
from nltk.parse.stanford import StanfordParser
parser = StanfordParser(model_path="path/to/englishPCFG.ser.gz")
parser._classpath = tuple(find_jars_within_path(stanford_dir))
All credit for the solution goes to alvas, I'm just reposting it here so it's easier to find.
You need to download slf4j jar from here and add that on the path as well.