In my mockito test case i'm using the below snippet ,
this.mockMvc.perform(get(myURL + myId).param("mock", "false").param("filter","false")).andDo(print())
.andExpect(status().isOk()).andExpect(jsonPath("$myVar.id", is(SOME_ID)));
at this line i'm getting the below error ,
com.jayway.jsonpath.InvalidPathException: Invalid path $myVar.id
at com.jayway.jsonpath.internal.PathCompiler.compile(PathCompiler.java:76)
at com.jayway.jsonpath.JsonPath.<init>(JsonPath.java:98)
at com.jayway.jsonpath.JsonPath.compile(JsonPath.java:374)
at org.springframework.test.util.JsonPathExpectationsHelper.<init>(JsonPathExpectationsHelper.java:62)
at org.springframework.test.web.servlet.result.JsonPathResultMatchers.<init>(JsonPathResultMatchers.java:63)
at org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath(MockMvcResultMatchers.java:202)
at com.mypackage.MyTest.testMyMetod(MyTest.java:232)
and FYI,
i'm using the json-path and json-path-assert as a dependency with below version
1.1.0
and i tried the latest version 2.4.0 and also the very old version 0.8.1
But i got the same issue.
Help will be really appreciated.
It is look like path should be "$.myVar.id" or "myVar.id". According to source of PathCompiler they are equal.
I have to use below pattern matcher in jsonPath,
.andExpect(jsonPath("$['myVar'].id", is(SOME_ID)));
Related
I'm trying to fix errors which are reported by forbiddenapis. I had that line:
paramMap.put(Config.TITLEBOOST.toUpperCase(), titleBoost);
So, its been reported as error as usual. I've tried that:
paramMap.put(Config.TITLEBOOST.toUpperCase(Locale.getDefault()), titleBoost);
and that:
paramMap.put(Config.TITLEBOOST.toUpperCase(Locale.ROOT), titleBoost);
also that:
paramMap.put(Config.TITLEBOOST.toUpperCase(Locale.ENGLISH), titleBoost);
However none of them fixed the error:
[forbiddenapis] Forbidden method invocation:
java.lang.String#toUpperCase() [Uses default locale]
What I miss?
Double-check that the bytecode you are analyzing is actually your most recent build output, and that you're looking at the same line forbiddenapis is :) . This looks to me like your source/bytecode/analysis are falling out of sync — the relevant rule shouldn't flag an error on String.toUpperCase(Locale).
Disclaimer: I haven't used forbiddenapis myself --- I wrote this answer based on the repo and on a blog post I found.
Currenty I have a web project with JSF 1.2 and Facelets running in tomcat 6.0.18.0. I decided to upgrade the servlet container, thus i deployed in tomcat 7 and all seemed ok until we hit one view using my custome facelet functions.
javax.el.ELException: Failed to parse the expression [{pz:instanceof(object,'com.project.domain.MyClass')}]
Caused by: org.apache.el.parser.ParseException: Encountered " ":" ": "" at line 1, column 5. Was expecting one of:
"}" ...
"." ...
"[" ...
This error occurs when parsing the following code:
<ui:repeat var="object" value="#{objects}">
<ui:fragment rendered="#{pz:instanceof(object,'com.project.domain.MyClass')}">
...
If i understand correctly it throws an error because of the colon in the expression . I have tracked it down to the jasper-el that come with in the tomcat/lib directory, and if I replace jasper.jar and jasper-el.jar with the ones from tomcat 6.0.18 everythign works well.
Has anyone else had this problem before upgrading their tomcat? And How did they resolve it?
Could I deploy in production tomcat 7 with these jasper jar from tomcat 6, or could this cause further problems.
This is actually a misleading exception. It has a different underlying cause. The function name instanceof is invalid.
The EL 2.2 specification says the following:
1.14 Reserved Words
The following words are reserved for the language and must not be used as
identifiers.
and eq gt true instanceof
or ne le false empty
not lt ge null div mod
Note that many of these words are not in the language now, but they may be in the
future, so developers must avoid using these words.
and
1.19 Collected Syntax
...
Identifier ::= Java language identifier
...
Where the Java language identifier stands for keywords like instanceof, if, while, class, return, static, new, etc. They may not be used as variable/function names in EL. In case you have properties with those names, use the brace notation instead like so #{bean['class'].simpleName} instead of #{bean.class.simpleName}.
This was been fixed in Tomcat 7.0.4 or somewhere near before this version as indicated by issue 50147 wherein someone else pointed out the same problem as you have. So, to solve your problem, you have to rename your EL function name to for example isInstanceOf or something.
Add this line in catalina.properties ([tomcat folder]/conf), and it should fix the issue.
org.apache.el.parser.SKIP_IDENTIFIER_CHECK=true
However, you should not use the reserved words.
You can also try changing the syntax. I had the same exact problem with code that I was maintaining when we were moving from Tomcat 6 to 7. I had to change myobject.class.name to myobject['class'].name. After I made this change my code worked perfectly again.
Great hint, indeed! I had to change in my jspx ${instance.class.simpleName == ...} with ${instance['class'].simpleName eq ...}.
I was moving from vFabric on tomcat 6 to vFabric on tomcat 7
I'm trying the quickstart from here: http://datafu.incubator.apache.org/docs/datafu/getting-started.html
I tried nearly everything, but I'm sure it must be my fault somewhere. I tried already:
exporting PIG_HOME, CLASSPATH, PIG_CLASSPATH
starting pig with -cpdatafu-pig-incubating-1.3.0.jar
registering datafu-pig-incubating-1.3.0.jar locally and in hdfs => both succesful (at least no error shown)
nothing helped
Trying this on pig:
register datafu-pig-incubating-1.3.0.jar
DEFINE Median datafu.pig.stats.StreamingMedian();
data = load '/user/hduser/numbers.txt' using PigStorage() as (val:int);
data2 = FOREACH (GROUP data ALL) GENERATE Median(data);
or directly
data2 = FOREACH (GROUP data ALL) GENERATE datafu.pig.stats.StreamingMedian(data);
I get this name-resolve error:
2016-06-04 17:22:22,734 [main] ERROR org.apache.pig.tools.grunt.Grunt
- ERROR 1070: Could not resolve datafu.pig.stats.StreamingMedian using imports: [, java.lang., org.apache.pig.builtin.,
org.apache.pig.impl.builtin.] Details at logfile:
/home/hadoop/pig_1465053680252.log
When I look into the datafu-pig-incubating-1.3.0.jar it looks OK, everything in place. I also tried some Bag functions, same error then.
I think it's kind of a noob-error which I just don't see (as I did not find particular answers for datafu in SO or google), so thanks in advance for shedding some light on this.
Pig script is proper, the only thing that could break is that while registering datafu there were some class dependencies that coudn't been met.
Try to run locally (pig -x local) and see a detailed log.
Check also the version of pig - it should be newer than 0.14.0.
I'm using the owl2java plugin to generate Java code from an Ontology file. But I'm always getting de same error.
Exception in thread "main" com.hp.hpl.jena.ontology.ConversionException: Cannot convert node http://www.w3.org/2002/07/owl#bottomObjectProperty to TransitiveProperty
at com.hp.hpl.jena.ontology.impl.TransitivePropertyImpl$1.wrap(TransitivePropertyImpl.java:66)
at com.hp.hpl.jena.enhanced.EnhNode.convertTo(EnhNode.java:142)
at com.hp.hpl.jena.enhanced.EnhNode.convertTo(EnhNode.java:22)
at com.hp.hpl.jena.enhanced.Polymorphic.asInternal(Polymorphic.java:54)
at com.hp.hpl.jena.enhanced.EnhNode.viewAs(EnhNode.java:92)
at com.hp.hpl.jena.enhanced.EnhGraph.getNodeAs(EnhGraph.java:135)
at com.hp.hpl.jena.ontology.impl.OntModelImpl$SubjectNodeAs.map1(OntModelImpl.java:3040)
at com.hp.hpl.jena.ontology.impl.OntModelImpl$SubjectNodeAs.map1(OntModelImpl.java:3033)
at com.hp.hpl.jena.util.iterator.Map1Iterator.next(Map1Iterator.java:35)
at com.hp.hpl.jena.util.iterator.WrappedIterator.next(WrappedIterator.java:68)
at com.hp.hpl.jena.util.iterator.UniqueExtendedIterator.nextIfNew(UniqueExtendedIterator.java:61)
at com.hp.hpl.jena.util.iterator.UniqueExtendedIterator.hasNext(UniqueExtendedIterator.java:69)
at com.hp.hpl.jena.util.iterator.NiceIterator.asList(NiceIterator.java:185)
at com.hp.hpl.jena.util.iterator.NiceIterator.toList(NiceIterator.java:159)
at de.incunabulum.owl2java.core.generator.OwlReader.handleProperties(OwlReader.java:862)
at de.incunabulum.owl2java.core.generator.OwlReader.generateJModel(OwlReader.java:457)
at de.incunabulum.owl2java.core.JenaGenerator.generate(JenaGenerator.java:65)
at onto.main.main(main.java:99)
I have no idea about what I'm doing wrong. Any Ideas?
Thanks you a lot.
I looked at the top line on your exception, and see com.hp.hpl.jena.ontology.impl.TransitivePropertyImpl.
Googling for that leads to a version of the source code. It may not be exactly the same version as you're using, but is probably close enough to be informative. Reading the code leads to these questions:
Does your Model have a profile? It must.
Does the profile support Transitivity? It must.
Are you combining Transitive with something else that it's incompatible with?
I'm new in "Play! Framework" and I'm trying to do a i18n for pt-BR.
My message file is called 'Message.pt-BR' and i put the pt-BR lang in application.conf.
In Java I'm using something like this:
flash("success", Messages.get("logout.success"));
And in scala.html files I'm using this:
#Messages("logout")
In my Message.pt-BR file I've this:
logout=Sair
logout.success=Logout realizado com sucesso. Volte sempre!
When I compile the project I have no errors, but when I request some page a have this error:
`=' expected but `-' found
Messages.pt-BR
Someone can help me?
I think you have to rename your message file from Messages.pt-BR to Messages.pt_BR (with a lower '_').