org.springframework.beans.factory.BeanCreationException: Error creating bean with name ” defined in class path resource [.xml]: No matching factory method found on class []: factory method ‘aspectOf()’. Check that a method with the specified name exists and that it is static.

Solution was to update the aspectj version to  <aspectj.version>1.9.9.1</aspectj.version> <dependency><groupId>org.aspectj</groupId><artifactId>aspectjrt</artifactId><version>${aspectj.version}</version></dependency> <dependency><groupId>org.aspectj</groupId><artifactId>aspectjweaver</artifactId><version>${aspectj.version}</version></dependency><dependency><groupId>org.aspectj</groupId><artifactId>aspectjtools</artifactId><version>${aspectj.version}</version></dependency>  

Failed to execute goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3:wsimport (MyWebServiceClient) on project com.myproject: Execution MyWebServiceClient of goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3:wsimport failed: start 0, end -1, length 0 -> [Help 1]

We recently upgraded from Java 8 to openjdk16. And our webservice clients failed with below error. Failed to execute goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3:wsimport (MyWebServiceClient) on project com.myproject: Execution MyWebServiceClient of goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3:wsimport failed: start 0, end -1, length 0 -> [Help 1] And the fix was to change the plugin for ws-import. Before we had  <groupId>org.jvnet.jax-ws-commons</groupId><artifactId>jaxws-maven-plugin</artifactId><version>2.3</version> And … Read more

Caused by: org.hibernate.MappingException: The increment size of the [MY_SEQ] sequence is set to [50] in the entity mapping while the associated database sequence increment size is [1].

While upgrading from hibernate 3 to hibernate 5, this was one of the issues. Here is how id fields were defined in hibernate 3. @[email protected](strategy=GenerationType.AUTO, generator=”my_seq_gen”)@SequenceGenerator(name=”my_seq_gen”, sequenceName=”MY_SEQ”)private long id; So now, I added allocationSize = 1 to resolve the issue @[email protected](strategy=GenerationType.AUTO, generator=”my_seq_gen”)@SequenceGenerator(name=”my_seq_gen”, sequenceName=”MY_SEQ”, allocationSize = 1)private long id; And for new Ids I used the … Read more

Cannot create JDBC driver of class ‘com.mysql.jdbc.Driver’ for connect URL ‘jdbc:postgresql://localhost:5432/my_test’

This turned out to be a mistake in the config.  I was using mysql driver. It was a copy-paste mistake. <bean id=”dataSource” class=”org.apache.commons.dbcp2.BasicDataSource”destroy-method=”close”><property name=”driverClassName”><value>com.mysql.jdbc.Driver</value></property>   Here is the correct config: <bean id=”dataSource” class=”org.apache.commons.dbcp2.BasicDataSource”destroy-method=”close”><property name=”driverClassName”> <value>org.postgresql.Driver</value></property>   And the postgres entry in pom.xml : <dependency><groupId>org.postgresql</groupId><artifactId>postgresql</artifactId><version>42.2.23</version></dependency>

Exception encountered during context initialization – cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sessionFactory’ defined in class path resource [xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/validation/ValidatorFactory

The above error is quite obvious that javax.validation is missing. To fix this issue, we would need to import hibernate validator. Here is the dependency to be added to the pom. <dependency><groupId>org.hibernate</groupId><artifactId>hibernate-validator</artifactId><version>6.2.1.Final</version></dependency> Make sure that the version defined above is compatible with hibernate core.

[main] WARN GenericApplicationContext:591 – Exception encountered during context initialization – cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sessionFactory’ defined in class path resource : Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: net/bytebuddy/TypeCache

On upgrading Hibernate from version 3 to version 5, I got the above error. Turned out that we were also using Mockito and it also has a dependency on byte buddy. So there was conflict of versions of byet buddy. So here is fix: <dependency><groupId>org.mockito</groupId><artifactId>mockito-core</artifactId><version>2.2.28</version><scope>test</scope><exclusions><exclusion><groupId>net.bytebuddy</groupId><artifactId>byte-buddy</artifactId></exclusion></exclusions></dependency> exclude the byte-buddy jar from mockito.    

GWT Module X not found in project sources or resources. -> [Help 1]

I get this error a lot of times while building my GWT project. I have a get module imported from a jar which is downloaded from artifactory. GWT Module com.model.MyCommonModel not found in project sources or resources. -> [Help 1] So I usually resolve it by deleting the jar locally or by running  mvn dependency:purge-local-repository … Read more

Creating a maintenance thread in Spring

Recently we needed to reindex our data due to some changes. Here is how we did it. We defined a file on the file system. If that file is present the reindexing thread runs, so it would easy for our deployment team to run reindexing when needed. Here is the code creating the thread.  So … Read more

Enums saved to database. How

Recently we ended up in an issue with enums. One of the developers changed the order of enums because of a change he had to do. And he thought that enum values that are logically together should be put together in enum class also. But when he was done with the change, all the tests … Read more