Skip to content
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 · 10 comments
Closed

JaVers dependency on Google Guava #692

shirishpandharikar opened this issue Jul 31, 2018 · 10 comments

Comments

@shirishpandharikar
Copy link
Contributor

@shirishpandharikar 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
Copy link
Member

@bartoszwalacik 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
Fixes #692
@bartoszwalacik bartoszwalacik added the fixed label Aug 4, 2018
@bartoszwalacik
Copy link
Member

@bartoszwalacik bartoszwalacik commented Aug 4, 2018

released in 3.11.0

@PodusovMaxim
Copy link

@PodusovMaxim 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
Copy link
Contributor Author

@shirishpandharikar 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
Copy link

@PodusovMaxim 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
Copy link
Contributor Author

@shirishpandharikar 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
Removed unnecessary use of Google Guava as reported by @PodusovMaxim.
bartoszwalacik added a commit that referenced this issue Aug 8, 2018
Fixes #692
@bartoszwalacik
Copy link
Member

@bartoszwalacik bartoszwalacik commented Aug 8, 2018

finally fixed in javers-3.11.1

@tWechdorn
Copy link

@tWechdorn tWechdorn commented May 14, 2020

RealNodePair.java also has a dependency on com.google.common.collect.Streams => which leads to a java.lang.NoClassDefFoundError: com/google/common/collect/Streams in getPropertiesFromBothSides()

@shirishpandharikar
Copy link
Contributor Author

@shirishpandharikar shirishpandharikar commented Jul 4, 2020

@tWechdorn The changes to RealNodePair were done much later than this fix. I will fix the code and submit a PR. @bartoszwalacik Can you please re-open this issue?

@bartoszwalacik
Copy link
Member

@bartoszwalacik bartoszwalacik commented Jul 4, 2020

fixed in 5.10.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants