persistence@glassfish.java.net

Re: entity-persistence CTS Issue - persistence xml with <mapping-file>

From: Mitesh Meswani <mitesh.meswani_at_Sun.COM>
Date: Mon, 13 Mar 2006 14:13:03 -0800

Tom Ware wrote:
> Ok, Thanks, we've got the right logger changed. Here is our error
> message:
>
> [#|2006-03-13T16:28:29.265-0500|FINE|sun-appserver-pe9.0|javax.enterprise.system.core.classloading|_ThreadID=16;_ThreadName=Thread-30;ClassName=PersistenceUnitLoaderImpl$PersistenceUnitInfoImpl;MethodName=initJarFiles;C:\GlassFish\glassfish\domains\domain1\applications\j2ee-apps\blog5\lib\entities_jar;_RequestID=b62677c2-e048-409b-b4b4-d5441b1ecac1;|jarFile
> =
> C:\GlassFish\glassfish\domains\domain1\applications\j2ee-apps\blog5\lib\entities_jar
> does not exist|#]
>
> Currently, the entities.jar file is actually contained within the
> persistence.jar file and therefore doesn't appear directly in the
> GlassFish\glassfish\domains\domain1\applications\j2ee-apps\blog5\lib
> directory. Should we be deploying with entities.jar at the same lavel
> as persistence.jar?
Yes. Thats the correct way to package. From the spec

" One or more JAR files may be specified using the jar-file elements
instead of, or in addition to the
mapping files specified in the mapping-file elements. If specified,
these JAR files will be searched
for managed persistence classes, and any mapping metadata annotations
found on them will be processed,
or they will be mapped using the mapping annotation defaults defined by
this specification.
*Such JAR files are specified relative to the root of the persistence
unit (e.g., utils/myUtils.jar)*."

Thanks,
Mitesh
>
> -Tom
>
> Mitesh Meswani wrote:
>
>> Tom Ware wrote:
>>
>>
>>> Hi Mitesh,
>>>
>>> Looking at the code below, I would expect to see a logged message of
>>> the form: "jarFile = {0} does not exist" in our log if there was an
>>> issue with the URL we are providing.
>>>
>>> We configured logging to be FINE in our admin console and still
>>> cannot see that message. Is there anything special we should to in
>>> order to see that logging message?
>>>
>> The logger used to log that message is classloader. Is that the
>> logger you changed the level for?
>>
>> Thanks,.
>> Mitesh
>>
>>
>>> -Tom
>>>
>>> Mitesh Meswani wrote:
>>>
>>>
>>>> Hi Tom,
>>>>
>>>> I have not yet looked into the ear. Meanwhile, here is the code
>>>> from PersistenceunitInfoImpl that creates the list that
>>>> getJarFileUrls() return.
>>>>
>>>> Thanks,
>>>> Mitesh
>>>>
>>>> private List<URL> _getJarFiles() {
>>>> List<String> jarFileNames = new ArrayList<String>(
>>>> persistenceUnitDescriptor.getJarFiles());
>>>> List<URL> jarFiles = new ArrayList<URL>(jarFileNames.size() +
>>>> 1);
>>>> String absolutePuRoot =
>>>> getAbsolutePuRootFile().getAbsolutePath();
>>>> for (String jarFileName : jarFileNames) {
>>>> String nativeJarFileName = jarFileName.replace('/',
>>>> File.separatorChar);
>>>> // only components are exploded, hence first look for
>>>> original archives.
>>>> File jarFile = new File(new
>>>> File(absolutePuRoot).getParentFile(),
>>>> nativeJarFileName);
>>>> if (!jarFile.exists()) {
>>>> // if the referenced jar is itself a component, then
>>>> // it might have been exploded, hence let's see
>>>> // if that is the case.
>>>> jarFile = new File(new
>>>> File(absolutePuRoot).getParentFile(),
>>>>
>>>> FileUtils.makeFriendlyFileName(nativeJarFileName));
>>>> }
>>>> if (jarFile.exists()) {
>>>> try {
>>>> jarFiles.add(jarFile.toURI().toURL());
>>>> } catch (MalformedURLException e) {
>>>> throw new RuntimeException(e);
>>>> }
>>>> } else {
>>>> // TODO: Should be a caught by verifier.
>>>> PersistenceUnitInfoImpl.logger.logp(Level.FINE,
>>>>
>>>> "PersistenceUnitLoaderImpl$PersistenceUnitInfoImpl",
>>>> "initJarFiles", "jarFile = {0} does not exist",
>>>> jarFile);
>>>> }
>>>> }
>>>> return jarFiles;
>>>> }
>>>>
>>>>
>>>>
>>>> Tom Ware wrote:
>>>>
>>>>
>>>>
>>>>> Hi all,
>>>>>
>>>>> Hopefully someone can help us out. We are debugging a CTS issue
>>>>> in the entity-persistence module and we are seeing the following
>>>>> problem:
>>>>>
>>>>> We are deploying the attached ear file and trying to make use of
>>>>> the persistence unit defined in persistence.jar. When we call
>>>>> getJarFileUrls() on the PersitenceUnitInfo instance we are given
>>>>> in createContainerEntityManagerFactory(), we get an empty list.
>>>>> How build our ear and write our persistence.xml file so the result
>>>>> of getJarFileUrls() includes a URL to entities.jar?
>>>>>
>>>>> -Tom
>>>>>
>>>>>
>