Edit:
To better/shorter folmulate my main question;
Is it possible to get an OSGI application running using spring-osgi (1.2.1) and Spring 4 at the same time? And if so, how?
Original:
I am trying to make servicemix 6.1.3 work with Spring 4.
I know support has been officially dropped as of Spring version 3 but I need spring 4 for security reasons and frankly keeping our application up to date with newer functionality.
So I imported the required servicemix spring V4 bundles.
The issue here is that our application also uses the spring-osgi functionality (so not the abovementioned osgi-ified bundles by servicemix but the actual spring-osgi bundles which have V 1.2.1 as seen below)
The error:
Error executing command: Error executing command on bundles:
Unable to execute command on bundle 352: Uses constraint violation. Unable to resolve bundle revision my.app.service [352.7] because it is exposed to package 'org.springframework.context.support' from bundle revisions org.apache.servicemix.bundles.spring-
context [240.0] and org.apache.servicemix.bundles.spring-context [105.0] via two dependency chains.
Chain 1:
my.app.service [352.7]
import: (&(osgi.wiring.package=org.springframework.context.support)(version>=4.2.0)(version<=4.4.0))
|
export: osgi.wiring.package=org.springframework.context.support
org.apache.servicemix.bundles.spring-context [240.0]
Chain 2:
my.app.service [352.7]
import: (&(osgi.wiring.package=org.springframework.osgi.web.context.support)(version>=1.2.1))
|
export: osgi.wiring.package=org.springframework.osgi.web.context.support; uses:=org.springframework.osgi.context.support
org.springframework.osgi.web [252.0]
import: (&(osgi.wiring.package=org.springframework.osgi.context.support)(version>=1.2.1)(version<=1.2.1))
|
export: osgi.wiring.package=org.springframework.osgi.context.support; uses:=org.springframework.context.support
org.springframework.osgi.core [109.0]
import: (&(osgi.wiring.package=org.springframework.context.support)(version>=2.5.6)(!(version>=4.0.0)))
|
export: osgi.wiring.package=org.springframework.context.support
org.apache.servicemix.bundles.spring-context [105.0]
Now as you can see the issue is that I have spring-context twice running in servicemix. Once from the default installation [105] (I expect on the background a lot of servicemix's bundles (camel, activeMQ, etc) are using Spring 3, hence I dont want to remove them in fear of other issues; but if you know better, please enlighten me) and a Spring V4 bundle [240].
Our usage of spring-osgi requires us to use its bundles which are hardcoded to use "org.springframework.context.support version>=2.5.6 !version>=4.0.0".
Now my question;
- Is there a way around this? To force org.springframework.osgi.core to use the spring-context V4 bundle? Or is it just impossible to use Spring 4 at the same time as Spring 3's OSGI bundles?
Additional info:
I used the following in my pom's maven-bundle-plugin import-Package tag to enforce usage of Spring 4: (spring.version=[4.2,4.4])
org.springframework.context.support;version="${spring.version}",
And in the parent pom has the following in the dependency-management section.
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.spring-context</artifactId>
<version>${spring.version}</version>
<scope>provided</scope>
</dependency>
Edit 2:
Maybe I can manually bypass the org.springframework.context.support (version>=2.5.6)(!(version>=4.0.0)) requirement by downloading the spring osgi 1.2.x branch from github, change the in the pom and recompile.
Still obviously this isnt a good solution at all sice im hacking myself through to unsupported versions, so please advise.
Related
Problem summary: we've upgraded our Java 17 monolith application with multiple modules from Vaadin 21.0.1 to 23.3.5 and now our application routes don't resolve anymore, instead resulting in 404 Whitelabel errorpages.
This not being our first Vaadin rodeo (originating from Vaadin 7), we followed the Vaadin upgrade guide generator and expanded accordingly upon that.
Steps we took, each having been validated seperately:
Upgraded our backend to use Spring 5.3.18 (coming from 5.3.10). No issue there
Upgraded our frontend to use Spring Boot 2.6.7 (coming from 2.5.4). No issue there
this step was project-specific and not in the guide Removed Vaadin-addons from pom.xml. Also removed those imports from our package.json. Naturally removed all addons-code from application (EnhancedDialog and MultiselectComboBox -> using v23's regular Dialog and MultiSelectComboBox)
Removed webpack.config.js, package-lock.json and the node_modules folder
Raised global (-g) npm version to 9.4.0 (coming from 8.3.3)
Cleared npm with commandline npm cache clear --force
Upgraded the Vaadin flow version to 23.3.5 (coming from 21.0.1)
added the following dependency and reloaded the pom.xml:
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>flow-maven-plugin</artifactId>
<version>23.3.3</version>
</dependency>
Invalidated and restarted IntelliJ
ran clean-install Maven command through IntelliJ (with Production flag on/off makes no difference)
-> This results in a 404 whitelabel errorpage.
Next, I made sure that all our views annotated with com.vaadin.flow.router.#Route contained at least the javax.annotation.security.#PermitAll annotation.
I added spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration to our application.properties trying to get a more descriptive message.
-> This results in the Apache Tomcat errorpage with description: "The origin server did not find a current representation for the target resource or is not willing to disclose that one exists."
In both cases, the F12 DevTools are empty and showing nothing more than a 404 for the given URL.
So I continued debugging and validated that our custom security roles were validated correctly, a bit like this answer hinted at.
I'm getting into the breakpoints placed in the configure(HttpSecurity http) method from the WebSecurityConfigurerAdapter, but I'm unable to enter the serviceInit(ServiceInitEvent event) from the VaadinServiceInitListener.
I'm not a pro concerning servletRequests, but when hitting the isFrameworkInternalRequest(HttpServletRequest request) (called during the adapter's configuration), it seems only logical that for REQUEST_TYPE_PARAMETER a value of null is returned.
I was intrigued by these upgrade steps for an even higher Vaadin version, but nothing in there changed a bit for me.
When asked, I'd say that Spring isn't picking up on my views. Even the older #EnableVaadin() annotation did nothing. At this point I can't think straight anymore, even looking into the change of why Vaadin now uses vite.config.ts instead of webpack.config.js. Any pointers to where the issue might lay are immensely appreciated.
all credit to #Knoobie whose concise answer contained the correct solution.
Vaadin 23.3.x requires at least 2.7.x in order to work.
The Vaadin upgrade guide generator, when looking at the steps to migrate from v21 to v23, mistakenly referenced the minimum version of SpringBoot as 2.6.6. They will fix this in the immediate future.
I have been struggling with this error for an entire day and I just couldn't find any posts out there. This is the error I am getting:
org.netbeans.InvalidException: Netigso: my-module-path: Cannot start com.my-bundle state remains INSTALLED after start()
This is my scenario:
-I have a NetBeans Platform v7.4 app, that uses an OSGi Module.
-Inside of the OSGi module I have a simple POJO API
-I need to add JAXB annotations "import javax.xml.bind.annotation" to the POJOs because in another non-OSGi module I am saving/reading the model from an XML file
-The OSGi module import works, as long as I do not add the #XML annotations. The moment I add the annotations, I get the error above.
Can somebody help me figure out how do I need to handle the "javax.xml.bind.annotation" import inside of the OSGi bundle? What is causing this error?
I have felix-framework-5.0.1 and I'm trying to start slf4j-api-1.6.0.jar bundle into felix isgi container.
in felix console I'm typing install file:bundle/slf4j-api-1.6.0.jar
I'm getting a message Bundle ID: 42
then I'm trying to start the bundle start 42
I'm getting the message
org.osgi.framework.BundleException: Unable to resolve slf4j.api [42](R 42.0): missing requirement [slf4j.api [42](R 42.0)] osgi.wiring.package; (&(osgi.wiring.p
ackage=org.slf4j.impl)(version>=1.5.5)) Unresolved requirements: [[slf4j.api [42](R 42.0)] osgi.wiring.package; (&(osgi.wiring.package=org.slf4j.impl)(version>=
1.5.5))]
g!
Can any body help me? how can I start slf4j bundle into felix?
slf4j-api needs org.slf4j.impl package. This package is included into every slf4j implementations like slf4j-simple, slf4j-logback, etc.
The implementation bundles need org.slf4j package that comes from the API artifact. There is a cross-reference. This can work only due to the reason that implementations are fragment bundles of the API. When the implementation is installed together with the API, they will have a common classloader and they will be resolved together. Both of their requirements will be satisfied.
In short: You must choose one of the implementations and install that as well. E.g.: slf4j-simple.
You should use the same version of API and implementation to satisfy their "cross requirement".
Your library contains the following 3 packages (link):
org.slf4j
org.slf4j.helpers
org.slf4j.spi
but you have to have an additional library that will contain org.slf4j.impl package.
Also, from manifest file you can see what packages are exported (Export-Package) (they are visible by other bundles) and what packages are imported (Import-Package) (they have to be accessible for the given bundle). Sometimes the given package have to be from bundle with the correct version.
If you cannot find correct bundle maybe this page will help you.
I'm having hibernate3.jar and hibernate-core-4.2.0.CR1.jar in my classpath and I'm using Spring 3.1.3 version. Code got compiles sucessfully but while runtime I'm getting following error
2014-10-28 10:51:25,174 DEBUG [RMI TCP Connection(2)-10.126.30.203] -
Target method failed for RemoteInvocation: method name
'getPriceByKeys'; parameter types [java.util.List, java.util.Date]
java.lang.NoSuchMethodError:
org.hibernate.SessionFactory.openSession()Lorg/hibernate/Session;
I google it but not find any solution. Please note : My project needs hibernate3.jar but at the same time my project dependent on some other 3rd party jar which inturn using hibernet4.2.0 jar.
Any help Pls ??
You need to remove multiple hibernate JAR files from your classpath. Without doing this, your application may not work as you expect; which means you need to migrate the hibernate version of your application from 3 to 4.1.
Although Spring 3.1 uses Hibernate 3 JAR files, you can still migrate to Hibernate 4. Check out Spring blog gives a small tutorial to do so.
Migrating to Spring 3.1 and Hibernate 4.1
As part of the Core-Spring course, we have a lab application that we
use to show how to integrate Spring and JPA/Hibernate together. We
have just upgraded it to Spring 3.1 / Hibernate 4.1, and thought we
should share a few tips.
Just an update. The cause of problem is , I'm having two spring-context xml files in project (one of my project and one related to another module that I'm integrating). I'm loading context xmls from two different classes. So one of the DAO class loaded by one of spring-context xml not getting the hibernate Session.
Later on using import tag, I included 2nd spring application context file in 1st application context file and then loaded a Single application context file from the class. It solved the error.
Thanks,
I am attempting to upgrade an appliaction from Hibernate 3 to Hibernate 4. The application uses ehcache.
When upgrading to Hibernate 4.2.0.Final I added a dependency on hibernate-ehcache-4.2.0.Final as suggested.
When I started up the application I received the following error:
Caused by: java.lang.NoClassDefFoundError: org/hibernate/cache/TimestampsRegion
According to http://www.javacraft.org/2012/03/migrate-to-hibernate-4-ehcache.html I should remove the dependency on ehcache-core and only use the hibernate provided jar to resolve this error.
Now, if I follow these instructions and remove this dependency my application which uses the net.sf.ehcache.CacheManager no-longer compiles.
// For example, this no-longer works
CacheManager manager = CacheManager.getInstance();
So my question is, can I use both libraries and continue working as before (Without updating the app), or do I have to change the app, in which case does hibernate-ehcache even provide the functionality required to access the cache?
When using Hibernate 4 you have to use the org.hibernate packaged classes.
The net.sf.ehcache ones are target at Hibernate 3.
Form 4 they have ported to 4 within the Hibernate repo directly (which is the most sensible thing in our opinion).
So using org.hibernate.cache.ehcache.EhCacheRegionFactory should solve your problem.
Check if there any .properties file in your project like hsqlDatabaseConfig.properties, try to update the property as below
sessionFactory.hibernateProperties = hibernate.cache.use_second_level_cache=true\n\
hibernate.cache.use_query_cache=true\n\
hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.internal.EhcacheRegionFactory\n\