This week's book giveaway is in the Beginning Java forum.
We're giving away four copies of Murach's Java Programming and have Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Java Programming this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Error Running Code with External Library  RSS feed

 
Robert Johnston
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a project that contains 3 packages:

com.code.contacts - This contains two data models
com.code.client - This contains the code to run a console App
com.code.json - This contains code to interact with the Jackson 2 Libraries of code. 

In the ProcessJson class (com.code.json package), I am executing this code:


In the Main Class (com.code.console package), I call the above class/function and get the below error:

java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z
at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:571)
at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:480)
at com.code.jsonGenerics.ProcessJson.GetJson(ProcessJson.java:26)
at com.code.console.HelloWorld.main(HelloWorld.java:15)

I can see the java class in question in the jar for com.fasterxml.jackson.core, and have imported it in both classes, but I am still getting this error message. 

Any help would be greatly appreciated!
 
Norm Radder
Rancher
Posts: 2036
26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z 

Can there be different versions of the class?  One with the method used for compiling and one without the method used for execution.
 
Ralph van Delft
Greenhorn
Posts: 11
Angular Framework Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And if you reload your imports or recompile your project?

I don't have an IDE at the moment on my work computer but could it be that you are working with a framework like maven?
Some times it helps to right click on your project and do a kind of reload.
Sorry I cannot give you an specific example.
 
Rob Spoor
Sheriff
Posts: 21019
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JsonFactory is in jackson-core, and ObjectMapper is in jackson-databind. These should ideally have the same version, or at least compatible ones. JsonFactory.requiresPropertyOrdering has been added in Jackson 2.3, so make sure the version you're using is high enough.
 
Lasagna is spaghetti flvored cake. Just like this tiny ad:
Thoughts on deprecation in Java
https://coderanch.com/t/683016/java/Deprecation-Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!