Hi Chris,
Thanks for the response.
I had been using spring 4.0.9 even before I switched to tomcat 8 and I am
continuing to use the same now.

I have tried to configure the Resource a couple of different ways:
1st way: In the context.xml file as below:
<Resource name="jdbc/ADS" auth="Container"
            type="javax.sql.DataSource"
            driverClassName="oracle.jdbc.OracleDriver"
            url="jdbc:oracle:thin:@xxxxxxxxxxx/xxxxx"
            username="xxxxxxxxx"
            password="xxxxxxxxxx"
            initialSize="10"
            logAbandoned="false"
            maxTotal="20"
            maxIdle="10"
            maxWaitMillis="10000"
            removeAbandonedOnBorrow="true"
            removeAbandonedOnMaintenance="true"
            removeAbandonedTimeout="120"
            testOnBorrow="true"
            validationQuery="Select 1 from dual"/>

2nd Way:
configured a global datasource and a resource link as shown below:
in the context.xml file:
<ResourceLink global="jdbc/ADS" name="jdbc/ADS"
type="javax.sql.DataSource"/>

in the server.xml file:
<GlobalNamingResources>

    <Resource name="jdbc/ADS" auth="Container"
      type="javax.sql.DataSource"
      driverClassName="oracle.jdbc.OracleDriver"
      url="jdbc:oracle:thin:@xxxxxxxxxxxxxxxxxxxxx/xxxxx"
      username="xxxxx"
      password="xxxxxx"
      initialSize="10"
      logAbandoned="false"
      maxTotal="20"
      maxIdle="10"
      maxWaitMillis="10000"
      removeAbandonedOnBorrow="true"
      removeAbandonedOnMaintenance="true"
      removeAbandonedTimeout="120"
      testOnBorrow="true"
      validationInterval="30000"
      validationQuery="Select 1 from dual"/>

  </GlobalNamingResources>


The spring config looks like: I have tried both the jee and the bean way of
configuring it..with the same results.
<!-- <jee:jndi-lookup id="datasource"   jndi-name="jdbc/ADS"
expected-type="javax.sql.DataSource" />-->

        <bean id=*"datasource"* class=
*"org.springframework.jndi.JndiObjectFactoryBean"*>
                <property name=*"jndiName"* value=*"java:comp/env/jdbc/ADS"*
 />
        </bean>


I am also attaching the log file to this email. Please let me know if any
other information could help.
I really appreciate you taking the time to look into this.

Thank you,
Bhanu Lakkala


On Tue, Apr 26, 2016 at 4:04 PM, Christopher Schultz <
ch...@christopherschultz.net> wrote:

