esper icon indicating copy to clipboard operation
esper copied to clipboard

7.0.0: Janino packages are not included into OSGi Import-Package

Open dpishchukhin opened this issue 8 years ago • 17 comments

com.espertech.esper.client.ConfigurationException: Failed to load Janino compiler class 'org.codehaus.janino.SimpleCompiler': org.codehaus.janino.SimpleCompiler not found by com.espertech.esper [16] at com.espertech.esper.codegen.compile.CodegenCompilerJanino.setupJanino(CodegenCompilerJanino.java:142) [16:com.espertech.esper:7.0.0] at com.espertech.esper.codegen.compile.CodegenCompilerJanino.<init>(CodegenCompilerJanino.java:59) [16:com.espertech.esper:7.0.0] at com.espertech.esper.core.service.EPServicesContextFactoryDefault.makeEngineImportService(EPServicesContextFactoryDefault.java:536) [16:com.espertech.esper:7.0.0]

dpishchukhin avatar Dec 13 '17 10:12 dpishchukhin

Can be fixed by disabling byte code gen

bernhardttom avatar Dec 13 '17 12:12 bernhardttom

agree but I would like to test byte code gen with OSGi.

dpishchukhin avatar Dec 13 '17 18:12 dpishchukhin

Feel free to add to the manifest. They are an optional dependency and if there will be added to the manifest they become a required dependency in OSGi.

bernhardttom avatar Dec 13 '17 18:12 bernhardttom

I tried to create the Manifest to the janino jar (two of them) but they have many dependencies to ester that could not be added. Any success to create the manifest?

rlegorreta avatar Apr 10 '18 16:04 rlegorreta

What are the "dependencies to ester"???

bernhardttom avatar Apr 10 '18 22:04 bernhardttom

Thanks for your promptly answer. When I created a Manifest file for janino.3.0.7.jar and run it inside Equinox (i.e. Liferay DXP) it is installed correctly, but at run-time the OSGi container sends errors for class not found because there is no import package inside the manifest (for example import for com.espertech.esper.epl.core.resultset.core, com.espertech.esper.collection, and many more). The same happens for janino-common-compiler.3.07.jar but the dependencies are less. For example: inside the janino SimpleCompiler class it is called some Esper classes.

Or maybe I'm doing something wrong. Do you need the trace log?

rlegorreta avatar Apr 11 '18 00:04 rlegorreta

You could generate the manifest or import all Janino packages.

bernhardttom avatar Apr 11 '18 02:04 bernhardttom

I already import the janino package in Esper, it advances since now Esper recognize janino classes. But the error is inside the janino packages (e.g., SimpleCompiler class) that calls Esper classes (I don't know how, if it is by reflection or some interface implementation, I need to check the source code) and after adding many Esper package in janino I could not advance more. This is a circular class dependency that I don't understand yet. I'm going to start all over again, because maybe I´m doing something wrong. Your advise should work. If you solved the issue please let me know and send me the jars.

rlegorreta avatar Apr 11 '18 14:04 rlegorreta

I managed to use Esper with Janino and OSGi

Janino bnd:

Export-Package: org.codehaus.janino.*;version=3.0.7
Import-Package: org.apache.tools.ant*;resolution:=optional, *

Esper bnd:

Export-Package: com.espertech.esper.*;version=7.0.0
Import-Package: com.sun.org.apache.xerces.internal.*;resolution:=optional, \
    sun.reflect.*;resolution:=optional, \
    org.codehaus.janino;version="[3,4)", \
    *

dpishchukhin avatar Apr 11 '18 14:04 dpishchukhin

Excellent

I wil try with these bnd files.

Ricardo.

On Apr 11, 2018, at 9:25 AM, Dmytro Pishchukhin [email protected] wrote:

I managed to use Esper with Janino and OSGi

Janino bnd:

Export-Package: org.codehaus.janino.;version=3.0.7 Import-Package: org.apache.tools.ant;resolution:=optional, * Esper bnd:

Export-Package: com.espertech.esper.;version=7.0.0 Import-Package: com.sun.org.apache.xerces.internal.;resolution:=optional,
sun.reflect.*;resolution:=optional,
org.codehaus.janino;version="[3,4)",
* — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/espertechinc/esper/issues/97#issuecomment-380471276, or mute the thread https://github.com/notifications/unsubscribe-auth/AE-bwOaohQGEMAuLCDPOp2r2ho6dGSOoks5tnhJRgaJpZM4RAT1h.

rlegorreta avatar Apr 11 '18 17:04 rlegorreta

I tried with these and but I’m still having problems.

This is the trace that I get:

Caused by: org.codehaus.commons.compiler.CompileException: Line 5, Column 7: A class 'com.espertech.esper.collection.TransformEventIterator' could not be found at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:11672) at org.codehaus.janino.UnitCompiler.getSingleTypeImport(UnitCompiler.java:10047) at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:408) at org.codehaus.janino.UnitCompiler.access$400(UnitCompiler.java:212) at org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:390) at org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:385) at org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:1405) at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:385) at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:357) at org.codehaus.janino.SimpleCompiler.cook(SimpleCompiler.java:234) at org.codehaus.janino.SimpleCompiler.compileToClassLoader(SimpleCompiler.java:446) at org.codehaus.janino.SimpleCompiler.cook(SimpleCompiler.java:213) at org.codehaus.janino.SimpleCompiler.cook(SimpleCompiler.java:204) at org.codehaus.commons.compiler.Cookable.cook(Cookable.java:50) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.espertech.esper.codegen.compile.CodegenCompilerJanino.compileClass(CodegenCompilerJanino.java:113)

