Apicurio / apicurio-studio

Open Source API Design
https://www.apicur.io/studio/
Apache License 2.0
967 stars 489 forks source link

java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 6 #227

Closed esteveavi closed 6 years ago

esteveavi commented 6 years ago

Hi,

I have 486 edits and now I am not able to download the yml. Please help:

14:22:22,970 DEBUG [io.apicurio.hub.core.storage.jdbc.JdbcStorage] (default task-20) Selecting the content 'command' rows for API 2 since content version 207
14:22:22,984 ERROR [io.apicurio.hub.editing.EditApiDesignEndpoint] (default task-20) Failed to rollup commands for API with id: 2: io.apicurio.hub.core.js.OaiCommandException: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 6
        at io.apicurio.hub.core.js.OaiCommandExecutor.executeCommands(OaiCommandExecutor.java:106)
        at io.apicurio.hub.core.js.OaiCommandExecutor$Proxy$_$$_WeldClientProxy.executeCommands(Unknown Source)
        at io.apicurio.hub.editing.EditApiDesignEndpoint.rollupCommands(EditApiDesignEndpoint.java:267)
        at io.apicurio.hub.editing.EditApiDesignEndpoint.onCloseSession(EditApiDesignEndpoint.java:237)
        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:497)
        at io.undertow.websockets.jsr.annotated.BoundMethod.invoke(BoundMethod.java:87)
        at io.undertow.websockets.jsr.annotated.AnnotatedEndpoint$4.run(AnnotatedEndpoint.java:211)
        at io.undertow.websockets.jsr.ServerWebSocketContainer$1.call(ServerWebSocketContainer.java:162)
        at io.undertow.websockets.jsr.ServerWebSocketContainer$1.call(ServerWebSocketContainer.java:159)
        at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.websockets.jsr.ServerWebSocketContainer.invokeEndpointMethod(ServerWebSocketContainer.java:575)
        at io.undertow.websockets.jsr.ServerWebSocketContainer$6.run(ServerWebSocketContainer.java:561)
        at io.undertow.websockets.jsr.OrderedExecutor$ExecutorTask.run(OrderedExecutor.java:67)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 6
        at java.util.Arrays.rangeCheck(Arrays.java:120)
        at java.util.Arrays.fill(Arrays.java:2868)
        at jdk.nashorn.internal.runtime.BitVector.setRange(BitVector.java:273)
        at jdk.nashorn.internal.runtime.arrays.DeletedArrayFilter.delete(DeletedArrayFilter.java:151)
        at jdk.nashorn.internal.runtime.arrays.DeletedRangeArrayFilter.delete(DeletedRangeArrayFilter.java:231)
        at jdk.nashorn.internal.runtime.ScriptObject.doesNotHaveEnsureDelete(ScriptObject.java:3125)
        at jdk.nashorn.internal.runtime.ScriptObject.defineOwnProperty(ScriptObject.java:725)
        at jdk.nashorn.internal.runtime.JSONFunctions.setPropertyValue(JSONFunctions.java:200)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:182)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:181)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:181)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:181)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:181)
        at jdk.nashorn.internal.runtime.JSONFunctions.parse(JSONFunctions.java:93)
        at jdk.nashorn.internal.objects.NativeJSON.parse(NativeJSON.java:105)
        at jdk.nashorn.internal.scripts.Script$Recompilation$1197$339564A$\^eval\_.L:5$OasDocumentFactory$createFromJson(<eval>:10249)
        at jdk.nashorn.internal.scripts.Script$Recompilation$1195$533756A$\^eval\_.L:5$OasLibraryUtils$createDocument(<eval>:15107)
        at jdk.nashorn.internal.scripts.Script$Recompilation$1194$44AA$\^eval\_.executeCommands(<eval>:4)
        at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:640)
        at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:229)
        at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:387)
        at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:192)
        at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:381)
        at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:187)
        at io.apicurio.hub.core.js.OaiCommandExecutor.executeCommands(OaiCommandExecutor.java:102)
        ... 23 more

14:22:23,361 DEBUG [io.apicurio.hub.api.rest.impl.DesignsResource] (default task-21) Getting an API design with ID 2
14:22:23,364 DEBUG [io.apicurio.hub.core.storage.jdbc.JdbcStorage] (default task-21) Selecting a single API Design: 2
14:22:23,377 DEBUG [io.apicurio.hub.api.rest.impl.DesignsResource] (default task-22) Retrieving collaborators list for design with ID: 2
14:22:23,378 DEBUG [io.apicurio.hub.core.storage.jdbc.JdbcStorage] (default task-22) Selecting all collaborators for API Design: 2
14:22:26,008 DEBUG [io.apicurio.studio.shared.config.Configuration] (default task-23) Config Property: APICURIO_UI_HUB_API_URL/apicurio-ui.hub-api.url = null
14:22:26,014 DEBUG [io.apicurio.hub.api.rest.impl.DesignsResource] (default task-24) Getting content for API design with ID: 2
14:22:26,015 DEBUG [io.apicurio.hub.core.storage.jdbc.JdbcStorage] (default task-24) Selecting the most recent api_content row of type 'document' for: 2
14:22:26,016 DEBUG [io.apicurio.hub.core.storage.jdbc.JdbcStorage] (default task-24) Selecting the content 'command' rows for API 2 since content version 207
EricWittmann commented 6 years ago

Given that you have a debug log I'm assuming you are running apicurio locally. Is that right? Are you running the quickstart download or something else?

EricWittmann commented 6 years ago

Also what version are you running? Any other details of your system would be useful (e.g. database if you changed it).