> Bhanu,
>
> On 4/22/16 9:46 AM, bhanu lakkala wrote:
> > I have been working on an issue for the past few days and wanted to check
> > with you guys if you have any suggestions on fixing this issue.
> > My current technology stack is: windows 7, java 7/8, tomcat 8, axis2
> 1.6.3.
> > I have an axis2 based web service that is very basic and it just connects
> > to a database and reads some info and spits out the info it read.
> > I have setup a JNDI resource for the datasource.  In the service's init
> > class's startup method, I am attempting to load the spring's
> > ApplicationContext and thereby load the JNDI resource.
> > All of this used to work well with the combination of java 7, tomcat 7.x
> > axis2 1.6.3.
> > Recently due to a need to upgrade to newer version of tomcat, I upgraded
> to
> > tomcat 8. this resulted in "Name not found" exception.
>
> I don't believe anything significant changed with Tomcat's handling of
> JNDI DataSources. Are you sure you upgraded only Tomcat and not some
> other component at the same time (e.g. Spring)?
>
> > I ditched the spring's usage of finding jndi resource and used the
> > initContext to lookup the JNDI resource and it worked fine.
>
> That suggests to me that the JNDI context is correctly-configured by
> Tomcat, and the problem lies within your configuration (likely) or
> Spring itself (unlikely).
>
> > I have to use spring to find the JNDI
> > context since most of our applications are already using spring and if i
> > need to change every single one of them it is a tedious process.
> >
> > We also have a unix environment that I tested this with and I didn't find
> > any issues there. i.e., I used spring to load the jndi resource, tomcat
> > 8.x, java 7, axis2 1.6.3.
> > Since this is a windows only issue, I tried to upgrade to Tomcat 9.x and
> > that resulted in the same error.
> > I have also posted this issue on the stackoverflow site but haven't had
> > much luck finding a solution to the issue.
> >
> http://stackoverflow.com/questions/36207119/tomcat-8-axis2-webservices-aar-spring-jndi-not-bound-in-context
>
> What is your <Resource> configuration in Tomcat, and how are you
> specifying your JNDI DataSource name in your Spring configuration?
>
> What do the (Spring) logs say?
>
> -chris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>
[INFO] Refreshing 
org.springframework.context.support.ClassPathXmlApplicationContext@67aa1e71: 
startup date [Tue Apr 26 22:36:49 EDT 2016]; root of context hierarchy
[INFO] Loading XML bean definitions from class path resource [DST-Context.xml]
[WARN] Exception encountered during context initialization - cancelling refresh 
attempt: org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'datasource': Invocation of init method failed; nested 
exception is javax.naming.NameNotFoundException: Name [jdbc/ADS] is not bound 
in this Context. Unable to find [jdbc].
org.springframework.beans.factory.BeanCreationException: Error creating bean 
with name 'datasource': Invocation of init method failed; nested exception is 
javax.naming.NameNotFoundException: Name [jdbc/ADS] is not bound in this 
Context. Unable to find [jdbc].
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        at 
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at 
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at 
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:753)
        at 
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
        at 
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
        at 
com.bpl.ws.service.ScoreServiceInitializer.startUp(ScoreServiceInitializer.java:59)
        at 
org.apache.axis2.deployment.ServiceBuilder.startupServiceLifecycle(ServiceBuilder.java:942)
        at 
org.apache.axis2.deployment.ServiceBuilder.populateService(ServiceBuilder.java:444)
        at 
org.apache.axis2.deployment.repository.util.ArchiveReader.buildServiceGroup(ArchiveReader.java:109)
        at 
org.apache.axis2.deployment.repository.util.ArchiveReader.processServiceGroup(ArchiveReader.java:232)
        at 
org.apache.axis2.deployment.ServiceDeployer.deploy(ServiceDeployer.java:154)
        at 
org.apache.axis2.deployment.repository.util.DeploymentFileData.deploy(DeploymentFileData.java:144)
        at 
org.apache.axis2.deployment.DeploymentEngine.doDeploy(DeploymentEngine.java:585)
        at 
org.apache.axis2.deployment.repository.util.WSInfoList.update(WSInfoList.java:164)
        at 
org.apache.axis2.deployment.RepositoryListener.update(RepositoryListener.java:377)
        at 
org.apache.axis2.deployment.RepositoryListener.checkServices(RepositoryListener.java:254)
        at 
org.apache.axis2.deployment.DeploymentEngine.loadServices(DeploymentEngine.java:136)
        at 
org.apache.axis2.deployment.WarBasedAxisConfigurator.loadServices(WarBasedAxisConfigurator.java:289)
        at 
org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:95)
        at 
org.apache.axis2.transport.http.AxisServlet.initConfigContext(AxisServlet.java:620)
        at 
org.apache.axis2.transport.http.AxisServlet.init(AxisServlet.java:471)
        at 
org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1231)
        at 
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1144)
        at 
org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1031)
        at 
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4997)
        at 
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5289)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at 
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
        at 
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
        at 
org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:586)
        at 
org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1777)
        at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
Caused by: javax.naming.NameNotFoundException: Name [jdbc/ADS] is not bound in 
this Context. Unable to find [jdbc].
        at org.apache.naming.NamingContext.lookup(NamingContext.java:818)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:166)
        at javax.naming.InitialContext.lookup(InitialContext.java:411)
        at 
org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:155)
        at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
        at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
        at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:179)
        at 
org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:104)
        at 
org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:106)
        at 
org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:231)
        at 
org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:217)
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
        ... 41 more
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to