Search code examples
javaspringpropertieswebspherewebsphere-8

accessing websphere 8 shareLib path frim Spring java code


I am making a Spring 4.1.4 REST service and deploying it to websphere application server 8 in my local Windows 7.

I have created a share lib as below and gave its refernce to the respected war file sharedLib configuration

in that location I am keeping my property file as /abc/application.properties

loaction of the abc folder in APPSERVER

CODE: I am trying to load the file as below in spring-rest.xml

<bean id="fileSystemResource" class="org.springframework.core.io.FileSystemResource">

    <constructor-arg value="#{systemProperties['sharedLib']}/abc/">
    </constructor-arg>
</bean>
 <bean id="propertyLoader" name="propertyLoader"     class="com.framework.RuntimeEnvironmentPropertiesConfigurer">

  <property name="propertyLocation" ref="fileSystemResource" /> 
  </bean>

my propertyloader class:which is working fine :::

 public class RuntimeEnvironmentPropertiesConfigurer  extends     PropertyPlaceholderConfigurer implements InitializingBean,RuntimeEnvironmentInterface  {



/** The Environment */
public String environment;

/** The Property Location */
public FileSystemResource propertyLocation;

but sadly this is searching for abc folder in my C:/ drive.

If I keep the following in C:/abc/application.properties..then my application properties are getting fetched.And application is running fineSo no problem in Loading the Bean.

Also giving my dependencies in pom.xml,not sure if I need to add any other dependency.

<properties>
<springframework.version>4.1.4.RELEASE</springframework.version>
<jackson.library>2.7.5</jackson.library>
</properties>
<dependencies>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-core</artifactId>
  <version>4.1.4.RELEASE</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-web</artifactId>
  <version>4.1.4.RELEASE</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-webmvc</artifactId>
  <version>4.1.4.RELEASE</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-jdbc</artifactId>
  <version>3.0.0.RELEASE</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-tx</artifactId>
  <version>3.0.0.RELEASE</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>javax.servlet-api</artifactId>
  <version>3.1.0</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>com.fasterxml.jackson.core</groupId>
  <artifactId>jackson-databind</artifactId>
  <version>2.7.5</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>org.xerial</groupId>
  <artifactId>sqlite-jdbc</artifactId>
  <version>3.8.11.2</version>
  <scope>runtime</scope>
</dependency>
<dependency>
  <groupId>log4j</groupId>
  <artifactId>log4j</artifactId>
  <version>1.2.9</version>
  <scope>compile</scope>
  <exclusions>
    <exclusion>
      <artifactId>mail</artifactId>
      <groupId>javax.mail</groupId>
    </exclusion>
    <exclusion>
      <artifactId>jms</artifactId>
      <groupId>javax.jms</groupId>
    </exclusion>
    <exclusion>
      <artifactId>jmxtools</artifactId>
      <groupId>com.sun.jdmk</groupId>
    </exclusion>
    <exclusion>
      <artifactId>jmxri</artifactId>
      <groupId>com.sun.jmx</groupId>
    </exclusion>
  </exclusions>
</dependency>

But I need to fetch the path from shared lib location. Can anyone help me to point what I am missing? Please provide answer how can I achieve this in Spring .


Solution

  • Java System properties in WebSphere come from the Application Server's Process Definition > Java Virtual Machine > Custom Properties, not from WebSphere variables