Does Gemini Blueprint support JSR 250 annotations? [message #1807926] |
Wed, 12 June 2019 11:40  |
Eclipse User |
|
|
|
Hi,
Does Gemini Blueprint support JSR 250 annotations? I am testing a long-needed migration from Spring DM 1.2.1 to Gemini Blueprint 3.0.0.M01 and found that our @PostContruct initialization methods are not being called.
Thanks,
Jim
[Updated on: Fri, 14 June 2019 09:59] by Moderator
|
|
|
|
Re: Does Gemini Blueprint support JSR 250 annotations? [message #1808352 is a reply to message #1808287] |
Fri, 21 June 2019 15:59   |
Eclipse User |
|
|
|
Hi Florian,
Thank you for the reply. We have a good amount of Spring-DM XML, so I was trying to maintain our original Spring-DM file format while migrating, however, I have tried using a blueprint file similar to yours for this test, and it is still not working. The classes used to verify that annotations are functional are very simple and don't include any product code. Perhaps
the platform is coming into play? I am using Karaf 4.2.5 on Java 9 and Spring 5.0.12_RELEASE_1.
The two classes used to verify functionality are:
PostConstructUser -
package test.postconstruct;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@Component
public class PostConstructUser
{
private Integer i = null;
@PostConstruct
public void init()
{
System.out.println( "PostConstructUser initializing: " + this );
i = new Integer(1);
}
public Integer getI()
{
return i;
}
}
PostConstructTester -
package test.postconstruct;
import javax.inject.Inject;
public class PostConstructTester
{
private PostConstructUser user;
public void init()
{
if (user.getI() == null)
{
System.out.println("PostConstruct check failed. Karaf is not properly handling annotated classes.");
}
}
@Inject
public void setUser( PostConstructUser user )
{
this.user = user;
}
}
And the 'XML':
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"
default-activation="eager">
<!--
Enables annotation configurations (e.g. @PreDestroy,
@PostConstruct, @Autowired)
-->
<context:component-scan base-package="test.postconstruct"/>
<context:property-placeholder />
<!--<bean id="user" class="test.test.postconstruct.PostConstructUser"/>-->
<bean id="tester" class="test.postconstruct.PostConstructTester"
init-method="init">
</bean>
</blueprint>
I install using features and these are the features 'XML' file:
<?xml version="1.0" encoding="UTF-8"?>
<features name="my-features">
<feature name="libs" version="1.0.0">
<bundle start-level="32">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.javax-inject/1_3</bundle>
</feature>
<feature name="gemini-blueprint" description="Eclipse Gemini Blueprint support" version="3.0.0.M01">
<feature version="1.0.0">libs</feature>
<feature version="5.0.12.RELEASE_1">spring</feature>
<bundle start-level="30">mvn:org.eclipse.gemini.blueprint/gemini-blueprint-core/3.0.0.M01</bundle>
<bundle start-level="30">mvn:org.eclipse.gemini.blueprint/gemini-blueprint-io/3.0.0.M01</bundle>
<bundle start-level="30">mvn:org.eclipse.gemini.blueprint/gemini-blueprint-extensions/3.0.0.M01</bundle>
<bundle start-level="30">mvn:org.eclipse.gemini.blueprint/gemini-blueprint-extender/3.0.0.M01</bundle>
<!-- Shouldn't need this, but Gemini Blueprint doesn't include Provide-Capability header for osgi.extender=osgi.blueprint
so the deployer feature doesn't install this bundle -->
<!--<bundle start-level="24">mvn:org.apache.karaf.deployer/org.apache.karaf.deployer.blueprint/4.2.5</bundle>-->
</feature>
<feature name="my-test-postconstruct" version="1.0.0">
<feature version="3.0.0.M01">gemini-blueprint</feature>
<bundle start-level="50">mvn:testing/postconstruct/3.8.0-SNAPSHOT</bundle>
</feature>
</features>
Regardless of whether I install with our product code or the simpler version, I always see the message shown below that is emitted from the tester class:
karaf@root(feature)> install libs
karaf@root(feature)> install gemini-blueprint
karaf@root(feature)> install my-test-postconstruct
karaf@root(feature)> PostConstruct check failed. Karaf is not properly handling annotated classes.
Thanks again,
Jim
[Updated on: Fri, 21 June 2019 16:17] by Moderator
|
|
|
Re: Does Gemini Blueprint support JSR 250 annotations? [message #1809489 is a reply to message #1808352] |
Tue, 16 July 2019 15:03  |
Eclipse User |
|
|
|
I figured out what was wrong. My previous post had a lot of inaccuracies, but I fixed them on my local system, and after that the annotation processing worked fine with the basic features.
When I went back to our product installation, it still failed. Some of our dependencies rely on javax.annotation [1.2-2.0). jre.properties exports javax.annotation 1.0 from the system bundle, so CXF installed a javax.annotation api v1.3 bundle to satisfy its needs. That threw Spring/Gemini for a loop. I found that the javax.annotation jar in the lib/jdk9plus directory is actually version 1.3. So, I updated jre.properties to export the packages as version 1.3, and that resolved the issue.
I have opened https://issues.apache.org/jira/browse/KARAF-6358 to get the fix applied to the properties file.
Thanks again for the assistance, Florian.
|
|
|
Powered by
FUDForum. Page generated in 0.03774 seconds