How can i read extended file attribute in Java? - java

I have file with extended attribute user.MYATTR
when I run command: getfattr fileName -d, I get this:
user.MYATTR="attribute_value"
My OS is Red Hat Enterprise Linux Server release 6.4 (Santiago)
but when I am running my Java code
LOG.debug("readExtentedAttribute(path={},name={}", path, name);
UserDefinedFileAttributeView view = Files.getFileAttributeView(path, UserDefinedFileAttributeView.class);
ByteBuffer buffer = ByteBuffer.allocate(view.size(name));
view.read(name, buffer);
buffer.flip();
String value = Charset.defaultCharset().decode(buffer).toString();
LOG.trace("extended attribute value = {}", value);
I am getting exception
java.nio.file.FileSystemException: /opt/myfolder/myfile: Unable to get size of extended attribute 'user.MYATTR': No data available
at sun.nio.fs.LinuxUserDefinedFileAttributeView.size(LinuxUserDefinedFileAttributeView.java:141) ~[na:1.7.0_25]
at sk.tempest.cda.impex.service.FileServiceImpl.readExtentedAttribute(FileServiceImpl.java:39) ~[impex-impl-0.0.1-SNAPSHOT.jar!/:na]
at sk.tempest.cda.impex.service.TapeMediumServiceImpl.hasDissemFlag(TapeMediumServiceImpl.java:189) ~[impex-impl-0.0.1-SNAPSHOT.jar!/:na]
at sun.reflect.GeneratedMethodAccessor35.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_25]
at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_25]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) ~[spring-aop-4.0.3.RELEASE.jar!/:4.0.3.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:201) ~[spring-aop-4.0.3.RELEASE.jar!/:4.0.3.RELEASE]
at com.sun.proxy.$Proxy85.hasDissemFlag(Unknown Source) ~[na:na]
at sk.tempest.cda.impex.service.TapeStorageServiceImpl.registerNewMedia(TapeStorageServiceImpl.java:158) ~[impex-impl-0.0.1-SNAPSHOT.jar!/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_25]
at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_25]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) ~[spring-aop-4.0.3.RELEASE.jar!/:4.0.3.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[spring-aop-4.0.3.RELEASE.jar!/:4.0.3.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.0.3.RELEASE.jar!/:4.0.3.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98) ~[spring-tx-4.0.3.RELEASE.jar!/:4.0.3.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262) ~[spring-tx-4.0.3.RELEASE.jar!/:4.0.3.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95) ~[spring-tx-4.0.3.RELEASE.jar!/:4.0.3.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.0.3.RELEASE.jar!/:4.0.3.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) ~[spring-aop-4.0.3.RELEASE.jar!/:4.0.3.RELEASE]
at com.sun.proxy.$Proxy87.registerNewMedia(Unknown Source) ~[na:na]
at sk.tempest.cda.impex.service.WorkerServiceImpl.checkNewMedia(WorkerServiceImpl.java:46) ~[impex-impl-0.0.1-SNAPSHOT.jar!/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_25]
at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_25]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) ~[spring-aop-4.0.3.RELEASE.jar!/:4.0.3.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[spring-aop-4.0.3.RELEASE.jar!/:4.0.3.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.0.3.RELEASE.jar!/:4.0.3.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98) ~[spring-tx-4.0.3.RELEASE.jar!/:4.0.3.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262) ~[spring-tx-4.0.3.RELEASE.jar!/:4.0.3.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95) ~[spring-tx-4.0.3.RELEASE.jar!/:4.0.3.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.0.3.RELEASE.jar!/:4.0.3.RELEASE]
at org.springframework.aop.interceptor.AsyncExecutionInterceptor$1.call(AsyncExecutionInterceptor.java:97) ~[spring-aop-4.0.3.RELEASE.jar!/:4.0.3.RELEASE]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) ~[na:1.7.0_25]
at java.util.concurrent.FutureTask.run(FutureTask.java:166) ~[na:1.7.0_25]
at java.lang.Thread.run(Thread.java:724) ~[na:1.7.0_25]

Finally I found that when I want to read attribute user.MYATTR, i have to use name MYATTR.
I just wanna mention what interesting behaviour I found, that may lead to mystakes and i wanna warn you :)
My file has these two attributes:
user.MYATTR1
user.somethingElse.MYATTR2
When I was listing attributes using view.list() method I saw only this one (without user.):
MYATTR1
when i wanna read attribute value, i have to use name of attribute without 'user.', so for mentioned attributes it is:
MYATTR1
or
somethingElse.MYATTR2

