lightblue-platform / lightblue-audit-hook

Audit hook for lightblue.
GNU General Public License v3.0
1 stars 9 forks source link

Getting internal server error while having audit-hook with light blue metadata rest #66

Open JankiGadhiya opened 7 years ago

JankiGadhiya commented 7 years ago

This is the error :

Context Path:/rest/metadata
Servlet Path:
Path Info:/temp/1.0.0
Query String:null
Stack Trace
java.lang.ExceptionInInitializerError
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance(Constructor.java:423)
org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:100)
org.jboss.resteasy.plugins.server.resourcefactory.POJOResourceFactory.createResource(POJOResourceFactory.java:53)
org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:235)
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:395)
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:202)
org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221)
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
com.redhat.lightblue.rest.audit.LightblueAuditServletFilter.doFilter(LightblueAuditServletFilter.java:75)
io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:284)
io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263)
io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174)
io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)

&

Caused by: {"objectType":"error","errorCode":"rest-metadata:CantGetMetadata","msg":"{\"objectType\":\"error\",\"errorCode\":\"metadata:ConfigurationNotValid\",\"msg\":\"com.redhat.lightblue.hook.audit.AuditHookConfigurationParser from [Module \\\"deployment.lightblue-rest-metadata-2.10.0-SNAPSHOT.war:main\\\" from Service Module Loader]\"}"}
    at com.redhat.lightblue.util.Error.get(Error.java:110)
    at com.redhat.lightblue.rest.metadata.AbstractMetadataResource.<clinit>(AbstractMetadataResource.java:83)
    ... 45 more

while i try to create metadata with hook by: http://localhost:8080/rest/metadata/temp/1.0.0

This is my input payload :

{
  "entityInfo": {
    "name": "temp",
    "hooks": [
            {
                "name": "auditHook",
                "configuration": {
                    "entityName": "audit",
                    "version": "1.0.0"
                },
                "actions": [
                    "insert",
                    "update",
                    "delete"
                ]
            }
        ],
    "datastore": {
      "backend": "mongo",
      "datasource": "metadata",
      "collection": "temp"
    }
  },
  "schema": {
    "name": "temp",
    "version": {
      "value": "1.0.0",
      "changelog": "Initial version"
    },
    "status": {
      "value": "active"
    },
    "access": {
      "insert": [
        "anyone"
      ],
      "find": [
        "anyone"
      ],
      "update": [
        "anyone"
      ],
      "delete": [
        "anyone"
      ]
    },
    "fields": {
      "question": {
        "type": "string",
                "constraints": {
                    "required": true
                }

      },
      "question_media": {
        "type": "string",
        "description": "Contains the link of medai when question contains any",
        "constraints": {
          "required": true
        }
      },
      "question_value": {
        "type": "string",
        "description": "Contains Question text",
        "constraints": {
          "required": true
        }
      }
    }
  }
}

Note : i have already created metadata for audit table with the use of audit.json & i have added this line "hookConfigurationParsers": ["com.redhat.lightblue.hook.audit.AuditHookConfigurationParser"] in lightblue_metadata.json for confugiration

Is this something that i am missing & can be the cause of this error ?

bserdar commented 7 years ago

Do you need the audit hook in your project? Audit hook is not included in the latest version of the rest artifacts. You can try building lightblue rest artifacts with audit hook included. Remove the "test" scope for audit hook from the root pom to try.

On Fri, Sep 30, 2016 at 12:47 AM, JankiGadhiya notifications@github.com wrote:

This is the error :

Context Path:/rest/metadata Servlet Path: Path Info:/temp/1.0.0 Query String:null Stack Trace java.lang.ExceptionInInitializerError sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) java.lang.reflect.Constructor.newInstance(Constructor.java:423) org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:100) org.jboss.resteasy.plugins.server.resourcefactory.POJOResourceFactory.createResource(POJOResourceFactory.java:53) org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:235) org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:395) org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:202) org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221) org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56) org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51) javax.servlet.http.HttpServlet.service(HttpServlet.java:790) io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) com.redhat.lightblue.rest.audit.LightblueAuditServletFilter.doFilter(LightblueAuditServletFilter.java:75) io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60) io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78) io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50) io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61) io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:284) io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263) io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81) io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174) io.undertow.server.Connectors.executeRootHandler(Connectors.java:202) io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) java.lang.Thread.run(Thread.java:745)

while i try to create metadata with hook by: http://localhost:8080/rest/ metadata/temp/1.0.0

This is my input payload :

