Menu

#35 Missing directory entries in jars

closed-fixed
None
3
2010-05-05
2003-10-07
No

I found proguard to be too strict about entries in jars.

I use the following code to get a base-url for images
in an application which may run via WebStart:

String id = "images/";
URL url = getClass().getResource(id);
if (id != null && url != null) {
imageBase = url.toExternalForm();
logger.info("imageBase: " + imageBase);
}
else {
logger.warn("WARNING: Cannot load images.");
}

This does not work anymore when the jar was processed
with proguard because the directory entry is missing,
allthough all the images in the directory are in place.

My current workaround is to extract the processed jar
and create a new one .

I also noticed that the entries are unsorted, but I
guess this does not have any effect.

BTW: proguard does its job very well !!!!

Related

Bugs: #562

Discussion

  • Eric Lafortune

    Eric Lafortune - 2003-10-09
    • priority: 5 --> 3
     
  • Eric Lafortune

    Eric Lafortune - 2003-10-09
    • assigned_to: nobody --> lafortune
     
  • Eric Lafortune

    Eric Lafortune - 2003-10-09

    Logged In: YES
    user_id=555208

    You're right. Directory entries are always removed from the
    output jar files. They always seemed useless, but clearly
    that's not always true. I'll think about a solution. For
    now, I'll add a note that people should add them manually
    after the processing. I assume the -u option of the jar
    command can be helpful here.

    Eric.

     
  • Eric Lafortune

    Eric Lafortune - 2003-12-19
    • status: open --> open-later
     
  • victor

    victor - 2006-02-17

    Logged In: YES
    user_id=1422395

    I've also run into this problem. Can the priority of this
    particular bug be increased?

     
  • Jonathan Brown

    Jonathan Brown - 2008-04-05

    Logged In: YES
    user_id=2055146
    Originator: NO

    For Spring developers this is a serious bug. In my project we use wildcards [classpath*:com/mycompany/myproject/*-sc.xml] to specify the configuration files to load into our application context. Because the directories are removed from the obfuscated jar, the classloader cannot load the files and we are left with a busted app following the obfuscation process.

    If you're not familiar with Spring, I can provide you with additional details should you need/care for them. However, the crux of the issue is that ClassLoader.getResources(String name) *should* return an Enumeration with at least one value in it when provided a valid package for value of the 'name' parameter.

    With all due respect, the obfuscated jars are corrupt. Would you please expose an option to retain the directories in the archive?

     
  • Eric Lafortune

    Eric Lafortune - 2010-05-05
    • status: open-later --> closed-fixed
     
  • Eric Lafortune

    Eric Lafortune - 2010-05-05

    The option -keepdirectories in recent versions allows to selectively keep directory entries in the output.

     

Log in to post a comment.

MongoDB Logo MongoDB