Did you read the docs to the class UserDefinedFileAttributeView?
Reading carefully gives a few hints, why your code doesn't work properly.
For example you can check that:
... This FileAttributeView is not intended for use where the size of an
attribute value is larger than Integer.MAX_VALUE ...
or check, if you have a security manager installed:
... in the case of the default provider at least, all methods that
access user-defined attributes require the
RuntimePermission("accessUserDefinedAttributes") permission when a
security manager is installed. ...
Or try out another method to get an attribute:
... Where dynamic access to file attributes is required, the
getAttribute method may be used to read the attribute value. The attribute value is returned as a byte array (byte[]). ...
Maybe any of the hints helps you, good luck! :-)
EDIT
Here's an example code, which checks, if your file system provides user defined file attributes and prints them (on succes):
Path file = Paths.get("filename.ext");
// check that user defined attributes are supported by the file system
FileStore store = file.getFileStore();
if (!store.supportsFileAttributeView("xattr")) {
System.err.format("UserDefinedFileAttributeView not supported on %s\n", store);
System.exit(-1);
}
UserDefinedFileAttributeView view = file.getFileAttributeView(UserDefinedFileAttributeView.class);
// list user defined attributes
if (args.length == 1) {
System.out.println(" Size Name");
System.out.println("-------- --------------------------------------");
for (String name: view.list()) {
System.out.format("%8d %s\n", view.size(name), name);
}
}
Full source code here linked from this page your question code is from ;-)

Related

Unable to Validate Json Schema in rest assured