{ "entityInfo": { "name": "temp", "hooks": [ { "name": "auditHook", "configuration": { "entityName": "audit", "version": "1.0.0" }, "actions": [ "insert", "update", "delete" ] } ], "datastore": { "backend": "mongo", "datasource": "metadata", "collection": "temp" } }, "schema": { "name": "temp", "version": { "value": "1.0.0", "changelog": "Initial version" }, "status": { "value": "active" }, "access": { "insert": [ "anyone" ], "find": [ "anyone" ], "update": [ "anyone" ], "delete": [ "anyone" ] }, "fields": { "question": { "type": "string", "constraints": { "required": true }

  },
  "question_media": {
    "type": "string",
    "description": "Contains the link of medai when question contains any",
    "constraints": {
      "required": true
    }
  },
  "question_value": {
    "type": "string",
    "description": "Contains Question text",
    "constraints": {
      "required": true
    }
  }
}

} }

Note : i have already created metadata for audit table with the use of audit.json & i have added this line "hookConfigurationParsers": ["com.redhat.lightblue.hook.audit.AuditHookConfigurationParser"] in lightblue_metadata.json for confugiration

Is this something that i am missing & can be the cause of this error ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lightblue-platform/lightblue-audit-hook/issues/66, or mute the thread https://github.com/notifications/unsubscribe-auth/ADgDDVrThEYd-umtyZqqndRbVQdmR-3Jks5qvLBpgaJpZM4KKxwD .

JankiGadhiya commented 7 years ago

I have removed test scope from audit-hook.

I have included below maven dependency in light blue rest metadata pom.xml:

<dependency>
    <groupId>com.redhat.lightblue.hook</groupId>
    <artifactId>lightblue-audit-hook</artifactId>
    <version>1.11.0-SNAPSHOT</version>
</dependency>

Still i am facing the same error saying :

Caused by: {"objectType":"error","errorCode":"rest-metadata:CantGetMetadata","msg":"{\"objectType\":\"error\",\"errorCode\":\"metadata:ConfigurationNotValid\",\"msg\":\"com.redhat.lightblue.hook.audit.AuditHookConfigurationParser from [Module \\\"deployment.lightblue-rest-metadata-2.10.0-SNAPSHOT.war:main\\\" from Service Module Loader]\"}"}
    at com.redhat.lightblue.util.Error.get(Error.java:110)
    at com.redhat.lightblue.rest.metadata.AbstractMetadataResource.<clinit>(AbstractMetadataResource.java:83)
    ... 45 more

As a result i am not able to create metadata after deploying war.

bserdar commented 7 years ago

Make that audit hook change in the root pom for the rest module, rebuild, redeploy, and re-test please. It is required in both metadata and crud apps.

On Mon, Oct 3, 2016 at 10:38 PM, JankiGadhiya notifications@github.com wrote:

I have removed test scope from audit-hook.

I have included below maven dependency in light blue rest metadata pom.xml :

com.redhat.lightblue.hook lightblue-audit-hook 1.11.0-SNAPSHOT

Still i am facing the same error saying :

Caused by: {"objectType":"error","errorCode":"rest-metadata:CantGetMetadata","msg":"{\"objectType\":\"error\",\"errorCode\":\"metadata:ConfigurationNotValid\",\"msg\":\"com.redhat.lightblue.hook.audit.AuditHookConfigurationParser from [Module \"deployment.lightblue-rest-metadata-2.10.0-SNAPSHOT.war:main\" from Service Module Loader]\"}"} at com.redhat.lightblue.util.Error.get(Error.java:110) at com.redhat.lightblue.rest.metadata.AbstractMetadataResource.(AbstractMetadataResource.java:83) ... 45 more

As a result i am not able to create metadata after deploying war.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lightblue-platform/lightblue-audit-hook/issues/66#issuecomment-251294019, or mute the thread https://github.com/notifications/unsubscribe-auth/ADgDDdbdVm_t8yUev8aLhI3euVRjpnPlks5qwdg7gaJpZM4KKxwD .

JankiGadhiya commented 7 years ago

@bserdar Thanx I have added that dependency in root pom.

I have rebuilt, redeployed & re-tested the same thing again & again facing same error as above. I am not able to create metadata at all just facing the same error as above.

bserdar commented 7 years ago

Can you paste your lightblue_metadata.json file? Remove any urls/passwords.

On Tue, Oct 4, 2016 at 7:22 AM, JankiGadhiya notifications@github.com wrote:

@bserdar https://github.com/bserdar Thanx I have added that dependency in root pom.