(The good news is that no data has been lost - so everything's in there but something is gumming up the works a bit. We just need to figure out which command is doing it!)

esteveavi commented 6 years ago

Hi Eric,

Yes I am running it locally. Last version 0.2.1. Default database, too.

Which kind of information do you need?

Thanks.

esteveavi commented 6 years ago

Hi,

The generated file is the following:

{
    "errorType": "ServerError",
    "message": "Unexpected server error",
    "trace": "io.apicurio.hub.core.exceptions.ServerError: Unexpected server error\r\n\tat io.apicurio.hub.api.rest.impl.DesignsResource.getContent(DesignsResource.java:323)\r\n\tat io.apicurio.hub.api.rest.impl.DesignsResource$Proxy$_$$_WeldClientProxy.getContent(Unknown Source)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:497)\r\n\tat org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:139)\r\n\tat org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)\r\n\tat org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249)\r\n\tat org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:236)\r\n\tat org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:402)\r\n\tat org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:209)\r\n\tat org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221)\r\n\tat org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)\r\n\tat org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)\r\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:790)\r\n\tat io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)\r\n\tat io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)\r\n\tat io.apicurio.hub.api.security.KeycloakAuthenticationFilter.doFilter(KeycloakAuthenticationFilter.java:72)\r\n\tat io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)\r\n\tat io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)\r\n\tat io.apicurio.hub.api.filters.DisableCachingFilter.doFilter(DisableCachingFilter.java:66)\r\n\tat io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)\r\n\tat io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)\r\n\tat io.apicurio.hub.api.filters.CorsFilter.doFilter(CorsFilter.java:64)\r\n\tat io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)\r\n\tat io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)\r\n\tat io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)\r\n\tat io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)\r\n\tat io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)\r\n\tat org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)\r\n\tat io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\r\n\tat org.keycloak.adapters.undertow.UndertowAuthenticatedActionsHandler.handleRequest(UndertowAuthenticatedActionsHandler.java:66)\r\n\tat io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)\r\n\tat io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)\r\n\tat io.undertow.server.handlers.DisableCacheHandler.handleRequest(DisableCacheHandler.java:33)\r\n\tat io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\r\n\tat io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:53)\r\n\tat io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)\r\n\tat io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)\r\n\tat io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:59)\r\n\tat io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)\r\n\tat io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)\r\n\tat io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)\r\n\tat io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)\r\n\tat io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\r\n\tat org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)\r\n\tat io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\r\n\tat org.keycloak.adapters.undertow.ServletPreAuthActionsHandler.handleRequest(ServletPreAuthActionsHandler.java:69)\r\n\tat io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\r\n\tat io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)\r\n\tat io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)\r\n\tat io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)\r\n\tat io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)\r\n\tat io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)\r\n\tat io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)\r\n\tat io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)\r\n\tat io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)\r\n\tat io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)\r\n\tat io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)\r\n\tat io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)\r\n\tat io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)\r\n\tat io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)\r\n\tat io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)\r\n\tat io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)\r\n\tat io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\r\n\tat java.lang.Thread.run(Thread.java:745)\r\nCaused by: io.apicurio.hub.core.js.OaiCommandException: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 6\r\n\tat io.apicurio.hub.core.js.OaiCommandExecutor.executeCommands(OaiCommandExecutor.java:106)\r\n\tat io.apicurio.hub.core.js.OaiCommandExecutor$Proxy$_$$_WeldClientProxy.executeCommands(Unknown Source)\r\n\tat io.apicurio.hub.api.rest.impl.DesignsResource.getContent(DesignsResource.java:305)\r\n\t... 68 more\r\nCaused by: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 6\r\n\tat java.util.Arrays.rangeCheck(Arrays.java:120)\r\n\tat java.util.Arrays.fill(Arrays.java:2868)\r\n\tat jdk.nashorn.internal.runtime.BitVector.setRange(BitVector.java:273)\r\n\tat jdk.nashorn.internal.runtime.arrays.DeletedArrayFilter.delete(DeletedArrayFilter.java:151)\r\n\tat jdk.nashorn.internal.runtime.arrays.DeletedRangeArrayFilter.delete(DeletedRangeArrayFilter.java:231)\r\n\tat jdk.nashorn.internal.runtime.ScriptObject.doesNotHaveEnsureDelete(ScriptObject.java:3125)\r\n\tat jdk.nashorn.internal.runtime.ScriptObject.defineOwnProperty(ScriptObject.java:725)\r\n\tat jdk.nashorn.internal.runtime.JSONFunctions.setPropertyValue(JSONFunctions.java:200)\r\n\tat jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:182)\r\n\tat jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:181)\r\n\tat jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:181)\r\n\tat jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:181)\r\n\tat jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:181)\r\n\tat jdk.nashorn.internal.runtime.JSONFunctions.parse(JSONFunctions.java:93)\r\n\tat jdk.nashorn.internal.objects.NativeJSON.parse(NativeJSON.java:105)\r\n\tat jdk.nashorn.internal.scripts.Script$Recompilation$598$339564A$\\^eval\\_.L:5$OasDocumentFactory$createFromJson(<eval>:10249)\r\n\tat jdk.nashorn.internal.scripts.Script$Recompilation$596$533756A$\\^eval\\_.L:5$OasLibraryUtils$createDocument(<eval>:15107)\r\n\tat jdk.nashorn.internal.scripts.Script$Recompilation$595$44AA$\\^eval\\_.executeCommands(<eval>:4)\r\n\tat jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:640)\r\n\tat jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:229)\r\n\tat jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:387)\r\n\tat jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:192)\r\n\tat jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:381)\r\n\tat jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:187)\r\n\tat io.apicurio.hub.core.js.OaiCommandExecutor.executeCommands(OaiCommandExecutor.java:102)\r\n\t... 70 more\r\n"
}
EricWittmann commented 6 years ago

Thanks for the info - that's good to get us started. In order to track down the bug you're hitting, we have two options:

1) You can check out the latest version on github, build it, and check the logs for info (I have added more useful logging info for this problem) 2) You can send me your H2 database files and I can figure it out. :)

What do you think? Please note that if you opt for (2) there is no user data stored in that database. Login credentials (if you created them rather than logged in with your Google account) are stored on the authentication server which is not local.

esteveavi commented 6 years ago

Hi,

I can not build the master branch: In: Building apicurio-studio-be-hub-core 0.2.2-SNAPSHOT

[INFO] Running io.apicurio.hub.core.beans.ApiDesignResourceInfoTest
[INFO] Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.583 s - in io.apicurio.hub.core.beans.ApiDesignResourceInfoTest
[INFO] Running io.apicurio.hub.core.editing.EditingSessionManagerTest
[main] INFO io.apicurio.hub.core.storage.jdbc.JdbcStorage - Initializing the Apicurio Hub API database.
[main] INFO io.apicurio.hub.core.storage.jdbc.JdbcStorage -     Database type: h2
[main] INFO io.apicurio.hub.core.storage.jdbc.JdbcStorage - Initializing the Apicurio Hub API database.
[main] INFO io.apicurio.hub.core.storage.jdbc.JdbcStorage -     Database type: h2
[main] INFO io.apicurio.hub.core.storage.jdbc.JdbcStorage - Initializing the Apicurio Hub API database.
[main] INFO io.apicurio.hub.core.storage.jdbc.JdbcStorage -     Database type: h2
[main] INFO io.apicurio.hub.core.storage.jdbc.JdbcStorage - Initializing the Apicurio Hub API database.
[main] INFO io.apicurio.hub.core.storage.jdbc.JdbcStorage -     Database type: h2
[main] INFO io.apicurio.hub.core.storage.jdbc.JdbcStorage - Initializing the Apicurio Hub API database.
[main] INFO io.apicurio.hub.core.storage.jdbc.JdbcStorage -     Database type: h2
[INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.946 s - in io.apicurio.hub.core.editing.EditingSessionManagerTest
[INFO] Running io.apicurio.hub.core.js.OaiCommandExecutorTest

{
  "openapi": "3.0.0",
  "info": {
    "title": "Nashorn Test API",
    "license": {
      "name": "Apache 2.0",
      "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
    },
    "version": "1.0.1"
  },
  "components": {
    "schemas": {
      "MySchema": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "address": {
            "$ref": "#/components/schemas/Address"
          },
          "age": {
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          }
        }
      }
    }
  }
}

[ERROR] Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 4.363 s <<< FAILURE! - in io.apicurio.hub.core.js.OaiCommandExecutorTest
[ERROR] testExecuteCommands2(io.apicurio.hub.core.js.OaiCommandExecutorTest)  Time elapsed: 4.015 s  <<< ERROR!
io.apicurio.hub.core.js.OaiCommandException: java.lang.ArrayIndexOutOfBoundsException: 4
        at io.apicurio.hub.core.js.OaiCommandExecutorTest.testExecuteCommands2(OaiCommandExecutorTest.java:76)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 4
        at io.apicurio.hub.core.js.OaiCommandExecutorTest.testExecuteCommands2(OaiCommandExecutorTest.java:76)

[INFO] Running io.apicurio.hub.core.storage.jdbc.DdlParserTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.005 s - in io.apicurio.hub.core.storage.jdbc.DdlParserTest
[INFO] Running io.apicurio.hub.core.storage.jdbc.JdbcStorageTest
[main] INFO io.apicurio.hub.core.storage.jdbc.JdbcStorage - Initializing the Apicurio Hub API database.
[main] INFO io.apicurio.hub.core.storage.jdbc.JdbcStorage -     Database type: h2
....
[main] INFO io.apicurio.hub.core.storage.jdbc.JdbcStorage -     Database type: h2
[main] INFO io.apicurio.hub.core.storage.jdbc.JdbcStorage - Initializing the Apicurio Hub API database.
[main] INFO io.apicurio.hub.core.storage.jdbc.JdbcStorage -     Database type: h2
[INFO] Tests run: 23, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.445 s - in io.apicurio.hub.core.storage.jdbc.JdbcStorageTest
[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR]   OaiCommandExecutorTest.testExecuteCommands2:76 » OaiCommand java.lang.ArrayInd...
[INFO]
[ERROR] Tests run: 37, Failures: 0, Errors: 1, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] apicurio-studio .................................... SUCCESS [  3.736 s]
[INFO] apicurio-studio-shared ............................. SUCCESS [  0.158 s]
[INFO] apicurio-studio-be-shared-beans .................... SUCCESS [  5.478 s]
[INFO] apicurio-studio-be-shared-config ................... SUCCESS [  2.389 s]
[INFO] apicurio-studio-be-shared-servlet .................. SUCCESS [  0.605 s]
[INFO] apicurio-studio-be ................................. SUCCESS [  0.257 s]
[INFO] apicurio-studio-be-test-core ....................... SUCCESS [  2.231 s]
[INFO] apicurio-studio-be-hub-core ........................ FAILURE [ 12.832 s]
[INFO] apicurio-studio-be-hub-api ......................... SKIPPED
EricWittmann commented 6 years ago

