Announcement Announcement Module
Collapse
No announcement yet.
Using Spring without having it in the classpath Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using Spring without having it in the classpath

    Hi together,

    I am a Spring newbie and I want to use the Spring framework within an OpenOffice extension. The difficulty is, that the spring.jar is not found within the classpath. Thus the META-INF/spring.handlers and META-INF/spring.schemes and may be all other configuration files can not be found.

    My question: is there a possibility - may be an interface - to set the path of the spring.jar? A kind of prefix-path for enabling spring to find the needed files?

    If not, I have to patch spring for me. Can anybody tell me were to start? Were can I read about the Spring developer basics?

    Greetings, Tobias

  • #2
    I dont understand ... If you are using Spring, the Spring classes are loaded ... so the Spring jar has to be on the classpath (or you have some very strange things happening with your classloaders ...).

    Could you give us some more informations ?

    Comment


    • #3
      Hi Gehel,

      I can give you some additional information. First, a detailed description of the issue can be found here http://www.openoffice.org/issues/show_bug.cgi?id=80100.

      Second, here the structure of an OpenOffice extension (name of the extension is JudasComponent.oxt):
      JudasComponent.oxt
      |-> lib/
      | |-> spring.jar
      | |-> other relevant jars
      |-> JudasComponent.uno.jar
      | |-> de/
      | | |-> classes of the OpenOffice Extension
      | |-> META-INF/
      | | |-> MANIFEST.MF
      |-> other files, irrelevant for spring

      Within the JudasComponent.uno.jar/META-INF/MANIFEST.MF you find:
      -----%<-----
      Class-Path: lib/spring.jar ...
      -----%<-----
      With this line I get access to the classes in the spring.jar, but it is not added to the JVM of OpenOffice and thus I cannot find the configuration files within the spring.jar.

      Sounds curious? But that is how it works... I hope you understand my problem better. Otherwise, feel free to continue asking.

      Greetings, Tobias

      Comment


      • #4
        Ok, I see the problem. Welcome to Classloader hell ! It seems that ClassPathXmlApplicationContext has a constructor that takes a class as argument :

        clazz - the class to load resources with (basis for the given paths)
        It's not clear from the documentation if it will use this class' classloader, or just its basename. But you could try to give it a class which has a classloader that has access to the Spring jars ...

        Other than that, this is well outside of my expertise ...

        Comment


        • #5
          You might try setting the current thread's classloader. Afaik this will be used by Spring if it is set.

          Comment


          • #6
            Hi Andreas,

            thats it!

            Originally posted by Andreas Senft View Post
            You might try setting the current thread's classloader. Afaik this will be used by Spring if it is set.
            Here the solution: add following lines in the ProtocolHandler.dispatch(URL aURL, PropertyValue[] lArgs) method:
            -----%<-----
            ClassLoader clazzLoader = ProtocolHandler.class.getClassLoader();
            Thread.currentThread().setContextClassLoader(clazz Loader);
            -----%<-----
            This sets the classloader with the classes defined in your MANIFEST.MF of the jar with the ProtocolHandler in the extension.

            Thanks for your help!

            Greetings, Tobias

            Comment

            Working...
            X