ClassLoader issue

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

ClassLoader issue

fschmidt
Administrator
If I put the parboiled jars in my jre/lib/ext dir and then try run CalculatorParser1 example, I get the exception below.  The problem is that AsmUtils was loaded with ExtClassLoader while CalculatorParser1 needs to be loaded with AppClassLoader.  Ideally you should get the classloader in Parboiled.createParser() from parserClass and save it somewhere for use later.


Exception in thread "main" java.lang.RuntimeException: Error creating extended parser class: Error at instruction 2: Error loading class 'org.parboiled.examples.calculators.CalculatorParser1' for rule method analysis
        at org.parboiled.Parboiled.createParser(Parboiled.java:58)
        at org.parboiled.examples.calculators.CalculatorParser.main(CalculatorParser.java:46)
        at org.parboiled.examples.calculators.CalculatorParser1.main(CalculatorParser1.java:100)
Caused by: org.objectweb.asm.tree.analysis.AnalyzerException: Error at instruction 2: Error loading class 'org.parboiled.examples.calculators.CalculatorParser1' for rule method analysis
        at org.objectweb.asm.tree.analysis.Analyzer.analyze(Unknown Source)
        at org.parboiled.transform.InstructionGraphCreator.process(InstructionGraphCreator.java:43)
        at org.parboiled.transform.ParserTransformer.runMethodTransformers(ParserTransformer.java:62)
        at org.parboiled.transform.ParserTransformer.extendParserClass(ParserTransformer.java:45)
        at org.parboiled.transform.ParserTransformer.transformParser(ParserTransformer.java:38)
        at org.parboiled.Parboiled.createParser(Parboiled.java:54)
        ... 2 more
Caused by: java.lang.RuntimeException: Error loading class 'org.parboiled.examples.calculators.CalculatorParser1' for rule method analysis
        at org.parboiled.transform.AsmUtils.getClassForInternalName(AsmUtils.java:75)
        at org.parboiled.transform.AsmUtils.isAssignableTo(AsmUtils.java:286)
        at org.parboiled.transform.AsmUtils.isCallOnContextAware(AsmUtils.java:336)
        at org.parboiled.transform.InstructionGraphNode.<init>(InstructionGraphNode.java:57)
        at org.parboiled.transform.RuleMethod.setGraphNode(RuleMethod.java:198)
        at org.parboiled.transform.RuleMethodInterpreter.createNode(RuleMethodInterpreter.java:100)
        at org.parboiled.transform.RuleMethodInterpreter.naryOperation(RuleMethodInterpreter.java:87)
        at org.parboiled.transform.RuleMethodInterpreter.naryOperation(RuleMethodInterpreter.java:37)
        at org.objectweb.asm.tree.analysis.Frame.execute(Unknown Source)
        ... 8 more
Caused by: java.lang.ClassNotFoundException: org.parboiled.examples.calculators.CalculatorParser1
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        at org.parboiled.transform.AsmUtils.getClassForInternalName(AsmUtils.java:73)
        ... 16 more
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ClassLoader issue

mathias
Administrator
I just published parboiled 1.1.4-SNAPSHOT to https://oss.sonatype.org/content/repositories/snapshots/org/parboiled/, which contains a fix for issue #51 (https://github.com/sirthias/parboiled/issues/51).
Would class loading from the context classLoader fix your issue?

Cheers,
Mathias

---
[hidden email]
http://www.parboiled.org

On 20.11.2012, at 01:22, fschmidt [via parboiled users] <[hidden email]> wrote:

> If I put the parboiled jars in my jre/lib/ext dir and then try run CalculatorParser1 example, I get the exception below.  The problem is that AsmUtils was loaded with ExtClassLoader while CalculatorParser1 needs to be loaded with AppClassLoader.  Ideally you should get the classloader in Parboiled.createParser() from parserClass and save it somewhere for use later.
>
>
> Exception in thread "main" java.lang.RuntimeException: Error creating extended parser class: Error at instruction 2: Error loading class 'org.parboiled.examples.calculators.CalculatorParser1' for rule method analysis
>         at org.parboiled.Parboiled.createParser(Parboiled.java:58)
>         at org.parboiled.examples.calculators.CalculatorParser.main(CalculatorParser.java:46)
>         at org.parboiled.examples.calculators.CalculatorParser1.main(CalculatorParser1.java:100)
> Caused by: org.objectweb.asm.tree.analysis.AnalyzerException: Error at instruction 2: Error loading class 'org.parboiled.examples.calculators.CalculatorParser1' for rule method analysis
>         at org.objectweb.asm.tree.analysis.Analyzer.analyze(Unknown Source)
>         at org.parboiled.transform.InstructionGraphCreator.process(InstructionGraphCreator.java:43)
>         at org.parboiled.transform.ParserTransformer.runMethodTransformers(ParserTransformer.java:62)
>         at org.parboiled.transform.ParserTransformer.extendParserClass(ParserTransformer.java:45)
>         at org.parboiled.transform.ParserTransformer.transformParser(ParserTransformer.java:38)
>         at org.parboiled.Parboiled.createParser(Parboiled.java:54)
>         ... 2 more
> Caused by: java.lang.RuntimeException: Error loading class 'org.parboiled.examples.calculators.CalculatorParser1' for rule method analysis
>         at org.parboiled.transform.AsmUtils.getClassForInternalName(AsmUtils.java:75)
>         at org.parboiled.transform.AsmUtils.isAssignableTo(AsmUtils.java:286)
>         at org.parboiled.transform.AsmUtils.isCallOnContextAware(AsmUtils.java:336)
>         at org.parboiled.transform.InstructionGraphNode.<init>(InstructionGraphNode.java:57)
>         at org.parboiled.transform.RuleMethod.setGraphNode(RuleMethod.java:198)
>         at org.parboiled.transform.RuleMethodInterpreter.createNode(RuleMethodInterpreter.java:100)
>         at org.parboiled.transform.RuleMethodInterpreter.naryOperation(RuleMethodInterpreter.java:87)
>         at org.parboiled.transform.RuleMethodInterpreter.naryOperation(RuleMethodInterpreter.java:37)
>         at org.objectweb.asm.tree.analysis.Frame.execute(Unknown Source)
>         ... 8 more
> Caused by: java.lang.ClassNotFoundException: org.parboiled.examples.calculators.CalculatorParser1
>         at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
>         at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
>         at org.parboiled.transform.AsmUtils.getClassForInternalName(AsmUtils.java:73)
>         ... 16 more
>
>
> If you reply to this email, your message will be added to the discussion below:
> http://users.parboiled.org/ClassLoader-issue-tp4024098.html
> To start a new topic under parboiled users, email [hidden email]
> To unsubscribe from parboiled users, click here.
> NAML

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ClassLoader issue

fschmidt
Administrator
I tried 1.1.4-SNAPSHOT and now I get the exception below.  It should be very easy for you to reproduce this, just put the parboiled jars into jre/lib/ext and try to run your CalculatorParser1 example.


Exception in thread "main" java.lang.RuntimeException: Error creating extended parser class: Error at instruction 2: null
        at org.parboiled.Parboiled.createParser(Parboiled.java:58)
        at org.parboiled.examples.calculators.CalculatorParser.main(CalculatorParser.java:46)
        at org.parboiled.examples.calculators.CalculatorParser1.main(CalculatorParser1.java:100)
Caused by: org.objectweb.asm.tree.analysis.AnalyzerException: Error at instruction 2: null
        at org.objectweb.asm.tree.analysis.Analyzer.analyze(Unknown Source)
        at org.parboiled.transform.InstructionGraphCreator.process(InstructionGraphCreator.java:43)
        at org.parboiled.transform.ParserTransformer.runMethodTransformers(ParserTransformer.java:62)
        at org.parboiled.transform.ParserTransformer.extendParserClass(ParserTransformer.java:45)
        at org.parboiled.transform.ParserTransformer.transformParser(ParserTransformer.java:38)
        at org.parboiled.Parboiled.createParser(Parboiled.java:54)
        ... 2 more
Caused by: java.lang.NullPointerException
        at java.lang.Class.isAssignableFrom(Native Method)
        at org.parboiled.transform.AsmUtils.isAssignableTo(AsmUtils.java:294)
        at org.parboiled.transform.AsmUtils.isCallOnContextAware(AsmUtils.java:344)
        at org.parboiled.transform.InstructionGraphNode.<init>(InstructionGraphNode.java:57)
        at org.parboiled.transform.RuleMethod.setGraphNode(RuleMethod.java:198)
        at org.parboiled.transform.RuleMethodInterpreter.createNode(RuleMethodInterpreter.java:100)
        at org.parboiled.transform.RuleMethodInterpreter.naryOperation(RuleMethodInterpreter.java:87)
        at org.parboiled.transform.RuleMethodInterpreter.naryOperation(RuleMethodInterpreter.java:37)
        at org.objectweb.asm.tree.analysis.Frame.execute(Unknown Source)
        ... 8 more
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ClassLoader issue

mathias
Administrator
Hmm… those ClassLoader issues really are a pain.
Unfortunately I don't have time right now to really dig into this.
However, if you'd like to submit a pull request, I'd be happy to pull in any fixes you come up with wrt. this problem.

Cheers,
Mathias

---
[hidden email]
http://www.parboiled.org

