1

I would like to load a context file from a jar file. For example, I want to create a data access jar file - holds entity and dao objects and it would have a spring context file: dataaccess-context.xml.

Now in my Web application I want to be able to access this jar using the context file.

I have placed the following in my web.xml:

<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>
    classpath:com/vsg/dataccess/framework/context/dataaccess-context.xml
  </param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

When I do this I get a file not found exception. The jar file is placed into the WEB-INF/lib directory.

Now running from with in Eclipse using JBoss I placed the spring jar files into the class path this did not solve the issue.

Any direction, I have read several links and so forth here and google and it all seems to be possible so not sure what I am doing incorrect here.

1 Answer 1

4

It is possible and it should be working for you.

Maybe is just some error in your configuration file. Try this:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        classpath:/com/vsg/dataccess/framework/context/dataaccess-context.xml
    </param-value>
</context-param>

See that the path starts with a slash.

Sign up to request clarification or add additional context in comments.

1 Comment

Did a complete clean of the environment and using the above suggestion it all works now

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.