oblac / jodd

Jodd! Lightweight. Java. Zero dependencies. Use what you like.
https://jodd.org
BSD 2-Clause "Simplified" License
4.06k stars 724 forks source link

NoClassDefFoundError in AutomagicMadvocConfigurator will break down madvoc #50

Closed zqq90 closed 10 years ago

zqq90 commented 10 years ago

For example, my project has a support named webit.script.support.struts.WebitScriptResult for struts2

AutomagicMadvocConfigurator will find and try to load it, unfortunately, it throws an error

java.lang.NoClassDefFoundError: org/apache/struts2/dispatcher/StrutsResultSupport
at java.lang.ClassLoader.defineClass1(Native Method)
....

now we can avoid this problem:

[automagicMadvocConfigurator]
includedEntries=webit.script.support.jodd.madvoc.*,jodd.*

however, this will be simpler and better if there has a flag to ignore NoClassDefFoundError or not.

javamonkey commented 10 years ago

I get this error while try to integrate beetl into jodd-madvoc. now, i fix it by overloading the method configure(MadvocConfigurator configurator) in WebApplication like this :

public void configure(MadvocConfigurator configurator) {

    AutomagicMadvocConfigurator auto = (AutomagicMadvocConfigurator)configurator;

    auto.setExcludedJars("**/beetl.1.25.03.jar");

    super.configure(configurator);

}

igr commented 10 years ago

You can do as @javamonkey correctly said - to ignore problematic jars (btw, a suggestion: you can use "**/beetl*.jar" pattern to make your code independent from the jar version:). Even better: to include jars only from your app, as that would speedup startup time.

Moreover, there is an option in ClassFinder (i.e. in AutomagicMadvocConfigurator): ignoreExceptions. By default it is set to false, but if you set it to true, your exceptions should be ignored, as you asked for.

Please let me know if that helped!

zqq90 commented 10 years ago

Yes, ignoreExceptions is just what i wanted.

webit-script put all mvc-support(s) in one jar, including Jodd-Madvoc, SpringMVC, Struts2, JFinal, so, excludedJars=**/webit-script**.jar shouldn't been use.

For some catechumen this will be a big trouble for them to try Jodd Madvoc + Webit Script, so, I have renamed ..struts.WebitScriptResult to ..struts.WebitScriptResultSupport.

Thinks for your answer,@jodder,@javamonkey.

igr commented 10 years ago

You are right, for webit-script where you have all in one jar you can also use: excludedEntries and includedEntries instead of jars. This way you can scan only your classes, so that may be also a solution :)

I will leave this issue open not to forget to better document it.