JSON Parser -java.lang.NoSuchFieldError: defaultReader - json

I am using a JSON parser to extract the value and I am using the following jar
json-path-2.1.0, and I am getting the following error when I invoke the use case deployed as webservice on weblogic server
I wrote a small main program to extract the value from the json string and it works fine, but the server version of the use case is giving the issue. I am not sure if there are any other jars part of my ear can negatively impact this
SEVERE: defaultReader
java.lang.NoSuchFieldError: defaultReader
at com.jayway.jsonpath.spi.json.JsonSmartJsonProvider.<init>(JsonSmartJsonProvider.java:39)
at com.jayway.jsonpath.internal.DefaultsImpl.jsonProvider(DefaultsImpl.java:21)
at com.jayway.jsonpath.Configuration.defaultConfiguration(Configuration.java:174)
at com.jayway.jsonpath.internal.JsonContext.<init>(JsonContext.java:52)
at com.jayway.jsonpath.JsonPath.parse(JsonPath.java:596)

Stumbled about the same problem.
The reason why it does not work is not the JDK 8.
The reason why you encounter this issue, is the fact that weblogic 12.2.1.X is bundling some old version of json-smart.
On my machine this would be found here:
jar:file:/C:/dev/WLS_12_2_1_2_0/oracle_common/modules/net.minidev.json-smart.jar!/net/minidev/json/JSONValue.class
Now if you are using a library like json-path that depends on json-smart, then by default the container will load the required class using one of its built-in modules.
The blowup you have, seems to be that the JSONValue class that your json-path depends on seemed to have this defaultReder field.
Here is a snipet of the clode that is blowing up.
public JsonSmartJsonProvider() {
this(JSONParser.MODE_PERMISSIVE, JSONValue.defaultReader.DEFAULT_ORDERED);
}
That
JSONValue.defaultReader
Seems not to be valid on weblogs older system class loader class.
You can tell the container to use what you are packing by putting into your weblogic.xml deployment descriptor something like this:
<wls:prefer-application-packages>
<wls:package-name>net.minidev.json.*</wls:package-name>
</wls:prefer-application-packages>
I am having quite a bit of trouble getting weblogic to swallow the fine-grained instruction above.
I found myself to force weblogic to swallog all that goes into the web-inf folder instead doing:
<wls:container-descriptor>
<wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
</wls:container-descriptor>
I would have rather not be using a hammer like the web-inf-classes, but I am dancing with the weblogic system classloader when I do not go coarse grained...
Regards.

I too was facing this issue, It turned out some other library was using json-smart's older version, and it was getting precedence over json-path's json-smart dependency. Removing the other jar solved the issue. Or you can also downgrade your json-path's version to appropriate version such that it support json-smart's older version.

Looks like JsonParser jar is present in JVM 1.8 version and it seems to have more precedence over the JsonParser class available in Json-path.jar. Apparently the us case doesn't work in 12.2.1 version of the weblogic server but it works fine in 12.1.3

I had the same problem but I use Gradle so I had to add:
compile group: 'net.minidev', name: 'json-smart', version: '2.3' to my dependencies.

Related

CodeEffects exception with .net core 3.1 and running in docker container

