I have a requirement where my Spring JndiObjectFactoryBean has to do lazy lookup of Java mail session configured in my jetty server
Following is the Mail session declaration in my jetty.xml
<New id="mailSessionId" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>mail/GmailMailSession</Arg>
<Arg>
<New class="org.mortbay.naming.factories.MailSessionReference">
<Set name="user">xxx@gmail.com</Set>
<Set name="password">xxx</Set>
<Set name="properties">
<New class="java.util.Properties">
<Put name="mail.host">smtp.gmail.com</Put>
<Put name="mail.debug">true</Put>
<Put name="mail.smtp.auth">true</Put>
<Put name="mail.smtp.starttls.enable">true</Put>
</New>
</Set>
</New>
</Arg>
</New>
In my Spring bean definition file I have following bean definition
<bean id="dsrouterMailSession" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="mail/GmailMailSession" />
<property name="resourceRef" value="true" />
<property name="proxyInterface" value="javax.mail.Session"></property>
<property name="lookupOnStartup" value="false" />
</bean>
I don't want Spring to do lookup for mail/GmailMailSession on startup. So I have set 'lookupOnStartup' property to 'false'. If I set 'lookupOnStartup' to false Spring expects me to provide a proxyInterface. I searched a lot but could not find an interface for mail session. I tried setting "javax.mail.Session" which is a class. I got following Exception which is obvious
Caused by: java.lang.IllegalArgumentException: [javax.mail.Session] is not an interface
at org.springframework.aop.framework.AdvisedSupport.addInterface(AdvisedSupport.java:216)
at org.springframework.aop.framework.AdvisedSupport.setInterfaces(AdvisedSupport.java:205)
at org.springframework.jndi.JndiObjectFactoryBean$JndiObjectProxyFactory.createJndiObjectProxy(JndiObjectFactoryBean.java:323)
at org.springframework.jndi.JndiObjectFactoryBean$JndiObjectProxyFactory.access$000(JndiObjectFactoryBean.java:307)
at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:200)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
My question is is there any interface available for Java mail session which I can set to 'proxyInterface' and get lazy lookup working?