Results 1 to 5 of 5

Thread: Properties file in web start

  1. #1
    Join Date
    May 2005
    Posts
    20

    Default Properties file in web start

    I'm having some difficulty setting up an application to be deployed using web start. Simply put, the end user needs to configure the DB properties (as well as a few other things), so I tried to use this example;

    http://opensource.atlassian.com/conf...ur +XML+files

    But I when the context loads, I get the following message;

    Code:
    org.springframework.beans.factory.BeanInitializationException: Could not load properties from class path resource [WEB-INF/classes/myapp.properties]; nested exception is java.io.FileNotFoundException: Could not open class path resource [WEB-INF/classes/myapp.properties]
    java.io.FileNotFoundException: Could not open class path resource [WEB-INF/classes/myapp.properties]
    	at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:109)
    	at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:120)
    	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:315)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:266)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:80)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65)
    	at myapp.AV.<init>(Unknown Source)
    My property loader is;

    Code:
    	<bean id="propertyConfigurer"
    		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    		<property name="locations">
    			<list>
    				<value>/WEB-INF/classes/myapp.properties</value>
    				<!-- <value>classpath:myapp.properties</value> -->
    			</list>
    		</property>
    		<property name="ignoreUnresolvablePlaceholders">
    			<value>true</value>
    		</property>
    	</bean>
    Any ideas? Is this a fundamental issue w/ webstart (probably the wrong forum here, but since the petclinic has a webstart example...) Anyways, TIA. (Also, as I was flailing about, I included the commented out location as well. Am I misunderstanding the "ignoreUnresolvablePlaceholders"...should it ignore the resources it can't find?)

  2. #2
    Join Date
    Aug 2004
    Location
    San Francisco
    Posts
    423

    Default

    Hi,

    well, your configuration file is telling spring to get the .properties file from the a certain location, but the WEB-INF directory on the server is not directly available to the remote web started application.

    I'm not a webstart expert but I'd bet there is a way of telling the jnlp file to include a properties file as a resource, much in the same way as telling it to include a jar file as a resource.

    That said, how does making a properties file available on the web start server help the end user change database settings? To me that sounds like a job for the preferences API, with maybe some code to force the user to configure the first time they run the program.

    Jonny

  3. #3
    Join Date
    May 2005
    Posts
    20

    Default

    Best I can tell, most everything needs to be jarred up and signed to play nice--but I am not a webstart expert, either. You can pass properties in via the <property> tag as a child of the <resources> element, however, that JNLP is viewable by the end user, so raw DB params like user name, password, etc probably aren't something that would be good to expose. (http://java.sun.com/j2se/1.5.0/docs/...tml#resources). As you alluded to; there should be another way, but I'm at a loss. I have considered using a properties file on the server and retrieving it via my config by extending the PropertyPlaceholderConfigurer to get it's value from a URL vs. a classpath...thoughts?

    I misspoke--the end user of the application does not need to set the config files, rather, the administration of the application would. So, we give our application to company XYZ who configures to hit their DB and environment. The customers of XYZ have no idea (nor concern) about the properties--they just go about their business in the most pleasant manner they can, whistling if the mood strikes.

  4. #4
    Join Date
    Aug 2004
    Location
    San Francisco
    Posts
    423

    Default

    Well, the PropertiesLoaderSupport works with a Resource to specify the location of files. Have you tryed putting a full URL as the location? I've not done this myself but it may well work.

    eg
    Code:
    <bean id="propertyConfigurer"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    	<property name="locations">
    		<list>
    			<value>http://server/application/myapp.properties</value>
    		</list>
    	</property>
    Note that this still would allow someone just to get the properties directly by downloading the file.

    Jonny

  5. #5
    Join Date
    May 2005
    Posts
    20

    Default

    That does work, although as you said, it does allow someone to simply download the props themselves. Until I can uncover another solution, that will have to work. If/when I do, I'll post back. Thanks.

Posting Permissions

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