After the upgrade from .net core 2.2 to 3.1 (without changing codeffects related code or library versions) we have problems when loading the xml into the rule editor (in the backend), but only when running the application in a docker container (which is based on mcr.microsoft.com/dotnet/aspnet:3.1.11 image). When running exactly the same code from Visual Studio everything is fine. Like it is also if we revert to the .net core 2.2 version of the app.
The problem is on loading the existing rule xml into the rule editor:
editor.LoadRuleXml(ruleXml);
or this way
editor.Rule = CodeEffects.Rule.Models.RuleModel.Create(ruleXml, type);
The exception is:
CodeEffects.Rule.Common.InvalidRuleException: Invalid rule XML. Input string was not in a correct format. (#125) at CodeEffects.Rule.Formats.Ce.FillRule(List`1 list, XmlNode ruleXml, XmlDocument sourceXml, GetRuleDelegate ruleDelegate, Type sourceObject) at CodeEffects.Rule.Formats.Ce.LoadXml(XmlDocument rule, XmlDocument source, GetRuleDelegate ruleDelegate, Type sourceObject) at CodeEffects.Rule.Core.RuleLoader.LoadXml(XmlDocument rule, XmlDocument source, RuleFormatType format, GetRuleDelegate getRuleDelegate, Type sourceObject) at CodeEffects.Rule.Core.RuleLoader.LoadXml(String xmlRule, XmlDocument sourceXml, GetRuleDelegate ruleDelegate, Type sourceObject) at CodeEffects.Rule.Web.RuleEditor.LoadRuleXml(String ruleXml, GetRuleDelegate ruleDelegate) at CodeEffects.Rule.Web.RuleEditor.LoadRuleXml(String ruleXml)
Logging the xml that we pass to the load method shows that the xml is as it should be, so like it was stored in the db, and this same xml otherwise works fine, just not when the app is running in a docker based on .net core 3.1.
Unfortunatelly there is no inner exception that would point us closer to the source of the problem. And since it can be only reproduced when running in docker container, we are running out of ideas.
Our version of CodeEffects.Rule.Editor.Web.Core library is quite old, 5.0.7.6, but the same problem persists even if we upgrade to the latest 5.0.38.4.
Any idea what could be the problem?

Library class doesn't know of ConfigureWebHostDefaults extension method

I'm building a suite of REST micro-services using .Net Core 3.0 Preview 6. All these services will have the same start up logic. So, I'm trying to place all the code in a .Net Standard library.
The goal is to have the IHostBuilder:CreateHostBuilder method, as well as the Startup:Configure and Startup:ConfigureServices class and methods in the library. The library will also contain error handling logic, customized http response messages, etc.
However, I can't seem to find the correct package that contains the ConfigureWebHostDefaults method. I tried adding the Microsoft.AspNetCore package 2.2.0, but that didn't resolve the issue.
I added the Microsoft.Extensions.Hosting (3.0.0-preview-6) package, that also doesn't resolve the issue.
Is what I'm attempting even possible?
Thanks
-marc
I resolved it, not the best way, but it works. I decided to make the library targeted specifically for .NET Core 3.0. So, I changed the targetframework in the project file. That change automatically resolved my other issue.
Import the Microsoft.AspNetCore package, and use WebHost.CreateDefaultBuilder() instead. According to the code it is built from, both CreateDefaultBuilder() and ConfigureWebHostDefaults() call the same internal method: ConfigureWebDefaults().
The only downside of this is that the returned host will be an IWebHost instead of an IHost.

java.lang.UnsatisfiedLinkError: com.chrysalisits.crypto.LunaAPI.Initialize()V

I am getting below exception while running my application.
Caused by: java.lang.UnsatisfiedLinkError:
com.chrysalisits.crypto.LunaAPI.Initialize()V
at com.chrysalisits.crypto.LunaAPI.Initialize(Native Method)
at com.chrysalisits.crypto.LunaTokenManager.(LunaTokenManager.java:107)
at com.chrysalisits.crypto.LunaTokenManager.getInstance(LunaTokenManager.java:62)
I have added LunaProvider.jar and libLunaAPI in $JAVA_HOME/jre/lib/ext.
I strongly recommend that you ask the HSM Support Team for help on this instead of Stackoverflow.
This error comes up if Java is not able to find the concerned .so / .dll (Library) file. Also, make sure that you have the correct 32 / 64 Bit version of the Library in the location.
That said, in the VM Arguments you could also set :
-Djava.library.path=/location_to_the_libLunaAPI_so_file (possibly, /usr/lunasa/JSP/lib .. or something)
I have solved my problem.
Actual Problem was mismatch between native client library (libLunaAPI.so) and Luna client.
My application was using old library's com.chrysalisits.crypto.* classes to interact with Luna client however my Luna client got updated and functions which it exposed in its native library was not present in current library.
I updated my client application by using com.safenetinc.luna.* classes and latest client library.

parse4cn1 has some issue when working with Node JS and parse-server open source

The parse4cn1 library works well with parse.com but it has some issues when working with Node 4.3.2 and parse-server open source. For example, when calling the ParseUser.signup() function, the "Invalid key name" exception is always happened. I tried to debug and figure out that the ParseCommand object should add the ParseConstants.CONTENT_TYPE_JSON to its header in order to make it can work. I don't why because it still works without doing this with parse.com.
Another issue is the ParseQuery.find() is always failed when using the ParseQuery.whereContainedIn(). The server exception is "ParseException [code=102, msg=Improper encode of parameter, cause=null]". I guess this issue probably regarding the parameter has the json format in this case as well but I don't know to to resolve it. Any advice is appreciate. Sidiabale, do you have any advice? Thanks!
These problems are solved in version 3.0 of parse4cn1. Apparently, Parse Server is stricter with the need to specify the content-type header so code that previously worked with Parse.com does not work with Parse Server. I've addressed these issues in the aforementioned release. Try again with version 3.0 and let me know if you encounter any issues.

Sonar Unit tests report parameter - sonar.junit.reportPath vs sonar.java.junit.reportPath

I found that my Sonar instance 5.1 or 5.1.1 (with latest sonar-runner 2.x) stopped showing part of the Unit test info (Unit test widget) on the project's dashboard.
The properties I had were (in Gradle's sonarRunner > sonarProperties section):
property "sonar.junit.reportsPath", "build/test-results/UT"
property "sonar.surefire.reportsPath", "build/test-results/UT"
To fix it, I had to include the following properties as well:
property "sonar.java.junit.reportsPath", "build/test-results/UT"
property "sonar.java.surefire.reportsPath", "build/test-results/UT"
Just FYI: All my Unit tests reports go under build/test-results/UT folder, all Integration Tests result files go unedr build/test-results/IT folder and etc.
I'm wondering if this is due to Gradle version that I'm using (2.3) or is it due to a later version of SonarQube (4.5+) as I have both SQ 5.1 and 5.1.1 instance.
I know SonarQube team started Multi language support since SonarQube version 4.12
Since SonarQube 4.2, it is possible to run an analysis on a multi-language project.
Now, it raises a question. For Getting the same Unit test info for Groovy based projects, do I need to use:
property "sonar.groovy.junit.reportsPath", "build/test-results/UT"
property "sonar.groovy.surefire.reportsPath", "build/test-results/UT"
something like that if my project has Groovy code instead of java?
Searching "**sonar.java.junit.reportPath"** with using double quotes shows No results found in Google and it forces me to try and see google results if I can run the search again without using " double quotes (for this property).
Doing the same in SonarQube site "search box" shows:
No results found for sonar.java.junit.reportPath. Please try one of the following suggestions:
Though in Gradle, inside
sonarRunner task {
.. inside ..
sonarProperties {
... section ... where I define various sonar props..
}
...
}
I can define both sonar.junit.reportPath, sonar.java.junit.reportPath and similarly, sonar.surefire.reporPath and sonar.java.surefire.reportPath and while running sonarRunner task in Gradle, it doesn't error out. Thus it makes me believe that the property variables are valid.
There are also issues with running sonarRunner or stand alone sonar-runner command for a mixed Java and Groovy based project (i.e. source code in Java but tests in Groovy). Setting sonar.language=java,grvy didn't help. I posted this question on stackoverflow but so far I have no perfect result/answer on how to get a full fledged sonar dashboard up and running for a Groovy projects like I get for a Java project.
Groovy project - Sonar - Publish project and Unit + Integration Test code coverage data
PS: I have tried various values for setting sonar.. variables (as far a sonar source, tests, etc, etc properties are concerned, which they have mentioned on their site's docs section)
The only valid property to use as of now is sonar.junit.reportsPath which will tell the java sonarqube plugin where to import your result of unit tests.
For groovy, this is work in progress, see : http://jira.sonarsource.com/browse/SONARGROOV-2
All the other properties you mentioned do not exist and are not taken into account.