Start upload failed error while performing checkin operation in FIleNet P8 - filenet-p8

In this code document represents a document object which is already there in content engine. The newDocument represents a document to which I want assign all the properties along with the content of document. My_Class has all the property fields of document's class. I am using the below code to perform this action.
public class DocumentHandler implements EventActionHandler{
private static Logger log = Logger.getLogger(DocumentHandler.class.getName());
#Override
public void onEvent(ObjectChangeEvent event, Id subscriptionId) throws EngineRuntimeException {
PropertyConfigurator.configure("log4j.properties");
try {
if(event.getClassName().equalsIgnoreCase("UpdateEvent")){
ObjectStore objectStore = event.getObjectStore();
Id docId = event.get_SourceObjectId();
Document document = (Document)Factory.Document.fetchInstance(objectStore, docId, null);
log.info("Document fetched after detecting UpdateEvent");
Properties properties = document.getProperties();
if(some condition....)
{
String[] propertyName = {"Prop1","Prop2","Prop3"};
Document newDocument = Factory.Document.createInstance(objectStore, "My_Class");
Properties newDocProps = newDocument.getProperties();
Properties properties = document.getProperties();
//Assigning all the properties from document to newDocument
newDocProps.putValue("DocumentTitle", document.get_Name().toString());
for(int i=0;i<propertyName.length;i++)
{
newDocProps.putValue(propertyName[i], properties.getStringValue(propertyName[i]));
}
try{
createNewDocument(newDocument,document);
}catch (Exception exp) {
log.error("Error while checking in the document "+exp.getLocalizedMessage());
}
Folder folder = Factory.Folder.fetchInstance(objectStore, "/TestDoc", null);
ReferentialContainmentRelationship rcr= Factory.ReferentialContainmentRelationship.createInstance(objectStore, null,AutoUniqueName.AUTO_UNIQUE,DefineSecurityParentage.DO_NOT_DEFINE_SECURITY_PARENTAGE);
rcr.set_Tail(folder);
rcr.set_Head(newDocument);
rcr.set_ContainmentName(newDocument.get_Name());
rcr.save(RefreshMode.NO_REFRESH);
//Delete document
document.delete();
document.save(RefreshMode.NO_REFRESH);
}else{
Do something else.....
}
}catch(Exception e){
log.error(e.getLocalizedMessage());
}
}
}
Here is the private method that creates new document
private void createNewDocument(Document newDocument, Document document) throws IOException {
if(document != null){
ContentElementList transferList = document.get_ContentElements();
if(!transferList.isEmpty()){
ContentTransfer transfer = (ContentTransfer) transferList.get(0);
InputStream fileInputStream = transfer.accessContentStream();
byte[] bs = IOUtils.toByteArray(fileInputStream);
ContentElementList elementList = Factory.ContentElement.createList();
ContentTransfer contentTransfer = Factory.ContentTransfer.createInstance();
contentTransfer.set_ContentType(document.get_MimeType());
contentTransfer.set_RetrievalName(transfer.get_RetrievalName());
contentTransfer.setCaptureSource(new ByteArrayInputStream(bs));
elementList.add(contentTransfer);
newDocument.set_ContentElements(elementList);
newDocument.set_MimeType(document.get_MimeType());
newDocument.checkin(AutoClassify.DO_NOT_AUTO_CLASSIFY, CheckinType.MAJOR_VERSION);
newDocument.save(RefreshMode.NO_REFRESH);
}
}
}
While performing the checkin process I'm getting the error
Error while checking in the document Start upload failed /opt/FileNet_FileStore/ObjStMyPrj_FSA/inbound/I0/FN{443F423A-3165-41DE-9CAD-ADB9689A8754}{A0CD3934-918F-416D-B289-FDAD8F3C43C5}.
java.io.FileNotFoundException: /opt/FileNet_FileStore/ObjStMyPrj_FSA/inbound/I0/FN{443F423A-3165-41DE-9CAD-ADB9689A8754}{A0CD3934-918F-416D-B289-FDAD8F3C43C5} (The file access permissions do not allow the specified action.)
As I am using EventActionHandler and testing is done on server; so, I could only get the error log generated. Thanks!
EDIT: Error stack trace
com.filenet.api.exception.EngineRuntimeException: FNRCC0023E: CONTENT_CA_START_UPLOAD_FAILED: Start upload failed /opt/FileNet_FileStore/ObjStMarcomPrj_FSA/inbound/I56/FN{7406E592-EBBF-4240-9665-A0A9E876AA4F}{8974CE3E-8F6C-4366-B6A7-DE774FED8AB0}.
at com.filenet.engine.content.BaseContentArea.createPutContentUpload(BaseContentArea.java:861)
at com.filenet.engine.content.FileContentArea.startPutContent(FileContentArea.java:929)
at com.filenet.engine.content.ContentOperations.startPutContent(ContentOperations.java:583)
at com.filenet.engine.content.PutContentHandler.startNewElement(PutContentHandler.java:613)
at com.filenet.engine.content.PutContentHandler.putContent(PutContentHandler.java:206)
at com.filenet.engine.jca.impl.RequestBrokerImpl.putContent(RequestBrokerImpl.java:393)
at com.filenet.engine.context.ServerSession.uploadContent(ServerSession.java:159)
at com.filenet.engine.context.ServerSession.executeChanges(ServerSession.java:88)
at com.filenet.apiimpl.core.Session.callExecuteChanges(Session.java:181)
at com.filenet.apiimpl.core.Session.executeChanges(Session.java:557)
at com.filenet.apiimpl.core.Session.executeChange(Session.java:846)
at com.filenet.apiimpl.core.IndependentlyPersistableObjectImpl.save(IndependentlyPersistableObjectImpl.java:83)
at com.filenet.apiimpl.core.IndependentlyPersistableObjectImpl.save(IndependentlyPersistableObjectImpl.java:74)
at com.ibm.idea.publishDocumentHandler.PublishDocumentHandler.createDocument(PublishDocumentHandler.java:161)
at com.ibm.idea.publishDocumentHandler.PublishDocumentHandler.onEvent(PublishDocumentHandler.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at com.filenet.engine.queueitem.SubscriptionProcessor.executeHandler(SubscriptionProcessor.java:1110)
at com.filenet.engine.queueitem.SubscriptionProcessor.execute(SubscriptionProcessor.java:902)
at com.filenet.engine.queueitem.SubscriptionProcessor.fireOrQueue(SubscriptionProcessor.java:737)
at com.filenet.engine.queueitem.SubscriptionProcessor.processEvent(SubscriptionProcessor.java:694)
at com.filenet.engine.queueitem.SubscriptionProcessor.fetchActionAndProcessEvents(SubscriptionProcessor.java:669)
at com.filenet.engine.queueitem.SubscriptionProcessor.processEvents(SubscriptionProcessor.java:504)
at com.filenet.engine.persist.SubscribablePersister.postExecuteChange(SubscribablePersister.java:352)
at com.filenet.engine.persist.ReplicablePersister.postExecuteChange(ReplicablePersister.java:135)
at com.filenet.engine.persist.WithContentPersister.postExecuteChange(WithContentPersister.java:525)
at com.filenet.engine.persist.VersionablePersister.postExecuteChange(VersionablePersister.java:302)
at com.filenet.engine.persist.IndependentPersister.executeChangeWork(IndependentPersister.java:437)
at com.filenet.engine.persist.IndependentPersister.executeChange(IndependentPersister.java:225)
at com.filenet.engine.persist.SubscribablePersister.executeChange(SubscribablePersister.java:172)
at com.filenet.engine.jca.impl.RequestBrokerImpl.executeChanges(RequestBrokerImpl.java:1266)
at com.filenet.engine.jca.impl.RequestBrokerImpl.executeChanges(RequestBrokerImpl.java:1146)
at com.filenet.engine.ejb.EngineCoreBean._executeChanges(EngineCoreBean.java:618)
at com.filenet.engine.ejb.EngineCoreBean.executeChanges(EngineCoreBean.java:586)
at com.filenet.engine.ejb.EJSLocalStatelessEngineCore_22877cb1.executeChanges(Unknown Source)
at com.filenet.engine.ejb.EngineBean.executeChanges(EngineBean.java:832)
at com.filenet.apiimpl.transport.ejbstubs.EJSRemoteStatelessEngine_2e64c374.executeChanges(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at com.ibm.rmi.util.ProxyUtil$4.run(ProxyUtil.java:620)
at java.security.AccessController.doPrivileged(AccessController.java:277)
at com.ibm.rmi.util.ProxyUtil.invokeWithClassLoaders(ProxyUtil.java:616)
at com.ibm.CORBA.iiop.ClientDelegate.invoke(ClientDelegate.java:1094)
at $Proxy32.executeChanges(Unknown Source)
at com.filenet.apiimpl.transport.ejbstubs._Engine_Stub.executeChanges(Unknown Source)
at com.filenet.apiimpl.transport.ejb.EJBSession$EJBImpl._executeChanges(EJBSession.java:898)
at com.filenet.apiimpl.transport.ejb.EJBSession$EJBImpl.executeChanges(EJBSession.java:623)
at com.filenet.apiimpl.transport.ejb.EJBSession.executeChanges(EJBSession.java:389)
at com.filenet.apiimpl.util.SessionHandle.executeChanges(SessionHandle.java:130)
at com.filenet.apiimpl.core.Session.callExecuteChanges(Session.java:174)
at com.filenet.apiimpl.core.Session.executeChanges(Session.java:557)
at com.filenet.apiimpl.core.Session.executeChange(Session.java:846)
at com.filenet.apiimpl.core.IndependentlyPersistableObjectImpl.save(IndependentlyPersistableObjectImpl.java:83)
at com.filenet.apiimpl.core.IndependentlyPersistableObjectImpl.save(IndependentlyPersistableObjectImpl.java:74)
at com.filenet.wcm.api.impl.bd.ZMI_SetProperties.execute(ZMI_SetProperties.java:180)
at com.filenet.wcm.api.impl.bd.MethodImplementation.createAndCall(MethodImplementation.java:154)
at com.filenet.wcm.api.impl.bd.RcBd.performMethodAndGetResponse(RcBd.java:222)
at com.filenet.wcm.api.impl.bd.RcBd.doRpc(RcBd.java:147)
at com.filenet.wcm.api.impl.bd.RcBd.doRpc(RcBd.java:40)
at com.filenet.wcm.api.impl.RemoteCommand.execute(RemoteCommand.java:415)
at com.filenet.wcm.api.impl.RemoteCommand.executeInner(RemoteCommand.java:397)
at com.filenet.wcm.api.impl.RemoteCommand.execute(RemoteCommand.java:329)
at com.filenet.wcm.api.impl.RemoteCommand.executeExpectingVoid(RemoteCommand.java:243)
at com.filenet.wcm.api.impl.BaseObjectImpl.setClassPropsPerms(BaseObjectImpl.java:1461)
at com.filenet.wcm.api.impl.BaseObjectImpl.setProperties(BaseObjectImpl.java:1492)
at com.filenet.wcm.api.impl.BaseObjectImpl.setProperties(BaseObjectImpl.java:1468)
at com.filenet.wcm.toolkit.server.dp.WcmAuthoringDataProvider.setProperties(WcmAuthoringDataProvider.java:937)
at com.filenet.wcm.apps.server.ui.info.WcmPropertiesInfoPage.panelFinish(WcmPropertiesInfoPage.java:2133)
at com.filenet.wcm.apps.server.ui.WcmInfoModule.applyModifiedPanels(WcmInfoModule.java:488)
at com.filenet.wcm.apps.server.ui.WcmInfoModule.apply(WcmInfoModule.java:454)
at com.filenet.wcm.apps.server.ui.WcmInfoModule.onApply(WcmInfoModule.java:445)
at sun.reflect.GeneratedMethodAccessor843.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at com.filenet.wcm.toolkit.server.base.WcmController.invokeNamedEvent(WcmController.java:4500)
at com.filenet.wcm.toolkit.server.base.WcmController.dispatchEvent(WcmController.java:4618)
at com.filenet.wcm.toolkit.server.base.WcmController.executeModel(WcmController.java:3764)
at com.filenet.wcm.apps.server.controller.WcmWorkplaceController.executeModel(WcmWorkplaceController.java:525)
at com.filenet.wcm.toolkit.server.base.WcmController.initializeModulesWork(WcmController.java:3677)
at com.filenet.wcm.toolkit.server.base.WcmController.initializeModules(WcmController.java:3614)
at com.filenet.wcm.toolkit.server.base.WcmController.initializeModules(WcmController.java:3491)
at com.filenet.wcm.toolkit.server.base.WcmController.handleEvent(WcmController.java:3202)
at com.filenet.wcm.apps.server.controller.WcmWorkplaceController.handleEvent(WcmWorkplaceController.java:569)
at com.filenet.wcm.toolkit.server.base.WcmController.handleEvent(WcmController.java:3134)
at com.ibm._jsp._ObjectInfo._jspService(_ObjectInfo.java:175)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1657)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1597)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:131)
at com.filenet.ae.servlet.filter.SecurityPluginFilter.doFilter(SecurityPluginFilter.java:162)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:116)
at com.filenet.ae.toolkit.server.servlet.filter.ThreadLocalCleanupFilter.doFilter(ThreadLocalCleanupFilter.java:40)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:116)
at com.filenet.ae.toolkit.server.servlet.filter.PostprocessorFilter.doFilter(PostprocessorFilter.java:38)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:116)
at com.filenet.ae.toolkit.server.servlet.filter.ContainerBasedFilter.doFilter(ContainerBasedFilter.java:228)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:116)
at com.filenet.ae.toolkit.server.servlet.filter.SessionStateFilter.doFilter(SessionStateFilter.java:158)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:116)
at com.filenet.ae.toolkit.server.servlet.filter.PreprocessorFilter.doFilter(PreprocessorFilter.java:118)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:116)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:77)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:908)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:934)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:502)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:181)
at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:121)
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:259)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:864)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1592)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1646)

