I don't have first-hand experience with JEE6 namespaces, but default Cayenne 
config loading is based on ClassLoader URLs. You didn't mention what version of 
Cayenne you are using, but assuming 3.1, ClassLoaderResourceLocator.class is 
responsible for XML file location. It does the following to find the right 
ClassLoader:

protected ClassLoader getClassLoader() {
        ClassLoader loader = Thread.currentThread().getContextClassLoader();

        if (loader == null) {
            loader = getClass().getClassLoader();
        }

        if (loader == null) {
            loader = ClassLoader.getSystemClassLoader();
        }

        if (loader == null) {
            throw new IllegalStateException(
                    "Can't detect ClassLoader to use for resouyrce location");
        }

        return loader;
}

What this means is that XML files must be accessible from the ClassLoader that 
loads Cayenne's own classes. BTW, you didn't post the error you are getting 
either. Maybe there are some clues. And finally - if the standard 
ResourceLocator above doesn't work, you can define your own.

Sorry if this answer is too abstract. I guess I'll need to experiment with 
namespaces to better understand class loading patterns involved.

Andrus



On Aug 20, 2013, at 8:58 PM, Rick Bonnett <[email protected]> wrote:
> This is all related to a RESTful service running under Glassfish and 
> developed in Eclipse.
> 
> In my current project, I have all my Cayenne model classes, and a 
> corresponding manager class contained in a separate namespace, say 
> EventModel. I export a jar file for this namespace and use Maven to then 
> include it as a dependency for a separate project, EventService.
> 
> The problem I am running into is getting the Cayenne XML files accessible at 
> runtime when I call the service on Glassfish. They are being included in the 
> jar file for EventModel, which is being deployed when I publish to Glassfish 
> in Eclipse. However, they are not sitting separately outside of the jar file 
> for EvenrtModel. 
> 
> Is it possible to specify the path to the config files based on the jar file? 
> If so how would I go about doing so? Everything related to Cayenne is 
> contained within the same EventModel.jar file.
> 
> Thanks
> Rick

Reply via email to