I have problems to declare an e-mail session as an OSGI service. I am using Apache Karaf 3.0.1 as container, Apache Aries for the blueprint JPA and JNDI enhancement.
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<bean id="mailSession" class="javax.mail.Session" init-method="getInstance">
<property name="mail.smtp.host" value="mysmptpip"/>
<property name="mail.smtp.port" value="25"/>
</bean>
<service auto-export="interfaces" ref="mailSession">
<service-properties>
<entry key="osgi.jndi.service.name" value="java:mail/MailSession"/>
</service-properties>
</service>
</blueprint>
I have an error of type enable to find a matching method on class javax.mail.Session for arguments [{mail.smtp.host=mysmptpip, mail.smtp.port=25}]
...
Does anybody have any idea how this should be fixed ?
In addtion I would like to know how can I declare a JavaMail session as a JNDI resource via Apache blueprint (that will create the service)?
I think you could provide a configured mail Session as a service. So the configuration would be centralized.