Solr
  1. Solr
  2. SOLR-3260

Improve exception handling / logging for ScriptTransformer.init()

    Details

      Description

      This came up on the user-list. ScriptTransformer logs the same "need a >=1.6 jre" message for several problems, making debugging difficult for users.

        Activity

        Hide
        James Dyer added a comment -

        I will commit this shortly.

        Show
        James Dyer added a comment - I will commit this shortly.
        Hide
        James Dyer added a comment -

        committed.

        Trunk: r1302972
        Branch_3x: r1303042

        Show
        James Dyer added a comment - committed. Trunk: r1302972 Branch_3x: r1303042
        Hide
        Steve Rowe added a comment -

        Hi James,

        The branch_3x Maven Jenkins job is now failing in TestScriptTransformer as a result of your commit from this issue, e.g. https://builds.apache.org/job/Lucene-Solr-Maven-3.x/432/testReport/.

        I'd like to expand the set of exception message checked in the JUnit assumptions that allow tests to be skipped to include the two new messages your changes on this issue introduced:

        Currently:

        } catch (DataImportHandlerException e) {
          assumeFalse("JRE does not contain a JavaScript engine (OpenJDK)", e.getMessage().startsWith("<script> can be used only in java 6 or above"));
          throw e;
        }
        

        Expanded:

        } catch (DataImportHandlerException e) {
          assumeFalse("JRE does not contain a JavaScript engine (OpenJDK)", 
                      e.getMessage().startsWith("<script> can be used only in java 6 or above")
                      || e.getMessage().startsWith("Cannot load Script Engine for language:")
                      || e.getMessage().startsWith("'eval' failed with language:"));
          throw e;
        }
        

        What do you think?

        Show
        Steve Rowe added a comment - Hi James, The branch_3x Maven Jenkins job is now failing in TestScriptTransformer as a result of your commit from this issue, e.g. https://builds.apache.org/job/Lucene-Solr-Maven-3.x/432/testReport/ . I'd like to expand the set of exception message checked in the JUnit assumptions that allow tests to be skipped to include the two new messages your changes on this issue introduced: Currently: } catch (DataImportHandlerException e) { assumeFalse("JRE does not contain a JavaScript engine (OpenJDK)", e.getMessage().startsWith("<script> can be used only in java 6 or above")); throw e; } Expanded: } catch (DataImportHandlerException e) { assumeFalse("JRE does not contain a JavaScript engine (OpenJDK)", e.getMessage().startsWith("<script> can be used only in java 6 or above") || e.getMessage().startsWith("Cannot load Script Engine for language:") || e.getMessage().startsWith("'eval' failed with language:")); throw e; } What do you think?
        Hide
        James Dyer added a comment -

        That is probably the right thing to do. If its using a JRE that supports the class "javax.script.ScriptEngineManager" but there are nop ScriptingEngines installed, you'll get the "Cannot load Script Engine..." message. I am a bit confused why it is giving the "eval failed..." message though.

        Why don't you make the fix you've proposed and I'll look later to see if there is something less-blunt we can do. Sound ok?

        Show
        James Dyer added a comment - That is probably the right thing to do. If its using a JRE that supports the class "javax.script.ScriptEngineManager" but there are nop ScriptingEngines installed, you'll get the "Cannot load Script Engine..." message. I am a bit confused why it is giving the "eval failed..." message though. Why don't you make the fix you've proposed and I'll look later to see if there is something less-blunt we can do. Sound ok?
        Hide
        Steve Rowe added a comment -

        I am a bit confused why it is giving the "eval failed..." message though.

        It's an NPE, but beyond that I'm not sure what's happening.

        The branch_3x Maven job compiles under a 1.5 JDK, then runs tests via Maven's Surefire plugin under a 1.6 (OpenJDK) JVM.

        These tests appear to pass on the Solr_3x job under the same 1.6 JVM, though, so there's something weird going on here. (The Solr_3x job runs under Ant, but I'm not sure why the Ant/Maven difference would be the cause of this.)

        Why don't you make the fix you've proposed and I'll look later to see if there is something less-blunt we can do. Sound ok?

        Sure, I'll commit those changes now.

        Show
        Steve Rowe added a comment - I am a bit confused why it is giving the "eval failed..." message though. It's an NPE, but beyond that I'm not sure what's happening. The branch_3x Maven job compiles under a 1.5 JDK, then runs tests via Maven's Surefire plugin under a 1.6 (OpenJDK) JVM. These tests appear to pass on the Solr_3x job under the same 1.6 JVM, though, so there's something weird going on here. (The Solr_3x job runs under Ant, but I'm not sure why the Ant/Maven difference would be the cause of this.) Why don't you make the fix you've proposed and I'll look later to see if there is something less-blunt we can do. Sound ok? Sure, I'll commit those changes now.
        Hide
        Steve Rowe added a comment -

        I committed the test skipping changes to branch_3x. I haven't seen the same problem (yet) on trunk, so I'll hold off there.

        Show
        Steve Rowe added a comment - I committed the test skipping changes to branch_3x. I haven't seen the same problem (yet) on trunk, so I'll hold off there.
        Hide
        James Dyer added a comment -

        Thanks, Steven! I'll look a little bit more at this tomorrow. Sorry to break the build.

        Show
        James Dyer added a comment - Thanks, Steven! I'll look a little bit more at this tomorrow. Sorry to break the build.
        Hide
        James Dyer added a comment -

        In light of the maven 3.x failure, I think I need to move some of the reflection calls from the 3nd try/catch to the 2nd. This means we can ignore 2 of the 3 exceptions instead of all 3.

        For trunk, I can change this to not use reflection at all since we require a 1.6+ jvm. However, this can still fail if the scripting engines are not in the jvms so these checks need to stay in place.

        Show
        James Dyer added a comment - In light of the maven 3.x failure, I think I need to move some of the reflection calls from the 3nd try/catch to the 2nd. This means we can ignore 2 of the 3 exceptions instead of all 3. For trunk, I can change this to not use reflection at all since we require a 1.6+ jvm. However, this can still fail if the scripting engines are not in the jvms so these checks need to stay in place.
        Hide
        Steve Rowe added a comment -

        I see we got the same failures on the trunk Maven build today: https://builds.apache.org/job/Lucene-Solr-Maven-trunk/431/testReport/

        I'll forward-port my test-skipping changes to trunk.

        Show
        Steve Rowe added a comment - I see we got the same failures on the trunk Maven build today: https://builds.apache.org/job/Lucene-Solr-Maven-trunk/431/testReport/ I'll forward-port my test-skipping changes to trunk.
        Hide
        Steve Rowe added a comment -

        In light of the maven 3.x failure, I think I need to move some of the reflection calls from the 3nd try/catch to the 2nd. This means we can ignore 2 of the 3 exceptions instead of all 3.

        +1

        Show
        Steve Rowe added a comment - In light of the maven 3.x failure, I think I need to move some of the reflection calls from the 3nd try/catch to the 2nd. This means we can ignore 2 of the 3 exceptions instead of all 3. +1
        Hide
        Ryan McKinley added a comment -

        class "javax.servlet.FilterRegistration"'s signer information does not match signer information of other classes in the same package

        I have seen this before when servlet-2.5 and servlet-api 3.0 are both in the classpath

        Show
        Ryan McKinley added a comment - class "javax.servlet.FilterRegistration"'s signer information does not match signer information of other classes in the same package I have seen this before when servlet-2.5 and servlet-api 3.0 are both in the classpath
        Hide
        Steve Rowe added a comment -

        class "javax.servlet.FilterRegistration"'s signer information does not match signer information of other classes in the same package

        I have seen this before when servlet-2.5 and servlet-api 3.0 are both in the classpath

        Yeah, I'm testing a change to the solr-core POM that would make the servlet dependency use the "provided" scope, which would exclude it from the runtime classpath.

        Seems to fix the trunk failures you're referring to in the DIH tests. Running all Solr tests locally now before I commit the change.

        Show
        Steve Rowe added a comment - class "javax.servlet.FilterRegistration"'s signer information does not match signer information of other classes in the same package I have seen this before when servlet-2.5 and servlet-api 3.0 are both in the classpath Yeah, I'm testing a change to the solr-core POM that would make the servlet dependency use the "provided" scope, which would exclude it from the runtime classpath. Seems to fix the trunk failures you're referring to in the DIH tests. Running all Solr tests locally now before I commit the change.
        Hide
        James Dyer added a comment -

        Trunk: r1303470 - Removed reflection as Trunk uses JRE 1.6+. Unit Test no longer ignores exceptions.

        Branch_3x: r1303464 - moved things in try/catch blocks so as to be able to ignore 1 fewer exception (also better from a user's perspective)

        Hopefully this is it!

        Show
        James Dyer added a comment - Trunk: r1303470 - Removed reflection as Trunk uses JRE 1.6+. Unit Test no longer ignores exceptions. Branch_3x: r1303464 - moved things in try/catch blocks so as to be able to ignore 1 fewer exception (also better from a user's perspective) Hopefully this is it!
        Hide
        Steve Rowe added a comment -

        > > class "javax.servlet.FilterRegistration"'s signer information does not
        > > match signer information of other classes in the same package
        >
        > I have seen this before when servlet-2.5 and servlet-api 3.0 are both in the classpath

        Yeah, I'm testing a change to the solr-core POM that would make the servlet dependency use the "provided" scope, which would exclude it from the runtime classpath.

        Seems to fix the trunk failures you're referring to in the DIH tests. Running all Solr tests locally now before I commit the change.

        See SOLR-3263

        Show
        Steve Rowe added a comment - > > class "javax.servlet.FilterRegistration"'s signer information does not > > match signer information of other classes in the same package > > I have seen this before when servlet-2.5 and servlet-api 3.0 are both in the classpath Yeah, I'm testing a change to the solr-core POM that would make the servlet dependency use the "provided" scope, which would exclude it from the runtime classpath. Seems to fix the trunk failures you're referring to in the DIH tests. Running all Solr tests locally now before I commit the change. See SOLR-3263
        Hide
        Steve Rowe added a comment -

        James, the trunk Maven build is still unhappy:

        Build: https://builds.apache.org/job/Lucene-Solr-Maven-trunk/433/
        
        1 tests failed.
        FAILED:  org.apache.solr.handler.dataimport.TestScriptTransformer.testOneparam
        
        Error Message:
        Cannot load Script Engine for language: JavaScript
        
        Stack Trace:
        org.apache.solr.handler.dataimport.DataImportHandlerException: Cannot load Script Engine for language: JavaScript
        	at org.apache.solr.handler.dataimport.ScriptTransformer.initEngine(ScriptTransformer.java:76)
        
        Show
        Steve Rowe added a comment - James, the trunk Maven build is still unhappy: Build: https://builds.apache.org/job/Lucene-Solr-Maven-trunk/433/ 1 tests failed. FAILED: org.apache.solr.handler.dataimport.TestScriptTransformer.testOneparam Error Message: Cannot load Script Engine for language: JavaScript Stack Trace: org.apache.solr.handler.dataimport.DataImportHandlerException: Cannot load Script Engine for language: JavaScript at org.apache.solr.handler.dataimport.ScriptTransformer.initEngine(ScriptTransformer.java:76)
        Hide
        James Dyer added a comment -

        I missed one. Sorry about that. Should be fixed now.

        Show
        James Dyer added a comment - I missed one. Sorry about that. Should be fixed now.
        Hide
        Steve Rowe added a comment -

        I missed one. Sorry about that. Should be fixed now.

        Thanks James, I think it's fixed - just now in the console output from the Jenkins Maven trunk job (still running as I write this), I saw:

        Running org.apache.solr.handler.dataimport.TestScriptTransformer
        NOTE: Assume failed in 'testCheckScript(org.apache.solr.handler.dataimport.TestScriptTransformer)' (ignored): got: <org.apache.lucene.util.InternalAssumptionViolatedException: failed assumption: This JVM does not have Rhino installed.  Test Skipped.>, expected: null
        NOTE: Assume failed in 'testBasic(org.apache.solr.handler.dataimport.TestScriptTransformer)' (ignored): got: <org.apache.lucene.util.InternalAssumptionViolatedException: failed assumption: This JVM does not have Rhino installed.  Test Skipped.>, expected: null
        NOTE: Assume failed in 'testOneparam(org.apache.solr.handler.dataimport.TestScriptTransformer)' (ignored): got: <org.apache.lucene.util.InternalAssumptionViolatedException: failed assumption: This JVM does not have Rhino installed.  Test Skipped.>, expected: null
        Tests run: 4, Failures: 0, Errors: 0, Skipped: 3, Time elapsed: 0.023 sec
        
        Show
        Steve Rowe added a comment - I missed one. Sorry about that. Should be fixed now. Thanks James, I think it's fixed - just now in the console output from the Jenkins Maven trunk job (still running as I write this), I saw: Running org.apache.solr.handler.dataimport.TestScriptTransformer NOTE: Assume failed in 'testCheckScript(org.apache.solr.handler.dataimport.TestScriptTransformer)' (ignored): got: <org.apache.lucene.util.InternalAssumptionViolatedException: failed assumption: This JVM does not have Rhino installed. Test Skipped.>, expected: null NOTE: Assume failed in 'testBasic(org.apache.solr.handler.dataimport.TestScriptTransformer)' (ignored): got: <org.apache.lucene.util.InternalAssumptionViolatedException: failed assumption: This JVM does not have Rhino installed. Test Skipped.>, expected: null NOTE: Assume failed in 'testOneparam(org.apache.solr.handler.dataimport.TestScriptTransformer)' (ignored): got: <org.apache.lucene.util.InternalAssumptionViolatedException: failed assumption: This JVM does not have Rhino installed. Test Skipped.>, expected: null Tests run: 4, Failures: 0, Errors: 0, Skipped: 3, Time elapsed: 0.023 sec

          People

          • Assignee:
            James Dyer
            Reporter:
            James Dyer
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development