I'm having the following issue with my hibernate 3.6.10 project:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testSessionFactory' defined in class path resource [db.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z
Reading some of the issues here on stack overflow, it said I was using the wrong persistence API. So I downloaded the matching hibernate (I've been using the Spring deployment) and copied out the hibernate-jpa-2.0-api-1.0.1.Final.jar which comes with the hibernate distrib, only to get the self-same message.
Is this telling me that OneToMany is not supported by Hibernate 3.6.10?
It tells your that you have a JPA 1.0 API jar somewhere in your classpath. Such a problem cannot be reliably solved by adding proper JPA 2.0 jar to the classpath, you need to find and remove the offending jar before.
Related
I have problem with my project after bump liquibase version to 4.9.1.
There is error:
BeanCreationException: Error creating bean with name
'entityManagerFactory' defined in class path resource
[org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]:
Invocation of init method failed; nested exception is
javax.persistence.PersistenceException: [PersistenceUnit: default]
Unable to build Hibernate SessionFactory; nested exception is
org.hibernate.tool.schema.spi.SchemaManagementException:
Schema-validation: missing table [rev_info]
There is spring-data-envers version 2.5.5
Everyting works fine with liquibse 4.4
But when I change to newest version (4.9.1) applicantion do not start.
I have revision entity - RevInfo and changeset to create this table
create table public.rev_info
(
id INTEGER NOT NULL,
timestamp BIGSERIAL,
CONSTRAINT rev_pk PRIMARY KEY (id) );
ddl-auto is set validate
The Java Revisited blog had a solution for this error on their site here, but to summarize:
There could be numerous reasons why Spring was unable to create a bean with name X, but the reason can be found on the detailed stack trace. This error always has some underlying cause e.g. a ClassNotFoundException or a NoClassDefFoundError, which potentially signals a missing JAR file in the classpath.
In short, you should always give a detailed look at the stack trace of your error message and find out the exact cause of "org.springframework.beans.factory.BeanCreationException: Error creating a bean with name" error. The solution would vary accordingly.
Sometimes I get a BeanCreationException when starting a Java Spring Boot single-JAR application built by Gradle. My investigations show that it depends on the JAR file and how it has been built by Gradle. Most often (but not always) I see the exception when I build the project on a Linux system. But I have never reproduced the issue with a JAR built on Windows or when running from IntelliJ Idea.
I tried to compare the content of a working JAR with the JAR throwing the exception - all the *.class files (including meta and resources) were binary equal, the only difference was in the order the files were stored in the JAR/ZIP archive. I also tried to unpack the failing JAR on Windows and just repack it into a new JAR file (using 7-zip) - the application started without any exceptions. This weird workaround solved the issue, but it's not something I'd like to do after each build on a linux machine.
The exception suggests to check circular references, so I tried replacing #Autowired properties with #Autowired bean constructors to help me to find the problem but that didn't help. The stacktrace does not mention any of my classes, so I don't know what bean could be responsible for the issue. And because of the fact the issue happens only sometimes and is solvable by repacking the JAR file, I'm not sure there are any circular references anyway.
Could you please help me? Any advice or suggestion is welcomed.
JDK: openjdk 8u262
Gradle version 5.6
Spring boot 2.3.1
Exception message:
BeanCreationException: Error creating bean with name 'webConfig':
Invocation of init method failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'requestMappingHandlerAdapter' defined in class path resource
[org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]:
Unsatisfied dependency expressed through method 'requestMappingHandlerAdapter' parameter 0;
nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException:
Error creating bean with name 'mvcContentNegotiationManager':
Requested bean is currently in creation: Is there an unresolvable circular reference?
By default, Spring manages itself bean's lifecycle and then, arranges their initialization order during the startup.
Here a full example of usage #DependsOn annotation to order the bean instanciation.
You can also found more detail in the official Spring documentation
I'm getting the following error since I added neo4j to my spring mvc project (add default packages like spring-context, spring-webmvc, etc).
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: AnnotationConfigUtils.processCommonDefinitionAnnotations(…) is not public! Make sure you're using Spring 3.2.5 or better. The class was loaded from file:/Users/mariamdost/Downloads/sts-bundle/pivotal-tc-server-developer-3.1.1.RELEASE/base-instance/wtpwebapps/CodeChallenge/WEB-INF/lib/spring-context-3.1.1.RELEASE.jar.
Offending resource: ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]; nested exception is java.lang.IllegalStateException: AnnotationConfigUtils.processCommonDefinitionAnnotations(…) is not public! Make sure you're using Spring 3.2.5 or better. The class was loaded from file:/Users/mariamdost/Downloads/sts-bundle/pivotal-tc-server-developer-3.1.1.RELEASE/base-instance/wtpwebapps/CodeChallenge/WEB-INF/lib/spring-context-3.1.1.RELEASE.jar.
org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
As the error says I then deleted the default spring-context (3.1.1) and added again and it got rid of that error but then I ran into even more errors. The next error was that spring-expression and spring-context were of different versions so I fixed it by adding spring-expression and excluding spring-expression from neo4j. Then I ran into the final error:
Java.Lang.NoSuchMethod: tried to access method org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingletonMutex()
The last error I cannot find any solution. So reverted back to my initial state and I'm wondering is there another db I can use that will work with my current project setup? If not then how can I fix the current error I have? Any help would be greatly appreciated. Thanks in advance.
Seems like you have added some incompatible spring jars. The java.lang.NoSuchMethod error suggests that the expected method is not found in the dependent class . You would need to have look at the classes that you have added and correct them.
I am getting an exception while deploying on Weblogic Server:
[2012-01-13 01:17:11,496] ERROR [org.springframework.web.servlet.DispatcherServlet] Context
initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0': Invocation of init method
failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.
I have some jars as below:
log4j-1.2.14.jar
spring-asm-3.0.3.RELEASE.jar
spring-beans-3.0.3.RELEASE.jar
spring-context-3.0.3.RELEASE.jar
spring-core-3.0.3.RELEASE.jar
spring-expression-3.0.3.RELEASE.jar
spring-web-3.0.3.RELEASE.jar
spring-webmvc-3.0.3.RELEASE.jar
servlet-2.3.jar
validation-api-1.0.0.GA.jar
commons-logging-1.1.1.jar
hibernate-validator-4.0.2.GA.jar
slf4j-api-1.5.6.jar
slf4j-log4j12-1.5.6.jar
standard.jar
commons-fileupload-1.1.1.jar
ESAPI-1.4.4.jar
I am guessing the issues can be but need guidance to solve it:
After researching the issue, 2 likely scenarios came to the forefront:
Hibernate Validator Library has a bug resulting in a dependency on JDK 6
Hibernate Validator has a dependency on the JAXBException Class, and the class is not present in the existing Weblogic Environment
Upon further research, the hibernate-validator-4.0.2.jar build states a clear dependency on JDK 5.
Digging deeper into the Hibernate Validator code, it appears that version 4.0.2 relies on JAXB API 2.1.
Weblogic servers are on java 1.5 and code is also compiled on java 1.5 then why the exceptions seems to pop up??
You're being bitten by JAr incompatibilities. Your project has one version of the JAR, but WebLogic has another. The two don't match. (This is what OSGi was born to solve.)
You'll need to tell WebLogic which JAR you prefer. There's a setting in the weblogic.xml for "prefer WAR file JARs." I'm sorry, I can't recall the exact tag name; please Google for it.
i try to use iReport with an hibernate connection loaded using spring xml config file.
So, in netbeans wizard, i choose new datasource and i select "spring loaded Hibernate collection".
I set my xml spring file, but when i click test i have this exception:
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [META-INF/spring.cfg.xml]; nested exception is org.springframework.beans.FatalBeanException: NamespaceHandler class [org.springframework.context.config.ContextNamespaceHandler] for namespace [http://www.springframework.org/schema/context] not found; nested exception is java.lang.ClassNotFoundException: org.springframework.context.config.ContextNamespaceHandler
The spring xml is ok beacouse al works great in application, the problem is when i try to use it for iRepor in netbeans plugin.
Documentation about jasper report using hibernate and spring are very very slightly.
EDIT
I added all spring-dependance jar in Tools->Options->iReport->classpath (i'm refering to netbeans, this is totaly undocumented...) and finally seem to load context, but now i have this excpetions:
WARNING [org.netbeans.ProxyClassLoader]: Will not load class org.springframework.beans.factory.xml.NamespaceHandlerSupport arbitrarily from one of ModuleCL#10eaeda[com.jaspersoft.ireport] and ModuleCL#19e3bdd[org.netbeans.libs.springframework] starting from SystemClassLoader[569 modules]; see http://wiki.netbeans.org/DevFaqModuleCCE
WARNING [org.netbeans.ProxyClassLoader]: Will not load class org.springframework.beans.factory.xml.NamespaceHandler arbitrarily from one of ModuleCL#10eaeda[com.jaspersoft.ireport] and ModuleCL#19e3bdd[org.netbeans.libs.springframework] starting from SystemClassLoader[569 modules]; see http://wiki.netbeans.org/DevFaqModuleCCE
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [META-INF/spring.cfg.xml]; nested exception is org.springframework.beans.FatalBeanException: Class [org.springframework.context.config.ContextNamespaceHandler] for namespace [http://www.springframework.org/schema/context] does not implement the [org.springframework.beans.factory.xml.NamespaceHandler] interface
I think this is a problem of the netbeans plugin only and i can do anything :(
Thanks.
Installing iReport standalone app all work good, so is a problem of iReport plugin in netbeans.