Hi,
perhaps there is somebody in this forum who can help with this problem. So I just post my recent insights.
Judy recommended to avoid ice:popupPanel and to introduce a manager which should take care of a bean representing the file to upload. I tried this but the problem is still there. So here's what I posted in the mentioned ICEfaces forum posting:
Erm, I think I have to take back the multiple
when I'm talking about the up-/download functionality I want to implement.
Thanks for your hints. I took all your hints, but still I got this could not find stateful bean
exception. But this time I had a look to JBoss AS's server.log:
2008-04-07 09:45:31,668 DEBUG [org.jboss.seam.contexts.FacesLifecycle] <<< End JSF request for /ares/toDo.seam
2008-04-07 09:45:31,683 DEBUG [com.icesoft.faces.webapp.http.servlet.PathDispatcher] path: /ares/block/receive-updates
2008-04-07 09:45:44,450 DEBUG [com.icesoft.faces.webapp.http.servlet.PathDispatcher] path: /ares/block/send-receive-updates
2008-04-07 09:45:44,450 DEBUG [org.jboss.seam.contexts.FacesLifecycle] >>> Begin JSF request for /ares/toDo.seam
2008-04-07 09:45:44,450 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
2008-04-07 09:45:44,450 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
2008-04-07 09:45:44,450 DEBUG [org.jboss.seam.jsf.SeamPhaseListener] beginning transaction prior to phase: RESTORE_VIEW 1
2008-04-07 09:45:44,450 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
2008-04-07 09:45:44,465 DEBUG [org.jboss.seam.transaction.UTTransaction] beginning JTA transaction
2008-04-07 09:45:44,465 DEBUG [org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager] Attempting to activate; id=4sub52-nntvel-feqqjdfz-1-feqqo5ca-2d
2008-04-07 09:45:44,465 ERROR [org.jboss.seam.jsf.SeamPhaseListener] uncaught exception
java.lang.IllegalStateException: Could not start transaction
at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:581)
at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsBeforePhase(SeamPhaseListener.java:312)
at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:140)
at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:114)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:222)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
at com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:17)
at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.renderCyclePartial(ReceiveSendUpdates.java:64)
at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.service(ReceiveSendUpdates.java:40)
at com.icesoft.faces.webapp.http.core.ViewBoundServer.service(ViewBoundServer.java:65)
at com.icesoft.faces.webapp.http.core.RequestVerifier.service(RequestVerifier.java:44)
at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer$Matcher.serviceOnMatch(PathDispatcherServer.java:50)
at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:19)
at com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet.service(ThreadBlockingAdaptingServlet.java:19)
at com.icesoft.faces.webapp.http.servlet.EnvironmentAdaptingServlet.service(EnvironmentAdaptingServlet.java:29)
at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:106)
at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:35)
at com.icesoft.faces.webapp.http.servlet.PathDispatcher$Matcher.serviceOnMatch(PathDispatcher.java:52)
at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:29)
at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:79)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:343)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServlet.java:54)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73)
at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Thread.java:595)
Caused by: javax.ejb.NoSuchEJBException: Could not find stateful bean: 4sub52-nntvel-feqqjdfz-1-feqqo5ca-2d
at org.jboss.ejb3.cache.simple.SimpleStatefulCache.get(SimpleStatefulCache.java:390)
at org.jboss.ejb3.cache.simple.SimpleStatefulCache.get(SimpleStatefulCache.java:375)
at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:61)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:206)
at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:119)
at $Proxy365.afterTransactionBegin(Unknown Source)
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:585)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
at org.javassist.tmp.java.lang.Object_$$_javassist_0.afterTransactionBegin(Object_$$_javassist_0.java)
at org.jboss.seam.transaction.UTTransaction.begin(UTTransaction.java:40)
at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:576)
... 56 more
2008-04-07 09:45:44,465 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.exception.exceptions
To cause this exception, I upload a file, what proceeds successfully (i. e. the file is saved and then shown in the list of available files) and then click any commandButton or link. Whether it is used for navigation or to call an action doesn't matter.
Perhaps some more code helps to spot the problem.
This page shows the entity and includes a template which is responsible for displaying all available files:
<ice:form id="showTestactionForDeveloper">
<ui:include src="inc/messages.xhtml" />
<s:div styleClass="buttonLine">
<h:commandButton action="backToList" image="img/icon_buttonLine_back.gif" styleClass="graphical" title="#{ares_messages.tooltip_backToList}" />
<h:graphicImage width="3" height="16" value="img/separator_buttonLine.gif" styleClass="separator" />
<ice:commandButton image="img/icon_buttonLine_protocol.gif" styleClass="graphical" partialSubmit="true" actionListener="#{protocolProvider.showProtocolDialog}" title="#{ares_messages.tooltip_showProtocol}" />
<ice:commandButton image="img/icon_buttonLine_attach.gif" styleClass="graphical" partialSubmit="true" actionListener="#{testactionDeveloper.showUpDownloadDialog}" title="#{ares_messages.tooltip_upDownload}" />
<h:outputText value="(#{testactionDeveloper.countOfAttachedFiles})" converter="javax.faces.Long" rendered="#{testactionDeveloper.countOfAttachedFiles > 0}" styleClass="fileCounter" />
<h:graphicImage width="3" height="16" value="img/separator_buttonLine.gif" styleClass="separator" />
<h:commandButton action="#{testactionDeveloper.saveTestaction}" image="img/icon_buttonLine_save.gif" styleClass="graphical" title="#{ares_messages.tooltip_saveTestaction}" />
<h:commandButton action="#{testactionDeveloper.saveTestactionAndNext}" image="img/icon_buttonLine_saveAndNext.gif" styleClass="graphical" rendered="#{testactionDeveloper.testactionsSize > 1}" title="#{ares_messages.tooltip_saveTestactionAndNext}" />
<h:graphicImage width="3" height="16" value="img/separator_buttonLine.gif" styleClass="separator" />
<h:commandButton action="#{testactionDeveloper.prevTestaction}" image="img/icon_buttonLine_left.gif" styleClass="graphical" rendered="#{testactionDeveloper.testactionsSize > 1}" title="#{ares_messages.tooltip_prevTestaction}" />
<h:outputText value="#{testactionDeveloper.testactionIndexHR} | #{testactionDeveloper.testactionsSize}" styleClass="indexAndSize" />
<h:commandButton action="#{testactionDeveloper.nextTestaction}" image="img/icon_buttonLine_right.gif" styleClass="graphical" rendered="#{testactionDeveloper.testactionsSize > 1}" title="#{ares_messages.tooltip_nextTestaction}" />
</s:div>
<s:div styleClass="clearButtonLineFloat" />
<h:panelGrid cellpadding="0" cellspacing="0" border="0" columns="10" rowClasses="tableRowHeader, tableRowContent" styleClass="testaction">
<h:outputText value="#{ares_messages.label_testaction_ID}" />
<h:outputText value="#{ares_messages.label_testaction_TDate}" />
<h:outputText value="#{ares_messages.label_testaction_TCaseID}" />
<h:outputText value="#{testaction.ID}" />
<h:outputText value="#{testaction.TDate}" />
<ice:selectOneMenu value="#{testaction.TCaseID}" id="TCaseID" converter="com.idsscheer.ares.converter.TestcaseConverter">
<s:selectItems value="#{selectMenuHelper.testcases}" var="testcase" label="#{testcase.ID} - #{testcase.token}" />
</ice:selectOneMenu>
<ui:include src="inc/popup_protocol.xhtml" />
<ui:include src="inc/popup_upDownload.xhtml">
<ui:param name="fileProvider" value="#{testactionDeveloper}" />
</ui:include>
</ice:form>
This is the included template:
<!-- <ice:panelPopup draggable="true"
rendered="#{fileProvider.showUpDownloadDialog}"
visible="#{fileProvider.showUpDownloadDialog}"
style="width: 700px;"
autoCentre="true"> -->
<ice:panelCollapsible expanded="#{fileProvider.showUpDownloadDialog}">
<f:facet name="header">
<!-- skipped -->
</f:facet>
<!-- <f:facet name="body"> -->
<ice:panelGrid columns="1" cellpadding="0" cellspacing="0" border="0">
<h:dataTable value="#{fileProvider.attachedFiles}"
var="attachedFile"
rendered="#{!empty fileProvider.attachedFiles}"
styleClass="testactionList" rowClasses="tableRowEven, tableRowOdd"
style="text-align: center;">
<h:column>
<f:facet name="header">
<h:outputText value="#{ares_messages.label_upDownload_filename}" />
</f:facet>
<h:outputText value="#{attachedFile.name}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{ares_messages.label_upDownload_view}" />
</f:facet>
<ice:commandButton image="img/icon_upDownload_view.gif"
styleClass="graphical" partialSubmit="true"
action="#{fileProvider.viewFile(attachedFile)}"
style="width: 16px;" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{ares_messages.label_upDownload_download}" />
</f:facet>
<ice:commandButton image="img/icon_upDownload_download.gif"
styleClass="graphical"
action="#{fileProvider.downloadFile(attachedFile)}"
style="width: 16px;" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{ares_messages.label_upDownload_remove}" />
</f:facet>
<ice:commandButton image="img/icon_upDownload_remove.gif"
styleClass="graphical" partialSubmit="true"
action="#{fileProvider.removeFile(attachedFile)}"
style="width: 16px;" />
</h:column>
</h:dataTable>
<ice:outputStyle href="css/screen.css" />
<ice:inputFile actionListener="#{fileProvider.fileUpload.upload}"
style="margin-top: 30px;" id="upload" />
</ice:panelGrid>
<!-- </f:facet> -->
</ice:panelCollapsible>
<!-- </ice:panelPopup> -->
The manager
extends a class which implements general functionality for this and other similar managers. Here's the superclass (I skipped some methods and attributes):
public abstract class TestactionHandling {
@PersistenceContext(unitName = "aresDatabase")
protected transient EntityManager em;
@In
protected transient FacesContext facesContext;
@In
protected IUpDownloadService upDownload;
@In(required=false) /* required=false is necessary since the upload
is done in a separate form, so all this Seam stuff doesn't work */
@Valid
protected User user;
@DataModel
protected List<Testaction> testactions;
@In(required=false)
@Out(required=false, scope=ScopeType.SESSION)
protected Testaction testaction;
protected int testactionIndex;
protected boolean showUpDownloadDialog = false;
protected UpDownloadFileinfo fileUpload;
public String upload(ActionEvent event) {
InputFile uploadedFile = (InputFile) event.getSource();
boolean success = false;
if(uploadedFile.getStatus() == InputFile.SAVED) {
if(testaction == null) {
testaction = testactions.get(testactionIndex);
}
UpDownloadFileinfo fileInfo = new UpDownloadFileinfo();
fileInfo.setName(uploadedFile.getFileInfo().getFileName());
fileInfo.setFile(uploadedFile.getFile());
fileInfo.setContentType(uploadedFile.getFileInfo().getContentType());
fileInfo.setTestactionID(testaction.getID());
success = upDownload.upload(fileInfo);
}
if( !success ) {
return "failed";
}
return null;
}
public List<UpDownloadFileinfo> getAttachedFiles() {
return upDownload.getAttachedFiles(testaction.getID());
}
public Long getCountOfAttachedFiles() {
return upDownload.getCountOfAttachedFiles(testaction.getID());
}
public String downloadFile(UpDownloadFileinfo selectedFile) {
UpDownloadFileinfo fileInfo = upDownload.downloadFile(selectedFile);
JavascriptContext.addJavascriptCall(facesContext, "window.open('downloadFile?fileName=" + fileInfo.getName() + "&directory=" + fileInfo.getPath() + "&contentType=" + fileInfo.getContentType() + "', 'downloadFile');");
return null;
}
public String viewFile(UpDownloadFileinfo selectedFile) {
UpDownloadFileinfo fileInfo = upDownload.viewFile(selectedFile);
JavascriptContext.addJavascriptCall(facesContext, "window.open('downloadFile?action=view&fileName=" + fileInfo.getName() + "&directory=" + fileInfo.getPath() + "&contentType=" + fileInfo.getContentType() + "', 'downloadFile');");
return null;
}
public String removeFile(UpDownloadFileinfo selectedFile) {
upDownload.removeFile(selectedFile);
return null;
}
public boolean isShowUpDownloadDialog() {
return showUpDownloadDialog;
}
public void setShowUpDownloadDialog(boolean showProtocolDialog) {
this.showUpDownloadDialog = showProtocolDialog;
}
@SuppressWarnings("unused")
public void showUpDownloadDialog(ActionEvent event) {
showUpDownloadDialog = true;
}
@SuppressWarnings("unused")
public void closeUpDownloadDialog(ActionEvent event) {
showUpDownloadDialog = false;
}
public UpDownloadFileinfo getFileUpload() {
if(fileUpload == null) {
fileUpload = new UpDownloadFileinfo(testaction, testactions, testactionIndex, upDownload);
}
return fileUpload;
}
public void setFileUpload(UpDownloadFileinfo fileUpload) {
this.fileUpload = fileUpload;
}
}
Here's the testactionDeveloper
subclass (it doesn't redefine its superclass methods):
@Stateful
@Scope(ScopeType.SESSION)
@Name("testactionDeveloper")
public class TestactionDeveloperAction extends TestactionHandling implements TestactionDeveloper, Serializable {
//nothing of interest here
}
The UpDownloadFileinfo
is used for data transfer. That means it represents a file when uploading or downloading a file. The @Name annotation, the additional constructor and the upload method are implemented because it's done similar in the example you mentioned. In the first version this class was a plain getter/setter class.
@Name("fileUpload")
public class UpDownloadFileinfo implements IUpDownloadFileinfo {
private String name;
private File file;
private String contentType;
private long testactionID;
private long dbFileID;
private Testaction testaction;
private List<Testaction> testactions;
private int testactionIndex;
@In
private IUpDownloadService upDownload;
public UpDownloadFileinfo() {
}
public UpDownloadFileinfo(Testaction testaction, List<Testaction> testactions, int testactionIndex, IUpDownloadService upDownload) {
this.testaction = testaction;
this.testactions = testactions;
this.testactionIndex = testactionIndex;
this.upDownload = upDownload;
}
public String upload(ActionEvent event) {
InputFile uploadedFile = (InputFile) event.getSource();
boolean success = false;
if(uploadedFile.getStatus() == InputFile.SAVED) {
if(testaction == null) {
testaction = testactions.get(testactionIndex);
}
setName(uploadedFile.getFileInfo().getFileName());
setFile(uploadedFile.getFile());
setContentType(uploadedFile.getFileInfo().getContentType());
setTestactionID(testaction.getID());
success = upDownload.upload(this);
}
if( !success ) {
return "failed";
}
return null;
}
}
As you can see from the code above I added this addtional constructor which takes four parameters. It was necessary to do this because Seam destroyed its contexts before the upload method was invoked, what caused a NPE.
Just to make it clearer for me (and maybe for you): The upload before and after those changes worked fine. A file was received and saved. After the upload finished the page refreshed and displayed the new file in a list of available files. But when I click any button I'm getting this exception. It happens in the RESTORE_VIEW phase and it seems that the JTA transaction can't be restored (whatever this JTA transaction is good for).
I don't know why this happens, but I thought it would be a good idea to test Seam's file upload component. But it can't work with ICEfaces since the upload component expects a MultipartRequest
in the responsible servlet but it gets an com.icesoft.faces.webapp.http.servlet.ServletExternalContext.
I hope this information helps you in solving this problem.
Thanks in advance
Jens