I am new to this field and i have no idea where am i going wrong.
org.codehaus.jettison.json.JSONException: JSONObject["State load X2\/SETTINGS\/SETTINGS.XML"] not found.
at org.codehaus.jettison.json.JSONObject.get(JSONObject.java:360)
at com.comcast.xre.testframework.services.TestModuleDataClient.convertJSON2String(TestModuleDataClient.java:258)
at com.comcast.xre.testframework.services.TestModuleDataClient.hashGet(TestModuleDataClient.java:112)
at com.comcast.xre.testframework.util.X1ToolkitActions.getAppTimerValue(X1ToolkitActions.java:417)
at com.comcast.xre.testframework.util.X1ToolkitActions.waitForAppTimerValueChange(X1ToolkitActions.java:527)
at com.comcast.guide.actionhandlers.X1GuideBaseTestActions.enterSettingsScreenAndSelectDesiredSetting(X1GuideBaseTestActions.java:838)
at com.comcast.guide.actionhandlers.ParentalControlSettingsAction.setPurchasePIN(ParentalControlSettingsAction.java:635)
at com.comcast.guide.functests.ParentalControlTest.purchasePINTest(ParentalControlTest.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.InvokeMethodRunnable.runOne(InvokeMethodRunnable.java:46)
at org.testng.internal.InvokeMethodRunnable.run(InvokeMethodRunnable.java:37)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
My first suggestion would be to surround your code with a try-catch block to catch the exception. I would also suggest using the JSONObject.has method to see if this file exists.
See http://www.json.org/javadoc/org/json/JSONObject.html#has(java.lang.String) for more info.
Related
I found that
It cannot bind a JNI method implemented in C to Scala's object, demo as this subproject, with errors going as
Exception in thread "sbt-bg-threads-1" java.lang.UnsatisfiedLinkError: HelloWorld$.hi()V
at HelloWorld$.hi(Native Method)
at Main$.delayedEndpoint$Main$1(Main.scala:3)
at Main$delayedInit$body.apply(Main.scala:1)
at scala.Function0.apply$mcV$sp(Function0.scala:39)
at scala.Function0.apply$mcV$sp$(Function0.scala:39)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
at scala.App.$anonfun$main$1(App.scala:76)
at scala.App.$anonfun$main$1$adapted(App.scala:76)
at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:563)
at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:561)
at scala.collection.AbstractIterable.foreach(Iterable.scala:926)
at scala.App.main(App.scala:76)
at scala.App.main$(App.scala:74)
at Main$.main(Main.scala:1)
at Main.main(Main.scala)
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 sbt.Run.invokeMain(Run.scala:143)
at sbt.Run.execute$1(Run.scala:93)
at sbt.Run.$anonfun$runWithLoader$5(Run.scala:120)
at sbt.Run$.executeSuccess(Run.scala:186)
at sbt.Run.runWithLoader(Run.scala:120)
at sbt.Defaults$.$anonfun$bgRunTask$6(Defaults.scala:1983)
at sbt.Defaults$.$anonfun$termWrapper$2(Defaults.scala:1922)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
at scala.util.Try$.apply(Try.scala:213)
at sbt.internal.BackgroundThreadPool$BackgroundRunnable.run(DefaultBackgroundJobService.scala:369)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
while it's good with Java as indirection, demo as this subproject
Reproduction repository goes here.
Really appreciate if someone could help me out.
I have searched online for a few days, but only find that my object is not implementing serializable? Which object? DataKey or ResponseEntity? I can't reproduce this error in my local and I can only see this error in remote server log.
Updated: Since this issue is only happening when trying to refresh a cache object, first time load into cache does not have this issue, so I apply the fix by setting overflowToDisk="false" in ehcache.xml, and issue gone.
2020-03-30_12:15:30.941 [refdata.data] ERROR n.s.e.store.disk.DiskStorageFactory - Disk Write of DataKey [refDataType=Machine, subDataType=Laptop] failed:
java.io.NotSerializableException: org.springframework.http.ResponseEntity
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)2
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:441)
at net.sf.ehcache.Element.writeObject(Element.java:875)
at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1028)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1496)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
at net.sf.ehcache.util.MemoryEfficientByteArrayOutputStream.serialize(MemoryEfficientByteArrayOutputStream.java:97)
at net.sf.ehcache.store.disk.DiskStorageFactory.serializeElement(DiskStorageFactory.java:403)
at net.sf.ehcache.store.disk.DiskStorageFactory.write(DiskStorageFactory.java:385)
at net.sf.ehcache.store.disk.DiskStorageFactory$DiskWriteTask.call(DiskStorageFactory.java:477)
at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1071)
at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1055)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run
I have a 4 servers nodes cluster in Aerospike 3.8.4 with Java Client 3.2.2. When I try to save an object, I get this error:
error code 0 for key test:docs2:80000001:cd60b46ba665c24e646f74053de2846b2a17f7d0
com.aerospike.client.AerospikeException: java.io.EOFException
at com.aerospike.client.command.SyncCommand.execute(SyncCommand.java:95)
at com.aerospike.client.AerospikeClient.put(AerospikeClient.java:339)
at $line58.$read$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw$.<init>(<console>:41)
at $line58.$read$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw$.<clinit>(<console>)
at $line58.$eval$.$print$lzycompute(<console>:7)
at $line58.$eval$.$print(<console>:6)
at $line58.$eval.$print(<console>)
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 scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:784)
at scala.tools.nsc.interpreter.IMain$Request.loadAndRun(IMain.scala:1039)
at scala.tools.nsc.interpreter.IMain$WrappedRequest$$anonfun$loadAndRunReq$1.apply(IMain.scala:636)
at scala.tools.nsc.interpreter.IMain$WrappedRequest$$anonfun$loadAndRunReq$1.apply(IMain.scala:635)
at scala.reflect.internal.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:31)
at scala.reflect.internal.util.AbstractFileClassLoader.asContext(AbstractFileClassLoader.scala:19)
at scala.tools.nsc.interpreter.IMain$WrappedRequest.loadAndRunReq(IMain.scala:635)
at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:567)
at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:563)
at scala.tools.nsc.interpreter.ILoop.reallyInterpret$1(ILoop.scala:802)
at scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:836)
at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:694)
at scala.tools.nsc.interpreter.ILoop.processLine(ILoop.scala:404)
at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:424)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:925)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:911)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:911)
at scala.reflect.internal.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:97)
at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:911)
at scala.tools.nsc.interpreter.ILoop.main(ILoop.scala:936)
at xsbt.ConsoleInterface.run(ConsoleInterface.scala:69)
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 sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:102)
at sbt.compiler.AnalyzingCompiler.console(AnalyzingCompiler.scala:77)
at sbt.Console.sbt$Console$$console0$1(Console.scala:23)
at sbt.Console$$anonfun$apply$2$$anonfun$apply$1.apply$mcV$sp(Console.scala:24)
at sbt.Console$$anonfun$apply$2$$anonfun$apply$1.apply(Console.scala:24)
at sbt.Console$$anonfun$apply$2$$anonfun$apply$1.apply(Console.scala:24)
at sbt.Logger$$anon$4.apply(Logger.scala:90)
at sbt.TrapExit$App.run(TrapExit.scala:244)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.EOFException
at com.aerospike.client.cluster.Connection.readFully(Connection.java:100)
at com.aerospike.client.command.WriteCommand.parseResult(WriteCommand.java:67)
at com.aerospike.client.command.SyncCommand.execute(SyncCommand.java:57)
... 47 more
Why is this happening? One thing I noticed is that even with these exceptions, sometimes the objects are actually written to the kvs.
I wanted to try EasyTest to get input parameters from a CSV and found the following, nicely written, example in a blog posted here:
http://gpcmol.blogspot.com/2013/06/easytest-unit-testing-with-externalized.html
If I follow the example it runs beautifully giving me a nice PDF output as advertised.
However if I cause a test case failure, by changing the last line of input from ",9,-12" to ",9,-13", I no longer get PDF output and get 2 failures rather than one.
The first failure is the correct assertion that the test case fails. The second failure is the following exception:
<testcase name="classMethod" classname="TransformCelciusTest" time="0.0">
<failure message="org.junit.experimental.theories.internal.ParameterizedAssertionError: testToCelsiusConverter(TestInfo [testClass=org.junit.runners.model.TestClass#90bb3e6, dataLoader=org.easetech.easytest.loader.CSVDataLoader#5f4fc5ad, filePaths=[data/temperatureConversionData.csv], methodName=testToCelsiusConverter])" type="org.junit.experimental.theories.internal.ParameterizedAssertionError">org.junit.experimental.theories.internal.ParameterizedAssertionError: testToCelsiusConverter(TestInfo [testClass=org.junit.runners.model.TestClass#90bb3e6, dataLoader=org.easetech.easytest.loader.CSVDataLoader#5f4fc5ad, filePaths=[data/temperatureConversionData.csv], methodName=testToCelsiusConverter])
at org.easetech.easytest.util.RunAftersWithOutputData.writeData(RunAftersWithOutputData.java:157)
at org.easetech.easytest.util.RunAftersWithOutputData.evaluate(RunAftersWithOutputData.java:133)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:86)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:49)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:69)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:105)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:355)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
at org.easetech.easytest.loader.CSVDataLoader.writeDataToCSV(CSVDataLoader.java:364)
at org.easetech.easytest.loader.CSVDataLoader.writeData(CSVDataLoader.java:180)
at org.easetech.easytest.util.RunAftersWithOutputData.writeData(RunAftersWithOutputData.java:154)
... 27 more
Caused by: java.lang.NullPointerException
at org.easetech.easytest.loader.CSVDataLoader.writeOutputData(CSVDataLoader.java:382)
at org.easetech.easytest.loader.CSVDataLoader.writeDataToCSV(CSVDataLoader.java:347)
... 29 more
</failure>
</testcase>
Anybody understand how to modify the example so that it properly completes without the ParameterizedAssertionError exception so that the test case failure can be properly reported in the output (PDF)?
I think this is related:
JUnit #Theory : is there a way to throw meaningful exception?
I tested the scenario with EasyTest Core 1.3.1 library and indeed it is an issue(infact a bug) in EasyTest 1.3.1. Specifically there is a NullPointerException in CSVDataLoader because it is expecting the test Duration value but its not present because of test failure. I have to see whats the best solution for this problem. I will keep you posted of the solution. In the mean time, you could try the Excel and XML Data loader. Or if you want a quick solution, you can copy paste the CSVDataLoader and override the line 364 of CSVDataLoader such that it checks if DURATIOn is present and only then call toString on it. Then you can use this Loader as Custom loader in the #DataLoader annotation.
Thanks,
Anuj Kumar
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 ;-)