[
https://issues.apache.org/jira/browse/OPENEJB-1977?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13666458#comment-13666458
]
Timothy Ward commented on OPENEJB-1977:
---------------------------------------
I've just compared DeploymentLoader in trunk with 1.5.2, and the problem still
appears to be there.
In:
public AppModule load(final File jarFile)
there's a call
if (EjbModule.class.equals(moduleClass)) {
final URL[] urls = new URL[]{ baseUrl };
...
addPersistenceUnits(appModule, baseUrl);
return appModule;
}
in
protected AppModule createAppModule(final File jarFile, final String jarPath)
There's no equivalent call:
// EJB modules
for (final String moduleName : ejbModules.keySet()) {
try {
URL ejbUrl = ejbModules.get(moduleName);
// we should try to use a reference to the temp classloader
if (ClassLoaderUtil.isUrlCached(appModule.getJarLocation(),
ejbUrl)) {
try {
ejbUrl =
ClassLoaderUtil.getUrlCachedName(appModule.getJarLocation(),
ejbUrl).toURI().toURL();
} catch (MalformedURLException ignore) {
}
}
final File ejbFile = toFile(ejbUrl);
final String absolutePath = ejbFile.getAbsolutePath();
final EjbModule ejbModule = createEjbModule(ejbUrl,
absolutePath, appClassLoader);
appModule.getEjbModules().add(ejbModule);
} catch (OpenEJBException e) {
logger.error("Unable to load EJBs from EAR: " + appId + ",
module: " + moduleName + ". Exception: " + e.getMessage(), e);
}
}
Web apps get special handing later, but the EJB persistence.xml URLs are never
copied to the AppModule, and so are "missing"
> ear file deployment failed with persistence.xml in ear file's META-INF folder
> -----------------------------------------------------------------------------
>
> Key: OPENEJB-1977
> URL: https://issues.apache.org/jira/browse/OPENEJB-1977
> Project: OpenEJB
> Issue Type: Bug
> Components: tomee
> Affects Versions: 4.5.1
> Environment: windows
> Reporter: Peter He
> Attachments: jboss-as-kitchensink-ear-ear.ear
>
>
> I have a ear file which can run the other app server but failed in TOMEE when
> it has persistence.xml in ear file's META-INF folder. I look at the source
> code and find the issue.I am sure if it has been fixed in 1.5.2. But I'd like
> to share my fix.
> in DeploymentLoader.java in
> openejb-4.5.0\container\openejb-core\src\main\java\org\apache\openejb\config
> in method: AppModule createAppModule(final File jarFile, final String jarPath)
> after the following line:
> appModule.getAltDDs().putAll(appDescriptors);
> we should convert persistence.xml entry to List<URL>. I add a very simple
> method in the following lines
> private static void convertPersistenceToList(Map map){
> Object url = map.get("persistence.xml");
> if(url!=null && url instanceof URL){
> List<URL> persistences = new ArrayList<URL>();
> persistences.add((URL)url);
> map.put("persistence.xml", persistences);
> }
> }
> and call it like the following lines
> Map<String, Object> altDDs = appModule.getAltDDs();
> altDDs.putAll(appDescriptors);
> convertPersistenceToList(altDDs);
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira