Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Dynamic Class Loading "THIS IS A TOUGH ONE"

Posted on 2004-08-23
21
Medium Priority
?
247 Views
Last Modified: 2010-03-31
My application is deployed in a jar file.  During startup, the app needs to locate this jar file or the root directory to where it was extracted.  I will spare you the details as to why we do this.

The way we do this is by getting the ClassLoader object of a regular class found in the jar file.  We then use the getResource() method of the ClassLoader object in order to get the absolute path of the class.  From this path, we can extract the absolute path of the jar file or the root of where the jar file was extracted.

However, in this certain environment, I am not getting the absolute path when calling getResource().  Instead I get this:

classloader:/com/????/????/????.class

where the /com is the first directory in the package structure found in the jar file.

The environment is Oracle 9i application server, Linux OS with German locale.

Can anyone tell me why getResource() doesn't give me the absolute path of the loaded class?  It works fine with all of environments.

Thanks
0
Comment
Question by:leobaz2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
  • 3
  • +3
21 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 11873035
I'm not sure what you're trying to do is possible. As you know, these urls are based on class loader contexts rather than the underlying file system. It may be easier just to get the app to scan the file system. Are you certain you need to know these absolute paths?
0
 

Author Comment

by:leobaz2
ID: 11873143
Yes.  This has been working for many months.  I don't know why it is doing this now.
0
 
LVL 1

Expert Comment

by:SlimHealer
ID: 11873747
Probably there is an accented German character in the pathname where you have been extracted.  Often the parsers barf when they see unexpected UTF8 characters in paths.

Try extracting things to a more "vanilla" named folder; I bet it starts working again.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:leobaz2
ID: 11873807
The path doesn't have any German characters in it.  It look like a normal path with just english characters in it.
0
 
LVL 92

Expert Comment

by:objects
ID: 11877007
> Can anyone tell me why getResource() doesn't give me the absolute path of the loaded class?

are you sure its not?
What happens when you try to access the returned url?
0
 
LVL 9

Assisted Solution

by:Venci75
Venci75 earned 450 total points
ID: 11878989
>> classloader:/com/????/????/????.class
This value is specific to the class loader implementation. As objects metioned - this is probably a valid path, which uses the 'classloader' protocol, implemented by your Oracle 9i app server.
BTW: Why do you need to know the path to the .jar file?
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 1050 total points
ID: 11880677
>>- this is probably a valid path, which uses the 'classloader' protocol, implemented by your Oracle 9i app server.

And is an example of what i was saying earlier - you can't rely on the returned url being resolvable in terms of the file system
0
 

Author Comment

by:leobaz2
ID: 11882534
Thanks guys.  I understand now.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 11883072
8-)
0
 
LVL 92

Expert Comment

by:objects
ID: 11887240
???? What was wrong with my comment that the path perhaps was valid? ????
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 11887459
Where does 'valid' or 'invalid' come into it? All that matters is whether it's locatable in the file system
0
 
LVL 92

Expert Comment

by:objects
ID: 11887497
valid in that it points to the loaded class


0
 
LVL 86

Expert Comment

by:CEHJ
ID: 11887524
>>valid in that it points to the loaded class

But that's not of any interest. leobaz2 is aftera filesystem resolution
0
 
LVL 92

Expert Comment

by:objects
ID: 11887558
>  leobaz2 is aftera filesystem resolution

And that is???
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 11887571
Locating the absolute path of the class in the filesystem
0
 
LVL 92

Expert Comment

by:objects
ID: 11887624
So where did you explain how to do that :-D
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 11887688
I think you've rather missed the point ;-)
0
 
LVL 92

Expert Comment

by:objects
ID: 11887744
Not really, you're just being argumentative (again) :)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 11940091
>>What you had to do here to answer? Hm?

I'm sorry - i was just trying to explain that it was nothing to do with validity
0
 
LVL 20

Expert Comment

by:Venabili
ID: 11940128
If it is so,it is the Asker work. Not the work of the other experts. :)
So - do we have a deal that all this critising and blah-blah will stop? So we really have a good team  of experts in this area? Which show that  we are a team?

Venabili
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question