Missing table [rev_info] after bump liquibase version, spring data envers - java

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.

Related

Start problem application with StrategySelectionException and BeanCreationException (entityManagerFactory)

Please, help with the next issue, thank you.
I am in a need to make changes in an old project, but problem is in that I even cann't to start the app. I have the next problem.
org.springframework.beans.factory.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 org.hibernate.service.spi.ServiceException:
Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
caused by
org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
caused by
org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.spatial.dialect.mysql.MySQLSpatial5InnoDBDialect] as strategy [org.hibernate.dialect.Dialect]
This only from the end of a problem. Whole error description you can find in a file "problem from intellij terminal.txt" here
https://drive.google.com/drive/folders/14QZvGvUGkGp116Q2ENLywG3nziqJyp2J?usp=sharing
Also by the same link you'll find there files "application properties.txt" and "pomxml.txt"
Please, feel free to ask anything else )
As code was written few years ago, then:
I moved from java 11 to 8.
And I changed the url to spring.datasource.url=jdbc:mysql://localhost:3306/fds?useUnicode=yes&characterEncoding=UTF-8&allowPublicKeyRetrieval=true&useSSL=false
And also I added version to the dependency mysql-connector-java 5.1.49
I removed " spring.jpa.database-platform=org.hibernate.spatial.dialect.mysql.MySQLSpatial5InnoDBDialect".
And I added "spring.jpa.properties.hibernate.dialect= org.hibernate.spatial.dialect.mysql.MySQL56InnoDBSpatialDialect"
And I added one dependency: org.hibernate hibernate-core 5.4.15.Final
And I added one dependency:org.hibernate</groupId hibernate-spatial 5.2.3.Final
And I added one dependency:javax.xml.bind</groupId jaxb-api 2.3.0

IBM Mobileplatform foundation 7.0 error in log: Failed starting project

I am using IBM Mobilefirst Platform foundation 7.0 development environment
I am trying to add library hibernate-jpa-2.1-api-1.0.0.Final.jar for one of module in my project is using this library.
when I add it to the build path MF gives me following error:
[WARNING ] Exception encountered during context initialization - cancelling refresh attempt
Error creating bean with name 'ssoExpiredLoginContextsCleanupTask' defined in URL [wsjar:file:/Users/admin/Documents/Development7.0/MYAPP/MobileFirstServerConfig/shared/resources/worklight-jee-library-7.0.0.jar!/conf/core.xml]: Invocation of init method failed; nested exception is java.lang.LinkageError: loader constraint violation: loader (instance of com/ibm/ws/classloading/internal/ThreadContextClassLoader) previously initiated loading for a different type with name "javax/persistence/FlushModeType"
[ERROR ] FWLST0003E: ========= Failed starting project /MYAPP_Mobile [project MYAPP_Mobile]
Error creating bean with name 'ssoExpiredLoginContextsCleanupTask' defined in URL [wsjar:file:/Users/admin/Documents/Development7.0/MYAPP/MobileFirstServerConfig/shared/resources/worklight-jee-library-7.0.0.jar!/conf/core.xml]: Invocation of init method failed; nested exception is java.lang.LinkageError: loader constraint violation: loader (instance of com/ibm/ws/classloading/internal/ThreadContextClassLoader) previously initiated loading for a different type with name "javax/persistence/FlushModeType"
[ERROR ] Error creating bean with name 'ssoExpiredLoginContextsCleanupTask' defined in URL [wsjar:file:/Users/admin/Documents/Development7.0/MYAPP/MobileFirstServerConfig/shared/resources/worklight-jee-library-7.0.0.jar!/conf/core.xml]: Invocation of init method failed; nested exception is java.lang.LinkageError: loader constraint violation: loader (instance of com/ibm/ws/classloading/internal/ThreadContextClassLoader) previously initiated loading for a different type with name "javax/persistence/FlushModeType"
Error creating bean with name 'ssoExpiredLoginContextsCleanupTask' defined in URL [wsjar:file:/Users/admin/Documents/Development7.0/MYAPP/MobileFirstServerConfig/shared/resources/worklight-jee-library-7.0.0.jar!/conf/core.xml]: Invocation of init method failed; nested exception is java.lang.LinkageError: loader constraint violation: loader (instance of com/ibm/ws/classloading/internal/ThreadContextClassLoader) previously initiated loading for a different type with name "javax/persistence/FlushModeType"
[ERROR ] MYAPP_Mobile: worklight///172.25.16.55: 2015-04-29T09:08:21.260Z: Error creating bean with name 'ssoExpiredLoginContextsCleanupTask' defined in URL [wsjar:file:/Users/admin/Documents/Development7.0/MYAPP/MobileFirstServerConfig/shared/resources/worklight-jee-library-7.0.0.jar!/conf/core.xml]: Invocation of init method failed; nested exception is java.lang.LinkageError: loader constraint violation: loader (instance of com/ibm/ws/classloading/internal/ThreadContextClassLoader) previously initiated loading for a different type with name "javax/persistence/FlushModeType"
Got some good news regarding this issue. APAR PI59031 is now available that will address the issue of using Hibernate as the JPA implementation in an adapter. If you are using MobileFirst 7.0 or above, please upgrade to a fix level later than 2016-03-21 for MobileFirst 7.0 and 2016-04-02 for MobileFirst 7.1
If you're using the Developer Edition of Studio, fixes can be obtained from the Eclipse MarketPlace. If you're a licensed MobileFirst customer, fixes can be obtained from FixCentral.
You did not specify in the question where did you place this .jar file. That said, it is likely that you've added it to the runtime .war file.
This will for sure create a conflict, because MFP uses openJPA, and you're trying to add JPA...
Because OpenJPA is already uses and available, it is suggest then for you to use OpenJPA instead as it has the same purpose as Hibernate JPA.
Where are you putting jar?
If you have multiple java adapters, referring to same jar file. you should add jar file in 'lib' folder of 'server'.
If you need specific jar for single adapter, you should put jar into 'lib' folder of your java adapter.
one point should be taken into notice that if same jar is present in both adapter and server's lib folder. jar from adapter will be taken for built.

