?
Solved

WebLogic and custom ClassLoader. HELP!!!

Posted on 2003-03-20
31
Medium Priority
?
562 Views
Last Modified: 2012-05-04
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
Comment
Question by:mkaplunov
[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
  • 13
  • 12
  • 3
  • +2
31 Comments
 
LVL 9

Expert Comment

by:Venci75
ID: 8172804
what do you want to load with your custom class loader?
0
 
LVL 1

Author Comment

by:mkaplunov
ID: 8172834
Encrypted class files, which my MyCustomClassLoader would have to decrypt.
0
 
LVL 35

Expert Comment

by:girionis
ID: 8172929
 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 35

Expert Comment

by:girionis
ID: 8172934
0
 
LVL 1

Author Comment

by:mkaplunov
ID: 8172983
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
 
LVL 35

Expert Comment

by:girionis
ID: 8173061
 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
 
LVL 1

Author Comment

by:mkaplunov
ID: 8173079
If that is the case, then how can I put my classloader higher in the hierarchy?
0
 
LVL 35

Expert Comment

by:girionis
ID: 8173098
 Does the section "Declaring the Classloader Hierarchy" not explain it?
0
 
LVL 1

Author Comment

by:mkaplunov
ID: 8173117
I was looking for an example other than that provided by BEA...
0
 
LVL 1

Author Comment

by:mkaplunov
ID: 8173137
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
 
LVL 35

Expert Comment

by:girionis
ID: 8173161
 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
 
LVL 35

Expert Comment

by:girionis
ID: 8173196
 .. so theoretically putting your custom classloader higher in the hierarchy would do since it will have priority over its "children".
0
 
LVL 1

Author Comment

by:mkaplunov
ID: 8173221
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
 
LVL 35

Expert Comment

by:girionis
ID: 8173245
 .. so theoretically putting your custom classloader higher in the hierarchy would do since it will have priority over its "children".
0
 
LVL 35

Expert Comment

by:girionis
ID: 8173334
 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
 
LVL 1

Author Comment

by:mkaplunov
ID: 8173403
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
 
LVL 35

Expert Comment

by:girionis
ID: 8173497
 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
 
LVL 92

Expert Comment

by:objects
ID: 8176971
> I have written a classloader

Whats stopping someone simply using the classloader class directly to decrypt your classes?
0
 
LVL 1

Author Comment

by:mkaplunov
ID: 8177939
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
 
LVL 92

Expert Comment

by:objects
ID: 8177961
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
 
LVL 1

Author Comment

by:mkaplunov
ID: 8178218
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
 
LVL 92

Expert Comment

by:objects
ID: 8178249
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
 
LVL 35

Expert Comment

by:girionis
ID: 8179633
> 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
 
LVL 1

Author Comment

by:mkaplunov
ID: 8179948
I have gotten around this by explicitly using my custom classloader, but now I am getting a SecurityException when I call defineClass method.
0
 
LVL 35

Expert Comment

by:girionis
ID: 8179952
 Can you post the exact error message?
0
 
LVL 1

Author Comment

by:mkaplunov
ID: 8180380
I screwed up somewhere along the way... MyCustomClassLoader is working now.
0
 

Expert Comment

by:modulo
ID: 8360523
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
 
LVL 35

Expert Comment

by:girionis
ID: 8361307
 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
 
LVL 35

Expert Comment

by:girionis
ID: 8361311
 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
 
LVL 1

Author Comment

by:mkaplunov
ID: 8361912
The problem wasn't solved. I had to load classes by explicitly calling MyCustomClassLoader...
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 8373007
Saving this Q as a PAQ and refunding the points to the questionner

Thanks girionis !

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

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!

Question has a verified solution.

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

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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month13 days, 13 hours left to enroll

800 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