Rewrite & Weblogic, useful info and bugfix
Tagged: rewrite weblogic
February 9, 2014 at 1:27 pm #25826
Hi, there is an interesting behavior of Weblogic regarding class scanning – Weblogic does not explode war’s
/WEB-INF/classes/“as-is”, it archives all the classes into a jar and places it in the
/WEB-INF/lib/somewhere in the domain folder structure. This leads to the following:
1. You will need
org.ocpsoft.rewrite.annotation.SCAN_LIB_DIRECTORYset to ‘true’ to get your classes scanned.
2. But even with
SCAN_LIB_DIRECTORYset, you will still get exceptions during deployment, because the Rewrite’s
WebClassesFinderexpects classes to be present in
/WEB-INF/classes/. As one can not turn on
SCAN_LIB_DIRECTORYwith WebClassesFinder disabled, the deployment will end up with an
IllegalArgumentException: “Unable to build path relative to ‘/WEB-INF/classes/’ from:”, followed by a long and crazy deployment path on the server.
I’ve slightly modified
WebClassesFinder.javaso it could handle such situations, works fine both on the GF4 and WL12c, but it needs more intensive tests. The file is attached.
PS: There is another approach, even more simple, few lines of code – a single initial check whether the
/WEB-INF/classes/resource is empty.
- This topic was modified 6 years, 4 months ago by 0swald.
Attachments:February 10, 2014 at 1:25 am #25829
thanks for letting us know about this. This is really very weird behavior.
Could you please explain what you changed WebClassesFinder? The file you attached has been reformatted, so it is very difficult to diff it to see what changed.
ChristianFebruary 10, 2014 at 8:54 am #25830
I’m afraid I wont be able to explain what I’ve changed)) I spent several hours understanding the code in vain, and finally decided to rewrite the recursion from scratch. I think there is a bug in calculating relative path, most probably because it’s always been doing with respect to
/WEB-IN/classes/folder. I just reproduced the recursion and left comments on code variables and their resulting values. As I said, it works correctly for both WL and GF, but definitely requires more thorough testing, involving other server platforms. I’d appreciate it very much if you (we) could solve this issue. Either by testing and implementing my source code or, and this’d be pure WL bugfix, by using your code with a simple preliminary check on
/WEB-IN/classes/right in the
public void findClasses(ClassVisitor visitor)– empty or not, if empty then exit w/o recursion.
Osw.February 10, 2014 at 11:18 am #25831
Just to understand the issue completely. You say that the content of
/WEB-INF/classesis packaged into a JAR and put into
/WEB-INF/libby Weblogic? So do you think that annotation scanning would work if SCAN_LIB_DIRECTORY is active and the WebClassesFinder wouldn’t throw an exception and instead skip the entry if it doesn’t match the
/WEB-INF/classespattern?February 10, 2014 at 11:39 am #25832
No quite. Rewrite wont work at all if SCAN_LIB_DIRECTORY isn’t set to true, but, in addition to SCAN_LIB_DIRECTORY = true, the bug should be fixed,
WebClassesFinderdies with an
Now what WL does. It takes all the client classes, leaving
/WEB-INF/classes/completely empty, and packages them into the
/WEB-INF/lib/_wl_cls_gen.jar, to be exact.
Google says many frameworks are suffering from such behavior, but this is not the case with Rewrite – just make
WebClassesFinderskip empty classes folder, let users know that SCAN_LIB_DIRECTORY should be activated for WL, and we’re all happy))February 10, 2014 at 4:51 pm #25835
Does the file you attached contain the fix? What did you change? (Yes I could download and compare it, sorry!) Any chance we could get you to send a pull request against the rewrite github repo master branch? Should be fairly easy to test against all the servers at that point, since we have a good number of automated builds set up:
LincolnFebruary 10, 2014 at 4:53 pm #25836
Unfortunately we don’t have a Weblogic CI build available (It’s closed source,) so when we merge the change, if you could verify that the change fixes your problem, it would be much appreciated!February 11, 2014 at 1:04 am #25837
Sure, I’ll reformat styling (braces), add more comments and send the pull request. You’ll see that the code is 100% the same when it comes to class handling, but with a different package recursion algorithm.
We dont have a commercial WL CI either, we were just considering to migrate from buggy GF, so the Rewrie was tested as a part of migration tests against the evaluation version of WL – http://www.oracle.com/technetwork/middleware/weblogic/downloads/index.html And yes, there will no problem for me to test the Rewrite against it as many times as needed, I’m mostly worried about other server platforms – Tomcat, JBoss, etc which I’m not familiar with. Hope tests will be ok.
Osw.February 11, 2014 at 10:46 am #25838
Awesome, thank you! What I’ll do is merge your PR, let the tests run on all servers, and then we’ll be able to review the results. I don’t expect any problems, but if we see them, we’ll know we need to make additional changes.
Note that you can actually run the tests on other servers yourself using the following profiles:
mvn clean install -PJBOSS_AS_MANAGED_7.X mvn clean install -PGLASSFISH_MANAGED_3.1 mvn clean install -PTOMEE_MANAGED_1.5 mvn clean install -PWILDFLY_MANAGED_8 mvn clean install -PGLASSFISH_MANAGED_4.0
The servers will automatically be downloaded, then started and stopped for each test. It’s a bit slower, but it works very reliably.February 15, 2014 at 12:59 am #25852
This patch has been merged and released as of 2.0.11.Final
You must be logged in to reply to this topic.