You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Kevin Huntly <km...@gmail.com> on 2023/04/10 21:11:32 UTC

Context usage

Hello,

I have the following environment entries in my context.xml:

    <Environment name="environment" value="dev" type="java.lang.String"
override="false" />
    <Environment name="isTestSystem" value="true" type="java.lang.String"
override="false" />
    <Environment name="webURL" value="esolutions.caspersbox.com"
type="java.lang.String" override="false" />

I'm trying to reference them in my spring app using the following in the
XML:

<jee:jndi-lookup expected-type="java.lang.String" id="isTestSystem"
jndi-name="java:comp/env/isTestSystem" />

<jee:jndi-lookup expected-type="java.lang.String" id="webURL"
jndi-name="java:comp/env/webURL"
/>


I can reference one and the app boots fine. If I try to reference both I
get this:


Caused by:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error
creating bean with name 'appConfig': Unsatisfied dependency expressed
through field 'homePage'; nested exception is
org.springframework.beans.factory.NoUniqueBeanDefinitionException: No
qualifying bean of type 'java.lang.String' available: expected single
matching bean but found 2: isTestSystem,webURL
        at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:660)
~[spring-beans-5.3.26.jar:5.3.26]


Not sure what I'm doing wrong. I'm sure it's a Spring issue but I don't
know for sure.
________________________________________________

Kevin Huntly
Email: kmhuntly@gmail.com
Cell: 716/424-3311
________________________________________________

-----BEGIN GEEK CODE BLOCK-----
Version: 1.0
GCS/IT d+ s a C++ UL+++$ P+(++) L+++ E---
W+++ N+ o K(+) w--- O- M-- V-- PS+ PE Y(+)
PGP++(+++) t+ 5-- X-- R+ tv+ b++  DI++ D++
G++ e(+) h--- r+++ y+++*
------END GEEK CODE BLOCK------