We got this same error when our filestore disk became completely filled. Adding more disk fixed the issue.

Related

invalid stored block lengths java.io.IOException: invalid stored block lengths

I have one zip that contains 2 JSON files. When I process those files I got the following error. The first file is processed properly when it comes to the second file which throws ZipException.
How can I fix this?
My code,
private Path archivePath = Paths.get("src/test/resources/data/files.zip";
public void uploadData() throws IOException {
FileSystem fileFS = FileSystems.newFileSystem(archivePath,(ClassLoader) null);
String[] pathNames = {"file_1.json","file_2.json"};
for(String pathName : pathNames) {
//unzip files
Path path = fileFS.getPath(pathName);
Request request = new Request("POST","/_bulk");
RequestOptions.Builder options = RequestOptions.DEFAULT.toBuilder();
options.addHeader("Content-Type","application/x-ndjson");
request.setOptions(options);
request.setEntity(new InputStreamEntity(Files.newInputStream(path)));
Response response = client.performRequest(request);
assertResponseSuccessful(response,false);
}
Error:
invalid stored block lengths
java.io.IOException: invalid stored block lengths
at org.elasticsearch.client.RestClient.extractAndWrapCause(RestClient.java:828)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:248)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:235)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:134)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:597)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:173)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:816)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:146)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.testng.TestRunner.privateRun(TestRunner.java:766)
at org.testng.TestRunner.run(TestRunner.java:587)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:384)
at org.testng.SuiteRunner.access$000(SuiteRunner.java:28)
at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:425)
at org.testng.internal.thread.ThreadUtil.lambda$execute$0(ThreadUtil.java:68)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.util.zip.ZipException: invalid stored block lengths
at java.base/java.util.zip.InflaterInputStream.read(InflaterInputStream.java:165)
at java.base/java.nio.channels.Channels$ReadableByteChannelImpl.read(Channels.java:388)
at org.apache.http.nio.entity.EntityAsyncContentProducer.produceContent(EntityAsyncContentProducer.java:67)
at org.apache.http.nio.protocol.BasicAsyncRequestProducer.produceContent(BasicAsyncRequestProducer.java:125)
at org.apache.http.impl.nio.client.MainClientExec.produceContent(MainClientExec.java:262)
at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.produceContent(DefaultClientExchangeHandlerImpl.java:140)
at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.outputReady(HttpAsyncRequestExecutor.java:249)
at org.apache.http.impl.nio.client.InternalRequestExecutor.outputReady(InternalRequestExecutor.java:96)
at org.apache.http.impl.nio.DefaultNHttpClientConnection.produceOutput(DefaultNHttpClientConnection.java:290)
at org.apache.http.impl.nio.client.InternalIODispatch.onOutputReady(InternalIODispatch.java:86)
at org.apache.http.impl.nio.client.InternalIODispatch.onOutputReady(InternalIODispatch.java:39)
at org.apache.http.impl.nio.reactor.AbstractIODispatch.outputReady(AbstractIODispatch.java:145)
at org.apache.http.impl.nio.reactor.BaseIOReactor.writable(BaseIOReactor.java:187)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:341)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:315)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:276)
at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:591)
... 1 more
Any inputs here are really be appreciated.

