留言板

Calling JNDI in WebSphere from a Spring MVC portlet in Liferay DXP SP3

Rodrigo Hernández,修改在6 年前。

Calling JNDI in WebSphere from a Spring MVC portlet in Liferay DXP SP3

New Member 帖子: 9 加入日期: 17-1-10 最近的帖子
Hi.

I'm trying to call a JNDI resource in WebSphere to establish a connection to a DB from a Spring MVC portlet; but I'm getting a NoInitialContextException when my datasource bean is been created.

My configuration files are the following:

My-Portlet.xml

<!--?xml version="1.0"?-->

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee" xsi:schemalocation="http://www.springframework.org/schema/beans 
						http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
						http://www.springframework.org/schema/context 
						http://www.springframework.org/schema/context/spring-context.xsd
						http://www.springframework.org/schema/jee 
						http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
						">
	<context:component-scan base-package="TestSP3.**" />
	
	<jee:jndi-lookup id="dataSource" jndi-name="jdbc/ds" expected-type="javax.sql.DataSource" />
	
	<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
		<property name="dataSource" ref="dataSource" />
	</bean>
	
</beans>


web.xml

<!--?xml version="1.0"?-->

<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
	<resource-ref>
		<description>Customer master data</description>
		<res-ref-name>jdbc/ds</res-ref-name>
		<res-type>javax.sql.DataSource</res-type>
		<res-auth>Container</res-auth>
		<res-sharing-scope>Shareable</res-sharing-scope>
	</resource-ref>
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/spring-context/portlet-application-context.xml</param-value>
	</context-param>
	<servlet>
		<servlet-name>ViewRendererServlet</servlet-name>
		<servlet-class>org.springframework.web.servlet.ViewRendererServlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>ViewRendererServlet</servlet-name>
		<url-pattern>/WEB-INF/servlet/view</url-pattern>
	</servlet-mapping>
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
</web-app>


Besides this files... Is anything else that I'm missing?