I am using rest assured and validating JSON schema using it. I generated the schema using jsonschema.net(draft 7) and saved the generated schema in the file and matched the generated schema against the response of GET API.
But the code throwing the error with output like:
Actual: {"success":true,"message":"FacilityAttributes List","error":{},"result":[{"id":"aa2cdb2e-89cd-4970-a976-42df3349df74","name":"INTERNATIONAL","rank":null,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"BusinessType","description":"Please check if facility is international!"},{"id":"144e7c1c-9df4-4c65-ae7e-685013566731","name":"HEAVY","rank":null,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"BusinessType","description":"Please check if facility can handle heavy goods!"},{"id":"ca20c185-4c9a-425e-82e4-a5b244b5ef9d","name":"B2B","rank":5,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"BusinessType","description":null},{"id":"12a2c7f3-7da7-4682-953c-2e06ab8c8335","name":"B2C","rank":4,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"BusinessType","description":null},{"id":"34ef64ee-33dc-43ea-9ef0-722aeb2377f8","name":"HLD","rank":2,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"BusinessType","description":null},{"id":"5147ec36-59ac-4843-9f46-a881548e33aa","name":"dock_count","rank":null,"data_type":"INTEGER","default_value":"0","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Facility Attributes","description":"Dock Door count in Facility!"},{"id":"1bdd7e0f-3a47-4d57-b641-439ba8790e48","name":"capacity","rank":null,"data_type":"INTEGER","default_value":"0","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Facility Attributes","description":"Facility Capacity!"},{"id":"16e81b0c-fe3b-4827-bcf0-dbfd6f2cc386","name":"dimention_unit","rank":null,"data_type":"OPTION","default_value":"CM","mandatory":false,"business_unit":"TRA","options":["CM","IN"],"facility_type":null,"group_name":"Facility Attributes","description":"Dimention unit on facility works!"},{"id":"75569bc1-f5f0-40c1-8e36-f3ef88940486","name":"weight_unit","rank":null,"data_type":"OPTION","default_value":"KG","mandatory":false,"business_unit":"TRA","options":["KG","GM","LB"],"facility_type":null,"group_name":"Facility Attributes","description":"Weight unit on facility works!"},{"id":"48b121ba-e142-4f10-955c-12be4c33f787","name":"sort_code","rank":null,"data_type":"TEXT","default_value":null,"mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Facility Attributes","description":"Facility sort code!"},{"id":"dc5cc52c-2f65-4b92-beaa-d8165dfdc157","name":"slab_rate","rank":null,"data_type":"FLOAT","default_value":"0","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Facility Attributes","description":"Slab rate of facility"},{"id":"d6b3ac6d-5f97-46a5-8e71-72b96f2aa419","name":"slab_type","rank":null,"data_type":"OPTION","default_value":"Incentive Based","mandatory":false,"business_unit":"TRA","options":["Incentive Based","Fuel Based"],"facility_type":null,"group_name":"Facility Attributes","description":"Slab rate of facility"},{"id":"03654f31-150f-4420-837c-f22bda1bc476","name":"ProductivityBenchmark","rank":null,"data_type":"INTEGER","default_value":"0","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Productivity","description":"Productivity Benchmark of facility!"},{"id":"ad471316-0858-4ed7-b817-7b554c780536","name":"ReverseDispatchCutoff","rank":null,"data_type":"TIME","default_value":"09:00","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Facility Timings","description":"Reverse Dispatch Cutoff time"},{"id":"18041d87-a88d-4ed3-b457-9c6e96c2c250","name":"ForwardDispatchCutoff","rank":null,"data_type":"TIME","default_value":"12:00","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Facility Timings","description":"Forward Dispatch Cutoff time"},{"id":"c3e677a7-5b21-4c6b-8384-27c936720177","name":"Implant_enabled","rank":13,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Please check Implant is enabled in Facility!"},{"id":"0fcd0fbe-c448-455a-b825-8b1eb2fcc8b3","name":"DG_enabled","rank":12,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Please check DG is enabled in Facility!"},{"id":"34067f20-ece0-4775-8596-4447f74c5084","name":"FMODx_enabled","rank":11,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Please check Odx FM is enabled in Facility!"},{"id":"6237f744-e685-4aca-906a-48bd1bad9160","name":"FEApp_enabled","rank":9,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Please check FE App is enabled in Facility!"},{"id":"5ceb5fd0-74db-46fc-97a1-afbbaabc3686","name":"PayTM_enabled","rank":8,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Please check if PayTM is enabled in facility!"},{"id":"f69817cb-8662-4f38-b44b-fb875703e9cd","name":"CardOnDelivery_enabled","rank":7,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Please check if Card On Delivery is enabled in facility!"},{"id":"a3bcf54b-d734-4f95-92fd-a15bb2a00be3","name":"BagGuide_enabled","rank":6,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Please check if BagGuide is enabled in facility!"},{"id":"19cfc5d1-f5fb-4666-a13f-7519588e3bb2","name":"LMOdx_enabled","rank":5,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Please check if LMOdx is enabled in facility!"},{"id":"dc99d927-5925-4b09-a686-9c0231259337","name":"Constellation_enabled","rank":4,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Please check if Constellation is enabled in facility!"},{"id":"41ba47fe-ec23-4649-bf0b-51101e631e68","name":"Bagging_enabled","rank":3,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Please check if Bagging is enabled in facility!"},{"id":"7ead8afd-2e98-4330-8e15-40d4cb944a3c","name":"MidMile_enabled","rank":2,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Please check if MidMile is enabled in facility!"},{"id":"4b9ffcab-b5df-4f19-bbd9-52e208168039","name":"Sorter_enabled","rank":1,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Please check if sorter is enabled in facility!"},{"id":"c81e981d-2c44-4bd7-9cc9-5ea20a3eaa3a","name":"Can_Handle_Palletised_Load","rank":null,"data_type":"BOOLEAN","default_value":"false","mandatory":false,"business_unit":"TRA","options":null,"facility_type":null,"group_name":"Flags","description":"Check if facility Can Handle Palletised Load"}]}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:77)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:84)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:247)
at io.restassured.internal.ResponseSpecificationImpl$HamcrestAssertionClosure.validate(ResponseSpecificationImpl.groovy:471)
at io.restassured.internal.ResponseSpecificationImpl$HamcrestAssertionClosure$validate$1.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at io.restassured.internal.ResponseSpecificationImpl.validateResponseIfRequired(ResponseSpecificationImpl.groovy:643)
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:498)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
at io.restassured.internal.ResponseSpecificationImpl.content(ResponseSpecificationImpl.groovy:94)
at io.restassured.specification.ResponseSpecification$content$0.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:174)
at io.restassured.internal.ResponseSpecificationImpl.body(ResponseSpecificationImpl.groovy:244)
at io.restassured.internal.ValidatableResponseOptionsImpl.body(ValidatableResponseOptionsImpl.java:262)
at com.ums.api.AppTest.GetserData(AppTest.java:46)
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:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:669)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:877)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1201)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:776)
at org.testng.TestRunner.run(TestRunner.java:634)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:425)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:420)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:385)
at org.testng.SuiteRunner.run(SuiteRunner.java:334)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1318)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1243)
at org.testng.TestNG.runSuites(TestNG.java:1161)
at org.testng.TestNG.run(TestNG.java:1129)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
my genereated schema is schema link
Repsonse of the api API repsonse
Maybe the current REST Assured library work until draft 4. I'm using json-schema-generator tool to generate json schema in draft 4 and able to validate the response.
Commands to install and generate schema: -
npm install -g json-schema-generator
json-schema-generator path/to/input_response.json -o path/to/json_schema.json
Reference links:
https://github.com/krg7880/json-schema-generator

Grails 3.2.4 refuses to save domain instance: java.lang.IllegalArgumentException: object is not an instance of declaring class

