Multiple applications using Liquibase with different datasource in OSGi Container - osgi

I am using Liquibase in OSGi environment via bundle org.openengsb.labs.liquibase.extender (https://github.com/openengsb-labs/labs-liquibase) which defines datasource globaly in org.openengsb.labs.liquibase.cfg (https://github.com/openengsb-labs/labs-liquibase#configuration-file).
Does anyboady have experience with multiple bundles using different datasources for Liquibase?

Related

Grails - Customizing datasource configuration from a spring bean

I have a legacy grails app running grails v3.2.9. We are currently using properties files for setting the dataSource configuration.
We have an internal system that stores our configurations that is loaded as a spring bean. I need to use this to hook it into our configuration system for compliance reasons. Is there any way to configure the dataSource from these at startup?

Spring application context in multiple tomcats

If there are multiple web applications in different tomcats, how to configure same application context for all the tomcats
I am not sure if i understand the question correctly. I guess you misunderstand some concepts. First, what is your package; is it war or jar. Do you use Spring MVC or Spring Boot (If you are new i suggest you to use Spring Boot). If you are using Spring MVC you are required to deploy your war to a servlet container like Tomcat. And if you want to deploy your applications to multiple tomcats, it is possible of course. However each application run on their own application context. These application contexts will have same beans and will be on same state when they are firstly initialized. As far as i know it is not possible to share one application context over multiple spring mvc applications and i think it doesn't make sense.
If you are using Spring Boot, your application will run on JVM with an embedded servlet container. In this case, your application is packaged in a JAR file with servlet container and you are not required to deploy the application. When you run the application both servlet container and your application context is initialized. In this situation, you can run multiple applications and as i said before these applications will have different application contexts.

Eclipse RCP, Spring, Hibernate Class Loading Issue

I’m developing a RCP based app that uses a data access layer implemented using Spring Data JPA backed by hibernate. The annotated domain classes are in one jar/bundle, the Spring repositories and spring config to instantiate the datasource, entity manager, and transaction manager are in another bundle.These jars are used by other non-RCP apps across the project.I have all of the hibernate 3.6.8 jars and dependencies either wrapped and exposed through my own plugins or as OSGI bundles (jta, antlr, commons collections, etc) in the target platform. I’m using Eclipse Gemini Blueprint to manage the bundle spring contexts within the RCP app.
When the DAL bundle spring context is being initialized by the gemini extender, I get Hibernate related ClassDefNotFound exceptions, usually either on org.hibernate.ejb.HibernatePersistence or javax.persistence.spi.Persistenceprovider. I’ve tried putting all of the hibernate jars and dependencies in a single plugin that exports the javax and hibernate packages. I’ve tried setting Eclipse Buddy policies in the manifests of the plugins that I have control over, etc.
I haven’t been able to find any solution to this class loading issue between Spring and Hibernate under Eclipse RCP using Gemini. I’ve done past hibernate DAO projects within RCP by putting all of the hibernate jars in the same plugin as my domain and DAO classes, so only my classes are exported.
At this point I don’t think moving to a more OSGI friendly JPA provider like OpenJPA or EclipseLink is an option.
I found an answer to a slightly related question that suggested putting all of the spring jars and dependencies into a single plugin, with the hibernate jars and dependencies in another plugin with buddy policies set. This seems dirty when most of the jars involved are OSGi bundles.
I suppose I could create a plugin that holds the DAL jar, hibernate jars, and spring ORM jars, so they can all see each other.
Is there a clean way to get this to work?
The core bundle if you own it, add all the suspected bundles as registered buddies and make sure that you have defined packages or bundles are reuired otherwise sometimes buddy class loading is not going to work. If the loading is initiated from you bundle the eclipse buddy policy should cascade. Other option would be to modify the manfiest files in target bundles that are causing issues.

Spring configuration to call different database environments like dev,int,uat,prod

I am having a Java standalone application, which is using the Spring core container and spring jdbc. I have different database environments like dev,int,uat,prod. These database configuration details and datasources for each environments are configured in spring configuration file spring-beans.xml along with the DAO beans.
Now i have to update the application, like if i passed a particular the database environment(like dev,int,uat,prod) as arguments at the time of running the application, the application will invoke the database as mentioned in the arguments. is there any way out?
i think you should used spring with hibernate it much easier or you can use JDNI for that
db1Jndi=
jdbc.url=jdbc:mysql://localhost:3306/db1
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.username=root
jdbc.password=root
db2Jndi=
jdbc.url=jdbc:mysql://localhost:3306/db2
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.username=root
jdbc.password=root

Cloning Spring Application Context in OSGi bundle

I have a Spring-enabled OSGi bundle. I'd like this bundle to export a factory-type OSGi service which client software can use to create multiple instances of the application context defined in this bundle.
By default the Spring DM library bundles will automatically scan and create an instance of an application context from any Spring XML configuration found under "META_INF/spring". To avoid this I moved the Spring XML configuration files under a different folder and then tried creating the application context programmatically on demand from the factory class. Unfortunately I ran into issues with Spring schema files not being available on the bundle classpath. I really don't want to embed the required Spring jars within my bundle just to get access to those schemas.
Is there a simpler way to clone Spring application contexts under an OSGi environment?
I do not understand your problem in detail but if you just want to load the application-context from a different location than META-INF/spring you can define this in the MANIFEST.MF file using 'Spring-Context', e.g. for files in the root folder
Spring-Context: /application-context-core.xml,/application-context-osgi.xml
See the documentation for further information.

Resources