Announcement Announcement Module
Collapse
No announcement yet.
How do I call java.lang.System.setProperties Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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

      Comment

      Working...
      X