i want to use same ehcache.xml for different projects

Posted on 2012-08-20
Last Modified: 2012-09-04
i want to use same ehcache.xml for different projects

Where i put the ehcache.xml common for two projects

please help me
Question by:stmani2005
    LVL 26

    Assisted Solution

    There's no magic answer.  You'll have to pick a place you think is reasonable for both projects.  If they are usually installed together, you could have one of them read from the location of the other project.  For example, put your xml file in the WEB-INF directory of ProjectA and have ProjectB read from ProjectA's xml file location.

    Or pick a separate location.  There are problems with all of these.  Some people create a program invoked at install time to check if the required xml file exists in a reasonable location, and configures the new project to use the existing file.  That's more work, and usually means you can't rely solely on a war installation (if you are doing that).

    So as you might expect, the solution is really up to you.  No magic.
    LVL 8

    Author Comment


    import net.sf.ehcache.CacheManager;
    import net.sf.ehcache.Ehcache;
    * A simple example Java client which uses the built-in
    * @author BryantR
    * @author Greg Luck
    public class ehCacheClientParentCall{
    private static String TABLE_COLUMN_BASE =
    private static String TABLE_COLUMN_ELEMENT =
    private static Ehcache widgetCache;
    * Creates a new instance of EHCacheREST
    public ehCacheClientParentCall() {
    public static void main(String[] args) {
           CacheManager manager = new CacheManager(TABLE_COLUMN_BASE);
            widgetCache = manager.getEhcache( "widgets" );
    i have error when i pick other project
    LVL 8

    Author Comment

    the error is

    Exception in thread "main" net.sf.ehcache.CacheException: Error configuring from http:\localhost:8080\Parent\ehcache.xml. Initial cause was http:\localhost:8080\Parent\ehcache.xml (The filename, directory name, or volume label syntax is incorrect)
          at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(
          at net.sf.ehcache.CacheManager.parseConfiguration(
          at net.sf.ehcache.CacheManager.init(
          at net.sf.ehcache.CacheManager.<init>(
    Caused by: http:\localhost:8080\Parent\ehcache.xml (The filename, directory name, or volume label syntax is incorrect)
          at Method)
          at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(
          ... 4 more
    LVL 26

    Accepted Solution

    Do you mean that code works within one project?

    In that case, it's probably the "localhost" part.  You have to have ea way to identify the 2 different projects in your web server.  Can you use a url in a browser to get the xml file?  If not, then you don't have a correct configuration.

    In my experience, it usually works better not to use "localhost" but to have a real domain name.  If you are developing on a machine without a public host name for your server, then you put the alias in your hosts file.

    Work on being able to get the xml file from a browser and that will give you a url which works for projecta and projectb.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    maxMirror challenge 10 70
    Core java. Please help me catch a bug. 5 52
    Updating Java 9 62
    ArrayLists in ArrayLists/HashMaps? 4 30
    After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
    Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
    Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
    Video by: Michael
    Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now