I am upgrading from Grails 2.4.4 to Grails 3.2.4.
I have setup a few factories to help me with testing, the role factory works fine, which runs before the users get created. Then I have the following code:
println "create user."
def testUser = new User(username: 'admin#mail.com', firstName: "admin", lastName: "admin", email: "email#mail.com")
println "User. :: " + testUser
println "User class. :: " + testUser.getClass().toString()
println("User Errors: " + testUser.errors)
testUser.save()
println "create user2."
def testUser2 = new User(username: 'trade#mail.com', email: 'trade#mail.com', firstName: "trade", lastName: "trade").save()
Of which the output is:
create user
User. :: Person: admin#mail.com
User class. :: class UserManage.User
User Errors: grails.validation.ValidationErrors: 0 errors
2017-01-10 10:21:18.400 ERROR --- [ main] o.s.boot.SpringApplication : Application startup failed
java.lang.IllegalArgumentException: object is not an instance of declaring class
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:498)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaBeanProperty.getProperty(MetaBeanProperty.java:62)
at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1245)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1217)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1125)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:812)
at org.grails.validation.ConstrainedPropertyBuilder.doInvokeMethod(ConstrainedPropertyBuilder.java:74)
at groovy.util.BuilderSupport.invokeMethod(BuilderSupport.java:67)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects(ClosureMetaClass.java:446)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:369)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
at UserManage.User$__clinit__closure2.doCall(User.groovy:79)
at UserManage.User$__clinit__closure2.doCall(User.groovy)
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:498)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
at groovy.lang.Closure.call(Closure.java:414)
at UserManage.User$__clinit__closure2.call(User.groovy)
at groovy.lang.Closure.call(Closure.java:408)
at UserManage.User$__clinit__closure2.call(User.groovy)
at org.grails.validation.DefaultConstraintEvaluator.evaluateConstraintsMap(DefaultConstraintEvaluator.java:240)
at org.grails.validation.DefaultConstraintEvaluator.evaluateConstraints(DefaultConstraintEvaluator.java:132)
at org.grails.validation.DefaultConstraintEvaluator.evaluateConstraints(DefaultConstraintEvaluator.java:119)
at org.grails.validation.DefaultConstraintEvaluator.evaluate(DefaultConstraintEvaluator.java:108)
at org.grails.core.DefaultGrailsDomainClass.initializeConstraints(DefaultGrailsDomainClass.java:755)
at org.grails.core.DefaultGrailsDomainClass.getConstrainedProperties(DefaultGrailsDomainClass.java:746)
at org.grails.validation.GrailsDomainClassValidator.validate(GrailsDomainClassValidator.java:76)
at org.grails.orm.hibernate.AbstractHibernateGormInstanceApi.save(AbstractHibernateGormInstanceApi.groovy:122)
at org.grails.datastore.gorm.GormInstanceApi.save(GormInstanceApi.groovy:116)
at org.grails.datastore.gorm.GormEntity$Trait$Helper.save(GormEntity.groovy:98)
at org.grails.datastore.gorm.GormEntity$Trait$Helper$save$5.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at UserManage.User.save(User.groovy)
at UserManage.User.save(User.groovy)
at org.grails.datastore.gorm.GormEntity$save$0.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at groovy.Factories.UserFactory.Build(UserFactory.groovy:18)
at groovy.Factories.UserFactory$Build.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at agripedia.BootStrap$_closure1.doCall(BootStrap.groovy:24)
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:498)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1089)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
at groovy.lang.Closure.call(Closure.java:414)
at groovy.lang.Closure.call(Closure.java:408)
at grails.util.Environment.evaluateEnvironmentSpecificBlock(Environment.java:516)
at grails.util.Environment.executeForEnvironment(Environment.java:509)
at grails.util.Environment.executeForCurrentEnvironment(Environment.java:485)
at org.grails.web.servlet.boostrap.DefaultGrailsBootstrapClass.callInit(DefaultGrailsBootstrapClass.java:62)
at org.grails.web.servlet.context.GrailsConfigUtils.executeGrailsBootstraps(GrailsConfigUtils.java:65)
at org.grails.plugins.web.servlet.context.BootStrapClassRunner.onStartup(BootStrapClassRunner.groovy:53)
at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy:256)
at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:383)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:337)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:882)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:545)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at grails.boot.GrailsApp.run(GrailsApp.groovy:83)
at grails.boot.GrailsApp.run(GrailsApp.groovy:387)
at grails.boot.GrailsApp.run(GrailsApp.groovy:374)
at grails.boot.GrailsApp$run.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
at agripedia.Application.main(Application.groovy:8)
The save method fails, and it is not due to validation errors.
My class structure is APEntity as an abstract class and the User class inherits from the APEntity class. This code works fine in Grails 2.4.4
Any suggestions where I can look to fix the error would be greatly appreciated.
The class instance being constructed is User but the type seen is UserManage.User
at UserManage.User.save(User.groovy)
In my experience Grails 3 is much more type-safe than Grails 2 and less forgiving for ambiguity. Be explicit: User a = new User()
It turned out that validation was the problem.
After I ensured that the types were correct, I disabled all of my constraints. Once the constraints were turned off the validation problem became apparent. In my situation, it was that in Grails 2 I would simply input a null value for a date that is not specified. In grails 3 it seems that this is not allowed, I thus gave it a default value and the validation problem was fixed.
Just to add my notes on this topic since this was the post that made me put a lot of focus in the wrong aspects causing the issue, in the hope to save others spending time trying to identify something that doesn't seem correctly defined.
input a null value for a date that is not specified
This isn't strictly true.
I spent ages attempting to track where the issue was created a dummy site under 3.2.8 and tried to recreate the hasMany and actual objects that had nullable true. If this had been the case then a lot of additional work to fill in nulls where not needed and ultimately filling DB with stuff not required and breaking other logics of the code.
Either way so far as I understand this issue is caused in grails 3.2 by two things so far :
https://github.com/grails/grails-core/issues/10428
This was when a domain class object had
String aUser
static constraints = {
aUser(nullable:true)
}
The above is already fixed in later versions of 3.2.X
A new issue hit recently https://github.com/grails/grails-core/issues/10600 when a domain object has _underscore
String _user
static constraints = {
_user(nullable:true)
}
This appears to be in for fixing and should hopefully be fixed for 3.9
Meaning if you have _objects it will be safe to say it is likely to break under 3.2.X > - < 3.2.8 (was working in 3.1.10).