On 22.11.2012, at 23:44, fschmidt [via parboiled users] <[hidden email]> wrote:

> I tried 1.1.4-SNAPSHOT and now I get the exception below.  It should be very easy for you to reproduce this, just put the parboiled jars into jre/lib/ext and try to run your CalculatorParser1 example.
>
>
> Exception in thread "main" java.lang.RuntimeException: Error creating extended parser class: Error at instruction 2: null
>         at org.parboiled.Parboiled.createParser(Parboiled.java:58)
>         at org.parboiled.examples.calculators.CalculatorParser.main(CalculatorParser.java:46)
>         at org.parboiled.examples.calculators.CalculatorParser1.main(CalculatorParser1.java:100)
> Caused by: org.objectweb.asm.tree.analysis.AnalyzerException: Error at instruction 2: null
>         at org.objectweb.asm.tree.analysis.Analyzer.analyze(Unknown Source)
>         at org.parboiled.transform.InstructionGraphCreator.process(InstructionGraphCreator.java:43)
>         at org.parboiled.transform.ParserTransformer.runMethodTransformers(ParserTransformer.java:62)
>         at org.parboiled.transform.ParserTransformer.extendParserClass(ParserTransformer.java:45)
>         at org.parboiled.transform.ParserTransformer.transformParser(ParserTransformer.java:38)
>         at org.parboiled.Parboiled.createParser(Parboiled.java:54)
>         ... 2 more
> Caused by: java.lang.NullPointerException
>         at java.lang.Class.isAssignableFrom(Native Method)
>         at org.parboiled.transform.AsmUtils.isAssignableTo(AsmUtils.java:294)
>         at org.parboiled.transform.AsmUtils.isCallOnContextAware(AsmUtils.java:344)
>         at org.parboiled.transform.InstructionGraphNode.<init>(InstructionGraphNode.java:57)
>         at org.parboiled.transform.RuleMethod.setGraphNode(RuleMethod.java:198)
>         at org.parboiled.transform.RuleMethodInterpreter.createNode(RuleMethodInterpreter.java:100)
>         at org.parboiled.transform.RuleMethodInterpreter.naryOperation(RuleMethodInterpreter.java:87)
>         at org.parboiled.transform.RuleMethodInterpreter.naryOperation(RuleMethodInterpreter.java:37)
>         at org.objectweb.asm.tree.analysis.Frame.execute(Unknown Source)
>         ... 8 more
>
>
> If you reply to this email, your message will be added to the discussion below:
> http://users.parboiled.org/ClassLoader-issue-tp4024098p4024101.html
> To start a new topic under parboiled users, email [hidden email]
> To unsubscribe from parboiled users, click here.
> NAML

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ClassLoader issue

fschmidt
Administrator
The problem is just that you forgot to assign to clazz on AsmUtils.java:80.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ClassLoader issue

mathias
Administrator
Ok, thanks.
I just published 1.1.5-SNAPSHOT to sonatype containing this fix.
Can you check, whether this solves your problem?

Cheers,
Mathias

---
[hidden email]
http://www.parboiled.org

On 29.11.2012, at 09:35, fschmidt [via parboiled users] <[hidden email]> wrote:

> The problem is just that you forgot to assign to clazz on AsmUtils.java:80.
>
>
> If you reply to this email, your message will be added to the discussion below:
> http://users.parboiled.org/ClassLoader-issue-tp4024098p4024110.html
> To start a new topic under parboiled users, email [hidden email]
> To unsubscribe from parboiled users, click here.
> NAML

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ClassLoader issue

fschmidt
Administrator
mathias wrote
Ok, thanks.
I just published 1.1.5-SNAPSHOT to sonatype containing this fix.
Can you check, whether this solves your problem?
Yes that fixes it, thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ClassLoader issue

Sonson
I get the same exception when using pegdown. Would it be possible to publish parboiled 1.1.5 and a new pegdown release 1.2.2 with refreshed dependencies? Thanks!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ClassLoader issue

mathias
Administrator
Yes,
 I will do this soon.

Cheers,
Mathias

---
[hidden email]
http://www.parboiled.org

On 15.01.2013, at 12:31, Bernhard Berger [via parboiled users] <[hidden email]> wrote:

>
>
> I get the same exception when using pegdown. Would it be possible to publish
> parboiled 1.1.5 and a new pegdown release 1.2.2 with refreshed dependencies?
> Thanks!
>
>
>
> _______________________________________________
> If you reply to this email, your message will be added to the discussion below:
> http://users.parboiled.org/ClassLoader-issue-tp4024098p4024133.html
> To start a new topic under parboiled users, email [hidden email]
> To unsubscribe from parboiled users, visit
Loading...