Why is mybatis reporting this error in this concurrent scenario, the springboot integrated sqlsessiontemplate is not thread safe?

** fisrt. My project is about the list of articles recommended,every article have there own rule,so i use AsyncTaskExecutor this tool class to concurrent query different articles, and now,some rules is special,So I split them into different rules into two parts. next is my code:
i use springboot + mybatis to do**
#Bean
public AsyncTaskExecutor dataTaskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(16);
executor.setThreadNamePrefix("data_task_executor-");
return executor;
}
here i initialization AsyncTaskExecutor class for ready
Next is the partial code of the concurrent query.
// here i get different rule list
List<Rule> ruleList = JSON.parseArray(scene.getRules(), Rule.class);
Iterator<Rule> ruleIterator = ruleList.iterator();
CountDownLatch latch1 = new CountDownLatch(ruleList.size());
while (ruleIterator.hasNext()) {
Rule ruleNext = ruleIterator.next();
// unAsyncScenes is a array,this rule query in here
if (Arrays.binarySearch(unAsyncScenes, ruleNext.getSource()) >= 0) {
dataTaskExecutor.execute(() -> {
try {
searchIDSByRule(idWithRtsMap, articleReferralList, sceneId, feedSum, userId, isNewUserByHistory, discussHistoryList, discussList, graphHistorys, ruleNext);
//Record browsing history
graphHistorys.addAll(idWithRtsMap.keySet());
} catch (Exception e) {
log.warn("子规则查图失败", e);
} finally {
latch1.countDown();
}
});
//Query deleted
ruleIterator.remove();
} else {
latch1.countDown();
}
}
try {
latch1.await(10, TimeUnit.SECONDS);
} catch (InterruptedException e) {
log.error("多线等待异常:", e);
}
//deal with Duplicate article
Set<Long> articleSet = new HashSet();
articleReferralList.forEach(article -> articleSet.add(article));
if (articleReferralList.size() != articleSet.size()) {
log.warn("出现了重复的文章");
articleReferralList.clear();
articleReferralList.addAll(articleSet);
}
final CountDownLatch latch = new CountDownLatch(ruleList.size());
for (Rule rule : ruleList) {
// second concurrent query(query for other article)
dataTaskExecutor.execute(() -> {
try { *****// here hava error!!!!!!!!!!!!*****
searchIDSByRule(idWithRtsMap, articleReferralList, sceneId, feedSum, userId, isNewUserByHistory, discussHistoryList, discussList, graphHistorys, rule);
} catch (Exception e) {
log.warn("子规则查图失败", e);
} finally {
latch.countDown();
}
});
}
try {
latch.await(10, TimeUnit.SECONDS);
} catch (InterruptedException e) {
log.error("多线等待异常:", e);
}
this is all query code, but went i run this code, it sometimes gives an error like this:
org.apache.ibatis.exceptions.PersistenceException: \
### Error querying database. Cause: java.util.ConcurrentModificationException\
### Cause: java.util.ConcurrentModificationException\
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77) ~[mybatis-spring-1.3.1.jar!\/:1.3.1]\
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446) ~[mybatis-spring-1.3.1.jar!\/:1.3.1]\
at com.sun.proxy.$Proxy91.selectList(Unknown Source) ~[?:?]\
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230) ~[mybatis-spring-1.3.1.jar!\/:1.3.1]\
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:137) ~[mybatis-3.4.5.jar!\/:3.4.5]\
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:75) ~[mybatis-3.4.5.jar!\/:3.4.5]\
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59) ~[mybatis-3.4.5.jar!\/:3.4.5]\
at com.sun.proxy.$Proxy131.searchBySigAndExample(Unknown Source) ~[?:?]\
at com.coffee.ref.service.impl.ReferralServiceImpl.searchIDSByRule(ReferralServiceImpl.java:842) ~[classes!\/:0.0.1]\
at com.coffee.ref.service.impl.ReferralServiceImpl.lambda$findArticleIDSByRule$7(ReferralServiceImpl.java:625) ~[classes!\/:0.0.1]\
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_212]\
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_212]\
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_212]\
Caused by: org.apache.ibatis.exceptions.PersistenceException: \
### Error querying database. Cause: java.util.ConcurrentModificationException\
### Cause: java.util.ConcurrentModificationException\
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) ~[mybatis-3.4.5.jar!\/:3.4.5]\
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150) ~[mybatis-3.4.5.jar!\/:3.4.5]\
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) ~[mybatis-3.4.5.jar!\/:3.4.5]\
at sun.reflect.GeneratedMethodAccessor143.invoke(Unknown Source) ~[?:?]\
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]\
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]\
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433) ~[mybatis-spring-1.3.1.jar!\/:1.3.1]\
... 11 more\
Caused by: java.util.ConcurrentModificationException\
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:909) ~[?:1.8.0_212]\
at java.util.ArrayList$Itr.next(ArrayList.java:859) ~[?:1.8.0_212]\
at org.apache.ibatis.scripting.xmltags.ForEachSqlNode.apply(ForEachSqlNode.java:62) ~[mybatis-3.4.5.jar!\/:3.4.5]\
at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:33) ~[mybatis-3.4.5.jar!\/:3.4.5]\
at org.apache.ibatis.scripting.xmltags.IfSqlNode.apply(IfSqlNode.java:35) ~[mybatis-3.4.5.jar!\/:3.4.5]\
at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:33) ~[mybatis-3.4.5.jar!\/:3.4.5]\
at org.apache.ibatis.scripting.xmltags.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:41) ~[mybatis-3.4.5.jar!\/:3.4.5]\
at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:292) ~[mybatis-3.4.5.jar!\/:3.4.5]\
at com.github.pagehelper.PageInterceptor.intercept(PageInterceptor.java:83) ~[pagehelper-5.1.2.jar!\/:?]\
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61) ~[mybatis-3.4.5.jar!\/:3.4.5]\
at com.sun.proxy.$Proxy188.query(Unknown Source) ~[?:?]\
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148) ~[mybatis-3.4.5.jar!\/:3.4.5]\
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) ~[mybatis-3.4.5.jar!\/:3.4.5]\
at sun.reflect.GeneratedMethodAccessor143.invoke(Unknown Source) ~[?:?]\
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]\
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]\
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433) ~[mybatis-spring-1.3.1.jar!\/:1.3.1]\
... 11 more\"}"]
The place where the error was reported is marked above.I don't understand why, mybatis should be thread safe.
enter image description here
The official documentation says it is thread safe.
SqlSessionTemplate itself is thread safe. The problem is in your code.
The exception shows that error happens in the foreach element. Note this piece of the stacktrace:
Caused by: java.util.ConcurrentModificationException\
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:909) ~[?:1.8.0_212]\
at java.util.ArrayList$Itr.next(ArrayList.java:859) ~[?:1.8.0_212]\
at org.apache.ibatis.scripting.xmltags.ForEachSqlNode.apply(ForEachSqlNode.java:62) ~[mybatis-3.4.5.jar!\/:3.4.5]\
So what happens here? In the mapper you build SQL dynamically by iterating over some collection. This collection is modified concurrently by another thread. The iterator over the collection has built-in check that collection is not modified and this check indicates you that there is a problem.
In order to fix this you need to synchronize access to the collection that is used in multiple threads so that when you use the collection to query some data based on it this happens atomically and no modification can happen in the middle of the query generation.
One possible reason of this is that the result of this await is not analyzed:
latch1.await(10, TimeUnit.SECONDS);
If the processing takes more than 10 seconds the second part starts executing while the data that query is based on is still being modified. This can happen as the amount of work to do depends on the data.
You need to check the result of this await and do not continue processing until all tasks in the first part of the procedure are finished.

