I have a Spring Web MVC project. And, I am trying to Create a Spring Loaded Hibernate Connection in IReport using the existing spring web mvc projects application context.
In IReport, In the Options window, in the ClassPath tab, I have added all the latest Spring jars used by the project. As well as the application context's folder.
But, I am getting the following error while testing the connection
Error Creating bean name 'mySessionFactory' defined in the class path resource spring-hibernate.xml: invocation of init method failed;nested exception is org.hibernate.MappingException: entity class not found.
Has anyone successfully connected using the Spring loaded Hibernate connection in Ireport?
IReport uses internally an outdated Version of Spring(I think it is 2.0.0) so if you have for example Annotated Spring and Hibernate, there is no Chance to get run, because Ireport has a heavy use of Reflections.
So if you try to us a CustomClassLoader, you will hit a wall, because IReport tries to load your also after you give it your Custom DataSource.
Related
I am trying to upgrade my existing spring boot 2.7.x project to spring boot 3.x.x.
I have sorted out everything except this error while running the application.
APPLICATION FAILED TO START
Description:
Parameter 0 of method lockProvider in com.cox.config.ShedLockConfiguration required a bean of type 'org.elasticsearch.client.RestHighLevelClient' that could not be found.
Action:
Consider defining a bean of type 'org.elasticsearch.client.RestHighLevelClient' in your configuration.
Process finished with exit code 0
Spring Boot Version used is 3.0.0
I am aware that RestHighLevelClient is deprecated, but documentation says it's still available in spring-data-elasticsearch
Tried upgrading all dependencies to be compatible with spring boot 3
Update:
Also getting below error for another component with elastic search which I am trying to upgrade to spring boot 3
APPLICATION FAILED TO START
Description:
Parameter 2 of constructor in com.cox.service.esindex.EsIndexRefreshService required a bean of type 'org.springframework.data.elasticsearch.core.ElasticsearchOperations' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.data.elasticsearch.core.ElasticsearchOperations' in your configuration.
It looks like spring boot is no longer creating beans for deprecated methods/classes. Can you please help me map each deprecated method/class with the new spring-data-elasticsearch
The documentation explicitly states:
The old deprecated RestHighLevelClient can still be used, but you will need to add the dependency explicitly to your application as Spring Data Elasticsearch does not pull it in automatically anymore:
Edit 18.02.2023:
Check the documentation it also documents how to configure the different clients. You will have to do this configuraiton by yourself, I don't think that Spring Boot will configure this automatically, they are using the current stuff from Spring Data Elasticsearch .
Following other links I have tried all configurations including enabling jndi of embedded tomcat container. (A very good detailed like is: https://www.roytuts.com/spring-boot-jndi-datasource/) But the problem is that the DataSource is looked up against JNDI and I get follwoing exception:
Please note that From Spring 2.0.x Embedded configuration classes have changed.
Get:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial.
As for the question of JNDI lookup in Embedded tomcat is rare use case I am trying to simulate and reproduce a Database Connection Pooling Error in production and for that I have to use JavaConfig settings for Resource and DataSource both.
Problem:
I have a custom implementation of java.util.prefs in a maven jar module.
I am providing the system property to -djava.util.prefs.PreferencesFactory=com.blah.CustomePrefsFactory
to my Spring boot app that is using the custom preferences.
When the Spring boot app uses the Preferences for the first time, the Java.util.Preferences.java tries to load the CustomePrefsFactory using the
ClassLoader.getSystemClassLoader().
This results in errors as nested jar classes are not available to a system class loader of the spring boot app.
Is there a way to make nested jar classes available to the system class loader?
The short answer is no.
System ClassLoader delegates to the Bootstrap ClassLoader and Extension ClassLoader and then tries to load classes from classpath, but not from nested JARs.
You have to implement or use an existing ClassLoader that supports that functionality.
I am trying to make a crud application using Spring MVC and JPA with hibernate as a service provider.I already have a working CRUD application using spring MVC and jdbc.So I decided to make changes in already built application only
But the problem is when i include any class from org.springframewrok.orm jar file in beans.xml of spring it gives me HTTP 404- resource not found error. What could be the possible reasons??
I am using org.springframewrok.orm 3.1.1 release file.
I'm working on a project that delivers web services using Jersey, which has a dependency on JAXB 2.1. I have to add a feature that fetches data from another web service. The way this has been implemented elsewhere uses a Spring JaxWsPortProxyFactoryBean.
When Spring tries to initialize this bean it fails with a : ClassCastException (com.sun.xml.bind.v2.runtime.JAXBContextImpl cannot be cast to com.sun.xml.bind.api.JAXBRIContext).
It appears that this is because JavaSE6 includes JAX-WS 2.0 API.
The only solution I have found suggests putting the 2.1 jars in the JRE endorsed directory. This isn't an option - I'm sharing a server with other application teams so I can't mess with the JRE.
Does anybody know of another way to make Spring use the 2.1 jars?