That's fascinating! What version of the JDK are you using?

esteveavi commented 6 years ago

Hi, C:\Workspaces\apicurio-studio>java -version java version "1.8.0_151" Java(TM) SE Runtime Environment (build 1.8.0_151-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

On Windows 10.

I think that it should be interesting to provide a Docker image too for this project. The best way to avoid this kind of problems.

Thank you.

EricWittmann commented 6 years ago

Your version of java seems good. This is very strange! I'll try to reproduce it locally (the build error) . It's very interesting that the build error (in the unit test) is basically the same as what you're seeing at runtime. I have a Windows 10 machine and will install that version of the JDK to see what happens.

As for docker, we DO have a quickstart docker image but it's a bit stale right now. We also have an openshift template and separate docker images for each of the various components.

EricWittmann commented 6 years ago

So I cannot reproduce this locally. I'm running the build on Windows 10 with the same JDK and it builds fine for me. Something about your environment must be causing problems for the command executor.

The good news is that apparently you can reproduce the problem easily via an existing junit test. Let's confirm that. Can you run the following?

cd ~/git/apicurio/apicurio-studio/back-end/hub-core/
mvn -Dtest=OaiCommandExecutorTest -Dorg.slf4j.simpleLogger.defaultLogLevel=debug test

Obviously replace the path in line 1 with whatever makes sense for where you cloned the repo. :)

That should elevate the logging level during the unit test and show us some more info.

And thank you for doing this - I appreciate it. I can't track down problems like this without the help of the community!

EricWittmann commented 6 years ago

Note: this make take a few iterations of me adding more logging info and then you doing a git pull and running that unit test. Hopefully you are game and that the # of iterations will be small!!

esteveavi commented 6 years ago

Eric, Don't worry. Ask what you need. The least thing I can do is try to help people building opensource software that I use.

Maven output:

C:\Workspaces\apicurio-studio\back-end\hub-core>mvn -Dtest=OaiCommandExecutorTest -Dorg.slf4j.simpleLogger.defaultLogLevel=debug test
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=384M; support was removed in 8.0
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building apicurio-studio-be-hub-core 0.2.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- git-commit-id-plugin:2.2.1:revision (get-the-git-infos) @ apicurio-studio-be-hub-core ---
[INFO]
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ apicurio-studio-be-hub-core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 15 resources
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ apicurio-studio-be-hub-core ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-enforcer-plugin:1.4:enforce (enforcer-transitives-check) @ apicurio-studio-be-hub-core ---
[INFO] Flag 'useClassesFromLastBuild' is set. Try to use existing output folder.
[INFO] Analyze dependencies of artifact 'io.apicurio:apicurio-studio-be-hub-core:jar:0.2.2-SNAPSHOT'.
[INFO] No illegal transitive dependencies found in 'io.apicurio:apicurio-studio-be-hub-core:jar:0.2.2-SNAPSHOT'.
[INFO]
[INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ apicurio-studio-be-hub-core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 18 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ apicurio-studio-be-hub-core ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.20:test (default-test) @ apicurio-studio-be-hub-core ---
[INFO]
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running io.apicurio.hub.core.js.OaiCommandExecutorTest
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - Creating and initializing a Nashorn script engine.
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - Initialized a Nashorn script engine in 5148 millis.
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - Executing 4 OAS commands.
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - Executing [0] CMD: {
  "__type": "ChangeTitleCommand_30",
  "_newTitle": "Nashorn Test API"
}
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [ChangeTitleCommand] Executing.
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - Executing [1] CMD: {
  "__type": "ChangeVersionCommand_30",
  "_newVersion": "1.0.1"
}
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [ChangeVersionCommand] Executing.
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - Executing [2] CMD: {
  "__type": "ChangeLicenseCommand_30",
  "_newLicenseName": "Apache 2.0",
  "_newLicenseUrl": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [ChangeLicenseCommand] Executing.
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - Executing [3] CMD: {
  "__type": "AddSchemaDefinitionCommand_30",
  "_newDefinitionName": "MySchema",
  "_newDefinitionObj": {
    "required": [
      "name"
    ],
    "type": "object",
    "properties": {
      "name": {
        "type": "string"
      },
      "address": {
        "$ref": "#/components/schemas/Address"
      },
      "age": {
        "format": "int32",
        "minimum": 0,
        "type": "integer"
      }
    }
  }
}
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [AddSchemaDefinitionCommand] Executing.

{
  "openapi": "3.0.0",
  "info": {
    "title": "Nashorn Test API",
    "license": {
      "name": "Apache 2.0",
      "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
    },
    "version": "1.0.1"
  },
  "components": {
    "schemas": {
      "MySchema": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "address": {
            "$ref": "#/components/schemas/Address"
          },
          "age": {
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          }
        }
      }
    }
  }
}

[ERROR] Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 5.883 s <<< FAILURE! - in io.apicurio.hub.core.js.OaiCommandExecutorTest
[ERROR] testExecuteCommands2(io.apicurio.hub.core.js.OaiCommandExecutorTest)  Time elapsed: 5.434 s  <<< ERROR!
io.apicurio.hub.core.js.OaiCommandException: java.lang.ArrayIndexOutOfBoundsException: 4
        at io.apicurio.hub.core.js.OaiCommandExecutorTest.testExecuteCommands2(OaiCommandExecutorTest.java:76)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 4
        at io.apicurio.hub.core.js.OaiCommandExecutorTest.testExecuteCommands2(OaiCommandExecutorTest.java:76)

[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR]   OaiCommandExecutorTest.testExecuteCommands2:76 » OaiCommand java.lang.ArrayInd...
[INFO]
[ERROR] Tests run: 2, Failures: 0, Errors: 1, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.087 s
[INFO] Finished at: 2018-01-24T19:21:23+01:00
[INFO] Final Memory: 25M/286M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.20:test (default-test) on project apicurio-studio-be-hub-core: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Workspaces\apicurio-studio\back-end\hub-core\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
EricWittmann commented 6 years ago