Unknown host exception while using Java APIs to index documents (RestHighLevelClient) Elasticsearch

I am using the vpc endpoint for elastic search to index my documents using RestHighLevelClient.
I am using java high level rest client v6.2.2 to connect Elasticsearch version 6.0
I am able to access my cluster endpoint without the need of any authentication - https://vpc......us-east-1.es.amazonaws.com
Code is as below:
RestHighLevelClient client = null;
try {
Header[] headers = { new BasicHeader(HttpHeaders.CONTENT_TYPE, "application/json")};
RestClientBuilder restClientBuilder = RestClient.builder(new HttpHost("https://vpc...us-east-1.es.amazonaws.com", 9200, "https"));
restClientBuilder.setMaxRetryTimeoutMillis(30); //Currently, set as default
restClientBuilder.setDefaultHeaders(headers);
client = new RestHighLevelClient(restClientBuilder);
IndexRequest indexRequest = new IndexRequest(index, "doc", 1)
.source(documentJson, XContentType.JSON);
indexRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
IndexResponse indexResponse = client.index(indexRequest);
}catch(Exception e){
}finally {
try {
client.close();
} catch (IOException e) {
}
}
}
Exception:
Caused by: java.net.UnknownHostException: https://vpc-had-webapps-logs-umrm7skxqc2n5z6wc5jx632que.us-east-1.es.amazonaws.com/
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) ~[na:1.8.0_45]
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:907) ~[na:1.8.0_45]
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1302) ~[na:1.8.0_45]
at java.net.InetAddress.getAllByName0(InetAddress.java:1255) ~[na:1.8.0_45]
at java.net.InetAddress.getAllByName(InetAddress.java:1171) ~[na:1.8.0_45]
at java.net.InetAddress.getAllByName(InetAddress.java:1105) ~[na:1.8.0_45]
at org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45) ~[httpclient-4.5.5.jar:4.5.5]
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager$InternalAddressResolver.resolveRemoteAddress(PoolingNHttpClientConnectionManager.java:637) ~[httpasyncclient-4.1.3.jar:4.1.3]
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager$InternalAddressResolver.resolveRemoteAddress(PoolingNHttpClientConnectionManager.java:608) ~[httpasyncclient-4.1.3.jar:4.1.3]
at org.apache.http.nio.pool.AbstractNIOConnPool.processPendingRequest(AbstractNIOConnPool.java:474) ~[httpcore-nio-4.4.9.jar:4.4.9]
at org.apache.http.nio.pool.AbstractNIOConnPool.lease(AbstractNIOConnPool.java:280) ~[httpcore-nio-4.4.9.jar:4.4.9]
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.requestConnection(PoolingNHttpClientConnectionManager.java:268) ~[httpasyncclient-4.1.3.jar:4.1.3]
at org.apache.http.impl.nio.client.AbstractClientExchangeHandler.requestConnection(AbstractClientExchangeHandler.java:377) ~[httpasyncclient-4.1.3.jar:4.1.3]
at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.start(DefaultClientExchangeHandlerImpl.java:129) ~[httpasyncclient-4.1.3.jar:4.1.3]
at org.apache.http.impl.nio.client.InternalHttpAsyncClient.execute(InternalHttpAsyncClient.java:141) ~[httpasyncclient-4.1.3.jar:4.1.3]
at org.elasticsearch.client.RestClient.performRequestAsync(RestClient.java:346) ~[elasticsearch-rest-client-6.2.2.jar:5.6.8]
at org.elasticsearch.client.RestClient.performRequestAsync(RestClient.java:328) ~[elasticsearch-rest-client-6.2.2.jar:5.6.8]
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:221) ~[elasticsearch-rest-client-6.2.2.jar:5.6.8]
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:194) ~[elasticsearch-rest-client-6.2.2.jar:5.6.8]
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:488) ~[elasticsearch-rest-high-level-client-6.2.2.jar:5.6.8]
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:474) ~[elasticsearch-rest-high-level-client-6.2.2.jar:5.6.8]
at org.elasticsearch.client.RestHighLevelClient.index(RestHighLevelClient.java:335) ~[elasticsearch-rest-high-level-client-6.2.2.jar:5.6.8]
Appreciate any inputs.
thanks!
Replace the HttpHost object instantiantion with:
new HttpHost("vpc-had-webapps-logs-umrm7skxqc2n5z6wc5jx632que.us-east-1.es.amazonaws.com", 9200, "https")
like in this example.

