Results 1 to 5 of 5

Thread: Classpath within application

  1. #1
    Join Date
    Apr 2006
    Posts
    3

    Default Classpath within application

    I'm new to Spring and I've been assigned the task of incorporating an application (which isn't a true bean - which may be part of my problem) to use activemq.

    Using:
    <bean id="myApp" class="my.package.MyApp" init-method="start">

    does start the application. But the application uses class.getResource("/MyFile.xml");
    to load various data. It fails this because it looks like the classpath used to start activemq does not seem to get down to the application.

    System.out.println("Classpath = " + System.getProperty ("java.class.path"));

    returns --> Classpath = C:activemq-4.0-M4\bin\../bin/run.jar

    I was wondering if there was anything in Spring that would let me pass the classpath down to the application?

    Thx.

  2. #2
    Join Date
    Dec 2005
    Posts
    269

    Default

    Quote Originally Posted by rbrush
    But the application uses class.getResource("/MyFile.xml");
    to load various data. It fails this because it looks like the classpath used to start activemq does not seem to get down to the application.
    Why don't you let Spring locate that resource for you?

    Quote Originally Posted by rbrush
    I was wondering if there was anything in Spring that would let me pass the classpath down to the application?
    I had a similar problem, where I needed to set the default locale of the JVM.
    I had it like that:

    Code:
      <bean id="localeSetter" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
        <property name="staticMethod" value="java.util.Locale.setDefault"/>
        <property name="arguments">
          <list>
            <value>en_DE</value>
          </list>
        </property>
      </bean>
    you can use the same approach to set something else to the env.

  3. #3
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    "C:activemq-4.0-M4\bin\../bin/run.jar" looks a bit weird. Is the backslash after C: actually missing or is that a typo?

    Resides MyFile.xml in the root of run.jar?

    Regards,
    Andreas

  4. #4
    Join Date
    Apr 2006
    Posts
    3

    Default

    Quote Originally Posted by Andreas Senft
    "C:activemq-4.0-M4\bin\../bin/run.jar" looks a bit weird. Is the backslash after C: actually missing or is that a typo?

    Resides MyFile.xml in the root of run.jar?

    Regards,
    Andreas
    MyFile.xml resides in my own jar (test.jar) - run.jar is the activemq broker. I know my jar is in the initial classpath, else it wouldn't start at all.

    The classpath was a bit of typo - this is copied exactly:

    Classpath = C:\activemq-4.0-M4\bin\../bin/run.jar

  5. #5
    Join Date
    Apr 2006
    Posts
    3

    Default Fix found

    I got a solution from the activemq forum. Had to use the full path for the class

Posting Permissions

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