I created a project 3.6.1 Jhipster(Gradle)
To debug the back-end import the project STS 3.8.1.
From the "Boot Dashboard" tab to run the application.
I get the following error:
[2m2016-10-06 14:14:51.306[0;39m [31mERROR[0;39m [35m32187[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.s.boot.SpringApplication [0;39m [2m:[0;39m Application startup failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'categoriaResource': Unsatisfied dependency expressed through field 'categoriaMapper': No qualifying bean of type [com.abalia.atletico.service.mapper.CategoriaMapper] found for dependency [com.abalia.atletico.service.mapper.CategoriaMapper]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#javax.inject.Inject()}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.abalia.atletico.service.mapper.CategoriaMapper] found for dependency [com.abalia.atletico.service.mapper.CategoriaMapper]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#javax.inject.Inject()}
...
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.abalia.atletico.service.mapper.CategoriaMapper] found for dependency [com.abalia.atletico.service.mapper.CategoriaMapper]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#javax.inject.Inject()}
It is a new project with three entities.
If I run the console is doing well, but I need to debug.
Not if I add some plugin or configuration to Eclipse STS
.yo-rc.json:
{"generator-jhipster": {
"jhipsterVersion": "3.6.1",
"baseName": "atletico",
"packageName": "com.aaa.bbb",
"packageFolder": "com/aaa/bbb",
"serverPort": "8080",
"authenticationType": "jwt",
"hibernateCache": "hazelcast",
"clusteredHttpSession": "hazelcast",
"websocket": "spring-websocket",
"databaseType": "sql",
"devDatabaseType": "postgresql",
"prodDatabaseType": "postgresql",
"searchEngine": "elasticsearch",
"buildTool": "gradle",
"enableSocialSignIn": true,
"jwtSecretKey": "dabb542aa2359c0c77c19bc6aeefc3af1700cec6",
"useSass": true,
"applicationType": "monolith",
"testFrameworks": [
"gatling",
"cucumber",
"protractor"
],
"jhiPrefix": "jhi",
"enableTranslation": true,
"nativeLanguage": "es",
"languages": [
"es",
"en"
]
}
}
This seems to be a problem with the generated output.
Following these instructions, what you need to do is:
Add apt generated source folder to build path
When using buildship gradles default outputfolder is filtered and not visible in your workspace. Therefore you need to remove it from eclipse’s resource filter setting.
Right click on your project and select Properties
Select Resources
Remove the entry build
Select Java Build Path
Click Add Folder...
Check the path build/generated/source/apt/main
Make sure the new source folder contains the correctly generated mapper implementations when running JHipster via eclipse.
Related
I have a very simple JPA project based on eclipselink. All subprojects have module-info files, so they are java modules. And I have a huge problem with Hibernate Validator integration:
jakarta.persistence.PersistenceException: Exception [EclipseLink-28019] (Eclipse Persistence Services - 3.0.2.v202107160933): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Deployment of PersistenceUnit [TEST_RENT_PU] failed. Close all factories for this PersistenceUnit.
Internal Exception: Exception [EclipseLink-30014] (Eclipse Persistence Services - 3.0.2.v202107160933): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: The persistence unit specifies validation-mode as "CALLBACK" but a Bean Validation ValidatorFactory could not be initialized. Please refer to the nested exception for details. Please ensure that Bean Validation API and Bean Validation Provider is available in classpath.
Internal Exception: java.util.ServiceConfigurationError: jakarta.validation.spi.ValidationProvider: module jakarta.validation does not declare uses
without module-info.java file everything works perfectly (all required libraries are added to pom.xml). As you can see I changed validation settings in persistence.xml file to CALLBACK. With AUTO setting bean validation does not work at all. How should I change the project configuration to make Hibernate Validator working in JPMS environment?
When I've adapted 'io.spring.platform:platform-bom:2.0.1.RELEASE'
As a result,
Spring Data JPA was upgraded to 1.9.2.RELEASE from 1.4.3.RELEASE
and Spring Data Common was upgraded to 1.11.2.RELEASE from 1.6.3.RELEASE
Now, the JBoss EAP 6.2 raised the following complain during deployment
Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener: org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'jpaContext': Unsatisfied dependency expressed through constructor argument with index 0 of type [java.util.Set]: : No qualifying bean of type [javax.persistence.EntityManager] found for dependency [collection of javax.persistence.EntityManager]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {};
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [javax.persistence.EntityManager] found for dependency [collection of javax.persistence.EntityManager]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
Build Environment
Gradle 2.9
Build time: 2015-11-17 07:02:17 UTC
Build number: none
Revision: b463d7980c40d44c4657dc80025275b84a29e31f
Groovy: 2.4.4
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.7.0_60-ea (Oracle Corporation 24.60-b09)
OS: Windows 7 6.1 amd64
Any help in this regard will be highly appreciated.
I'm trying to run JPA servlet on Tomcat 8.
From my servlet I call method of a class named QueryDB.class located in another Eclipse project (JPA project, not WEB project).
But tomcat throws
SEVERE: Servlet.service() for servlet [MyRESTService] in context with path [/AutomationWeb] threw exception [org.glassfish.jersey.server.ContainerException: java.lang.NoClassDefFoundError: javax/persistence/Persistence] with root cause
java.lang.ClassNotFoundException: javax.persistence.Persistence
at java.net.URLClassLoader$1.run(Unknown Source)
...
Exception is thrown at line EntityManagerFactory emf = Persistence.createEntityManagerFactory( "AutomationDB_JPA" ); in QueryDB.class
I'm using Eclipse Mars with Maven. I have EclipseLink in my pom.xml defined:
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.6.1</version>
</dependency>
I have following jars in my Application's WEB-INF/lib:
eclipselink-2.6.1.jar
javax.persistence-2.1.0.jar , it has javax/persistence/Persistence.class inside
There is no other SEVERE messages in the tomcat log.
What's wrong with this setup?
I also tried adding the persistence jar to apache-tomcat-8.0.28\lib , but got the same error.
Update: I moved Persistence.createEntityManagerFactory call to the servlet itself and got no classloader exception. So the question changes: why classloader used for QueryDB.class is different from servlet's classloader? Also, why classloader used in QueryDB.class does not see the Persistence.class, which is seen by the servlet's classloader?
Ok I've found a solution.
Excluded my JPA project from tomcat VM classpath
Converted my JPA project to the Utility project
Modified Deployment Assembly in my Web project properties so that it
will accept JPA project as .jar archive into WEB-INF/lib
I have no classloader exception anymore.
If I build this project to war and deploy it on WebLogic, it works well, but if I run on server using Eclipse, i got this error:
Caused By: Bean type class com.opensymphony.xwork2.ObjectFactory
with the name xwork has already been loaded by bean -
zip:D:/Documents%20and%20Settings/admini/.m2/repository/org/apache/struts/struts2-core/2.3.12/struts2-core-2.3.12.jar!/struts-default.xml:29:72 - bean -
zip:H:/runtime/weblogic1033/user_projects/domains/crmFrameworkDomain/servers/AdminServer/tmp/_WL_user/_auto_generated_ear_/nefp93/war/WEB-INF/lib/struts2-core-2.3.12.jar!/struts-default.xml:29:72
stackTrace
<2013/4/20 下午06時59分34秒 CST> <Error> <HTTP> <BEA-101165> <Could not load user defined filter in web.xml: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.
Unable to load configuration. - bean - zip:H:/runtime/weblogic1033/user_projects/domains/crmFrameworkDomain/servers/AdminServer/tmp/_WL_user/_auto_generated_ear_/nefp93/war/WEB-INF/lib/struts2-core-2.3.12.jar!/struts-default.xml:29:72
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:485)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
at weblogic.servlet.internal.FilterManager$FilterInitAction.run(FilterManager.java:332)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
Truncated. see log file for complete stacktrace
Caused By: Unable to load configuration. - bean - zip:H:/runtime/weblogic1033/user_projects/domains/crmFrameworkDomain/servers/AdminServer/tmp/_WL_user/_auto_generated_ear_/nefp93/war/WEB-INF/lib/struts2-core-2.3.12.jar!/struts-default.xml:29:72
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:429)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:473)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
Truncated. see log file for complete stacktrace
Caused By: Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory - bean - zip:H:/runtime/weblogic1033/user_projects/domains/crmFrameworkDomain/servers/AdminServer/tmp/_WL_user/_auto_generated_ear_/nefp93/war/WEB-INF/lib/struts2-core-2.3.12.jar!/struts-default.xml:29:72
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:245)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:226)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:429)
Truncated. see log file for complete stacktrace
Caused By: Bean type class com.opensymphony.xwork2.ObjectFactory with the name xwork has already been loaded by bean - zip:D:/Documents%20and%20Settings/admini/.m2/repository/org/apache/struts/struts2-core/2.3.12/struts2-core-2.3.12.jar!/struts-default.xml:29:72 - bean - zip:H:/runtime/weblogic1033/user_projects/domains/crmFrameworkDomain/servers/AdminServer/tmp/_WL_user/_auto_generated_ear_/nefp93/war/WEB-INF/lib/struts2-core-2.3.12.jar!/struts-default.xml:29:72
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:229)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:226)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:429)
Truncated. see log file for complete stacktrace
I don't know why there's another struts2-core.2.3.12.jar in _auto_generated_ear
Is there any configuration of plugins should i change?
weblogic 10.3.3
jdk 1.6
eclipse juno
maven 3.0.5
and here is my eclipse project archive:
Loki.zip
I also faced the same issue.
In my case the one or more action classes configured in the struts.xml not defined on the package.
Once i defined the missing classes it worked fine.
please ensure all the action classes configured in struts.xml were defined in correct location.
struts.xml
<action name="welcome" class="com.vk.translate.action.DummyAction">
<result name="success">/login.jsp</result>
</action>
DummyAction is not defined in above code.
Once i defined it worked.
I imported Maven project using maven eclipse plugins (m2e) and everything is fine.
But when I am running JUnit Test cases, I am getting below errors
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'be.belgacom.rosy.betty.manager.impl.ReservationManagerImplTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests.setDataSource(javax.sql.DataSource); nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [javax.sql.DataSource] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:374)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:110)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:220)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:301)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:303)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests.setDataSource(javax.sql.DataSource); nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [javax.sql.DataSource] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:589)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:282)
... 26 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [javax.sql.DataSource] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:920)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:789)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:547)
... 28 more
I am sure you might be suggesting to look at properties and other xml files configurations are correct or not.
If I import the same project into Eclipse as normal project, I am able to run the JUnit tests.
When I Import as Maven Projects, it's giving such errors.
Any idea, how do i solve this.
Your question lacks a lot of context. Have you ever run this from the command line with Maven? For example, have you run "mvn test" on the command line? Try this first then let us know if you receive the same error messages.
Your problem suggests that your POM doesn't contain the appropriate dependencies.