[SPARK]: java.lang.IllegalArgumentException: java.net.UnknownHostException: plumber

I build a spark streaming application.This application read data form socket, and compute, then write the result into hdfs. But application run in A hadoop cluster, the hdfs in B hadoop cluster. Below is my code:
if (args.length < 2) {
System.out.println("Usage: StreamingWriteHdfs hostname port")
System.exit(-1)
}
val conf = new SparkConf()
conf.setAppName("StreamingWriteHdfs")
val ssc = new StreamingContext(conf, Durations.seconds(10))
ssc.checkpoint("/tmp")
val hostname: String = args(0)
val port :Int = Integer.parseInt(args(1))
val lines = ssc.socketTextStream(hostname, port)
val words = lines.flatMap(_.split(" "))
val pairs = words.map(word => (word, 1))
val wordCounts = pairs.reduceByKey(_ + _)
wordCounts.print()
//TODO write to hdfs
wordCounts.saveAsHadoopFiles("hdfs://plumber/tmp/test/streaming",
"out",
classOf[Text],
classOf[IntWritable],
classOf[TextOutputFormat[Text, IntWritable]])
ssc.start()
ssc.awaitTermination()
When run this appplication in A cluster,get this execption:
java.lang.IllegalArgumentException: java.net.UnknownHostException:plumber
at org.apache.hadoop.security.SecurityUtil.buildTokenService(SecurityUtil.java:377)
at org.apache.hadoop.hdfs.NameNodeProxies.createNonHAProxy(NameNodeProxies.java:310)
at org.apache.hadoop.hdfs.NameNodeProxies.createProxy(NameNodeProxies.java:176)
at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:678)
at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:619)
at org.apache.hadoop.hdfs.DistributedFileSystem.initialize(DistributedFileSystem.java:149)
at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2653)
at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:92)
at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:2687)
at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2669)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:371)
at org.apache.hadoop.fs.Path.getFileSystem(Path.java:295)
at org.apache.hadoop.yarn.util.FSDownload.copy(FSDownload.java:251)
at org.apache.hadoop.yarn.util.FSDownload.access$000(FSDownload.java:63)
at org.apache.hadoop.yarn.util.FSDownload$2.run(FSDownload.java:361)
at org.apache.hadoop.yarn.util.FSDownload$2.run(FSDownload.java:359)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1657)
at org.apache.hadoop.yarn.util.FSDownload.call(FSDownload.java:358)
at org.apache.hadoop.yarn.util.FSDownload.call(FSDownload.java:62)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.UnknownHostException: plumber
the B hadoop cluster's fs.defaultFS is hdfs://plumber.
some one can help me out! thxs.
I think you need to modify the host name like
"hdfs://plumber:8020/tmp/test/streaming".