Invalid Token in Jdeveloper with BPM 11G

I'm working with Oracle BPM 11G(11.1.1.7) and Jdeveloper.
I am getting below error while creating BPM MDS, my database and my SOA-MDS are working perfectly for a connection.
Only when I try to create the BPM-MDS error happens
Test Failed: ORABPEL-30503
Invalid Token Error in Verification Service.
Invalid Token Error in Verification Service. Received invalid token in null.
Verify that correct token is passed.
at oracle.bpel.services.workflow.verification.impl.VerificationService.validateContextToken(VerificationService.java:1769)
at oracle.bpel.services.workflow.verification.impl.VerificationService.validateContext(VerificationService.java:1662)
at oracle.bpel.services.workflow.verification.impl.VerificationService.validateContext(VerificationService.java:1969)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at oracle.bpel.services.workflow.common.WorkflowServiceCacheEventAdvice.invoke(WorkflowServiceCacheEventAdvice.java:91)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy243.validateContext(Unknown Source)
at oracle.bpm.services.pml.impl.SecurityService.validateContext(SecurityService.java:237)
at oracle.bpm.services.pml.impl.SecurityService.getSecurityService(SecurityService.java:247)
at oracle.bpm.services.pml.impl.SecurityService.getPrincipal(SecurityService.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at oracle.bpel.services.workflow.common.WorkflowServiceCacheEventAdvice.invoke(WorkflowServiceCacheEventAdvice.java:91)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy270.getPrincipal(Unknown Source)
at oracle.bpm.services.pml.ejb.SecurityServiceBean.getPrincipal(SecurityServiceBean.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at com.oracle.pitchfork.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:34)
at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
at com.oracle.pitchfork.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:42)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy269.getPrincipal(Unknown Source)
at oracle.bpm.services.pml.ejb.SecurityServiceBean_z7zjfk_ISecurityServiceRemoteImpl.__WL_invoke(Unknown Source)
at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:40)
at oracle.bpm.services.pml.ejb.SecurityServiceBean_z7zjfk_ISecurityServiceRemoteImpl.getPrincipal(Unknown Source)
at oracle.bpm.services.pml.ejb.SecurityServiceBean_z7zjfk_ISecurityServiceRemoteImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:667)
at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:522)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:518)
at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Caused By: java.lang.Exception: Null token
at oracle.bpel.services.workflow.verification.impl.VerificationService.validateContextToken(VerificationService.java:1769)
at oracle.bpel.services.workflow.verification.impl.VerificationService.validateContext(VerificationService.java:1662)
at oracle.bpel.services.workflow.verification.impl.VerificationService.validateContext(VerificationService.java:1969)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at oracle.bpel.services.workflow.common.WorkflowServiceCacheEventAdvice.invoke(WorkflowServiceCacheEventAdvice.java:91)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy243.validateContext(Unknown Source)
at oracle.bpm.services.pml.impl.SecurityService.validateContext(SecurityService.java:237)
at oracle.bpm.services.pml.impl.SecurityService.getSecurityService(SecurityService.java:247)
at oracle.bpm.services.pml.impl.SecurityService.getPrincipal(SecurityService.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at oracle.bpel.services.workflow.common.WorkflowServiceCacheEventAdvice.invoke(WorkflowServiceCacheEventAdvice.java:91)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy270.getPrincipal(Unknown Source)
at oracle.bpm.services.pml.ejb.SecurityServiceBean.getPrincipal(SecurityServiceBean.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at com.oracle.pitchfork.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:34)
at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
at com.oracle.pitchfork.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:42)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy269.getPrincipal(Unknown Source)
at oracle.bpm.services.pml.ejb.SecurityServiceBean_z7zjfk_ISecurityServiceRemoteImpl.__WL_invoke(Unknown Source)
at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:40)
at oracle.bpm.services.pml.ejb.SecurityServiceBean_z7zjfk_ISecurityServiceRemoteImpl.getPrincipal(Unknown Source)
at oracle.bpm.services.pml.ejb.SecurityServiceBean_z7zjfk_ISecurityServiceRemoteImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:667)
at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:522)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:518)
at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Could someone help me, I'm very difficult to find a solution for this problem!!
This has been resolved. I ended up generating my own web service proxy services for the TaskService, instead of using the one that was bundled with jDeveloper. So honestly speaking, because of time constraints, I did not get a chance to fix the exact root cause of this error. After generating this webservice proxy/stub, i bundled it as a shared webapp library and my Custom Worklist portlet refers to this library. This worked for me.
I used this WSDL to generate the proxy classes and then used the generated classes/methods to query tasks data.
http://soa_host:soa_port/integration/services/TaskQueryService/TaskQueryService?wsdl
Also, later taking the original case forward, I was also able to get around the token problem by using RMI/EBJ provider ( t3://: ) instead of SOAP binding (http://:).
Here's what my code looks like :
String serverUrl ="t3://soa_server:soa_port"; // host:Port of the soa server
Map<IWorkflowServiceClientConstants.CONNECTION_PROPERTY, String> connProperties = new HashMap<IWorkflowServiceClientConstants.CONNECTION_PROPERTY, String>();
connProperties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.CLIENT_TYPE,WorkflowServiceClientFactory.REMOTE_CLIENT);
connProperties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_PROVIDER_URL,serverUrl);
connProperties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
IWorkflowServiceClient wfSvcClient = WorkflowServiceClientFactory.getWorkflowServiceClient(connProperties, null, null);
ITaskQueryService querySvc = wfSvcClient.getTaskQueryService();
IWorkflowContext adminCtx = wfSvcClient.getTaskQueryService().authenticate(adminID, adminPass.toCharArray(), "jazn.com" );
IWorkflowContext userCtx = querySvc.authenticateOnBehalfOf(adminCtx, userID);
List displayColumns = new ArrayList();
displayColumns.add("TASKNUMBER");
displayColumns.add("TITLE");
displayColumns.add("STATE");
displayColumns.add("CREATOR");
List optionalInfo = new ArrayList();
optionalInfo.add("Comments");
optionalInfo.add("Payload");
tasks=querySvc.queryTasks(userCtx, null, null, ITaskQueryService.AssignmentFilter.MY,null, null, null, 0, 0);
This returns list of tasks assigned to the user whose ID you send to authenticateOnBehalfOf() method call above.
I hope this helps.
Below solution from Oracle Support Documentation fixed the issue for me. In summary, it's a jar mismatch between server and jdev that caused the issue.
=========================================================================
You are unable to get the BPM context successfully. There will not be an exception while retrieving the context but when trying to use it you see the exception:
BPM-70684
Exception
exception.70684.type: error
exception.70684.severity: 2
exception.70684.name: Invalid authentication context.
exception.70684.description: Invalid authentication context has been passed.
exception.70684.fix: Ensure valid authentication context is passed.
The following exceptions have known to be associated with the same issue:
Caused by: java.lang.NullPointerException
at oracle.bpel.services.workflow.verification.impl.WorkflowContext.hashCode(WorkflowContext.java:583)
at java.util.HashMap.get(HashMap.java:300)
at oracle.bpel.services.workflow.common.ThreadLocalCache.isContextValidated(ThreadLocalCache.java:146)
at oracle.bpel.services.workflow.verification.impl.VerificationService.validateNotNullWorkflowContext(VerificationService.java:1824)
at oracle.bpel.services.workflow.verification.impl.VerificationService.validateContext(VerificationService.java:1806)
Error while authenticating on behalf of user weblogic using adminContext [user=null][sessionKey=null][token=null][requester=null][objectId=null]
<<.> Verification Service cannot resolve user identity.
User null cannot be found in the identity repository.
Workflow Context token cannot be null in request.
ORABPEL-30511
Verification Service cannot resolve user identity.
User null cannot be found in the identity repository.
Workflow Context token cannot be null in request.
at oracle.bpel.services.workflow.verification.impl.LocalCacheManager.lookupUser(LocalCacheManager.java:600)
Caused By: ORABPEL-10501
Illegal argument.
Illegal argument.
This is because an unexpected value, possibly null, was passed as an argument. Check the error stack and fix the cause of the error. Contact Oracle Support Services if error is not fixable.
at oracle.tip.pc.services.identity.jps.AuthorizationServiceImpl.lookupUser(AuthorizationServiceImpl.java:236)
at oracle.tip.pc.services.identity.jps.IdentityServiceImpl.lookupUser(IdentityServiceImpl.java:183)
at oracle.bpel.services.workflow.verification.impl.LocalCacheManager.lookupUser(LocalCacheManager.java:596)
We are embedding a BPM task Flow list in an ADF App. It gives the following error
infra] <.> Invalid Token Error in Verification Service.[[
Invalid Token Error in Verification Service. Received invalid token in null.
Verify that correct token is passed.
ORABPEL-30503
Also, If you log the username from the context you'll notice it is null.
Cause
The bpm-services.jar on the client application and the server may not match. The SOA/BPM related jars being used on the client and server must be the same or unexpected issues can occur.
Solution
Copy the bpm-services.jar from the server
Replace the bpm-services.jar on the client application with the one from the server
Ensure that after any patches are applied that the jars on the server are replaced in the client application.
This also applies to using jars within JDeveloper which can become out of sync due to patches not being applied on both dev and server machines. You may need to replace the bpm-services.jar located here JDeveloper/soa/modules/oracle.soa.workflow_11.1.1/bpm-services.jar with the one located here [soa_install_dir]/soa/modules/oracle.soa.workflow_11.1.1/bpm-services.jar.

GWT Maps Icon.NewInstance intermittently throwing exception

I'm creating a custom icon to use as a marker on a map, and intermittently, but quite often this function:
private Icon createIcon(String Url) {
Icon icon = Icon.newInstance(Url); //<-- This line throws exception
icon.setIconSize(Size.newInstance(30, 30));
icon.setIconAnchor(Point.newInstance(6, 20));
icon.setInfoWindowAnchor(Point.newInstance(14, 4));
return icon;
}
throws this exception:
11:05:55.076 [ERROR] [simplemap] Uncaught exception escaped
com.google.gwt.core.client.JavaScriptException: (TypeError) #com.google.gwt.core.client.impl.Impl::apply(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)([JavaScript object(311), JavaScript object(310), JavaScript object(333)]): undefined is not a function
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:249)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:242)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
at java.lang.Thread.run(Unknown Source)
Does anybody have any insight as to why this happens and what I can do to fix this behavior?
This ended up being a concurrency issue where the map was not finished loading when the icons were trying to be generated. When I moved some code around so it only ran after the Maps asynchronous load was finished this issue went away.

