Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 585
  • Last Modified:

WebLogic and custom ClassLoader. HELP!!!

People,

I'm stuck here... According to what I have read so far (and please correct me if I am wrong), it is impossible to write a custom class loader and force Weblogic to use this class loader instead of its own. It is possible though to load classes explicitly using your own custom class loader by doing something like this (as far as I can tell):

MyCustomClassLoader cl = new MyCustomClassLoader();
Class c = cl.loadClass(name, resolve);
Object obj = c.newInstance();

Is it at least possible to make Weblogic use MyCustomClassLoader for a specific JAR file or a package? I have read something about weblogic-application.xml, but neither sure that it would work nor could I find any examples how to set it up.

PLEASE HELP!!!

P.S. I can add more points if you find my question to be "extremely difficult".
0
mkaplunov
Asked:
mkaplunov
  • 13
  • 12
  • 3
  • +2
1 Solution
 
Venci75Commented:
what do you want to load with your custom class loader?
0
 
mkaplunovAuthor Commented:
Encrypted class files, which my MyCustomClassLoader would have to decrypt.
0
 
girionisCommented:
 Yes you can write and use your own classloader to load classes. Not sure though how you can set up WebLogic to use your own classloader and not the default one. Have you checked the documentation? Does it say anything?
0
Independent Software Vendors: 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!

 
girionisCommented:
0
 
mkaplunovAuthor Commented:
To girionis:
I have already read this focument and couldn't find how to make Weblogic delegate class loading to my own class loader...
0
 
girionisCommented:
 The delegation of the classloading is left up to the parent on the hierarchy. If the child classloader cannot load the class then it asks the parent classloader to do it. If the parent cannot load the class then it asks the "grandparent" to do it etc. So I guess it is only a matter of putting your classloader higher at the classloading hierarchy. At least this is the case how classloaders work in the VM.
0
 
mkaplunovAuthor Commented:
If that is the case, then how can I put my classloader higher in the hierarchy?
0
 
girionisCommented:
 Does the section "Declaring the Classloader Hierarchy" not explain it?
0
 
mkaplunovAuthor Commented:
I was looking for an example other than that provided by BEA...
0
 
mkaplunovAuthor Commented:
And by the way, according to this document a custom classloader first tries to delegate the loading of any requested class to its parents and only when neither one of them can do it, tries do load the class itself.
0
 
girionisCommented:
 Yes true, sorry. The child classloader asks the parent first and if the parent hasn't already loaded the class or can't load the class then the child loads it. Sorry for the misinformation.
0
 
girionisCommented:
 .. so theoretically putting your custom classloader higher in the hierarchy would do since it will have priority over its "children".
0
 
mkaplunovAuthor Commented:
Theoretically - yes, but I need to find out if this can be done practically and how to do it (if it is possible at all).
0
 
girionisCommented:
 .. so theoretically putting your custom classloader higher in the hierarchy would do since it will have priority over its "children".
0
 
girionisCommented:
 Sorry for the double post.

>  but I need to find out if this can be done practically and how to do it (if it is possible at all).

  What do you mean how you can do it praactically? If you have written a classloader already can you not run it like: java <your classloader> <class to load> ?
0
 
mkaplunovAuthor Commented:
That part is easy. I have written a classloader and made it load the classes I have (via command line). The hard part is to make it work under Weblogic...
0
 
girionisCommented:
 From what I have read from the link above if you edit the weblogic-application.xml file you can define your own classloader. The top-level element includes an optional classloader-structure element. If you do not specify it then the standard classloader is loaded.

  What happens if you specify your own classloader there?
0
 
objectsCommented:
> I have written a classloader

Whats stopping someone simply using the classloader class directly to decrypt your classes?
0
 
mkaplunovAuthor Commented:
To girionis:
Right. Do you have a working example? I would like to see an example where a custom classloader is specified.

To objects:
I've thought of algorithm to prevent that.
0
 
objectsCommented:
Can you share any details of the algorithm. I would think it would be a simple matter to use your custom class loading to extract the decoded bytecode, as these have to be passed to the vm.
Am interested in hearing your approach.
0
 
mkaplunovAuthor Commented:
To objects:
Please don’t think that I’m an ingrate, but I can’t. I’m under contractual obligations… What I can tell you is that you are right, it’s fairly simple to use my custom classloader, but I have made it very hard to obtain the decryption key, even if my code is reverse-engineered. Sorry, but that’s all I can tell now…
0
 
objectsCommented:
Thats fine, I understand.
I just would have thought if WebLogic can access the key, then the WebLogic administrator (who I assume you are protecting against) also can.

Best of luck with it :)
0
 
girionisCommented:
> Right. Do you have a working example? I would like to see an example where a custom classloader is specified.

  No, sorry I do not have an example. What I would do wodl be to experiment with the configuration files until I come up with a solution (save a copy of the original files just in case).
0
 
mkaplunovAuthor Commented:
I have gotten around this by explicitly using my custom classloader, but now I am getting a SecurityException when I call defineClass method.
0
 
girionisCommented:
 Can you post the exact error message?
0
 
mkaplunovAuthor Commented:
I screwed up somewhere along the way... MyCustomClassLoader is working now.
0
 
moduloCommented:
Dear expert(s),

A request has been made to close this Q in CS:
http://www.experts-exchange.com/Community_Support/CleanUp/Q_20590119.html

Without a response in 72 hrs, a moderator will finalize this question by:

 - Saving this Q as a PAQ and refunding the points to the questionner

When you agree or disagree, please add a comment here.

Thank you.

modulo

Community Support Moderator
Experts Exchange
0
 
girionisCommented:
 Speaking from my point of view, since our comments did not help the asker to solve his problem I think it is a fair decision.
0
 
girionisCommented:
 It would also be good for the questionner to let us know the steps he took to solve the problem. Since it will be a PAQ other people will be spending points to get an answer, so it will be good to get an answer worth of the points they spent.
0
 
mkaplunovAuthor Commented:
The problem wasn't solved. I had to load classes by explicitly calling MyCustomClassLoader...
0
 
moduloCommented:
Saving this Q as a PAQ and refunding the points to the questionner

Thanks girionis !

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

  • 13
  • 12
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now