Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Could not resolve placeholder

  1. #1
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    7

    Default Could not resolve placeholder

    Hi all,
    I am trying to update a weblogic 8 ear to deploy in weblogic 10. We are currently using spring 1.2 and will upgrade spring after the ear successfully deploys in weblogic 10. I keep getting a Could not resolve placeholder 'staff.filename' .

    Here is what some of the code looks like:

    applicationContext.xml
    Code:
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    		<property name="locations">
    			<list>
    				<value>classpath://ici_app.properties</value>
    			</list>
    		</property>
    	</bean>
    authAppContext.xml
    Code:
    <bean id="targetMemberAdminDAO" 
    		class="org.ici.icinet.dao.JNDIMemberAdminDAOImpl" autowire="byName"
    		destroy-method="destroy">
    	    <property name="searchBase"><value>${ldap.search.base}</value></property>
    	    <property name="authenticatingContextProperties">
    	    	<props>
    				<prop key="java.naming.factory.initial">com.sun.jndi.ldap.LdapCtxFactory</prop>
    				<prop key="java.naming.provider.url">ldap://${ldap.host}:${ldap.port}/${ldap.search.base}</prop>
    	    	</props>
    	    </property>
    	    <property name="ldapContextProperties">
    	    	<props>
    				<prop key="java.naming.factory.initial">com.sun.jndi.ldap.LdapCtxFactory</prop>
    				<prop key="java.naming.provider.url">ldap://${ldap.host}:${ldap.port}/${ldap.search.base}</prop>
    				<prop key="java.naming.security.principal">${ldap.admin.dn}</prop>
    				<prop key="java.naming.security.credentials">${ldap.admin.password}</prop>
    				<prop key="java.naming.security.authentication">simple</prop>
    				<prop key="com.sun.jndi.ldap.connect.pool">true</prop>
    	    	</props>
    	    </property>
    	</bean>
    	
    	<bean id=":ldapRefresh" name="ldapRefresh" class="org.ici.icinet.admin.refresh.LDAPRefreshImpl" autowire="byName" singleton="false">
    		<property name="iciStaffFile"><value>${staff.filename}</value></property>
    	</bean>
    ici_app.properties
    Code:
    #LDAP User
    ldap.port=389
    ldap.pool.size=5
    ldap.pool.max=10
    ldap.pool.timeout=3600000
    #LDAP ICIstaff file
    ldap.icistaff.file.delimiter=:
    
    staff.filename=classpath://icistaff.txt
    Other placeholders in the same properties file are resolved. I am totally stumped Any help would be greatly appreciated.

  2. #2
    Join Date
    Sep 2006
    Location
    Hartford, CT
    Posts
    145

    Default

    One general comment- it wouldn't seem to be your problem, but there's generally only one forward slash after "classpath:" or none at all.

    Very curious that other placeholders in the same files are resolved. In light of that, my first inclination is to say there may be some obscure rule about punctuation, etc. in a properties file that we are both unaware of and it's causing the file to be parsed in a fashion contrary to what you would expect.

    (It's "ldap.icistaff.file.delimiter=:" that I'd be wary of.)

    The simple test for this is to play around with the file until you get it to work and then you should be able to see what was wrong exactly. Try moving "staff.filename=classpath://icistaff.txt" up to the top of the file or temporarily changing the value of anything you're suspicious of.

    I know this isn't a lot to go on, but just give it a shot and see what happens.
    Kent Rancourt
    DevOps Engineer

  3. #3
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    7

    Default

    Thank you for all of your suggestions. I agree that there must be some obscure rule with regards to properties files. I've tried moving "staff.filename=classpath://icistaff.txt" to various places in the file. I even tried renaming it "staff_filename". So far, replacing
    Code:
    <bean id=":ldapRefresh" name="ldapRefresh" class="org.ici.icinet.admin.refresh.LDAPRefreshImpl" autowire="byName" singleton="false">
    		<property name="iciStaffFile"><value>${staff.filename}</value></property>
    	</bean>
    with
    Code:
    <bean id=":ldapRefresh" name="ldapRefresh" class="org.ici.icinet.admin.refresh.LDAPRefreshImpl" autowire="byName" singleton="false">
    		<property name="iciStaffFile"><value>classpath://icistaff.txt</value></property>
    	</bean>
    in authAppContext.xml has been the only thing that worked, but it is not a good solution for production.

  4. #4
    Join Date
    Apr 2006
    Location
    South Carolina
    Posts
    122

    Default

    I assume you removed the second slash from the after the classpath: for the properties file?

    If you want to make sure the properties file is formatted correctly, write up a quick java program that instantiates a Properties object, fills it with the desired information and writes the data out to a file using Properties.storeToXml(...).

  5. #5
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    7

    Default

    Yes, I did try removing the second slash.

  6. #6
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    7

    Default

    Here are the steps that I followed to things working (about 90%)

    1. Make sure that the propertyConfigurer bean is only defined it one place. Having it defined in multiple context files was causing most of the problems. It is now defined in the beanRefFactory.xml
    2. Use one format for classpath: classpath:, classpath:/, and classpath:// were all replaced with classpath:

    Those were the big changes, but there were still two properties that wouldn't resolve. I tried upgrading from Spring 1.2.4 to Spring 2.0.2, but that didn't make a difference. Ultimately, I used a work around. Instead of PropertyPlaceholderConfigurer, I used @property_name@ so that the values would be replace using the ant build.

    I still don't know why the last two values don't work. One is a url and the other is a boolean. If anyone has any ideas, I'd love to hear them. Until then, I'll keep using the ant build to do the substitution.
    Last edited by alfa112; May 30th, 2008 at 11:52 AM. Reason: correct wrong word

  7. #7
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Default

    Try Spring 2.0.7 or above.

    Quote Originally Posted by alfa112 View Post
    Here are the steps that I followed to things working (about 90%)

    1. Make sure that the propertyConfigurer bean is only defined it one place. Having it defined in multiple context files was causing most of the problems. It is now defined in the beanRefFactory.xml
    2. Use one format for classpath: classpath:, classpath:/, and classpath:// were all replaced with classpath:

    Those were the big changes, but there were still two properties that wouldn't resolve. I tried upgrading from Spring 1.2.4 to Spring 2.0.2, but that didn't make a difference. Ultimately, I used a work around. Instead of PropertyPlaceholderConfigurer, I used @property_name@ so that the values would be replace using the ant build.

    I still don't know why the last two values don't work. One is a url and the other is a boolean. If anyone has any ideas, I'd love to hear them. Until the, I'll keep using the ant build to do the substitution.

  8. #8
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    7

    Default

    Thank you for the suggestion. I tried 2.0.8, but it did not make a difference. It turns out that the time stamp for 2.0.8 is one day older than the time stamp for 2.0.2-no-dependencies-on-wls-100.

  9. #9
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Default

    Quote Originally Posted by alfa112 View Post
    Thank you for the suggestion. I tried 2.0.8, but it did not make a difference. It turns out that the time stamp for 2.0.8 is one day older than the time stamp for 2.0.2-no-dependencies-on-wls-100.
    Timestamp does not matter here, 2.0.2 is much , much older version (and quite buggy one).

    Concerning your problem - I have tried to create sample application context with PropertyPlaceholderConfigurer and few beans with properties which values are specified via your placeholders, using properties file published by you.

    All placeholders are resolved correctly, including ${staff.filename}. So your problem should be really weird. May you publish complete context file and stack trace?

    Regards,
    Oleksandr

  10. #10
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    7

    Default

    The problem with is no longer with staff.filename or the authAppContext.xml. The steps listed in a previous post corrected that issue.

    The project has about 9 *Context.xml files. In all but 2 of those files, ${property_name} works correctly. There is one value in each of the remaining two files (calendarContext.xml and mailingsContext.xml) that fails to resolve. One of the values is a boolean. The other value is a url. Since other values in the same context file resolve, the properties file must be accessable.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •