|
|
Re: Eclipselink with Java Web Start [message #389459 is a reply to message #389425] |
Thu, 11 June 2009 16:24 |
pro3x Messages: 2 Registered: July 2009 |
Junior Member |
|
|
Hello. Thank you for your reply.
I have located cause of my problems. The function in URLArchive class (see
below) causes redownload of jar file that contains persistence.xml file.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public InputStream getEntry(String entryPath) throws IOException
{
URL subEntry = new URL(url, entryPath);
InputStream is = null; stari kod
try {
is = subEntry.openStream();
} catch (IOException ioe) {
// we return null when entry does not exist
}
return is;
}
Since I have only one persistence.xml file I replaced function with
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public InputStream getEntry(String entryPath) throws IOException
{
InputStream is = Thread.currentThread()
.getContextClassLoader().getResourceAsStream(entryPath);
return is;
}
I've changed AchiveFactoryImpl function to use only URLArchive class.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public Archive createArchive(URL url) throws URISyntaxException,
IOException {
logger.entering("ArchiveFactoryImpl", "createArchive", new
Object[]{url});
Archive result = null;
String protocol = url.getProtocol();
logger.logp(Level.FINER, "ArchiveFactoryImpl", "createArchive",
"protocol = {0}", protocol);
// if ("file".equals(protocol)) {
// URI uri = Helper.toURI(url);
//
// File f;
// try {
// // Attempt to create the file with the uri. The
pre-conditions
// // are checked in the constructor and an exception is
thrown
// // if the uri does not meet them.
// f = new File(uri);
// } catch (IllegalArgumentException e) {
// // Invalid uri for File. Go our back up route of using
the
// // path from the url.
// f = new File(url.getPath());
// }
//
// if (f.isDirectory()) {
// // e.g. file:/tmp/a_ear/ejb_jar
// result = new DirectoryArchive(f);
// } else {
// // e.g. file:/tmp/a_ear/lib/pu.jar
// // It's not a directory. Then it must be a jar file.
// result = new JarFileArchive(new JarFile(f));
// }
// } else if ("jar".equals(protocol)) { // NOI18N
// JarURLConnection conn =
JarURLConnection.class.cast(url.openConnection());
// JarEntry je = conn.getJarEntry();
// if (je == null) {
// // e.g. jar:file:/tmp/a_ear/lib/pu.jar!/
// // No entryName specified, hence URL points to a JAR
file and
// // not to any entry inside it. Ideally this should have
been
// // file:/tmp/a_ear/lib/pu.jar,
// // but containers (e.g.) WebLogic return this kind of
URL,
// // so we better handle this in our code to imrove
pluggability.
// // Read the entire jar file.
// result = new JarFileArchive(conn.getJarFile());
// } else if (je.isDirectory()) {
// // e.g. jar:file:/tmp/a_ear/b.war!/WEB-INF/classes/
// // entryName [je.getName()] is a directory
// result = new DirectoryInsideJarURLArchive(url);
// } else {
// // some URL (e.g.)
jar:file:/tmp/a_ear/b.war!/WEB-INF/lib/pu.jar
// // entryName [je.getName()] is a file, so treat this URL
as a
// // URL from which a JAR format InputStream can be
obtained.
// result = new JarInputStreamURLArchive(url);
// }
// } else if (isJarInputStream(url) || false){
// result = new JarInputStreamURLArchive(url);
// } else {
// result = new URLArchive(url);
// }
result = new URLArchive(url);
logger.exiting("ArchiveFactoryImpl", "createArchive", result);
return result;
}
This is just a dirty hack until this is solved. I'dont use Eclipse and
Maven, so I used bundled sources with dependent jar files and compiled it
with Netbeans.
The problem can only be traced in "http://" deployment, because in
"file://" deployment it works fast because it reads local file system.
Should I report this as a bug? I think that the problem is only in Java
1.6 version because of the changes to getResources (I found some post on
the forums that talked about this). I didn't test my application with Java
1.5 so I can't confirm this.
Thank you. Bye.
|
|
|
Powered by
FUDForum. Page generated in 0.03085 seconds