I have rebuilt, redeployed & re-tested the same thing again & again facing same error as above. I am not able to create metadata at all just facing the same error as above.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lightblue-platform/lightblue-audit-hook/issues/66#issuecomment-251386108, or mute the thread https://github.com/notifications/unsubscribe-auth/ADgDDWApzquZ2JBFxLjPNss_CRBrJf6Kks5qwlMtgaJpZM4KKxwD .

JankiGadhiya commented 7 years ago

@bserdar This is my lightblue_metadata.json file :

{
    "documentation": [
        "type - the class implementing MetadataConfiguration interface",
        "The remainder of the file is parsed by the implementation class"
    ],
    "validateRequests" : false,
    "type" : "com.redhat.lightblue.mongo.config.MongoMetadataConfiguration",
    "hookConfigurationParsers": ["com.redhat.lightblue.hook.audit.AuditHookConfigurationParser"],
    "dataSource" : "metadata",
    "collection": "metadata"
}
bserdar commented 7 years ago

Looks like my earlier comment about the pom was incomplete. Do this: 1) Remove rest module root pom audit hook test like 2) Add audit hook dependency to both metadata and crud poms

JankiGadhiya commented 7 years ago

@bserdar

Same error again. What i have done : 1) removed audit hook dependency from root pom 2) added audit hook dependency in both metadata & crud module's pom

What error is saying :

{"objectType":"error","errorCode":"rest-metadata:CantGetMetadata","msg":"{\"objectType\":\"error\",\"errorCode\":\"metadata:ConfigurationNotValid\",\"msg\":\"com.redhat.lightblue.hook.audit.AuditHookConfigurationParser from [Module \\\"deployment.lightblue-rest-metadata-2.10.0-SNAPSHOT.war:main\\\" from Service Module Loader]\"}"}

bserdar commented 7 years ago

I just tried it and it worked. Make sure lightblue-audit-hook-*.jar is included in the metadata war.

On Tue, Oct 4, 2016 at 10:19 PM, JankiGadhiya notifications@github.com wrote:

@bserdar https://github.com/bserdar

Same error again. What i have done : 1) removed audit hook dependency from root pom 2) added audit hook dependency in both metadata & crud module's pom

What error is saying :

{"objectType":"error","errorCode":"rest-metadata: CantGetMetadata","msg":"{\"objectType\":\"error\",\" errorCode\":\"metadata:ConfigurationNotValid\",\"msg\ ":\"com.redhat.lightblue.hook.audit.AuditHookConfigurationParser from [Module \"deployment.lightblue-rest-metadata-2.10.0-SNAPSHOT.war:main\" from Service Module Loader]\"}"}

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lightblue-platform/lightblue-audit-hook/issues/66#issuecomment-251578112, or mute the thread https://github.com/notifications/unsubscribe-auth/ADgDDe4MfTFQH7LZLBW0maJrk8fIicnLks5qwyU1gaJpZM4KKxwD .

JankiGadhiya commented 7 years ago

@bserdar Do I need to manually copy-paste that jar just adding dependency is not enough?? I have added dependency like this:

<dependency>
    <groupId>com.redhat.lightblue.hook</groupId>
    <artifactId>lightblue-audit-hook</artifactId>
    <version>1.11.0-SNAPSHOT</version>
</dependency> 
bserdar commented 7 years ago

If you add the dependency to metadata and crud poms, and remove the test scope from the main pom, it will be included in the war when you build.

On Tue, Oct 4, 2016 at 10:30 PM, JankiGadhiya notifications@github.com wrote:

@bserdar https://github.com/bserdar Do I need to manually copy-paste that jar just adding dependency is not enough?? I have added dependency like this:

com.redhat.lightblue.hook lightblue-audit-hook 1.11.0-SNAPSHOT

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lightblue-platform/lightblue-audit-hook/issues/66#issuecomment-251579168, or mute the thread https://github.com/notifications/unsubscribe-auth/ADgDDRsFFNZ3w3aLbqFmoznnrcCmnputks5qwyfTgaJpZM4KKxwD .

JankiGadhiya commented 7 years ago

@bserdar then what could be the error ?? I am facing the same error again and again for making sure i have downloaded new light blue rest code from GitHub just

and now the above dependency of audit hook is causing problems in light blue crud module.

bserdar commented 7 years ago

There is clearly some mismatch between our environments. Do you need the audit hook? I suggest you remove it from the lightblue-metadata.json and try without it, and make sure things are working.

Then, make sure lightblue-audit-hook jar is in the war. Run jar -tf lightblue-metadata-...-.war and make sure it is there. If it is not, it will not work.