This is from janino is calls some Esper classes !!

Any idea how to solve this dependency?

Ricardo

On Apr 11, 2018, at 9:25 AM, Dmytro Pishchukhin [email protected] wrote:

I managed to use Esper with Janino and OSGi

Janino bnd:

Export-Package: org.codehaus.janino.;version=3.0.7 Import-Package: org.apache.tools.ant;resolution:=optional, * Esper bnd:

Export-Package: com.espertech.esper.;version=7.0.0 Import-Package: com.sun.org.apache.xerces.internal.;resolution:=optional,
sun.reflect.*;resolution:=optional,
org.codehaus.janino;version="[3,4)",
* — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/espertechinc/esper/issues/97#issuecomment-380471276, or mute the thread https://github.com/notifications/unsubscribe-auth/AE-bwOaohQGEMAuLCDPOp2r2ho6dGSOoks5tnhJRgaJpZM4RAT1h.

rlegorreta avatar Apr 12 '18 15:04 rlegorreta

This is because janino que java reflection tries to use several esper classes (not just the TaransformEventIterator but many more) and janino bunds does not have any import package for esper (so it is a circular dependency). Any idea how can I solve this problem?

rlegorreta avatar Apr 17 '18 21:04 rlegorreta

I think Janino uses the thread context classloader, can you trying setting it?

bernhardttom avatar Apr 17 '18 22:04 bernhardttom

How do I do that

rlegorreta avatar Apr 17 '18 22:04 rlegorreta

If you refer something like this: epService.getEPAdministrator() .getConfiguration() .getTransientConfiguration( ).put(ClassForNameProvider.NAME, new ClassForNameProvider() { public Class classForName(String className) throws ClassNotFoundException { ....... } });

It didn't work since this is for Esper thread context classloadar and not janino. I think the problem is inside janino.

rlegorreta avatar Apr 17 '18 23:04 rlegorreta

Thread.currentThread().setContextClassLoader(...);

bernhardttom avatar Apr 17 '18 23:04 bernhardttom

Thanks for your help!! Now it works: When I add Thread.currentThread().setContextClassLoader(...); and see what Esper classes could not be loaded I added and import statement in the java class and they work... so I realized what was the error, it was not to set the class loader but:

In my Liferay portel bundle bnd file I defined de Import packages as '*' so it just add the packages that are referenced 'at compile time'. Since janino uses the Esper classes with classLoader (i.e., at run-time) it never adds the correct Import packages.

So the solution was to include as many Esper Import packages in my bnd portlet Liferay bundle and voila it works!!!! So finally I did not need to set the class loader, but if gave me the right debug idea to catch what was the error.

Thanks for your help !!

rlegorreta avatar Apr 18 '18 15:04 rlegorreta