Great, thanks! I've pushed some additional debug statements - if you could git pull those in and run that same mvn command we should get a little bit more insight. I'm honestly entirely stumped at this point. :(

esteveavi commented 6 years ago

Here you are:

C:\Workspaces\apicurio-studio\back-end\hub-core>mvn -Dtest=OaiCommandExecutorTest -Dorg.slf4j.simpleLogger.defaultLogLevel=debug test
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=384M; support was removed in 8.0
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building apicurio-studio-be-hub-core 0.2.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- git-commit-id-plugin:2.2.1:revision (get-the-git-infos) @ apicurio-studio-be-hub-core ---
[INFO]
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ apicurio-studio-be-hub-core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 15 resources
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ apicurio-studio-be-hub-core ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 38 source files to C:\Workspaces\apicurio-studio\back-end\hub-core\target\classes
[INFO]
[INFO] --- maven-enforcer-plugin:1.4:enforce (enforcer-transitives-check) @ apicurio-studio-be-hub-core ---
[INFO] Flag 'useClassesFromLastBuild' is set. Try to use existing output folder.
[INFO] Analyze dependencies of artifact 'io.apicurio:apicurio-studio-be-hub-core:jar:0.2.2-SNAPSHOT'.
[INFO] No illegal transitive dependencies found in 'io.apicurio:apicurio-studio-be-hub-core:jar:0.2.2-SNAPSHOT'.
[INFO]
[INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ apicurio-studio-be-hub-core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 18 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ apicurio-studio-be-hub-core ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 6 source files to C:\Workspaces\apicurio-studio\back-end\hub-core\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.20:test (default-test) @ apicurio-studio-be-hub-core ---
[INFO]
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running io.apicurio.hub.core.js.OaiCommandExecutorTest
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - ::testExecuteCommands2::
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - Creating and initializing a Nashorn script engine.
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - Initialized a Nashorn script engine in 5149 millis.
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [core-library] Entering executeCommands
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [core-library] Library: [object Object]
[main] ERROR io.apicurio.hub.core.js.OaiCommandExecutor - Error executing commands.
java.lang.ArrayIndexOutOfBoundsException: 4
        at jdk.nashorn.internal.runtime.BitVector.setRange(BitVector.java:274)
        at jdk.nashorn.internal.runtime.arrays.DeletedArrayFilter.delete(DeletedArrayFilter.java:151)
        at jdk.nashorn.internal.runtime.arrays.DeletedRangeArrayFilter.delete(DeletedRangeArrayFilter.java:231)
        at jdk.nashorn.internal.runtime.ScriptObject.doesNotHaveEnsureDelete(ScriptObject.java:3125)
        at jdk.nashorn.internal.runtime.ScriptObject.defineOwnProperty(ScriptObject.java:725)
        at jdk.nashorn.internal.runtime.JSONFunctions.setPropertyValue(JSONFunctions.java:200)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:182)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:181)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:181)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:181)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:181)
        at jdk.nashorn.internal.runtime.JSONFunctions.parse(JSONFunctions.java:93)
        at jdk.nashorn.internal.objects.NativeJSON.parse(NativeJSON.java:105)
        at jdk.nashorn.internal.scripts.Script$Recompilation$601$349811A$\^eval\_.L:5$OasDocumentFactory$createFromJson(<eval>:10249)
        at jdk.nashorn.internal.scripts.Script$Recompilation$599$548855A$\^eval\_.L:5$OasLibraryUtils$createDocument(<eval>:15107)
        at jdk.nashorn.internal.scripts.Script$Recompilation$597$45AA$\^eval\_.executeCommands(<eval>:6)
        at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:640)
        at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:229)
        at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:387)
        at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:192)
        at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:381)
        at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:187)
        at io.apicurio.hub.core.js.OaiCommandExecutor.executeCommands(OaiCommandExecutor.java:112)
        at io.apicurio.hub.core.js.OaiCommandExecutorTest.testExecuteCommands2(OaiCommandExecutorTest.java:78)
        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:497)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:272)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:236)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
        at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:386)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:323)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:143)
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - ::testExecuteCommands::
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [core-library] Entering executeCommands
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [core-library] Library: [object Object]
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [core-library] Document: [object Object]
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [core-library] Executing 4 OAS commands.
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [core-library] Executing [0] CMD: {
  "__type": "ChangeTitleCommand_30",
  "_newTitle": "Nashorn Test API"
}
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [ChangeTitleCommand] Executing.
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [core-library] Executing [1] CMD: {
  "__type": "ChangeVersionCommand_30",
  "_newVersion": "1.0.1"
}
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [ChangeVersionCommand] Executing.
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [core-library] Executing [2] CMD: {
  "__type": "ChangeLicenseCommand_30",
  "_newLicenseName": "Apache 2.0",
  "_newLicenseUrl": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [ChangeLicenseCommand] Executing.
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [core-library] Executing [3] CMD: {
  "__type": "AddSchemaDefinitionCommand_30",
  "_newDefinitionName": "MySchema",
  "_newDefinitionObj": {
    "required": [
      "name"
    ],
    "type": "object",
    "properties": {
      "name": {
        "type": "string"
      },
      "address": {
        "$ref": "#/components/schemas/Address"
      },
      "age": {
        "format": "int32",
        "minimum": 0,
        "type": "integer"
      }
    }
  }
}
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [AddSchemaDefinitionCommand] Executing.
[ERROR] Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 5.768 s <<< FAILURE! - in io.apicurio.hub.core.js.OaiCommandExecutorTest
[ERROR] testExecuteCommands2(io.apicurio.hub.core.js.OaiCommandExecutorTest)  Time elapsed: 5.692 s  <<< ERROR!
io.apicurio.hub.core.js.OaiCommandException: java.lang.ArrayIndexOutOfBoundsException: 4
        at io.apicurio.hub.core.js.OaiCommandExecutorTest.testExecuteCommands2(OaiCommandExecutorTest.java:78)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 4
        at io.apicurio.hub.core.js.OaiCommandExecutorTest.testExecuteCommands2(OaiCommandExecutorTest.java:78)

[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR]   OaiCommandExecutorTest.testExecuteCommands2:78 » OaiCommand java.lang.ArrayInd...
[INFO]
[ERROR] Tests run: 2, Failures: 0, Errors: 1, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.422 s
[INFO] Finished at: 2018-01-24T22:18:38+01:00
[INFO] Final Memory: 49M/282M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.20:test (default-test) on project apicurio-studio-be-hub-core: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Workspaces\apicurio-studio\back-end\hub-core\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
C:\Workspaces\apicurio-studio\back-end\hub-core>
EricWittmann commented 6 years ago

Interestingly, it's failing trying to parse the JSON. Essentially it's failing on a JSON.parse() call. I've added one more debug statement just as a sanity check to verify the input to JSON.parse(). So if you could git update and give it another go I'd appreciate it.

Note that this test runs fine on my machine and on the build server. So right now it's a bit unique to you - but clearly it's deterministic (which is good) and so we should be able to track it down. Congrats on stumbling onto something seemingly obscure though. :)

esteveavi commented 6 years ago

Here you are:

[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running io.apicurio.hub.core.js.OaiCommandExecutorTest
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - ::testExecuteCommands2::
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - Creating and initializing a Nashorn script engine.
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - Initialized a Nashorn script engine in 7583 millis.
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [core-library] Entering executeCommands
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [core-library] OAI Doc: {
  "openapi": "3.0.0",
  "info": {
    "title": "Simple OAI 3.0.0 API",
    "description": "A simple API using OpenAPI 3.0.0.",
    "contact": {
      "name": "Example Org",
      "url": "http://www.example.org",
      "email": "contact@example.org"
    },
    "license": {
      "name": "Apache 2.0",
      "url": "https://www.apache.org/licenses/LICENSE-2.0"
    },
    "version": "2.0.11"
  },
  "paths": {
    "/": {
      "get": {
        "summary": "List API versions",
        "operationId": "listVersionsv2",
        "responses": {
          "200": {
            "description": "200 response",
            "content": {
              "application/json": {
                "examples": {
                  "foo": {
                    "value": {
                      "versions": [
                        {
                          "status": "CURRENT",
                          "updated": "2011-01-21T11:33:21Z",
                          "id": "v2.0",
                          "links": [
                            {
                              "href": "http://127.0.0.1:8774/v2/",
                              "rel": "self"
                            }
                          ]
                        },
                        {
                          "status": "EXPERIMENTAL",
                          "updated": "2013-07-23T11:33:21Z",
                          "id": "v3.0",
                          "links": [
                            {
                              "href": "http://127.0.0.1:8774/v3/",
                              "rel": "self"
                            }
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "300": {
            "description": "300 response",
            "content": {
              "application/json": {
                "examples": {
                  "foo": {
                    "value": "{\n \"versions\": [\n       {\n         \"status\": \"CURRENT\",\n         \"updated\": \"2011-01-21T11:33:21Z\",\n         \"id\": \"v2.0\",\n         \"links\": [\n             {\n                 \"href\": \"http://127.0.0.1:8774/v2/\",\n                 \"rel\": \"self\"\n
      }\n         ]\n     },\n     {\n         \"status\": \"EXPERIMENTAL\",\n         \"updated\": \"2013-07-23T11:33:21Z\",\n         \"id\": \"v3.0\",\n
       \"links\": [\n             {\n                 \"href\": \"http://127.0.0.1:8774/v3/\",\n                 \"rel\": \"self\"\n             }\n
]\n     }\n ]\n}\n"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v2": {
      "get": {
        "summary": "Show API version details",
        "operationId": "getVersionDetailsv2",
        "responses": {
          "200": {
            "description": "200 response",
            "content": {
              "application/json": {
                "examples": {
                  "foo": {
                    "value": {
                      "version": {
                        "status": "CURRENT",
                        "updated": "2011-01-21T11:33:21Z",
                        "media-types": [
                          {
                            "base": "application/xml",
                            "type": "application/vnd.openstack.compute+xml;version=2"
                          },
                          {
                            "base": "application/json",
                            "type": "application/vnd.openstack.compute+json;version=2"
                          }
                        ],
                        "id": "v2.0",
                        "links": [
                          {
                            "href": "http://127.0.0.1:8774/v2/",
                            "rel": "self"
                          },
                          {
                            "href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf",
                            "type": "application/pdf",
                            "rel": "describedby"
                          },
                          {
                            "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl",
                            "type": "application/vnd.sun.wadl+xml",
                            "rel": "describedby"
                          },
                          {
                            "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl",
                            "type": "application/vnd.sun.wadl+xml",
                            "rel": "describedby"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "203": {
            "description": "203 response",
            "content": {
              "application/json": {
                "examples": {
                  "foo": {
                    "value": {
                      "version": {
                        "status": "CURRENT",
                        "updated": "2011-01-21T11:33:21Z",
                        "media-types": [
                          {
                            "base": "application/xml",
                            "type": "application/vnd.openstack.compute+xml;version=2"
                          },
                          {
                            "base": "application/json",
                            "type": "application/vnd.openstack.compute+json;version=2"
                          }
                        ],
                        "id": "v2.0",
                        "links": [
                          {
                            "href": "http://23.253.228.211:8774/v2/",
                            "rel": "self"
                          },
                          {
                            "href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf",
                            "type": "application/pdf",
                            "rel": "describedby"
                          },
                          {
                            "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl",
                            "type": "application/vnd.sun.wadl+xml",
                            "rel": "describedby"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "summary": "Update API version details",
        "responses": {
          "200": {}
        },
        "requestBody": {
          "description": "A description of the request body goes here.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/User"
              }
            }
          },
          "required": true
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Address": {
        "properties": {
          "name": {},
          "street": {},
          "city": {},
          "state": {},
          "zip": {}
        }
      },
      "User": {
        "properties": {
          "address": {
            "$ref": "#/components/schemas/Address"
          }
        }
      }
    },
    "securitySchemes": {
      "Basic": {
        "type": "http",
        "description": "Basic auth.",
        "scheme": "Basic"
      },
      "Implicit OAuth": {
        "type": "oauth2",
        "description": "Implicit oauth 2.0 auth.",
        "flows": {
          "implicit": {
            "authorizationUrl": "urn:auth:implicit",
            "refreshUrl": "urn:refresh:implicit",
            "scopes": {
              "implicit": "implicit scope"
            }
          }
        }
      },
      "Password OAuth": {
        "type": "oauth2",
        "description": "Password oauth 2.0 auth.",
        "flows": {
          "password": {
            "tokenUrl": "urn:token:password",
            "refreshUrl": "urn:token:refresh",
            "scopes": {
              "scope1": "Description 1.",
              "scope2": "Description 2."
            }
          }
        }
      },
      "Multi-OAuth": {
        "type": "oauth2",
        "description": "Multiple OAuth flows.",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "urn:token:client",
            "refreshUrl": "urn:refresh:client",
            "scopes": {
              "client": "Client scope."
            }
          },
          "authorizationCode": {
            "authorizationUrl": "urn:auth:auth",
            "tokenUrl": "urn:token:auth",
            "refreshUrl": "urn:refresh:auth",
            "scopes": {}
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "foo",
      "description": "The Foo tag."
    },
    {
      "name": "bar",
      "description": "The bar tag."
    },
    {
      "name": "baz",
      "description": "The baz tag.\n"
    }
  ]
}
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [core-library] Library: [object Object]
[main] ERROR io.apicurio.hub.core.js.OaiCommandExecutor - Error executing commands.
java.lang.ArrayIndexOutOfBoundsException: 4
        at jdk.nashorn.internal.runtime.BitVector.setRange(BitVector.java:274)
        at jdk.nashorn.internal.runtime.arrays.DeletedArrayFilter.delete(DeletedArrayFilter.java:151)
        at jdk.nashorn.internal.runtime.arrays.DeletedRangeArrayFilter.delete(DeletedRangeArrayFilter.java:231)
        at jdk.nashorn.internal.runtime.ScriptObject.doesNotHaveEnsureDelete(ScriptObject.java:3125)
        at jdk.nashorn.internal.runtime.ScriptObject.defineOwnProperty(ScriptObject.java:725)
        at jdk.nashorn.internal.runtime.JSONFunctions.setPropertyValue(JSONFunctions.java:200)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:182)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:181)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:181)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:181)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:181)
        at jdk.nashorn.internal.runtime.JSONFunctions.parse(JSONFunctions.java:93)
        at jdk.nashorn.internal.objects.NativeJSON.parse(NativeJSON.java:105)
        at jdk.nashorn.internal.scripts.Script$Recompilation$597$45AA$\^eval\_.executeCommands(<eval>:7)
        at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:640)
        at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:229)
        at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:387)
        at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:192)
        at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:381)
        at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:187)
        at io.apicurio.hub.core.js.OaiCommandExecutor.executeCommands(OaiCommandExecutor.java:112)
        at io.apicurio.hub.core.js.OaiCommandExecutorTest.testExecuteCommands2(OaiCommandExecutorTest.java:78)
        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:497)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:272)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:236)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
        at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:386)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:323)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:143)
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - ::testExecuteCommands::
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [core-library] Entering executeCommands
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [core-library] OAI Doc: {  "openapi": "3.0.0"}
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [core-library] Library: [object Object]
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [core-library] Document: [object Object]
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [core-library] Executing 4 OAS commands.
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [core-library] Executing [0] CMD: {
  "__type": "ChangeTitleCommand_30",
  "_newTitle": "Nashorn Test API"
}
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [ChangeTitleCommand] Executing.
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [core-library] Executing [1] CMD: {
  "__type": "ChangeVersionCommand_30",
  "_newVersion": "1.0.1"
}
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [ChangeVersionCommand] Executing.
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [core-library] Executing [2] CMD: {
  "__type": "ChangeLicenseCommand_30",
  "_newLicenseName": "Apache 2.0",
  "_newLicenseUrl": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [ChangeLicenseCommand] Executing.
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [core-library] Executing [3] CMD: {
  "__type": "AddSchemaDefinitionCommand_30",
  "_newDefinitionName": "MySchema",
  "_newDefinitionObj": {
    "required": [
      "name"
    ],
    "type": "object",
    "properties": {
      "name": {
        "type": "string"
      },
      "address": {
        "$ref": "#/components/schemas/Address"
      },
      "age": {
        "format": "int32",
        "minimum": 0,
        "type": "integer"
      }
    }
  }
}
[main] DEBUG io.apicurio.hub.core.js.OaiCommandExecutor - [AddSchemaDefinitionCommand] Executing.
[ERROR] Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 8.9 s <<< FAILURE! - in io.apicurio.hub.core.js.OaiCommandExecutorTest
[ERROR] testExecuteCommands2(io.apicurio.hub.core.js.OaiCommandExecutorTest)  Time elapsed: 8.828 s  <<< ERROR!
io.apicurio.hub.core.js.OaiCommandException: java.lang.ArrayIndexOutOfBoundsException: 4
        at io.apicurio.hub.core.js.OaiCommandExecutorTest.testExecuteCommands2(OaiCommandExecutorTest.java:78)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 4
        at io.apicurio.hub.core.js.OaiCommandExecutorTest.testExecuteCommands2(OaiCommandExecutorTest.java:78)

[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR]   OaiCommandExecutorTest.testExecuteCommands2:78 » OaiCommand java.lang.ArrayInd...
[INFO]
[ERROR] Tests run: 2, Failures: 0, Errors: 1, Skipped: 0
EricWittmann commented 6 years ago

I think we might be closing in on a theory for this. I still don't have any idea why you're seeing it and I'm not (on the same OS+jvm). However, the problem is that the JSON being parsed by the javascript engine has somehow been corrupted a little bit.

This part here is the problem:

https://gist.github.com/EricWittmann/9e56f398ee1ddaa1be93d4df989bdac5#file-openapi-json-L66-L69

The test originally gets that content by loading the following:

https://github.com/Apicurio/apicurio-studio/blob/master/back-end/hub-core/src/test/resources/io/apicurio/hub/core/js/testExecuteCommands2/__begin.json#L66

The source file has that value all on a single line, making it valid JSON. Somehow it's getting split into multiple lines for you before being passed into the JS layer. So it fails to parse. Now we just have to figure out why that's happening for you.

I'm going to put together a separate github repository in an attempt to isolate just this issue. I'll let you know when I have something.

I don't suppose you have a background in java development? If not it's no problem, just curious. :)

EricWittmann commented 6 years ago

Sorry for the delay on this - I haven't forgotten about it, just gotten distracted temporarily. :)

EricWittmann commented 6 years ago

OK can you try to clone this repository and just run mvn clean test from the root?

https://github.com/Apicurio/nashorn-js-test

It basically does the same thing as the Apicurio command executor test but tries to get at the core of what is failing. The test passes on my machine but I am interested to see what happens for you. :)

esteveavi commented 6 years ago

Eric,

Excuse me for the delay: test results:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running io.apicurio.nashorn.test.NashornTest
{DEBUG} :: Nashorn JS engine created.
{DEBUG} :: Nashorn JS engine initialized.
{DEBUG} :: Input doc loaded: {
  "openapi": "3.0.0",
  "info": {
    "title": "Simple OAI 3.0.0 API",
    "description": "A simple API using OpenAPI 3.0.0.",
    "contact": {
      "name": "Example Org",
      "url": "http://www.example.org",
      "email": "contact@example.org"
    },
    "license": {
      "name": "Apache 2.0",
      "url": "https://www.apache.org/licenses/LICENSE-2.0"
    },
    "version": "2.0.11"
  },
  "paths": {
    "/": {
      "get": {
        "summary": "List API versions",
        "operationId": "listVersionsv2",
        "responses": {
          "200": {
            "description": "200 response",
            "content": {
              "application/json": {
                "examples": {
                  "foo": {
                    "value": {
                      "versions": [
                        {
                          "status": "CURRENT",
                          "updated": "2011-01-21T11:33:21Z",
                          "id": "v2.0",
                          "links": [
                            {
                              "href": "http://127.0.0.1:8774/v2/",
                              "rel": "self"
                            }
                          ]
                        },
                        {
                          "status": "EXPERIMENTAL",
                          "updated": "2013-07-23T11:33:21Z",
                          "id": "v3.0",
                          "links": [
                            {
                              "href": "http://127.0.0.1:8774/v3/",
                              "rel": "self"
                            }
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "300": {
            "description": "300 response",
            "content": {
              "application/json": {
                "examples": {
                  "foo": {
                    "value": "{\n \"versions\": [\n       {\n         \"status\": \"CURRENT\",\n         \"updated\": \"2011-01-21T11:33:21Z\",\n         \"id\": \"v2.0\",\n         \"links\": [\n             {\n                 \"href\": \"http://127.0.0.1:8774/v2/\",\n                 \"rel\": \"self\"\n
      }\n         ]\n     },\n     {\n         \"status\": \"EXPERIMENTAL\",\n         \"updated\": \"2013-07-23T11:33:21Z\",\n         \"id\": \"v3.0\",\n
       \"links\": [\n             {\n                 \"href\": \"http://127.0.0.1:8774/v3/\",\n                 \"rel\": \"self\"\n             }\n
]\n     }\n ]\n}\n"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v2": {
      "get": {
        "summary": "Show API version details",
        "operationId": "getVersionDetailsv2",
        "responses": {
          "200": {
            "description": "200 response",
            "content": {
              "application/json": {
                "examples": {
                  "foo": {
                    "value": {
                      "version": {
                        "status": "CURRENT",
                        "updated": "2011-01-21T11:33:21Z",
                        "media-types": [
                          {
                            "base": "application/xml",
                            "type": "application/vnd.openstack.compute+xml;version=2"
                          },
                          {
                            "base": "application/json",
                            "type": "application/vnd.openstack.compute+json;version=2"
                          }
                        ],
                        "id": "v2.0",
                        "links": [
                          {
                            "href": "http://127.0.0.1:8774/v2/",
                            "rel": "self"
                          },
                          {
                            "href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf",
                            "type": "application/pdf",
                            "rel": "describedby"
                          },
                          {
                            "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl",
                            "type": "application/vnd.sun.wadl+xml",
                            "rel": "describedby"
                          },
                          {
                            "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl",
                            "type": "application/vnd.sun.wadl+xml",
                            "rel": "describedby"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "203": {
            "description": "203 response",
            "content": {
              "application/json": {
                "examples": {
                  "foo": {
                    "value": {
                      "version": {
                        "status": "CURRENT",
                        "updated": "2011-01-21T11:33:21Z",
                        "media-types": [
                          {
                            "base": "application/xml",
                            "type": "application/vnd.openstack.compute+xml;version=2"
                          },
                          {
                            "base": "application/json",
                            "type": "application/vnd.openstack.compute+json;version=2"
                          }
                        ],
                        "id": "v2.0",
                        "links": [
                          {
                            "href": "http://23.253.228.211:8774/v2/",
                            "rel": "self"
                          },
                          {
                            "href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf",
                            "type": "application/pdf",
                            "rel": "describedby"
                          },
                          {
                            "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl",
                            "type": "application/vnd.sun.wadl+xml",
                            "rel": "describedby"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "summary": "Update API version details",
        "responses": {
          "200": {}
        },
        "requestBody": {
          "description": "A description of the request body goes here.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/User"
              }
            }
          },
          "required": true
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Address": {
        "properties": {
          "name": {},
          "street": {},
          "city": {},
          "state": {},
          "zip": {}
        }
      },
      "User": {
        "properties": {
          "address": {
            "$ref": "#/components/schemas/Address"
          }
        }
      }
    },
    "securitySchemes": {
      "Basic": {
        "type": "http",
        "description": "Basic auth.",
        "scheme": "Basic"
      },
      "Implicit OAuth": {
        "type": "oauth2",
        "description": "Implicit oauth 2.0 auth.",
        "flows": {
          "implicit": {
            "authorizationUrl": "urn:auth:implicit",
            "refreshUrl": "urn:refresh:implicit",
            "scopes": {
              "implicit": "implicit scope"
            }
          }
        }
      },
      "Password OAuth": {
        "type": "oauth2",
        "description": "Password oauth 2.0 auth.",
        "flows": {
          "password": {
            "tokenUrl": "urn:token:password",
            "refreshUrl": "urn:token:refresh",
            "scopes": {
              "scope1": "Description 1.",
              "scope2": "Description 2."
            }
          }
        }
      },
      "Multi-OAuth": {
        "type": "oauth2",
        "description": "Multiple OAuth flows.",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "urn:token:client",
            "refreshUrl": "urn:refresh:client",
            "scopes": {
              "client": "Client scope."
            }
          },
          "authorizationCode": {
            "authorizationUrl": "urn:auth:auth",
            "tokenUrl": "urn:token:auth",
            "refreshUrl": "urn:refresh:auth",
            "scopes": {}
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "foo",
      "description": "The Foo tag."
    },
    {
      "name": "bar",
      "description": "The bar tag."
    },
    {
      "name": "baz",
      "description": "The baz tag.\n"
    }
  ]
}
{DEBUG} :: ======================================================
{DEBUG} :: Doing Test Now!
{DEBUG} :: ======================================================
{DEBUG} :: [core-library] Parsing document:
{DEBUG} :: {
  "openapi": "3.0.0",
  "info": {
    "title": "Simple OAI 3.0.0 API",
    "description": "A simple API using OpenAPI 3.0.0.",
    "contact": {
      "name": "Example Org",
      "url": "http://www.example.org",
      "email": "contact@example.org"
    },
    "license": {
      "name": "Apache 2.0",
      "url": "https://www.apache.org/licenses/LICENSE-2.0"
    },
    "version": "2.0.11"
  },
  "paths": {
    "/": {
      "get": {
        "summary": "List API versions",
        "operationId": "listVersionsv2",
        "responses": {
          "200": {
            "description": "200 response",
            "content": {
              "application/json": {
                "examples": {
                  "foo": {
                    "value": {
                      "versions": [
                        {
                          "status": "CURRENT",
                          "updated": "2011-01-21T11:33:21Z",
                          "id": "v2.0",
                          "links": [
                            {
                              "href": "http://127.0.0.1:8774/v2/",
                              "rel": "self"
                            }
                          ]
                        },
                        {
                          "status": "EXPERIMENTAL",
                          "updated": "2013-07-23T11:33:21Z",
                          "id": "v3.0",
                          "links": [
                            {
                              "href": "http://127.0.0.1:8774/v3/",
                              "rel": "self"
                            }
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "300": {
            "description": "300 response",
            "content": {
              "application/json": {
                "examples": {
                  "foo": {
                    "value": "{\n \"versions\": [\n       {\n         \"status\": \"CURRENT\",\n         \"updated\": \"2011-01-21T11:33:21Z\",\n         \"id\": \"v2.0\",\n         \"links\": [\n             {\n                 \"href\": \"http://127.0.0.1:8774/v2/\",\n                 \"rel\": \"self\"\n
      }\n         ]\n     },\n     {\n         \"status\": \"EXPERIMENTAL\",\n         \"updated\": \"2013-07-23T11:33:21Z\",\n         \"id\": \"v3.0\",\n
       \"links\": [\n             {\n                 \"href\": \"http://127.0.0.1:8774/v3/\",\n                 \"rel\": \"self\"\n             }\n
]\n     }\n ]\n}\n"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v2": {
      "get": {
        "summary": "Show API version details",
        "operationId": "getVersionDetailsv2",
        "responses": {
          "200": {
            "description": "200 response",
            "content": {
              "application/json": {
                "examples": {
                  "foo": {
                    "value": {
                      "version": {
                        "status": "CURRENT",
                        "updated": "2011-01-21T11:33:21Z",
                        "media-types": [
                          {
                            "base": "application/xml",
                            "type": "application/vnd.openstack.compute+xml;version=2"
                          },
                          {
                            "base": "application/json",
                            "type": "application/vnd.openstack.compute+json;version=2"
                          }
                        ],
                        "id": "v2.0",
                        "links": [
                          {
                            "href": "http://127.0.0.1:8774/v2/",
                            "rel": "self"
                          },
                          {
                            "href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf",
                            "type": "application/pdf",
                            "rel": "describedby"
                          },
                          {
                            "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl",
                            "type": "application/vnd.sun.wadl+xml",
                            "rel": "describedby"
                          },
                          {
                            "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl",
                            "type": "application/vnd.sun.wadl+xml",
                            "rel": "describedby"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "203": {
            "description": "203 response",
            "content": {
              "application/json": {
                "examples": {
                  "foo": {
                    "value": {
                      "version": {
                        "status": "CURRENT",
                        "updated": "2011-01-21T11:33:21Z",
                        "media-types": [
                          {
                            "base": "application/xml",
                            "type": "application/vnd.openstack.compute+xml;version=2"
                          },
                          {
                            "base": "application/json",
                            "type": "application/vnd.openstack.compute+json;version=2"
                          }
                        ],
                        "id": "v2.0",
                        "links": [
                          {
                            "href": "http://23.253.228.211:8774/v2/",
                            "rel": "self"
                          },
                          {
                            "href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf",
                            "type": "application/pdf",
                            "rel": "describedby"
                          },
                          {
                            "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl",
                            "type": "application/vnd.sun.wadl+xml",
                            "rel": "describedby"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "summary": "Update API version details",
        "responses": {
          "200": {}
        },
        "requestBody": {
          "description": "A description of the request body goes here.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/User"
              }
            }
          },
          "required": true
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Address": {
        "properties": {
          "name": {},
          "street": {},
          "city": {},
          "state": {},
          "zip": {}
        }
      },
      "User": {
        "properties": {
          "address": {
            "$ref": "#/components/schemas/Address"
          }
        }
      }
    },
    "securitySchemes": {
      "Basic": {
        "type": "http",
        "description": "Basic auth.",
        "scheme": "Basic"
      },
      "Implicit OAuth": {
        "type": "oauth2",
        "description": "Implicit oauth 2.0 auth.",
        "flows": {
          "implicit": {
            "authorizationUrl": "urn:auth:implicit",
            "refreshUrl": "urn:refresh:implicit",
            "scopes": {
              "implicit": "implicit scope"
            }
          }
        }
      },
      "Password OAuth": {
        "type": "oauth2",
        "description": "Password oauth 2.0 auth.",
        "flows": {
          "password": {
            "tokenUrl": "urn:token:password",
            "refreshUrl": "urn:token:refresh",
            "scopes": {
              "scope1": "Description 1.",
              "scope2": "Description 2."
            }
          }
        }
      },
      "Multi-OAuth": {
        "type": "oauth2",
        "description": "Multiple OAuth flows.",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "urn:token:client",
            "refreshUrl": "urn:refresh:client",
            "scopes": {
              "client": "Client scope."
            }
          },
          "authorizationCode": {
            "authorizationUrl": "urn:auth:auth",
            "tokenUrl": "urn:token:auth",
            "refreshUrl": "urn:refresh:auth",
            "scopes": {}
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "foo",
      "description": "The Foo tag."
    },
    {
      "name": "bar",
      "description": "The bar tag."
    },
    {
      "name": "baz",
      "description": "The baz tag.\n"
    }
  ]
}
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.697 sec <<< FAILURE!
test(io.apicurio.nashorn.test.NashornTest)  Time elapsed: 1.415 sec  <<< ERROR!
java.lang.ArrayIndexOutOfBoundsException: 4
        at jdk.nashorn.internal.runtime.BitVector.setRange(BitVector.java:274)
        at jdk.nashorn.internal.runtime.arrays.DeletedArrayFilter.delete(DeletedArrayFilter.java:151)
        at jdk.nashorn.internal.runtime.arrays.DeletedRangeArrayFilter.delete(DeletedRangeArrayFilter.java:231)
        at jdk.nashorn.internal.runtime.ScriptObject.doesNotHaveEnsureDelete(ScriptObject.java:3125)
        at jdk.nashorn.internal.runtime.ScriptObject.defineOwnProperty(ScriptObject.java:725)
        at jdk.nashorn.internal.runtime.JSONFunctions.setPropertyValue(JSONFunctions.java:200)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:182)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:181)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:181)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:181)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:181)
        at jdk.nashorn.internal.runtime.JSONFunctions.parse(JSONFunctions.java:93)
        at jdk.nashorn.internal.objects.NativeJSON.parse(NativeJSON.java:105)
        at jdk.nashorn.internal.scripts.Script$Recompilation$2$38A$\^eval\_.parseDocument(<eval>:5)
        at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:638)
        at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:229)
        at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:387)
        at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:192)
        at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:381)
        at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:187)
        at io.apicurio.nashorn.test.NashornTest.test(NashornTest.java:65)
        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:497)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
        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:497)
        at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
        at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
        at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0

Results :

Tests in error:
  test(io.apicurio.nashorn.test.NashornTest): 4

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.123 s
[INFO] Finished at: 2018-01-30T07:20:52+01:00
[INFO] Final Memory: 19M/171M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project nashorn-js-test: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Workspaces\nashorn-js-test\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
C:\Workspaces\nashorn-js-test>
EricWittmann commented 6 years ago

One thing is clear - the error happens during the parsing of the JSON in JSON.parse().

Some googling suggests there is a Nashorn bug that could cause this. Can you please tell me what happens when you do this:

jjs -v

I'm also going to see if there is a way to check the version of Nashorn at runtime within the junit test. It may be that an older version of Nashorn is being used for some reason...

EricWittmann commented 6 years ago

OK in addition to the jjs command above, I've updated the nashorn-js-test repository to output where the Nashorn engine was loaded from. For example, here is my output when I run mvn clean test:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running io.apicurio.nashorn.test.NashornTest
{DEBUG} :: Loaded Nashorn Engine from: jar:file:/C:/RedHat/jdk1.8.0_161/jre/lib/ext/nashorn.jar!/jdk/nashorn/api/scripting/NashornScriptEngine.class
{DEBUG} :: Nashorn JS engine created.
{DEBUG} :: Nashorn JS engine initialized.
{DEBUG} :: Input doc loaded.
{DEBUG} :: ======================================================
{DEBUG} :: Doing Test Now!
{DEBUG} :: ======================================================
{DEBUG} :: [core-library] Parsing document.
{DEBUG} :: [core-library] Document Parsed: [object Object]
{DEBUG} :: ======================================================
{DEBUG} :: Test passed.
{DEBUG} :: ======================================================
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.42 sec
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0

Could you run that guy again and we'll see what you get? The only theory I have right now is that an old version of Nashorn is somehow being used. I've found this reference to a bug in Nashorn that would explain the behavior:

https://stackoverflow.com/questions/45804312/can-i-bundle-a-newer-version-of-nashorn-in-a-war

esteveavi commented 6 years ago

Can not run jjs. I am on Windows and this is not installed. The output:

C:\Workspaces\nashorn-js-test>mvn clean test
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=384M; support was removed in 8.0
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for io.apicurio:nashorn-js-test:jar:1.0
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 130, column 21
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-surefire-plugin is missing. @ line 173, column 21
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-source-plugin is missing. @ line 140, column 21
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-javadoc-plugin is missing. @ line 152, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building nashorn-js-test 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ nashorn-js-test ---
[INFO] Deleting C:\Workspaces\nashorn-js-test\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ nashorn-js-test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Workspaces\nashorn-js-test\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ nashorn-js-test ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ nashorn-js-test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ nashorn-js-test ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Workspaces\nashorn-js-test\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ nashorn-js-test ---
[INFO] Surefire report directory: C:\Workspaces\nashorn-js-test\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running io.apicurio.nashorn.test.NashornTest
{DEBUG} :: Loaded Nashorn Engine from: jar:file:/C:/Program%20Files/Java/jdk1.8.0_51/jre/lib/ext/nashorn.jar!/jdk/nashorn/api/scripting/NashornScriptEngine.class
{DEBUG} :: Nashorn JS engine created.
{DEBUG} :: Nashorn JS engine initialized.
{DEBUG} :: Input doc loaded.
{DEBUG} :: ======================================================
{DEBUG} :: Doing Test Now!
{DEBUG} :: ======================================================
{DEBUG} :: [core-library] Parsing document.
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.384 sec <<< FAILURE!
test(io.apicurio.nashorn.test.NashornTest)  Time elapsed: 0.975 sec  <<< ERROR!
java.lang.ArrayIndexOutOfBoundsException: 4
        at jdk.nashorn.internal.runtime.BitVector.setRange(BitVector.java:274)
        at jdk.nashorn.internal.runtime.arrays.DeletedArrayFilter.delete(DeletedArrayFilter.java:151)
        at jdk.nashorn.internal.runtime.arrays.DeletedRangeArrayFilter.delete(DeletedRangeArrayFilter.java:231)
        at jdk.nashorn.internal.runtime.ScriptObject.doesNotHaveEnsureDelete(ScriptObject.java:3125)
        at jdk.nashorn.internal.runtime.ScriptObject.defineOwnProperty(ScriptObject.java:725)
        at jdk.nashorn.internal.runtime.JSONFunctions.setPropertyValue(JSONFunctions.java:200)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:182)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:181)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:181)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:181)
        at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:181)
        at jdk.nashorn.internal.runtime.JSONFunctions.parse(JSONFunctions.java:93)
        at jdk.nashorn.internal.objects.NativeJSON.parse(NativeJSON.java:105)
        at jdk.nashorn.internal.scripts.Script$Recompilation$2$38A$\^eval\_.parseDocument(<eval>:5)
        at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:638)
        at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:229)
        at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:387)
        at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:192)
        at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:381)
        at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:187)
        at io.apicurio.nashorn.test.NashornTest.test(NashornTest.java:67)
        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:497)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
        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:497)
        at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
        at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
        at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0

Results :

Tests in error:
  test(io.apicurio.nashorn.test.NashornTest): 4

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.862 s
[INFO] Finished at: 2018-01-31T12:03:52+01:00
[INFO] Final Memory: 18M/168M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project nashorn-js-test: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Workspaces\nashorn-js-test\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
C:\Workspaces\nashorn-js-test>
EricWittmann commented 6 years ago

OK! So I think perhaps you're using an older version of the JVM accidentally... perhaps? This line from the test output is indicative:

{DEBUG} :: Loaded Nashorn Engine from: jar:file:/C:/Program%20Files/Java/jdk1.8.0_51/jre/lib/ext/nashorn.jar!/jdk/nashorn/api/scripting/NashornScriptEngine.class

Note the location of the JAR containing the Nashorn class - it's version 1.8.0_51 of the JDK. I think the _51 version of Java 8 had a buggy version of Nashorn that causes this issue. Try using at least _71 or higher. If you have multiple java versions installed, it's possible that both are on your path. Or maybe JAVA_HOME points to one while the PATH points to another (or both).

Also note that, regarding jjs - that is a command line utility that does come with the JDK. It should be in the same location as java and javac. Mine is here:

$ where jjs
C:\RedHat\jdk1.8.0_161\bin\jjs.exe

I'm also running on Windows 10. Just don't tell anyone else at Red Hat! ;)

esteveavi commented 6 years ago

Hi,

It seams this bug has disappeared changing the jdk version:

INFO]
[INFO] --- maven-dependency-plugin:3.0.2:unpack (unpack) @ apicurio-studio-platforms-swarm-ui ---
[INFO] Configured Artifact: io.apicurio:apicurio-studio-fe-app:0.2.2-SNAPSHOT:jar
[INFO] Unpacking C:\Workspaces\apicurio-studio\front-end\app\target\classes to C:\Workspaces\apicurio-studio\platforms\swarm\ui\target\fe-app with includes "" and excludes ""
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] apicurio-studio .................................... SUCCESS [  6.628 s]
[INFO] apicurio-studio-shared ............................. SUCCESS [  0.080 s]
[INFO] apicurio-studio-be-shared-beans .................... SUCCESS [  3.292 s]
[INFO] apicurio-studio-be-shared-config ................... SUCCESS [  0.922 s]
[INFO] apicurio-studio-be-shared-servlet .................. SUCCESS [  0.550 s]
[INFO] apicurio-studio-be ................................. SUCCESS [  0.307 s]
[INFO] apicurio-studio-be-test-core ....................... SUCCESS [  0.637 s]
[INFO] apicurio-studio-be-hub-core ........................ SUCCESS [ 13.705 s]
[INFO] apicurio-studio-be-hub-api ......................... SUCCESS [ 12.041 s]
[INFO] apicurio-studio-be-hub-editing ..................... SUCCESS [  4.039 s]
[INFO] apicurio-studio-fe ................................. SUCCESS [  4.435 s]
[INFO] apicurio-studio-fe-app ............................. SUCCESS [ 46.971 s]
[INFO] apicurio-studio-fe-servlet ......................... SUCCESS [  1.592 s]
[INFO] apicurio-studio-platforms .......................... SUCCESS [  0.059 s]
[INFO] apicurio-studio-platforms-swarm .................... SUCCESS [  0.030 s]
[INFO] apicurio-studio-platforms-swarm-api ................ SUCCESS [  1.409 s]
[INFO] apicurio-studio-platforms-swarm-ui ................. FAILURE [  1.391 s]
[INFO] apicurio-studio-platforms-swarm-ws ................. SKIPPED
[INFO] apicurio-studio-platforms-wildfly .................. SKIPPED
[INFO] apicurio-studio-platforms-wildfly-api .............. SKIPPED
[INFO] apicurio-studio-platforms-wildfly-ui ............... SKIPPED
[INFO] apicurio-studio-platforms-wildfly-ws ............... SKIPPED
[INFO] apicurio-studio-distro ............................. SKIPPED
[INFO] apicurio-studio-distro-quickstart .................. SKIPPED
[INFO] apicurio-studio-tools .............................. SKIPPED
[INFO] apicurio-studio-tools-release ...................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:39 min
[INFO] Finished at: 2018-02-01T08:18:17+01:00
[INFO] Final Memory: 105M/716M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.0.2:unpack (unpack) on project apicurio-studio-platforms-swarm-ui: Artifact has not been packaged yet. When used on reactor artifact, unpack should be executed after packaging: see MDEP-98. -> [Help 1]

You can close this issue. Thank you very much,

EricWittmann commented 6 years ago

Sorry it took so long to figure this out. When you reported version 151 of the JDK earlier in the thread, that seemed to discount the possibility of that JDK Nashorn bug being the culprit. I'm guessing you ended up having multiple JDKs installed. The only reason I came back to that as a possibility was that I noticed the same thing happened on my machine. After installing JDK 1.8.0_161, doing java -version would report 161 but doing jjs -v would report 78!

Fortunately for me, neither version I was running had the Nashorn bug in it.

Anyway, glad we solved the mystery, even if it took longer than either of us would have liked. :) If you have a moment, please let me know if this has fixed the original reported issue!