Dropwizard, swagger and in-memory hiverunner/hiveqlunit integration - maven

I am having some trouble trying to run an in-memory hive while writing tests for a dropwizard swagger app. I have tried both hiverunner and hiveqlunit.
There are 2 types of tests. One is for testing dropwizard/swagger API endpoints using dropwizard integration testing (no need for hive here) and the other is for testing the hive integration where I need to hit the api and setup an in-memory hive to query and verify data is stored in hiveDB (psql).
The two in-memory hive dependencies (Note that I am using one at a time) always have some kind of conflict with the existing dropwizard and swagger dependencies. I am guessing it has something to do with jersey but I've tried a lot of things and still no luck.
I can run in-memory hive just fine and do all CRUD if I am not hitting the dropwizard/swagger api. But I just can't get the two services to play along at the moment.
Versions in Maven:
io.dropwizard:dropwizard-core version: 0.9.2
com.smoketurner:dropwizard-swagger version: 0.9.2-3
com.facebook.presto.hive:hive-apache-jdbc version: 0.13.1-3
com.klarna:hiverunner version: 3.0.0
OR
org.finra.hiveqlunit:hiveQLUnit version: 1.0
dropwizard-swagger uses org.reflections:reflections:jar:0.9.10 and com.klarna:hiverunner uses org.reflections:reflections:jar:0.9.8.
When I didn't exclude anything, I got the following:
java.lang.NoSuchMethodError: org.reflections.util.ClasspathHelper.forPackage(Ljava/lang/String;[Ljava/lang/ClassLoader;)Ljava/util/Collection;
So I tried excluding org.reflections:reflections from hiverunner and I got the 3 Exceptions:
java.lang.RuntimeException: javax.servlet.ServletException: io.dropwizard.jersey.setup.JerseyServletContainer-73437222#8a344094==io.dropwizard.jersey.setup.JerseyServletContainer,1,false
Caused by: A MultiException has 3 exceptions. They are:
1. java.lang.NullPointerException
2. java.lang.IllegalStateException: Unable to perform operation: method inject on com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$App
3. java.lang.IllegalStateException: Unable to perform operation: create on org.glassfish.jersey.message.internal.MessageBodyFactory
Then I tried excluding org.reflections:reflections from dropwizard-swagger and added a separate dependency for org.reflections:reflections by adding the following dependency to my pom.xml:
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.10</version>
</dependency>
And got the following:
java.lang.NoClassDefFoundError: com/google/common/base/MoreObjects
So I added the latest guava (version 20.0) and then it gives me another error. This seems like dependency hell.
Has anyone ever encountered this problem before? It seems like dropwizard and hiverunner do not play along well. Maybe it has to do with the versioning of jersey 1 & 2.
I got some other error regarding jackson-databind, so I did some research and found out I had to have the same version for the following dependencies:
com.fasterxml.jackson.core:jackson-databind (from `dropwizard`)
com.fasterxml.jackson.module:jackson-module-scala (from `hiverunner/hiveqlunit`)
And now I am back to the previous 3 Exceptions...
Any help will be appreciated.
Edit: Found out that hiveqlunit is using the following:
com.sun.jersey:jersey-server:jar:1.9
Which is one of the last versions before moving to the following maven dependency:
org.glassfish.jersey.core:jersey-server
It is having conflicts with dropwizard's org.glassfish.jersey.core:jersey-server:jar:2.22.
How can i resolve this conflict?

Related

Spring data jpa specifications and projections error

I am getting below error when I use (https://github.com/pramoth/specification-with-projection)
Caused By: org.springframework.data.mapping.PropertyReferenceException: No property findOne found for type <Entity class>
any idea why its throwing this exception?
Looks like you are using incorrect Spring Data version.
This library works with the old versions only. The last changes to support new Spring Data were merged, but not still published.
You can try to use the last version from here
https://mvnrepository.com/artifact/th.co.geniustree.springdata.jpa/specification-with-projections
Maybe it will work.
Also I have a fork of the library that supports the last Spring Boot versions and Java 17. It can be temporarily used before the last version of the library will be published
https://github.com/v-ladynev/specification-with-projection-embeded

conflicts between spring-mongo and spring-cassandra

1.Work well with spring-mongo in microservice.
2.Work well with spring-cassandra in microservice.
build project with gradle.
but when i add spring-cassandra into spring-mongo,there are errors.even just import spring-cassandra dependencies,without any cassandra
compile "org.springframework.data:spring-cql:1.5.0.M1"
compile "org.springframework.data:spring-data-cassandra:1.5.0.M1"
compile "com.datastax.cassandra:cassandra-driver-core:3.0.1"
The error trace is too long.just take a summary.
throw exceptions
` ``
org.springframework.beans.factory.BeanCreationException
com.datastax.driver.core.exceptions.NoHostAvailableException
not caused by one class.when i run the test with gradle.all testcase throw this exception.and spring boot application cannot start.which worked well before.
and i have not added any java code to call datastax driver to connect cassandra.dont know why there is an exception about cassandra connection.
solve this issue by putting mongo/cassandr repository/model into
different package

Spring Boot v1.2 AbstractMethodError due to RepositoryInformation

Im building an application based on Spring Boot v1.2. While my application boots successfully and executes well (so far.. ), I'm unable to test using the spring boot framework because of an AbstractMethodError.
The last few lines of the trace are as below
Caused by: java.lang.AbstractMethodError: org.springframework.data.jpa.repository.support.LockModeRepositoryPostProcessor.postProcess(Lorg/springframework/aop/framework/ProxyFactory;Lorg/springframework/data/repository/core/RepositoryInformation;)V
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:185)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:239)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:225)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:84)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1627)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1564)
... 55 more
To analyze the above error, I checked the jar files from classpath involving the above classes. So the info is available as below
jar:file:/C:/rearch/intellij-workspace/springbootproj/lib/spring-aop-4.1.2.RELEASE.jar!/org/springframework/aop/framework/ProxyFactory.class
jar:file:/C:/rearch/mavenrepo/org/springframework/data/spring-data-commons/1.9.1.RELEASE/spring-data-commons-1.9.1.RELEASE.jar!/org/springframework/data/repository/core/RepositoryInformation.class
jar:file:/C:/rearch/intellij-workspace/springbootproj/lib/spring-data-jpa-1.3.3.jar!/org/springframework/data/jpa/repository/support/LockModeRepositoryPostProcessor.class
jar:file:/C:/rearch/intellij-workspace/springbootproj/lib/spring-test-4.1.2.RELEASE.jar!/org/springframework/test/context/support/DependencyInjectionTestExecutionListener.class
I'm not exactly sure on why spring-data-commons is coming up from maven repostory folder, while the others are being served from the project library.
While I debug that, I meanwhile need your help in figuring out the version compatibility between the above libraries.
I wasnt able to exactly pin point on what exactly is causing the error. Please help!
Thanks
The issue was with the intellij configuration of libraries which conflicts with Spring boot application. I manually replaced the required libraries from Maven repository and that worked out for me.
Per request from Elron..
Open the project folder in explorer and verify if the third party library versions in your project matches the ones you actually expect it to be. If something doesnt match, just replace the file with the one you expect it to be. In my case, since I use Maven, I didnt see a need for explicitly saving those libraries in a new lib folder under the project. So, I just deleted all of the files inside the lib folder and things started working again.
For fix this error, change the spring-data-jpa version to 1.5.0.RELEASE
I have faced this issue .
Get rid of spring-data-commons and change spring-data-jpa version to 1.9.0.RELEASE.
For more details , please follow this link :-
Spring Data Rest PagingAndSortingRepository AbstractMethodError (RepositoryFactorySupport)

Spring Roo NoClassDefFoundError

my primary attempt is to build a CRUD app using Roo, following the example here:
https://www.icts.uiowa.edu/confluence/display/ICTSit/Spring+Roo+Tutorial
I am using Roo 1.2.5, Maven 3.1.1, and Spring 3.2.6 on JRE7.
This has been the best tutorial I have found so far. If anyone has a better example, please share!
However, when I execute the project in my Tomcat environment things still break. The primary error from there is:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.NoClassDefFoundError: org/springframework/util/MimeType
I have built multiple projects using Roo over the past few days, either from this tutorial or 10 others that all start with the reverse engineer command, and all give me the same type of a NoClassDefFoundError, either with this class or another. I understand this means that my pom.xml is more than likely incorrect, but I am hoping this is an issue with my configuration rather than something all Roo developers have simply accepted as manual maintenance.
Any advice would be tremendous... is it possible that the version of Roo combined with Spring and Maven I am using is simply buggy? I would love to use this framework/toolkit, but am nearing the point where manually writing the scaffolding by hand may be more straightforward.
.... UPDATE:
By adding the following dependency manually, I was able to run the project. However, I want to leave the question open to see if anyone further knows whether this missing jar is a known bug given the version of Spring Roo I am using, or otherwise:
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.2</version>
</dependency>
Thanks!
The best examples are those included in Roo: clinic.roo, pizzashop.roo, etc
Just run Roo and execute any of them as follows:
/_/ |_|\____/\____/ 1.2.4.RELEASE [rev 75337cf]
Welcome to Spring Roo. For assistance press TAB or type "hint" then hit ENTER.
roo> script --file clinic.roo
On the other side, the reference doc is a good starting point: http://docs.spring.io/spring-roo/reference/html/
Finally, about java.lang.NoClassDefFoundError: org/springframework/util/MimeType note MimeType class was included in Spring 4 and Roo sets up your project for Spring 3, so you must customize the pom.xml as needed.

Struts2 Dispatcher initialization failure with maven - jetty

I have the following problem:
I am working on a Web-Project using Struts2 with Tiles supported by a combination of Hibernate and Spring. In addition I am using Maven (which I'm new to) and the jetty server container. So my coworker told me what to do: just check out the project from the svn-repository and run the command (sudo) mvn jetty:run. According to my coworker this should work just fine, as it does when he checks out the project. But I always get the same error:
2011-08-22 10:09:20,568 ERROR org.apache.struts2.dispatcher.Dispatcher.error:38 -
Dispatcher initialization failed
Unable to load configuration. - [unknown location]
I already tried to re-check out the project, cleaned and updated maven, but still, the same error.
I think it has something to do with a missing struts2 .jar-file, but I thought maven downloads all necessary libraries automatically. Please give me a hint what could be missing, I'm sure it's something simple I overlooked.
Thanks in advance.

Resources