2014-09-11 2 views
0

Мы пытаемся успешно развернуть приложение Spring 3.2.6, разработанное на Tomcat 6 в Weblogic 12.1.2. Приложение отлично работает в Tomcat. Приложение вызывает службу Mail Connection на Tomcat (mail-1.4.7.jar). В Tomcat библиотека (почтовый ящик) находится в tomcat/lib, а в Weblogic мы помещаем ее в папку app/oracle/admin/domains/devtest_domain/lib.Развертывание в Weblogic с помощью javax.naming.NameNotFoundException

Это applicationContext.xml:

<!-- Data Source using JNDI --> 
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> 
    <property name="resourceRef"> 
     <value>true</value> 
    </property> 
    <property name="jndiName"> 
     <value>${datasource.JndiName.DS}</value> 
    </property> 
</bean> 
<bean id="mailService" class="com.xxxx.xxxx.utils.MailService"> 
    <property name="mailSender" ref="mailSender" /> 
</bean> 

<bean id="mailSender" 
     class="org.springframework.mail.javamail.JavaMailSenderImpl"> 
    <property name="session" ref="mailSession" /> 
</bean> 

<!-- Mail Session using JNDI --> 
<bean id="mailSession" class="org.springframework.jndi.JndiObjectFactoryBean"> 
    <property name="resourceRef"> 
     <value>true</value> 
    </property> 
    <property name="jndiName"> 
     <value>${mailSession.JndiName}</value> 
    </property> 
</bean> 

Файл свойств содержимого являются:

#Datasource 
datasource.JndiName.DS=java:comp/env/jdbc/xxxx 
#MailSession 
mailSession.JndiName=java:comp/env/mail/xxxx  

При запуске развертывания мы видим следующее исключение в журнале:

SEVERE: Context initialization failed 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'forgotPasswordAction': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.xxx.xxxx.utils.MailService com.xx.xx.action.ForgotPasswordAction.mailService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mailService' defined in file [/u01/app/oracle/admin/domains/devtest_domain/servers/WLS_DEV1/stage/xx-dev/xxx-dev/WEB-INF/classes/META-INF/spring/applicationContext.xml]: Cannot resolve reference to bean 'mailSender' while setting bean property 'mailSender'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mailSender' defined in file [/u01/app/oracle/admin/domains/devtest_domain/servers/WLS_DEV1/stage/xx-dev/xx-dev/WEB-INF/classes/META-INF/spring/applicationContext.xml]: Cannot resolve reference to bean 'mailSession' while setting bean property 'session'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mailSession' defined in file 
[/u01/app/oracle/admin/domains/devtest_domain/servers/WLS_DEV1/stage/xxx-dev/xxxx-dev/WEB-INF/classes/META-INF/spring/applicationContext.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: While trying to look up comp/env/mail/xxxin /app/webapp/xxx-dev/1749454341.; remaining name 'comp/env/mail/xxx' 
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mailSession' defined in file [/u01/app/oracle/admin/domains/devtest_domain/servers/WLS_DEV1/stage/xxxx-dev/xxxx-dev/WEB-INF/classes/META-INF/spring/applicationContext.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: While trying to look up comp/env/mail/xxin /app/webapp/xxx-dev/1749454341.; remaining name 'comp/env/mail/xxx' 
     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1146) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) 
     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296) 
     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) 
     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628) 
     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) 
     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) 
     at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389) 
     at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294) 
     at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) 

Я посмотрел дерево JNDI в Weblogic, и никаких ресурсов по имени «comp/env/mail/xxx» не существует s.

ли нам просто нужно настроить JavaMail на Weblogic как: http://docs.oracle.com/cd/E15586_01/apirefs.1111/e13952/taskhelp/mail/CreateMailSessions.html

Благодаря передовой!

Том

ответ

0

Я должен был настроить почтовый ресурс в Weblogic, а также файл конфигурации пришлось изменить, чтобы отразить новый ресурс JNDI для почтовых сессий в WebLogic Server тоже.

От mailSession.JndiName = Java: COMP/ENV/почте/хххх Для mailSession.JndiName = почта/XXXX

Спасибо,

Том

Смежные вопросы