Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

[Urgent] Problem - Attaching a file in a workitem web page

Hi,

I have a problem that I can not attach a file in a workitem web page.
When I try to attach a file in a workitem web page, I get a message as follow and exception in log.
Help me !

- Dialog message : Error uploading file: 'Save Work Item' failed.

- PIPreOperation.java 86 line code

IWorkItem newState = (IWorkItem) saveParameter.getNewState();

- Exception

java.lang.ClassCastException: com.ibm.team.workitem.common.internal.model.impl.AttachmentImpl incompatible with com.ibm.team.workitem.common.model.IWorkItem
    at lsg.ams.rtc.plugin.PIPreOperation.run(PIPreOperation.java:86)
    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 org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.invoke(ExportProxyServiceRecord.java:361)
    at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.access$0(ExportProxyServiceRecord.java:347)
    at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord$ExportedServiceInvocationHandler.invoke(ExportProxyServiceRecord.java:56)
    at $Proxy2039.run(Unknown Source)
    at com.ibm.team.process.internal.common.advice.runtime.OperationAdviceManager.runAdvisor(OperationAdviceManager.java:1253)
    at com.ibm.team.process.internal.common.advice.runtime.OperationAdviceManager.runAdvisors(OperationAdviceManager.java:912)
    at com.ibm.team.process.internal.common.advice.runtime.OperationAdviceManager.advise(OperationAdviceManager.java:293)
    at com.ibm.team.process.internal.common.util.AbstractProcess.doAdvise(AbstractProcess.java:194)
    at com.ibm.team.process.internal.service.ServerProcess.access$2(ServerProcess.java:1)
    at com.ibm.team.process.internal.service.ServerProcess$2.run(ServerProcess.java:156)
    at com.ibm.team.repository.service.internal.PrimitiveTransactionService$3.run(PrimitiveTransactionService.java:176)
    at com.ibm.team.repository.service.internal.rdb.RepositoryDatabase.runTransaction(RepositoryDatabase.java:339)
    at com.ibm.team.repository.service.internal.rdb.RepositoryDatabase.runInTransaction(RepositoryDatabase.java:263)
    at com.ibm.team.repository.service.internal.PrimitiveTransactionService.runInTransaction(PrimitiveTransactionService.java:110)
    at com.ibm.team.repository.service.internal.PrimitiveTransactionService.runInTransaction(PrimitiveTransactionService.java:105)
    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 org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.invoke(ExportProxyServiceRecord.java:361)
    at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.access$0(ExportProxyServiceRecord.java:347)
    at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord$ExportedServiceInvocationHandler.invoke(ExportProxyServiceRecord.java:56)
    at $Proxy90.runInTransaction(Unknown Source)
    at com.ibm.team.repository.service.internal.TransactionService.runInTransaction(TransactionService.java:37)
    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 org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.invoke(ExportProxyServiceRecord.java:361)
    at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.access$0(ExportProxyServiceRecord.java:347)
    at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord$ExportedServiceInvocationHandler.invoke(ExportProxyServiceRecord.java:56)
    at $Proxy170.runInTransaction(Unknown Source)
    at com.ibm.team.process.internal.service.ProcessService.runInTransaction(ProcessService.java:4772)
    at com.ibm.team.process.internal.service.ProcessService.runInTransaction(ProcessService.java:4779)
    at com.ibm.team.process.internal.service.ServerProcess.adviseAndExecute(ServerProcess.java:153)
    at com.ibm.team.workitem.service.internal.AuditableServerProcess.adviseAndExecute(AuditableServerProcess.java:86)
    at com.ibm.team.workitem.service.internal.WorkItemRepositoryService.processSave(WorkItemRepositoryService.java:568)
    at com.ibm.team.workitem.service.internal.WorkItemRepositoryService.save(WorkItemRepositoryService.java:496)
    at com.ibm.team.workitem.service.internal.WorkItemRepositoryService.save(WorkItemRepositoryService.java:464)
    at com.ibm.team.workitem.service.internal.WorkItemRepositoryService.access$3(WorkItemRepositoryService.java:460)
    at com.ibm.team.workitem.service.internal.WorkItemRepositoryService$1.run(WorkItemRepositoryService.java:340)
    at com.ibm.team.workitem.service.internal.WorkItemRepositoryService$1.run(WorkItemRepositoryService.java:1)
    at com.ibm.team.repository.service.internal.PrimitiveTransactionService$3.run(PrimitiveTransactionService.java:176)
    at com.ibm.team.repository.service.internal.rdb.RepositoryDatabase$Transaction.run(RepositoryDatabase.java:488)
    at com.ibm.team.repository.service.internal.rdb.RepositoryDatabase$1.run(RepositoryDatabase.java:312)
    at com.ibm.team.repository.service.internal.rdb.ConnectionPoolService.withCurrentConnection(ConnectionPoolService.java:381)
    at sun.reflect.GeneratedMethodAccessor115.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.invoke(ExportProxyServiceRecord.java:361)
    at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.access$0(ExportProxyServiceRecord.java:347)
    at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord$ExportedServiceInvocationHandler.invoke(ExportProxyServiceRecord.java:56)
    at $Proxy52.withCurrentConnection(Unknown Source)
    at com.ibm.team.repository.service.internal.rdb.RepositoryDatabase.runTransaction(RepositoryDatabase.java:308)
    at com.ibm.team.repository.service.internal.rdb.RepositoryDatabase.runInTransaction(RepositoryDatabase.java:263)
    at com.ibm.team.repository.service.internal.PrimitiveTransactionService.runInTransaction(PrimitiveTransactionService.java:110)
    at com.ibm.team.repository.service.internal.PrimitiveTransactionService.runInTransaction(PrimitiveTransactionService.java:105)
    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 org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.invoke(ExportProxyServiceRecord.java:361)
    at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.access$0(ExportProxyServiceRecord.java:347)
    at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord$ExportedServiceInvocationHandler.invoke(ExportProxyServiceRecord.java:56)
    at $Proxy90.runInTransaction(Unknown Source)
    at com.ibm.team.repository.service.AbstractService.runInTransaction(AbstractService.java:965)
    at com.ibm.team.workitem.service.internal.WorkItemRepositoryService.saveTransaction(WorkItemRepositoryService.java:326)
    at com.ibm.team.workitem.service.internal.WorkItemRepositoryService.save(WorkItemRepositoryService.java:284)
    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 org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.invoke(ExportProxyServiceRecord.java:361)
    at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.access$0(ExportProxyServiceRecord.java:347)
    at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord$ExportedServiceInvocationHandler.invoke(ExportProxyServiceRecord.java:56)
    at $Proxy1026.save(Unknown Source)
    at com.ibm.team.workitem.service.internal.WorkItemServer.save(WorkItemServer.java:298)
    at com.ibm.team.workitem.common.internal.WorkItemCommon.internalSaveAuditables(WorkItemCommon.java:1240)
    at com.ibm.team.workitem.common.internal.WorkItemCommon.saveAttachment(WorkItemCommon.java:978)
    at com.ibm.team.workitem.service.internal.rest.AttachmentRestService.saveAttachment(AttachmentRestService.java:495)
    at com.ibm.team.workitem.service.internal.rest.AttachmentRestService.perform_POST(AttachmentRestService.java:193)
    at com.ibm.team.repository.service.TeamRawService.service(TeamRawService.java:90)
    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 org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.invoke(ExportProxyServiceRecord.java:361)
    at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.access$0(ExportProxyServiceRecord.java:347)
    at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord$ExportedServiceInvocationHandler.invoke(ExportProxyServiceRecord.java:56)
    at $Proxy1040.service(Unknown Source)
    at com.ibm.team.repository.servlet.AbstractTeamServerServlet.doRestService(AbstractTeamServerServlet.java:914)
    at com.ibm.team.repository.servlet.AbstractTeamServerServlet.handleRequest2(AbstractTeamServerServlet.java:2100)
    at com.ibm.team.repository.servlet.AbstractTeamServerServlet.handleRequest(AbstractTeamServerServlet.java:1924)
    at com.ibm.team.repository.servlet.AbstractTeamServerServlet.service(AbstractTeamServerServlet.java:1800)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.service(ServletManager.java:180)
    at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
    at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:126)
    at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:76)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.eclipse.equinox.servletbridge.BridgeServlet.service(BridgeServlet.java:120)
    at com.ibm.team.repository.server.servletbridge.JazzServlet.service(JazzServlet.java:68)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at com.ibm.team.repository.server.servletbridge.BridgeFilter.processDelegate(BridgeFilter.java:133)
    at com.ibm.team.repository.server.servletbridge.BridgeFilter.doFilter(BridgeFilter.java:154)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:336)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919)
    at java.lang.Thread.run(Thread.java:738)

