Running JUnit Integration Tests Spring/JHipster in STS - eclipse

I have a Jhipster Generated with v3.4.0 (using Gradle).
I'm attempting to run and debug unit tests from STS.
From documentation:
Those tests can be run directly in your IDE, by right-clicking on each
test class, or by running mvn clean test (or ./gradlew test if you run
Gradle).
While the gradle task $.gradlew test executes as expected, when I attempt to "right click" and Run As Junit Test or Debug As Junit test - I get exceptions around the database:
Small part of stacktrace:
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name
'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration':
Injection of autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not
autowire method: public void
org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.setFilterChainProxySecurityConfigurer(org.springframework.security.config.annotation.ObjectPostProcessor,java.util.List)
throws java.lang.Exception; nested exception is
org.springframework.beans.factory.BeanExpressionException: Expression
parsing failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'securityConfiguration': Injection of
autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not
autowire field: private
org.springframework.security.core.userdetails.UserDetailsService
web.myapp.core.config.SecurityConfiguration.userDetailsService;
nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'userDetailsService': Injection of autowired
dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not
autowire field: private web.myapp.core.repository.UserRepository
web.myapp.core.security.UserDetailsService.userRepository; nested
exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'userRepository': Cannot create inner
bean '(inner bean)#1c752902' of type
[org.springframework.orm.jpa.SharedEntityManagerCreator] while setting
bean property 'entityManager'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name '(inner bean)#1c752902': Cannot resolve
reference to bean 'entityManagerFactory' while setting constructor
argument; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'entityManagerFactory' defined in class path
resource
[org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]:
Invocation of init method failed; nested exception is
org.hibernate.cache.NoCacheRegionFactoryAvailableException:
Second-level cache is used in the application, but property
hibernate.cache.region.factory_class is not given; please either
disable second level cache or set correct region factory using the
hibernate.cache.region.factory_class setting and make sure the second
level cache provider (hibernate-infinispan, e.g.) is available on the
classpath.
My assumption is that the correct profile for the test-database is not initialized: src/test/resources/application.yml
Any advice on setting this profile in STS?
Update
I have updated with some screen-shops per the https://jhipster.github.io/configuring-ide-eclipse-gradle/:
No Resource Filters Project Properties > Resource > Resource Filters (none were added by STS when I imported the project
Checked to make sure the build/generated/source/apt/main is added to my Java Build Path settings under Project Properties > Java Build Path

I had the same problem and this is how I got it working:
1. You need to initially run the test at least once as part of the gradle build task before you can then run it interactively with JUnit
2. JHipster generates the build.gradle file by default to only run tests that are named *UnitTest or *IntTest. If you have this default configuration, but have named your test differently, then step 1 above won't work because although the build may complete successfully it hasn't actually run your test and as a result it still can't be run in JUnit.
3. Follow the steps given in the screenshots that have been added above as an update to the original question.
Now trying running as JUnit Test.

Related

Eclipse build not working but maven build works; I get the error: Consider defining a bean of type 'mapper' in your configuration

I get the below error when I do a update maven in eclipse and then start the application. But when I run the application after doing a manual maven build manually it works. Why is that???
Description:
Parameter 1 of constructor in 'Command' required a bean of type 'Mapper' that could not be found.
The injection point has the following annotations:
- #org.springframework.beans.factory.annotation.Autowired(required=false)
Action:
Consider defining a bean of type 'Mapper' in your configuration.

Scala. NoSuchMethodException when instantiating trait

After refactoring some projects, I I got the following Exception when calling a scala class that implements a trait from a Spring Boot application
8/06/22 13:32:26 ERROR SpringApplication: Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'MLController' defined in URL [jar:file:/home/xxxx/environment/spark-2.2.1-bin-hadoop2.7/./xxxx/ikodaanalysis-mlserver-0.1.0.jar!/xxx/mlserver/MLController.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [xxx.mlserver.MLController]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: ikoda.utilobjects.SparkConfProviderWithStreaming.$init$(Lxxx/utilobjects/SparkConfProviderWithStreaming;)V
I checked the dependencies and everything appeared to be present in the jar.
So why was I getting the Exception?
I found the answer here. I felt it was probably a fairly common issue and worth reporting on SO.
I assume it's down to Java 8 and Scala 2.12 expecting to find the "init" method in the ScalaDsl.class file (new style Traits as interfaces) rather than in ScalaDsl$class.class file (old style Traits as interface and supporting class).
......
I think the Scala 2.12 package needs to be compiled (not just run)
under Java 8 to avoid this problem.

Bean Creation Exception when I run Liferay module

I get Bean Creation Exception:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'counterHibernateSessionFactory' defined in class path resourc
e [META-INF/hibernate-spring.xml]: Cannot resolve reference to bean 'counterData
Source' while setting bean property 'dataSource'; nested exception is org.spring
framework.beans.factory.BeanCreationException: Error creating bean with name 'co
unterDataSource' defined in class path resource [META-INF/counter-infrastructure
-spring.xml]: Cannot resolve reference to bean 'counterDataSourceImpl' while set
ting bean property 'targetDataSource';
I am trying to run a liferay module on a tomcat server.I use Eclipse Luna, tomcat server 8.0.32, liferay 7.0 ga3.I searched for helpful information, didn't find any to solve the problem.Thank you!
I solved this, the problem was that I didn't have Gradle IDE incorporated and also I was trying to run the module directly on my server, but firstly I had to build it with gradle.Now I am deploying my liferay modules on serves by going to the root path of the module and applying the command with blade cli: blade deploy.

BeanCreationException Vaadin

I'm trying to integrate Spring Boot Vaadin (https://github.com/peholmst/vaadin4spring) with Vaadin's Dashboard Demo Code (https://github.com/vaadin/dashboard-demo). The only thing modification I made was add the annotation "#VaadinUI" in the DashboardUI class. I checked in my code using the branch "integrate-vaadin-dashboard-demo-project".
I get the error message:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/validation/ParameterNameProvider.
I'm not really sure what the message means. Can somebody explain it and come up with a resolution to the error message?
Gist Error Output:
https://gist.github.com/anonymous/43d602c1105e00d4d7d6
Clone Url:
https://github.com/caritos/pangolin.git
Branch:
integrate-vaadin-dashboard-demo-project
You pack javax validation api 1.0 in your jar. This is the version the GWT compiler needs (when you build a widgetset). But spring-boot depends on version 1.1. Usually the problem is the other way around...

Spring-data-neo4j and compatibility with Scala

I suspect that Spring-data-neo4j 2.1.0-BUILD-SNAPSHOT isn't really compatible with some versions of Scala.
I use scala 2.10.0 and using a Play! web application based on scala 2.10.0 too.
While running a test involving a Neo4jTemplate autowired by Spring, I obtain this error:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'mappingInfrastructure' defined in class
org.springframework.data.neo4j.config.Neo4jConfiguration: Invocation of init method failed;
nested exception is java.lang.NoSuchMethodError:
scala.collection.JavaConverters$.mapAsScalaMapConverter(Ljava/util/Map;)Lscala/collection/JavaConverters$AsScala
Does a fix exist or would be scheduled?