WSO2 issue creating organization using TenantMgtAdminServiceStub

I wrote a code that adds a tenant to WSO2 using TenantMgtAdminServiceStub.
The tenant is added successfully, however when I try to add API to it using APIM 1.10.0 CreateApi::postApis, I get an exception (all details will follow below).
Only after I login to the admin of the newly created tenant's in the publisher UI (or by curl to login.jag) I'm able to add my API using the same CreateApi::postApis.
Here are the details.
The code to add the tenant:
System.setProperty("javax.net.ssl.trustStore", clientTrustStore.getAbsolutePath());
System.setProperty("javax.net.ssl.trustStorePassword", "admin");
System.setProperty("javax.net.ssl.trustStoreType", "admin");
System.setProperty("carbon.repo.write.mode", "true");
TenantMgtAdminServiceStub stub = new TenantMgtAdminServiceStub("https://localhost:9443/services/TenantMgtAdminService.TenantMgtAdminServiceHttpsSoap12Endpoint/");
ServiceClient sc = stub._getServiceClient();
setBasicAccessSecurityHeaders(adminUser, adminPasswd, sc);
try
{
TenantInfoBean tenant = new TenantInfoBean();
tenant.setActive(true);
tenant.setAdmin("admin");
tenant.setAdminPassword("admin");
tenant.setTenantDomain("testing123.com");
tenant.setFirstname("first");
tenant.setLastname("last");
tenant.setEmail("email#testing123.com");
stub.addTenant(tenant);
}
catch (RemoteException e) { ... }
catch (TenantMgtAdminServiceExceptionException e) { ... }
finally
{
stub.cleanup();
}
The code that adds the API:
ApiClient apiClient = Configuration.getDefaultApiClient();
apiClient.setBasePath("https://localhost:9443/api/am/publisher/v0.9");
apiClient.getAuthentications().put("BasicAuth", new HttpBasicAuth());
apiClient.setUsername("admin#testing123.com");
apiClient.setPassword("admin");
apiClient.setDebugging(true);
CreateApi crApi = new CreateApi(apiClient);
API body = new API();
... invoke setters of body ...
API createdApi = crApi.apisPost(body, "application/json");
...
Doing so I receive the following exception:
TID: [11] [] [2016-04-13 10:13:37,065] admin#testing123.com#testing123.com [11] [AM]ERROR {org.wso2.carbon.governance.api.common.dataobjects.GovernanceArtifactImpl} - Error in associating lifecycle for the artifact. id: b299a2ca-ae27-4198-a8dc-f69afda05379, path: /apimgt/applicationdata/provider/admin-AT-testing123.com/partnerInfo/1.0.0/api. {org.wso2.carbon.governance.api.common.dataobjects.GovernanceArtifactImpl}
org.wso2.carbon.registry.core.exceptions.RegistryException: Couldn't find aspectName 'APILifeCycle'
at org.wso2.carbon.registry.core.jdbc.EmbeddedRegistry.associateAspect(EmbeddedRegistry.java:2428)
at org.wso2.carbon.registry.core.caching.CacheBackedRegistry.associateAspect(CacheBackedRegistry.java:458)
at org.wso2.carbon.registry.core.session.UserRegistry.associateAspectInternal(UserRegistry.java:1900)
at org.wso2.carbon.registry.core.session.UserRegistry.access$3800(UserRegistry.java:60)
at org.wso2.carbon.registry.core.session.UserRegistry$39.run(UserRegistry.java:1872)
at org.wso2.carbon.registry.core.session.UserRegistry$39.run(UserRegistry.java:1869)
at java.security.AccessController.doPrivileged(Native Method)
at org.wso2.carbon.registry.core.session.UserRegistry.associateAspect(UserRegistry.java:1869)
at org.wso2.carbon.governance.api.common.dataobjects.GovernanceArtifactImpl.attachLifecycle(GovernanceArtifactImpl.java:378)
at org.wso2.carbon.apimgt.impl.APIProviderImpl.createAPI(APIProviderImpl.java:2119)
at org.wso2.carbon.apimgt.impl.APIProviderImpl.addAPI(APIProviderImpl.java:574)
at org.wso2.carbon.apimgt.impl.UserAwareAPIProvider.addAPI(UserAwareAPIProvider.java:48)
at org.wso2.carbon.apimgt.rest.api.publisher.impl.ApisApiServiceImpl.apisPost(ApisApiServiceImpl.java:180)
at org.wso2.carbon.apimgt.rest.api.publisher.ApisApi.apisPost(ApisApi.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:200)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:99)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:96)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:251)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160)
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:180)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:293)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:212)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:268)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.wso2.carbon.tomcat.ext.valves.CompositeValve.continueInvocation(CompositeValve.java:99)
at org.wso2.carbon.tomcat.ext.valves.CarbonTomcatValve$1.invoke(CarbonTomcatValve.java:47)
at org.wso2.carbon.webapp.mgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:57)
at org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer.invokeValves(TomcatValveContainer.java:47)
at org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:62)
at org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:159)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:57)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1739)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1698)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Now, as a workaround, I simply log into the admin of this newly created organization:
curl -X POST -c cookies http://localhost:9763/publisher/site/blocks/user/login/ajax/login.jag -d 'action=login&username=admin#testing123.com&password=admin'
And now when I'm trying to add API using the same code exactly, the API is added successfully.
I believe the meaningful part of the exception is:
{org.wso2.carbon.governance.api.common.dataobjects.GovernanceArtifactImpl} -
Error in associating lifecycle for the artifact.
id: b299a2ca-ae27-4198-a8dc-f69afda05379,
path: /apimgt/applicationdata/provider/admin-AT-testing123.com/partnerInfo/1.0.0/api.
{org.wso2.carbon.governance.api.common.dataobjects.GovernanceArtifactImpl}
org.wso2.carbon.registry.core.exceptions.RegistryException:
Couldn't find aspectName 'APILifeCycle'
at org.wso2.carbon.registry.core.jdbc.EmbeddedRegistry.associateAspect(EmbeddedRegistry.java:2428)
Again, I did not change anything in the code to make the postApis work, only logged-in to the admin user and it resolved by itself by re-run of the same code.
I cannot tell what exactly is the root cause.

Resources