【问题标题】:Spring Error: org.springframework.beans.factory.BeanCreationException弹簧错误:org.springframework.beans.factory.BeanCreationException
【发布时间】:2012-01-19 01:57:35
【问题描述】:

我有一个 Web 应用程序,我将其导出为 EAR 并尝试部署在 Websphere 6.1 应用程序服务器上。

部署顺利。甚至,索引页面加载正常,这是一个登录屏幕。

但是,在输入凭据并按 Enter 时,不会加载下一页并引发 HTTP 500 Internal Server Error。

下一个被加载的页面是一个带有国家下拉列表的 JSP,它的值是通过休眠从数据库中获取的。

我在 Websphere 中创建了包含所有详细信息的数据源,甚至测试连接成功。

但是,我在检查服务器 System.out 日志时收到以下错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ds': 
Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: 
Context: uschwasvmdev04Cell01/clusters/URMDUS, name: jdbc/mydbXA: First component in name 
mydbXA not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: 
IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]

NameNotFoundException 的描述说:

“当名称的组件因为未绑定而无法解析时抛出此异常。”

我的 services.xml 中的 JNDI 查找似乎也很好:

<jee:jndi-lookup id="ds" jndi-name="jdbc/mydbXA" resource-ref="true" />

我在这里错过了什么?

感谢阅读!

【问题讨论】:

    标签: spring web-applications websphere jndi


    【解决方案1】:

    这很有趣,但我做了相反的事情:我创建了资源引用,但我忘记告诉 Spring 使用它。

    以防万一,在命名空间中完成如上所示:resource-ref="true"

    如果您手动配置 bean:

    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
          <property name="jndiName" value="jdbc/database" /> 
          <property name="resourceRef" value="true" /><!-- It's false by default -->
    </bean>
    

    【讨论】:

      【解决方案2】:

      您正在使用resource-ref="true"。您是否在您的 web.xml 中创建了相应的 resource-reference 并且您有 map the DataSource to the application 吗?

      如果将其设置为false,则可以进行全局查找。否则你必须配置它。

      【讨论】:

        猜你喜欢
        • 2017-12-31
        • 2013-12-06
        • 2012-12-22
        • 2011-07-25
        • 1970-01-01
        • 1970-01-01
        • 2012-11-13
        • 2010-09-20
        • 2014-11-10
        相关资源
        最近更新 更多