Search code examples
javaspring-mvcoracle11gtomcat7jndi

tomcat Context initialization failed with oracle database


I'm deploying an application in a Linux environment, I have to install tomcat and Oracle database successfully, after that I generate my tables and I get a .war file (module) that Works fine in Windows environment

I deploy it under /tomcat/webapps and I configure my server xml correctly

    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />

    <Resource   auth="Container" 
	        driverClassName="oracle.jdbc.driver.OracleDriver"
		factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" 
		global="jdbc/vimsDs" 			
		initialSize="10" maxActive="100" maxWait="10000" minIdle="10" 
		username="****"
		name="jdbc/vimsDs" 			
		password="*****" 
		removeAbandoned="true" removeAbandonedTimeout="36000" 
		type="javax.sql.DataSource" 
		url="jdbc:oracle:thin:@localhost:1521:XE"/>

after that i start the app from tomcat manager app and it says for me that cannot start the app

FAILED - The application for the context /lounge path could not be started

and it show for me im my app logs this error

logs

2019-02-25 15:04:47.120 [http-bio-8080-exec-32] ERROR o.s.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'applicationConfig': Initialization of bean failed; nested exception is 

.....

at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:179) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:104) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	at Caused by: javax.naming.NameNotFoundException: Le Nom jdbc/vimsDs n'est pas lié à ce Contexte
at org.apache.naming.NamingContext.lookup(NamingContext.java:825) ~[catalina.jar:7.0.92]
at org.apache.naming.NamingContext.lookup(NamingContext.java:173) ~[catalina.jar:7.0.92]
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:156) ~[catalina.jar:7.0.92]
at javax.naming.InitialContext.lookup(InitialContext.java:417) ~[na:1.8.0_201]
at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:155) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:179) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:104) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup.getDataSource(JndiDataSourceLookup.java:45) ~[spring-jdbc-4.3.6.RELEASE.jar:4.3.6.RELEASE]
... 143 common frames omitted


Solution

  • After adding the JNDI to context.xml Also we need to add the OracleJDBC.jar to this file /tomcat/lib