Gwtp NullpointerException- annotation

I am trying to implement a mobileweb app using Gwtp. I have the desktop and tablet view working but i get an error for mobile view. I am binding 3 different presenters for desktop, mobile and tablet view. So it will be a different landing page on different devices. I need different landing page functionality on different devices. The first presenter on a tablet will be a list of tasks, but on a mobile the user has to login first to see the list of tasks. Also, some of the presenters will be shared by a tablet and mobile view.
MobileModule-
bindConstant().annotatedWith(DefaultPlace.class).to(NameTokens.login);
bindPresenter(LoginPresenter.class, LoginPresenter.MyView.class,
LoginView.class, LoginPresenter.MyProxy.class);
bindPresenter(MainListTabletPresenter.class,
MainListTabletPresenter.MyView.class, MainListMobileView.class,
MainListTabletPresenter.MyProxy.class);
TabletModule-
bindConstant().annotatedWith(DefaultPlace.class).to(NameTokens.mainList);
bindPresenter(MainListTabletPresenter.class,
MainListTabletPresenter.MyView.class, MainListTabletView.class,
MainListTabletPresenter.MyProxy.class);
bindPresenter(LoginPresenter.class, LoginPresenter.MyView.class,
LoginView.class, LoginPresenter.MyProxy.class);
Any ideas why i would get the following (NullpointerException about annotations), when i run the application? I think i have the annotations correct for the LoginPresenter.
(MainPageEntryPoint.java:83) 2012-08-27 18:43:54,360 [ERROR] e: com.google.gwt.event.shared.UmbrellaException: One or more exceptions caught, see full set in UmbrellaException#getCauses
com.google.gwt.event.shared.UmbrellaException: One or more exceptions caught, see full set in UmbrellaException#getCauses
at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129)
at com.google.gwt.user.client.impl.HistoryImpl.fireEvent(HistoryImpl.java:75)
at com.google.gwt.event.logical.shared.ValueChangeEvent.fire(ValueChangeEvent.java:43)
at com.google.gwt.user.client.impl.HistoryImpl.fireHistoryChangedImpl(HistoryImpl.java:82)
at com.google.gwt.user.client.History.fireCurrentHistoryState(History.java:121)
at com.gwtplatform.mvp.client.proxy.PlaceManagerImpl.revealCurrentPlace(PlaceManagerImpl.java:310)
at com.happs.curveapp.client.MainPageEntryPoint.revealCurrentPlace(MainPageEntryPoint.java:114)
at com.happs.curveapp.client.MainPageEntryPoint.onModuleLoad2(MainPageEntryPoint.java:68)
at com.happs.curveapp.client.MainPageEntryPoint$1.execute(MainPageEntryPoint.java:40)
at com.google.gwt.core.client.impl.SchedulerImpl$Task$.executeScheduled$(SchedulerImpl.java:50)
at com.google.gwt.core.client.impl.SchedulerImpl.runScheduledTasks(SchedulerImpl.java:228)
at com.google.gwt.core.client.impl.SchedulerImpl.flushPostEventPumpCommands(SchedulerImpl.java:388)
at com.google.gwt.core.client.impl.SchedulerImpl$Flusher.execute(SchedulerImpl.java:78)
at com.google.gwt.core.client.impl.SchedulerImpl.execute(SchedulerImpl.java:138)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:619)
Caused by: com.google.web.bindery.event.shared.UmbrellaException: One or more exceptions caught, see full set in UmbrellaException#getCauses
at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:203)
at com.google.web.bindery.event.shared.SimpleEventBus.fireEventFromSource(SimpleEventBus.java:96)
at com.gwtplatform.mvp.client.proxy.PlaceManagerImpl.fireEvent(PlaceManagerImpl.java:146)
at com.gwtplatform.mvp.client.proxy.PlaceManagerImpl.doRevealPlace(PlaceManagerImpl.java:121)
at com.gwtplatform.mvp.client.proxy.PlaceManagerImpl.revealPlace(PlaceManagerImpl.java:339)
at com.happs.curveapp.client.place.ClientPlaceManager.revealDefaultPlace(ClientPlaceManager.java:27)
at com.gwtplatform.mvp.client.proxy.PlaceManagerImpl.onValueChange(PlaceManagerImpl.java:264)
at com.google.gwt.event.logical.shared.ValueChangeEvent.dispatch(ValueChangeEvent.java:128)
at com.google.gwt.event.logical.shared.ValueChangeEvent.dispatch(ValueChangeEvent.java:1)
at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)
at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)
... 39 more
Caused by: java.lang.NullPointerException
at com.happs.curveapp.client.view.mobile.LoginView.<init>(LoginView.java:54)
at com.happs.curveapp.client.gin.MobileGinjectorImpl.com$happs$curveapp$client$view$mobile$LoginView_LoginView_methodInjection(MobileGinjectorImpl.java:1749)
at com.happs.curveapp.client.gin.MobileGinjectorImpl.create_Key$type$com$happs$curveapp$client$view$mobile$LoginView$_annotation$$none$$(MobileGinjectorImpl.java:1753)
at com.happs.curveapp.client.gin.MobileGinjectorImpl.get_Key$type$com$happs$curveapp$client$view$mobile$LoginView$_annotation$$none$$(MobileGinjectorImpl.java:1767)
at com.happs.curveapp.client.gin.MobileGinjectorImpl.create_Key$type$com$happs$curveapp$client$presenter$LoginPresenter$MyView$_annotation$$none$$(MobileGinjectorImpl.java:231)
at com.happs.curveapp.client.gin.MobileGinjectorImpl.get_Key$type$com$happs$curveapp$client$presenter$LoginPresenter$MyView$_annotation$$none$$(MobileGinjectorImpl.java:240)
at com.happs.curveapp.client.gin.MobileGinjectorImpl.create_Key$type$com$happs$curveapp$client$presenter$LoginPresenter$_annotation$$none$$(MobileGinjectorImpl.java:299)
at com.happs.curveapp.client.gin.MobileGinjectorImpl.get_Key$type$com$happs$curveapp$client$presenter$LoginPresenter$_annotation$$none$$(MobileGinjectorImpl.java:313)
at com.happs.curveapp.client.gin.MobileGinjectorImpl.access$0(MobileGinjectorImpl.java:311)
at com.happs.curveapp.client.gin.MobileGinjectorImpl$1$1.onSuccess(MobileGinjectorImpl.java:254)
at com.google.gwt.core.client.GWT.runAsync(GWT.java:255)
at com.happs.curveapp.client.gin.MobileGinjectorImpl$1.get(MobileGinjectorImpl.java:252)
at com.gwtplatform.common.client.CodeSplitProvider.get(CodeSplitProvider.java:48)
at com.gwtplatform.mvp.client.proxy.ProxyImpl.getPresenter(ProxyImpl.java:46)
at com.gwtplatform.mvp.client.proxy.ProxyPlaceAbstract.handleRequest(ProxyPlaceAbstract.java:193)
at com.gwtplatform.mvp.client.proxy.ProxyPlaceAbstract.access$0(ProxyPlaceAbstract.java:192)
at com.gwtplatform.mvp.client.proxy.ProxyPlaceAbstract$1.onPlaceRequest(ProxyPlaceAbstract.java:143)
at com.gwtplatform.mvp.client.proxy.PlaceRequestInternalEvent.dispatch(PlaceRequestInternalEvent.java:134)
at com.gwtplatform.mvp.client.proxy.PlaceRequestInternalEvent.dispatch(PlaceRequestInternalEvent.java:1)
at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)
at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
... 52 more

Categories

Resources