0 votes


Accepted answer

Permanent link
 You need to exit from your Work Item save participant early if it's not a Work Item save, otherwise your class cast will fail. This snippet above your line 86 should help:

	// Check that this was a save operation on a work item
		ISaveParameter saveParameter= (ISaveParameter) data;
		if (!(saveParameter.getNewState() instanceof IWorkItem))
			return;
	
	
Edit: Pressed save too quickly. A good starting point is to look at one of Ralph's examples. His examples are good starting points to help avoid some of these common setup type things. For example http://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/. 
Ralph Schoon selected this answer as the correct answer

1 vote

Comments

It works.

Thank you very much !

Benjamin, If you want to extent RTC and be reasonably sure you are not breaking anything, I would suggest to go over some material and examples out there. You can start here: http://rsjazz.wordpress.com/2013/02/28/setting-up-rational-team-concert-for-api-development/ there are numerous examples on that blog and it leads back to the RTC Extension Workshop that also introduces and explains the checking needed as Scott points out in his answer.

It will also enable you to debug which allows to look at variables (and types) and be able to better test your code.

1 vote

It Worked for me also ... Thanks Ralph

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Apr 16 '13, 8:50 p.m.

Question was seen: 3,714 times

Last updated: Oct 03 '16, 7:21 a.m.

Confirmation Cancel Confirm