2017-06-05 69 views
0

我試圖弄清楚使用websphere 8.5和spring的連接問題。我在本網站和其他網站上閱讀了一些問題,但似乎沒有任何效果。使用websphere 8.5.5.0和Spring配置數據源?

在websphere中,我們必須將數據源的jndi名稱設置爲jdbc/connection0。

比我試圖在web應用程序中使用web.xml和spring配置文件來設置連接。

<resource-ref > 
    <description>connection0</description> 
    <res-ref-name>connection0</res-ref-name> 
    <res-type>javax.sql.DataSource</res-type> 
    <res-auth>Container</res-auth> 
    <res-sharing-scope>Shareable</res-sharing-scope> 
    <mapped-name>connection0</mapped-name> 
</resource-ref> 

比彈簧datasource.xml我們嘗試引用連接:

 <property name="jndiName" value="jdbc/connection0"/> 
     <property name="lookupOnStartup" value="false"/> 
     <property name="cache" value="true"/> 
     <property name="proxyInterface" value="javax.sql.DataSource"/>   
    </bean> 

我還增加了文件IBM的web-bnd.xml指數據源(該文件是在WEB-INF目錄下):

< XML版本= 「1.0」 編碼= 「UTF-8」>?< web-bnd xmlns =「http://websphere.ibm.com/xml/ns/javaee」 xmlns:xsi =「http://www.w3.org/2001/XMLSchema-instance」 xsi:的schemaLocation = 「http://websphere.ibm.com/xml/ns/javaee>http://websphere.ibm.com/xml/ns/javaee/ibm-web-bnd_1_0.xsd」 版本= 「1.0」?>

我們生產EAR文件和我們成功部署在應用程序服務器上。 但是,當我們試圖訪問數據庫,我們收到一個錯誤,這是堆棧跟蹤:

