I am unable to find online which version of jackson-databind to use with Spring application that doesn't have remote execution vulnerability? Any help is appreciated.
Since version 2.10.0 this problem is resolved by adding new set of methods: activateDefaultTyping instead of deprecated set of methods enableDefaultTyping. Also this problem was one of reasons to why this version was released.
Major Goals for 2.10
Looking back, there were 3 major goals for this minor release:
Resolve the growing problem of “endless CVE patches”, a
stream of fixes for reported CVEs related to “Polymorphic
Deserialization” problem (described in “On Jackson CVEs… ”) that
resulted in security tools forcing Jackson upgrades. 2.10 now includes
“Safe Default Typing” that is hoped to resolve this problem.
More you can find in this article: Jackson 2.10 features.
Example code:
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.databind.jsontype.BasicPolymorphicTypeValidator;
import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator;
import java.util.ArrayList;
public class JsonPathApp {
public static void main(String[] args) throws Exception {
PolymorphicTypeValidator ptv = BasicPolymorphicTypeValidator.builder()
.allowIfSubType(MyValue.class)
.allowIfSubType(ArrayList.class)
.build();
ObjectMapper mapper = JsonMapper.builder()
.enable(SerializationFeature.INDENT_OUTPUT)
.activateDefaultTyping(ptv, ObjectMapper.DefaultTyping.NON_FINAL).build();
}
}
Related
Code is as below:
package nw;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class test {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver","C:\\geckodriver-v0.24.0-win64.exe");
WebDriver driver = new FirefoxDriver();
driver.get("http://www.shop.demoqa.com");
}
}
Hello i am facing this issue in selenium while launching the above given program --
program..plz help me
com/google/common/collect/ImmutableMap
at org.openqa.selenium.firefox.FirefoxDriver.<clinit>(FirefoxDriver.java:108)
at nw.test.main(test.java:14)
Caused by: java.lang.ClassNotFoundException:
com.google.common.collect.ImmutableMap
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
You have not added selenium-server.jar in your build or dependency in your POM.
You have added selenium-java.jar in your build or as dependency due to which your code is compiling fine
You need to add that too
Download jar from below location:
https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server
OR add below dependency
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.141.59</version>
</dependency>
Note that here I am using version 3.141.59 for server so your selenium java jar should of same version to prevent from any unrelated error
Selenium relies on Google Guava and your test is failing to find ImmutableMap class.
The solution is to add the relevant version of guava to your project classpath.
The full set of dependencies would be:
animal-sniffer-annotations-1.14.jar
byte-buddy-1.8.15.jar
checker-compat-qual-2.0.0.jar
commons-exec-1.3.jar
error_prone_annotations-2.1.3.jar
guava-25.0-jre.jar
j2objc-annotations-1.1.jar
jsr305-1.3.9.jar
okhttp-3.11.0.jar
okio-1.14.0.jar
selenium-api-3.141.59.jar
selenium-chrome-driver-3.141.59.jar
selenium-edge-driver-3.141.59.jar
selenium-firefox-driver-3.141.59.jar
selenium-ie-driver-3.141.59.jar
selenium-java-3.141.59.jar
selenium-opera-driver-3.141.59.jar
selenium-remote-driver-3.141.59.jar
selenium-safari-driver-3.141.59.jar
selenium-support-3.141.59.jar
Going forward I would recommend using a dependency management solution like Maven or Gradle so you won't have to manually download the .jars. Check out Selenium with Java article for comprehensive explanation and example code snippets.
Trying to run my eclipse plugin from within eclipse, I get error messages to the console, which make the nested eclipse fail to run the plugin:
org.osgi.framework.BundleException: Error starting module.
at org.eclipse.osgi.container.Module.doStart(Module.java:590)
...
Caused by: java.lang.Error: Unresolved compilation problems:
The import org.eclipse cannot be resolved
The import org.eclipse cannot be resolved
The import org.eclipse cannot be resolved
The import org.eclipse cannot be resolved
The import org.osgi cannot be resolved
AbstractUIPlugin cannot be resolved to a type
IStartup cannot be resolved to a type
The method earlyStartup() of type Plugin must override or implement a supertype method
BundleContext cannot be resolved to a type
BundleContext cannot be resolved to a type
Suggesting that my plugin has compilation errors to it, but:
The plugin has not compilation errors
It seems a bit surprising that running a plugin would cause a compilation.
There was indeed no compilation error: the problem lies elsewhere. The main
Plugin class was to be a singleton, which was implemented like so:
public class Plugin extends AbstractUIPlugin implements IStartup {
public static Plugin plugin;
/ ** an empty c'tor. creates an instance of the plugin. */
public Plugin() {
plugin = this;
}
....
}
Now, other classes were referring to this public field, which not initialized; for some reason, eclipse thought this was a compilation
error. It was not. using a getter for that field solved the problem.
I'm attempting to use Apache Curator with a dockerized zookeeper instance and no matter how I attempt to connect I always end up with a
org.apache.zookeeper.KeeperException$UnimplementedException:
KeeperErrorCode = Unimplemented for...
error. I've tried making sense of the documentation but I'm not getting anywhere. I've logged into the zookeeper CLI and ensured the port number is correct thusly:
snerd#powerglove:~$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 31f1093495ba compose_zookeeper "/opt/zookeeper/bin/ 3 weeks ago Up About a minute 0.0.0.0:32770->2181/tcp,
0.0.0.0:32769->2888/tcp, 0.0.0.0:32768->3888/tcp zookeeper
here is the code I'm trying to use:
public class App {
public static void main( String[] args ) {
CuratorFramework client = CuratorFrameworkFactory.newClient("0.0.0.0:32770", new RetryUntilElapsed(3000, 1000));
client.start();
try {
client.create().forPath("/larry-smells/foop", "tuna?".getBytes());
} catch (Exception e) {
System.out.println(e.toString());
}
}
}
As far as I can tell from the Curator getting started page, this should work. What am I missing?
edit1
just figured out that I'm able to pull data out of the zookeeper ensemble thusly:
System.out.println(new String(curatorFramework.getData().forPath("/larry-smells")));
but the create command is still blowing up.
edit2
stacktrace of the error:
org.apache.zookeeper.KeeperException$UnimplementedException:
KeeperErrorCode = Unimplemented for /larry-smells/foop at
org.apache.zookeeper.KeeperException.create(KeeperException.java:103)
at
org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:1297) at
org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1040)
at
org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1023)
at
org.apache.curator.connection.StandardConnectionHandlingPolicy.callWithRetry(StandardConnectionHandlingPolicy.java:67)
at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:99) at
org.apache.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:1020)
at
org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:501)
at
org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:491)
at
org.apache.curator.framework.imps.CreateBuilderImpl$4.forPath(CreateBuilderImpl.java:367)
at
org.apache.curator.framework.imps.CreateBuilderImpl$4.forPath(CreateBuilderImpl.java:309)
at com.mycompany.app.App.main(App.java:35)
Edit: Apparently this error can occur if you're using the wrong combination of Curator in combination with Zookeeper. From curator.apache.org :
Curator 2.x.x - compatible with both ZooKeeper 3.4.x and ZooKeeper 3.5.x
Curator 3.x.x - compatible only with ZooKeeper 3.5.x and includes support for new features such as dynamic reconfiguration, etc.
It's hard to pinpoint your problem with only that error-code and not a stack trace, but some improvements I would suggest to make your application more stable is:
public class App {
public static void main( String[] args ) {
CuratorFramework client = CuratorFrameworkFactory.newClient("0.0.0.0:32770", new RetryUntilElapsed(3000, 1000));
client.start();
try {
//make sure you're connected to zookeeper.
client.blockUntilConnected();
//Make sure the parents are created.
client.create().creatingParentsIfNeeded().forPath("/larry-smells/foop", "tuna?".getBytes());
} catch (Exception e) {
System.out.println(e.toString());
}
}
}
I also faced a similar exception, I used the below dependencies which are compatible and helps me to resolve the exception.
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.6</version>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-x-discovery</artifactId>
<version>4.0.1</version>
</dependency>
I had the same problem.
I tried to use inTransaction () as explained here: http://www.programcreek.com/java-api-examples/index.php?api=org.apache.curator.framework.CuratorFramework on exercise 6
and seems to work.
client.inTransaction ().create().forPath("/larry-smells/foop", "tuna?".getBytes()).and ().commit ();
The issue is caused because of incompatibility.
To fix this, you need to change the version like it's explained here:
https://curator.apache.org/zk-compatibility.html
If this doesn't work, just look for the newest curator version which depends on a 3.4.x zookeeper version (currently '2.12.0').
#Massimo Da Ros solution works, but in new version Curator 4.0.0 inTransaction is deprecated, it's recommented use transaction method like below:
CuratorOp op = client.transactionOp().create()
.withMode(CreateMode.PERSISTENT)
.withACL(Ids.OPEN_ACL_UNSAFE)
.forPath("/test", "Data".getBytes());
result = client.transaction().forOperations(op).get(0).toString();
I faced similiar problem. I was using spring-cloud-starter-zookeeper-discovery which by itself of course has compatible zookeeper and curator versions.
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
</dependency>
I checked the dependency tree and spring-cloud-starter-zookeeper-discovery Version 3.1.1. was using zookeeper Version 3.6.0
The problem was, in my docker-compose.yml I was using zookeeper Version 3.4!
So make sure your docker-compose.yml zookeeper version fits your maven zookeeper version.
version: "3.8"
services:
zookeeper:
container_name: zookeeper
image: zookeeper:3.6 <----------------- zookeeper version
ports:
- "2181:2181"
I am trying to run Mule Batch Code and getting below error when mule is trying to start an application:
org.mule.module.launcher.DeploymentInitException: ClassNotFoundException: org.mule.api.process.ProcessAdapter.
Which jars or mule module I am missing for org.mule.api.process.ProcessAdapter?
Is this enterprise license issue?
I am tried my mule code in both in mule studio and mule standalone but getting the same error.
Please provide input.
After backtracking to various versions (and actually downloading jar from each iteration from this https://repository.mulesoft.org/nexus/content/repositories/releases/org/mule/tools/devkit/mule-devkit-annotations/) I could find the class(actually an abstract interface) you are referring to in the mule-devkit-annotations but the last iteration that included the org.mule.api.process was 3.3.2 and it was dropped after 3.4.0
In mule-devkit-annotations-3.3.2:
public abstract interface ProcessAdapter<O>
{
public abstract <T> ProcessTemplate<T, O> getProcessTemplate();
}
However, I could find the same Interface in mule-module-devkit-support.jar (I was using 3.6.1)
In mule-module-devkit-support-3.6.1.jar:
public interface ProcessAdapter<O>
{
<T> ProcessTemplate<T, O> getProcessTemplate();
}
I want to create a web application running on Tomcat 7.0 with JRE JavaSE-1.6 on osx 10.8.
I am using a tutorial from the developers site and the error occurs when I try to call
clientSecrets = GoogleClientSecrets.load(new JacksonFactory(), reader);
I added the Jar google-http-client-jackson-1.16.0-rc.jar to my build path and still get following error:
java.lang.NoClassDefFoundError: com/google/api/client/json/JsonFactory
java.lang.ClassNotFoundException: com.google.api.client.json.JsonFactory
My classpath specifically points to this Jar too.
I just fixed this by changing the following lines:
Original: import com.google.api.client.json.jackson.JacksonFactory;
Modified: import com.google.api.client.json.jackson2.JacksonFactory;
I had a similar problem and solved it by manually adding the required JAR's to my WEB-INF\lib folder outside Eclipse.
From this page here, it says you need 3 libraries:
1) The Generated Java client library for BigQuery
2) The Google HTTP Client Library for Java
3) The Google OAuth Client Library for Java
Do you have them all? It sounds like you have #2, but it sounds like you're missing the google HTTP client.
In POM add below dependency-
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client-gson</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client-jetty</artifactId>
<version>1.34.1</version>
</dependency>
Note: In above dependency version can be changed
2.Import statement
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.gson.GsonFactory;
Usage
private static final JsonFactory JSON_FACTORY =
GsonFactory.getDefaultInstance();
GoogleClientSecrets clientSecrets =GoogleClientSecrets.load(JSON_FACTORY,
new InputStreamReader(in));