> I had expected that since my model classes are located in the jar file, that > the ClassLoader would also find my config files there as well.
cayenne-server.jar should be loaded by the same ClassLoader as your model classes. Andrus On Aug 28, 2013, at 4:02 PM, Rick Bonnett <[email protected]> wrote: > Had to put this one aside for a while, but picking it back up now. > > Yes, this is under 31B2. Here's the exception/stack trace I am receiving. I > had expected that since my model classes are located in the jar file, that > the ClassLoader would also find my config files there as well. > > I'd like to do this without having to write a custom resource locator, so > I'll be trying what I can. Any insights would be helpful.. > Thanks > > org.apache.cayenne.configuration.server.DataDomainLoadException: [v.3.1B2 Feb > 05 2013 20:48:18] Configuration resource "cayenne-mesca_events.xml" is not > found. > at > org.apache.cayenne.configuration.server.DataDomainProvider.createAndInitDataDomain(DataDomainProvider.java:143) > at > org.apache.cayenne.configuration.server.DataDomainProvider.get(DataDomainProvider.java:106) > at > org.apache.cayenne.configuration.server.DataDomainProvider.get(DataDomainProvider.java:60) > at > org.apache.cayenne.di.spi.CustomProvidersProvider.get(CustomProvidersProvider.java:38) > at > org.apache.cayenne.di.spi.FieldInjectingProvider.get(FieldInjectingProvider.java:42) > at > org.apache.cayenne.di.spi.DefaultScopeProvider.get(DefaultScopeProvider.java:49) > at > org.apache.cayenne.di.spi.DefaultInjector.getInstance(DefaultInjector.java:107) > at > org.apache.cayenne.di.spi.FieldInjectingProvider.injectMember(FieldInjectingProvider.java:93) > at > org.apache.cayenne.di.spi.FieldInjectingProvider.injectMembers(FieldInjectingProvider.java:58) > at > org.apache.cayenne.di.spi.FieldInjectingProvider.get(FieldInjectingProvider.java:43) > at > org.apache.cayenne.di.spi.DefaultScopeProvider.get(DefaultScopeProvider.java:49) > at > org.apache.cayenne.di.spi.DefaultInjector.getInstance(DefaultInjector.java:103) > at > org.apache.cayenne.configuration.CayenneRuntime.getContext(CayenneRuntime.java:180) > at > com.mesca.events.manager.EventManager.InitializeCayenne(EventManager.java:25) > > > On Aug 21, 2013, at 3:23 AM, Andrus Adamchik > <[email protected]<mailto:[email protected]>> wrote: > > 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]<mailto:[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 > >