Hibernate 3.6.10 NoSuchMethodError

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.

DispatcherServlet - Context initialization failed in Roo project

I develop a Roo project and deploy to a Tomcat 6 server.
Up until now everything was working fine.
I deleted and re-added an entity.
Now everytime when I start Tomcat I get this exception in the Spring Tool Suite:
SEVERE: StandardWrapper.Throwable
Throwable occurred: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.handler.MappedInterceptor#0': Cannot create inner bean '(inner bean)' of type [org.springframework.web.servlet.handler.ConversionServiceExposingInterceptor] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot resolve reference to bean 'applicationConversionService' while setting constructor argument; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [myproject.web.ApplicationConversionServiceFactoryBean] for bean with name 'applicationConversionService' defined in ServletContext resource [/WEB-INF/spring/webmvc-config.xml]; nested exception is java.lang.ClassNotFoundException: myproject.web.ApplicationConversionServiceFactoryBean
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [myproject.web.ApplicationConversionServiceFactoryBean] for bean with name 'applicationConversionService' defined in ServletContext resource [/WEB-INF/spring/webmvc-config.xml]; nested exception is java.lang.ClassNotFoundException: myproject.web.ApplicationConversionServiceFactoryBean
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
...
What do I need to do to make it work again?
spring is complainig about a bean not being available (probably the one you say you deleted).
exception is java.lang.ClassNotFoundException: myproject.web.ApplicationConversionServiceFactoryBean
try to search the config xml files & remove the reference made to this class, things should be back after that,
I had the same exact issue.
The problem was that I disabled the "Project > Build Automatically" feature, so I had to manually build the project.
Once I manually built the project everything went back to normal. :)
So, don't forget to build the project before deploying it, or just re-enable the "Project > Build Automatically" feature.
Hope it helps.
Your app deployed to Tomcat doesn't have a jar file in WEB-INF/lib that contains the class myproject.web.ApplicationConversionServiceFactoryBean. I don't know what that class is or where you'd find it, but it's missing.
my workaround (worked with eclipse and roo 1.1.5 as eclipse plugin)
open ApplicationConversionServiceFactoryBean.java class
delete class annotation #RooConversionService
wait for roo update
add back class annotation #RooConversionService
wait for roo update and try again
Inside of STS, click ->project->clean
It clean and discard all build problems and built states, The next time a build occurs the projects will be rebuilt from scratch.

Why do I get this `TypeMismatchException` with Spring

I'm trying to use Hibernate with Spring in Eclipse. I get the following error when I try to run the welcome file on the server:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]:
Initialization of bean failed; nested exception is
org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.util.ArrayList' to required type 'java.lang.Class[]' for property 'annotatedClasses';
nested exception is java.lang.IllegalArgumentException: Cannot find class [com.vaannila.domain.User]
The class com.vaannila.domain.User is in the Java Resources:src folder of the project in eclipse. Why isn't it being located?
From time to time Eclipse is a bit picky about deploying a project correctly. It seems that it has to do with the installed plugins. When this happens to me in the 'Servers'-view of the 'Debug'-Perspective i click the 'add and remove' menu and remove my project from deployment - save it - add it again and redeploy. Usually this does the trick.
Another try is to start Eclipse with the -clean option.

Categories