Tefloneddie
New Member
I'm trying to compile in-memory a class that implements an interface.I have an interface named CacheRule (in com/vpfw/proxy/logicRules/CacheRule.class).I have a class named \[code\]CacheRuleBean\[/code\] that I compile in-memory.If this class does not implement \[code\]CacheRule\[/code\], compilations works. But if this class implements \[code\]CacheRule\[/code\], then the error is:\[code\]java.lang.NoClassDefFoundError: com/vpfw/proxy/logicRules/CacheRule (wrong name: com/vpfw/proxy/logicRules/CacheRuleBean)\[/code\]Curiously, if I perform this compilation inside Eclipse, works.But when I execute it from Tomcat, I get the previous error.This is the code for the \[code\]CacheRule\[/code\] interface:\[code\]package com.vpfw.proxy.logicRules;public interface CacheRule{ void executeRule();}\[/code\]This is the code for \[code\]CacheRuleBean\[/code\]:\[code\]package com.vpfw.proxy.logicRules;import com.vpfw.proxy.logicRules.CacheRule;public class CacheRuleBean implements CacheRule{ public void executeRule() {}}\[/code\]And the call to compile is:\[code\]String[] compilationOptions = { "-cp", classDir };return (new CompilerService().compile("com.vpfw.proxy.logicRules.CacheRuleBean", source, compilationOptions));\[/code\]Where
- \[code\]classDir\[/code\] is the directory \[code\]/home/app/WEB-INF/classes\[/code\] that contains the \[code\]com\[/code\] folder of this project (classPath is correct, If I add another classes of this project as imports in \[code\]CacheRuleBean\[/code\], compile ok).
- The name of the class I use is \[code\]com.vpfw.proxy.logicRules.CacheRuleBean\[/code\].
- \[code\]source\[/code\] is the source code of \[code\]CacheRuleBean\[/code\].
- \[code\]CompilerService\[/code\] is my implementation of compiler API, which works perfectly with all classes except those that implement an interface.