New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JaVers dependency on Google Guava #692

Closed
shirishpandharikar opened this Issue Jul 31, 2018 · 7 comments

Comments

Projects
None yet
3 participants
@shirishpandharikar
Contributor

shirishpandharikar commented Jul 31, 2018

As documented I just ran the below code to view the diff. It seems that Google Guava is required as a runtime dependency for the below code to work.

Javers javers = JaversBuilder.javers().build();
Person tommyOld = new Person("tommy", "Tommy Smart");
Person tommyNew = new Person("tommy", "Tommy C. Smart");

Diff diff = javers.compare(tommyOld, tommyNew);
System.out.println(diff.prettyPrint());

The code above throws an exception as shown below:

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap
	at org.javers.core.Changes.<init>(Changes.java:35)
	at org.javers.core.diff.Diff.groupByObject(Diff.java:88)
	at org.javers.core.diff.Diff.toString(Diff.java:129)
	at org.javers.core.diff.Diff.prettyPrint(Diff.java:120)
	...
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.ImmutableMap
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 5 more

Not sure how the below line of code is used in org.javers.core.Changes.java
There are 3 more references in other classes HibernateConfig.java, JaversSpringJpaApplicationConfig.java and JaversSpringMongoApplicationConfig.java

The above code can be easily replaced with standard Java code to remove dependency on Goolge Guava.

Do let me know if these changes can be done. I will submit a PR.

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Jul 31, 2018

Thanks for reporting. You are right, there should be no references to Guava in javers-core classes (except of org.javers.guava package). Guava is the optional dependency:

optional "com.google.guava:guava:$guavaVersion"

and should not be required. I will be happy if you contribute a PR to fix it.

bartoszwalacik added a commit that referenced this issue Aug 4, 2018

@bartoszwalacik bartoszwalacik added the fixed label Aug 4, 2018

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Aug 4, 2018

released in 3.11.0

@PodusovMaxim

This comment has been minimized.

PodusovMaxim commented Aug 6, 2018

Hi!
I have same problem with guava stream:
java.lang.reflect.InvocationTargetException java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at org.javers.common.reflection.ReflectionUtil.newInstance(ReflectionUtil.java:89) .. 64 more Caused by: java.lang.NoClassDefFoundError: com/google/common/collect/Streams at org.javers.common.collections.Primitives.getPrimitiveAndBoxTypes(Primitives.java:30) at org.javers.core.metamodel.type.TypeMapper.registerCoreTypes(TypeMapper.java:54) at org.javers.core.metamodel.type.TypeMapper.<init>(TypeMapper.java:40) ... 69 more

@shirishpandharikar

This comment has been minimized.

Contributor

shirishpandharikar commented Aug 6, 2018

@PodusovMaxim What version are you using? I looked inside the org.javers.common.collections.Primitives class. I do not see any reference to com/google/common/collect/Streams class. getPrimitiveAndBoxTypes methods just returns a statically defined array of classes.

@PodusovMaxim

This comment has been minimized.

PodusovMaxim commented Aug 7, 2018

I'm using javers-3.11.0

link with com.google.common.collect.Streams

You need to change import from com.google.common.collect.Streams to java.util.stream.Stream

@shirishpandharikar

This comment has been minimized.

Contributor

shirishpandharikar commented Aug 7, 2018

@PodusovMaxim Thanks for reporting this. This is something that got added after #692 was reported and fixed. Will submit a PR.

shirishpandharikar added a commit to shirishpandharikar/javers that referenced this issue Aug 7, 2018

Fixes javers#692
Removed unnecessary use of Google Guava as reported by @PodusovMaxim.

bartoszwalacik added a commit that referenced this issue Aug 8, 2018

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Aug 8, 2018

finally fixed in javers-3.11.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment