I ran into a problem trying to use Spring-roo in STS ide.
I created a project and added EclipseLink ORM, and that is about it.
In persistence.xml i added all the details for the database connectivity.
When I tried to run the spring project, it failed to show the default jspx page i was expecting.
Here is the error:
2012-07-02 10:45:39,411 [pool-2-thread-1] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in file [/home/ubuntu/springsource/vfabric-tc-server-developer-2.7.0.RELEASE/spring-insight-instance/wtpwebapps/SpringRooStats/WEB-INF/classes/META-INF/spring/applicationContext.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in file [/home/ubuntu/springsource/vfabric-tc-server-developer-2.7.0.RELEASE/spring-insight-instance/wtpwebapps/SpringRooStats/WEB-INF/classes/META-INF/spring/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.reflect.UndeclaredThrowableException
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
It is complaining it seems that it needs to create an entity manager, but I think that
it should not since it should run a project that does not connect to a database and just run a simple jspx page.
Does one need to go thru the whole thing with entities just to run a simple project.
Hope someone can help.
Your applicationcontext.xml has a transactionManager defined. This needs a entity manager. Your would need to remove the transaction manager or add the entity manager.
I'm also not sure why you added the ORM framework if your not going to use it.
Related
The error is actually a Conflicting persistence unit, which is something defined in a component, which is a parent for my project. My spring context is taking that conflicting unit from both the target/classes folder of the component and the jar stored in the local maven repository as well. Why is this happening? This is the error trace:
Error creating bean with name 'persistenceUnitManager' defined in class
path resource [spring-config/framework-persistence-context.xml]: Invocation
of init method failed; nested exception is java.lang.IllegalStateException:
Conflicting persistence unit definitions for name 'persistence-framework':
file:/D:/fw/projects/springproj-core-project/springproj-core-framework/target/classes,
file:/C:/Users/prateek.chachra/.m2/repository/com/springproj/
springproj-core-framework/1.4.M1/springproj-core-framework-1.4.M1.jar
EDIT: Before reading the question: deleting the folder in wildfly deployment "solved" the issue. But I didn't put back my code for the other DB. Is the way I did it was right?
I was working this morning, everything was going fine.
I added a dependency which is the core of another maven project and the goal was to use that project to add data in the database of that project, not the one of my current project.
So I tried a lot of stuff, but at the end it was working. And then, I left to go eat.
The server is host on my computer, so localhost and I left it like that for about an hour.
Here's what I did:
Create new hibernate.cfg.xml in src/main/resources with properties.
So I had 2 hibernate.cfg.xml in my project. The original one in src/main/resources/my/hibernate/package/ and the new one in the default package.
In my code ->
Configuration cfg = new Configuration();
cfg.configure();
Note that before doing only that, I was setting the properties programmatically and it was working fine.
I thought it was taking the one in default package. That was working earlier.
So I came back, try to run the application and get this exception:
Nested exception: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
I haven't touch a thing... so I removed all my work (the new hibernate.cfg.xml too), restarted the server, even the computer.
I read about the exception, it says that maybe I have two dom4j, or that I need to put <scope>provided</scope> to some dependencies.
I added the scope everywhere, removed the dependency of the other project, but it won't help.
I have these logs in my wildfly server.log
WFLYCTL0186: Services which failed to start:
service jboss.undertow.deployment.default-server.default-host./PROJECT_NAME:
org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./PROJECT_NAME:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'firstControllerInMyDispatcher':
Unsatisfied dependency expressed through field 'DAO_name':
Error creating bean with name 'DAO_name' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]:
Cannot resolve reference to bean 'mySessionFactory' while setting constructor argument;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]:
Invocation of init method failed;
nested exception is org.hibernate.InvalidMappingException:
Unable to read XML;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'DAO_name' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]:
Cannot resolve reference to bean 'mySessionFactory' while setting constructor argument;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]:
Invocation of init method failed;
nested exception is org.hibernate.InvalidMappingException:
Unable to read XML
The dom4j exception only shows in the Netbeans console log and it's after all those same lines:
"{\"WFLYCTL0080: Failed services\" => {\"[previous exceptions lines]
Caused by:
org.dom4j.DocumentException:
org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory Nested exception:
org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory\"}}"
I'm clueless, can anyone help with this? Thanks.
I use spring-boot-starter-data-jpa for get data from mysql.
When my project structure is (Project.java file is in application package) everything works well, but when I put Project.java entity file to entities package I got bellow exception:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'controller': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.gehive.microservice.data.repositories.ProjectRepository com.gehive.microservice.application.Controller.repo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'projectRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not an managed type: class com.gehive.microservice.data.entities.Project
work without exceptions:
if structure like this I got exception:
The default #ComponntScan for Spring boot(the one that #SpringBootApplication inherits) scans the current package and all it's sub packages.
In the first case Project.java is in the same package as Application.java, so it's ok.
To make Project work from another package change the name to com.gehive.microservice.application.entities or whatever sub-package of the one with the main class.
Usually I keep the bootstraping class and all the configuration classes in package named <com|org|etc>.<myCompany>.<myProject> and then create the other packages as sub packages of this one.
Spring Data JPA has some other conditions related to the packages. Take a look at the Docs
I have created created a Grails application and created the Spring Security plugin set up into It.
When I run the application I get following error. Hibernate folder is empty. Can anyone help me resolve this?
2014-06-20 13:41:26,946 [http-bio-8080-exec-21] ERROR [/GrailsLoginWithSpring].[gsp] -
Servlet.service() for servlet [gsp] in context with path [/GrailsLoginWithSpring] threw exception
Message: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'org.grails.internal.SESSION_FACTORY_HOLDER':
Cannot create inner bean '(inner bean)#3720a15d' of type
[org.codehaus.groovy.grails.orm.hibernate.ConfigurableLocalSessionFactoryBean]
while setting bean property 'sessionFactory';
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name '(inner bean)#3720a15d': Invocation of init method failed;
nested exception is java.io.FileNotFoundException: class path resource [hibernate.cfg.xml]
cannot be resolved to URL because it does not exist
Try adding
hibernate {
reload = false
}
As suggested by Graeme Rocher in this JIRA
I am trying to deploy a web app on an Ubuntu system. The WAR is an EXPLODED folder. There are no issues with build. But I am unable to deploy to Tomcat6 server. Everything was working fine. Same Code, Same files. All of a sudden, unable to deploy.
The main difference I find now is that - the logs at /var/lib/tomcat6/logs - localhost.2010-11-01.log is locked and can be opened only by root user. Dont understand why?
Because of this issue, I am getting the following error (from localhost.2010-11-01.log):
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
Is my issue related to
BeanCreationException in Spring Framework .WAR deploy to Tomcat 6 on Ubuntu 9.10?
Update1:
The issue of Tomcat logs being readable by root user is gone now. However, these ERRORs remain.
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'africa' defined in ServletContext resource [/WEB-INF/applicationContext.xml]:
Cannot resolve reference to bean 'antarctica' while setting bean property 'antarctica'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'antarctica' defined in ServletContext resource [/WEB-INF/applicationContext.xml]:
Cannot resolve reference to bean 'australia' while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'australia' defined in ServletContext resource [/WEB-INF/applicationContext.xml]:
Invocation of init method failed; nested exception is java.lang.Exception: Unexpected line
Warning: mysql_connect(): Lost connection to MySQL server during query in .... #ERROR:Too Many Connections!
Update 2:
Just switched on my Ubuntu system. Only firefox running at the moment. No Eclipse or other software running. Did not shutdown or restart Tomcat. Just tried to launch the web app thru Tomcat Manager application (http://localhost:8080/manager/html) - the same thing I had been trying before.
Result: Web app gets launched with no issues!
I have absolutely NO CLUE why this did not work before. Also, NO CLUE why it's working now, if at all there was a serious issue. I WASTED one whole day :(.
if you set-up logging like so: Tomcat startup logs - SEVERE: Error filterStart how to get a stack trace?
Then at least you will get the stack trace.