Results 1 to 3 of 3

Thread: How do I call java.lang.System.setProperties

  1. #1

    Default How do I call java.lang.System.setProperties

    I can't figure out how to set a system property from /WEB-INF/applicationContext.xml. I tried the following (taken from the example at http://www.springframework.org/docs/...ctoryBean.html), but I get a java.lang.NullPointerException:

    Code:
    	<bean id="setKerberosProperties" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
    		<property name="targetClass"><value>java.lang.System</value></property>
    		<property name="targetMethod"><value>setProperties</value></property>
    		<property name="arguments">
    			<list>
    				<props>
    					<prop key="java.security.krb5.realm">xx.xx.com</prop>
    					<prop key="java.security.krb5.kdc">yy.yy.com</prop>
    				</props>
    			</list>
    		</property>
    	</bean>
    The interesting thing is that the java.lang.NullPointerException doesn't come from a Spring stack trace, it is comming from Tomcat:

    Code:
    java.io.IOException&#58; java.lang.NullPointerException at
    org.apache.catalina.core.StandardHostDeployer.install&#40;StandardHostDeployer.java&#58;283&#41;null
    ...
    If I remove the "setKerberosProperties" bean stanza from /WEB-INF/applicationContext.xml, the web application deploys fine (but doesn't work since I need to define those two system properties).

    What is the "Spring Way" to set system properties from one's /WEB-INF/applicationContext.xml?

    I need to set these system properties in oreder to get Acegi (and CAS) to use our Kerberos servers for authentication.

    Warmest regards, Matt

  2. #2
    Join Date
    Aug 2004
    Location
    Auburn, AL, USA.
    Posts
    106

    Default

    Take a look at org.springframework.util.Log4jConfigurer it is called by the Log4jWebConfigurer, and seems to be just a static wrapper around a System.setProperty() call so that it can be triggered from a Spring bean. I am not aware of any generic solution for this in Spring; but you could write a custom class that on init (or statically) sets the sytem properties.

  3. #3
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    Matt,

    The easiest way to set these system properties is to either create a simple wrapper like Log4JConfigurer, or just set them when starting tomcat. You need to set a value for the JAVA_OPTS env variable that contains the system property calls.

    Rob

Similar Threads

  1. setFunction(boolean) in stored procedure call
    By pikopepper in forum Data
    Replies: 1
    Last Post: Sep 29th, 2005, 06:33 PM
  2. Replies: 0
    Last Post: Jun 6th, 2005, 01:30 PM
  3. Replies: 2
    Last Post: May 19th, 2005, 09:39 AM
  4. Replies: 1
    Last Post: Feb 10th, 2005, 09:57 AM
  5. Replies: 0
    Last Post: Dec 19th, 2004, 11:50 PM

Posting Permissions

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