[17年5月6日9.59.33:514 CEST] 0000006f SystemOutØit.XXXX.sicurezza.db.DbHelper - - > openJndiConnection:找不到initCtx.lookup(「java:comp/env/url/connection0」)。墳!! [05/06/17 9.59.33:515 CEST] 0000006f SystemOut O 05-06-2017 09:59:33 ERROR [WebContainer:1] it.XXXX.sicurezza.taglib.allow.AllowTag - NamingManager.getURLContext找不到此方案的工廠:java javax.naming.ConfigurationException:NamingManager.getURLContext無法找到此方案的工廠:java at com.ibm.ws.naming.util.Helpers.checkForUrlContext(Helpers.java:1631) at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:160) at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:179) at org.apache.aries。在javax.naming.InitialContext.lookup(InitialContext.java:423) at it.XXXX.sicurezza.db.DbHelper.openJndiConnection(DbHelper.java:78) at it.XXXX.sicurezza.db.DbHelper.openConnection(DbHelper.java:53) at it.XXXX.sicurezza.db.DaoManager.isInternalSecurityEnabled(DaoManager.java:108) at it.XXXX.sicurezza.manager。 AbilitazioniManagerFactory.getAbilitazioniManager(AbilitazioniManagerFactory.java:29) 在it.XXXX.sicurezza.taglib.allow.AllowTag.doStartTag(AllowTag.java:116) 在com.ibm._jsp._editOrdineForm._jspx_meth_allow_allow_8(_editOrdineForm.java:7626) 在com.ibm._jsp._editOrdineForm._jspx_meth_c_if_39(_editOrdineForm.java:7668) 在com.ibm._jsp._editOrdineForm._jspService(_editOrdineForm.java:658) 在com.ibm.ws.jsp.runtime。HttpJspBase.service(HttpJspBase.java:99) at javax.servlet.http.HttpServlet.service(HttpServlet.java:668) at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1227) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:776) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:458) at com.ibm。 ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178) at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:122) at com.ibm.ws.jsp.webcontainerext。 AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:216) at com.ibm.ws.webcontainer.filter.WebA ppFilterChain.invokeTarget(WebAppFilterChain.java:136) at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:79) at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager。的java:928) 在com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1025) 在com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:1385) 在com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:549) at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:1045) at org.apache.jasper.runtime。 PageContextImpl.include(PageContextImpl.java:527) at org.apache.struts.tiles.TilesUtil Impl.doInclude(TilesUtilImpl.java:99) at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:135) at org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java: 760) 在org.apache.struts.taglib.tiles.InsertTag $ InsertHandler.doEndTag(InsertTag.java:892) 在org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:462) 在com.ibm._jsp._layout._jspx_meth_tiles_insert_3(_layout.java:451) at com.ibm._jsp._layout._jspService(_layout.java:201) at com.ibm.ws.jsp.runtime.HttpJspBase.service( (ServletWrapper.java:1227) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:776) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:458) at com.ibm。 ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178) at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:122) at com.ibm.ws.jsp.webcontainerext。 AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:216) 在com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136) 在com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain。 java:79) at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilt erManager.java:928) at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1025) at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:1385) 在com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:194) 在org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:240) 在org.springframework。 web.servlet.view.AbstractView.render(AbstractView.java:258) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1174) at org.springframework.web.servlet.DispatcherServlet.doDispatch( DispatcherServlet.java:901) at org.springframework.web.servlet。DispatcherServlet.doService(DispatcherServlet.java:809) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501) at javax.servlet.http.HttpServlet.service(HttpServlet.java:575) at javax.servlet.http.HttpServlet.service(HttpServlet.java:668) at com.ibm.ws.webcontainer.servlet.ServletWrapper。服務(ServletWrapper.java:1227) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:776) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java: 458) at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178) at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136) at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:79) at com.ibm。 ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:928) at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1025) at com.ibm.ws.webcontainer.webapp。 WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:1385) at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:194) at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView。 java:240) at org.springframework.web.servlet.view.AbstractView.render (AbstractView.java:258) 在org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1174) 在org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:901) 在有機.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571) at org.springframework.web.servlet.FrameworkServlet.doGet (FrameworkServlet.java:501) at javax.servlet.http.HttpServlet.service(HttpServlet.java:575) at javax.servlet.http.HttpServlet.service(HttpServlet.java:668) at com.ibm.ws .webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1227) at com.ibm.ws.we bcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:776) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:458) at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl。的handleRequest(ServletWrapperImpl.java:178) 在com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136) 在com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java: 97) 在org.acegisecurity.util.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:265) 在it.XXXX.oppe0.allow.filter.AllowFilter.doFilter(AllowFilter.java:125) 在org.acegisecurity。 util.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:275) at org.acegisecurity.interc ept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107) 在org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72) 在org.acegisecurity.util.FilterChainProxy $ VirtualFilterChain.doFilter(的FilterChainProxy。 Java的:275) 在org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:124) 在org.acegisecurity.util.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:275) 在org.acegisecurity.providers。 anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125) at org.acegisecurity.util.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:275) at org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter。的doFilter(SecurityContextHolderAwareRequestFilter.java:81) 在org.acegisecurity.util.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:275) 在org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271) 的組織。 acegisecurity.util.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:275) 在org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271) 在org.acegisecurity.util.FilterChainProxy $ VirtualFilterChain.doFilter(的FilterChainProxy。 Java的:275) 在org.acegisecurity.ui.logout.LogoutFilter.doFilter(LogoutFilter.java:110) 在org.acegisecurity.util.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:275) 在org.acegisecurity。 CON text.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249) 在org.acegisecurity.util.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:275) 在it.XXXX.oppe0.acegi.SessionExpirationFilter.doFilter(SessionExpirationFilter.java: 76) 在org.acegisecurity.util.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:275) 在org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149) 在org.acegisecurity.util.FilterToBeanProxy。在Web應用程序中, 91) at org.disp laytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125) at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) at com.ibm.ws.webcontainer.filter.WebAppFilterChain。 doFilter(WebAppFilterChain.java:91) at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:928) at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java: 1025) 在com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3761) 在com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304) 在融爲一體。 ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:976) at com.ibm.ws.webcontainer.WSWebContainer.handleReques t(WSWebContainer.java:1662) at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination( HttpInboundLink.java:459) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:526) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink。 processRequest(HttpInboundLink.java:312) at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:88) at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener。 futureCompleted(AioReadCompletionListener.java:175) at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217) at com.ibm.io.async.AsyncChannelFuture .fireCompletionActions(AsyncChannelFuture.java:161) at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138) at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204) com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775) at com.ibm.io.async.ResultHandler $ 2.run(ResultHandler.java:905) at com.ibm.ws.util。 ThreadPool $ Worker.run(ThreadPool.java:1862)

有關安裝的任何建議?

+0

您需要仔細查看此行。 '[05/06/17 9.59.33:514 CEST] 0000006f SystemOut O it.infogroup.sicurezza.db.DbHelper - > openJndiConnection:未找到initCtx.lookup(「java:comp/env/url/connection0」)。墳!! '路徑似乎是不正確的,因爲我期望看到「jdbc/connection0」,但是我看到「url/connection0」。 –

+0

請發佈查找數據源的代碼。 –

回答

0

如果您有想要查找的數據源,

java:comp/env/url/connection0 

和你的服務器配置定義了在網絡

jdbc/connection0 

那麼你的資源引用JNDI名稱的數據源的應用.xml應該是

<resource-ref > 
    <description>connection0</description> 
    <res-ref-name>url/connection0</res-ref-name> 
    <res-type>javax.sql.DataSource</res-type> 
    <res-auth>Container</res-auth> 
    <res-sharing-scope>Shareable</res-sharing-scope> 
</resource-ref> 

並且您可以在bi中定義映射ndings文件(ibm-web-bnd.xml)如下:

<resource-ref name="url/connection0" binding-name="jdbc/connection0"> 
</resource-ref> 
+0

感謝您的快速回復。但是我在spring-datasource.xml中遇到問題(它看起來並不像您所建議的那樣) –

+0

爲了澄清,我沒有建議對spring-datasource.xml進行任何修改,僅用於部署描述符(web.xml)和綁定(ibm-web-bnd.xml) – njr

相關問題