JSF Mojarra 2.1.5: java.lang.IllegalStateException: Cannot create a session after the response has been

bronks

Top Contributor
Hi!

Ich habe eine kleine App mit Tomcat 7.0 und JSF Mojarra 2.1.5 gebaut. Es gibt ein Problem, wenn ich Templates in Zusammenhang mit dem Form,siehe letzer Code, benutze.

Bitte schaut Euch mal den u.g. Code an. Wo liegt der Fehler?

Folgen Exception erhalte ich:
Code:
SCHWERWIEGEND: Error Rendering View[/index.xhtml]
java.lang.IllegalStateException: Cannot create a session after the response has been committed
	at org.apache.catalina.connector.Request.doGetSession(Request.java:2862)
	at org.apache.catalina.connector.Request.getSession(Request.java:2307)
	at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:897)
	at com.sun.faces.context.ExternalContextImpl.getSession(ExternalContextImpl.java:155)
        bla ... bla ...


Code des Templates:
Code:
<?xml version='1.0' encoding='UTF-8' ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html">
    
    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
        <title>Title</title>
        <link rel="STYLESHEET" type="text/css" href="application/css/application.css" />
        <title>Title</title>
     </h:head>
    
    <h:body style="margin:0px;">
        
        <table style="height:100%; width:100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td id="top" width="100%" colspan="2">
                    <ui:include src="header.xhtml" />
                </td>
            </tr>
            <tr style=" height : 96px;" align="left">
                <td id="left" style="height:100%; width : 220px;">
                    <ui:include src="navi.xhtml" />
                </td>
                <td id="content" style="height:100%;width:100%;padding-left:10px;padding-top:10px;vertical-align:top;">
                        <ui:insert name="content">Content</ui:insert>
                </td>
            </tr>
        </table>
    </h:body>
</html>


Code des Contents:
Code:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        
    </h:head>
    <h:body>

        <ui:composition template="./template.xhtml">
            <ui:define name="content">
                <p><h:messages /></p>
                <h:form id="asdf">
                    <h:inputText value="#{processBean.scanCode}" style="font-size:xx-large;font-weight:bold;width:200px" /><br />
                    <h:commandButton action="#{processBean.processScanCode}" value="OK" />
                </h:form>
            </ui:define>
        </ui:composition>

    </h:body>
</html>

Danke!

Bronks
 
Zuletzt bearbeitet:
Sind Deine Beans alle Serializable?
Die einzige Bean sieht so aus:
Habe ich etwas vergessen?

Code:
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean
@SessionScoped
public class ProcessBean implements Serializable{

    private String scanCode;
    
    public String getScanCode() {
    return scanCode;
    }
    
    public void setScanCode(String scanCode) {
    this.scanCode = scanCode;
    }

    public ProcessBean() {
    }
}
 
Auf den ersten Blick würde ich sagen das die Methode
Java:
processScanCode
und die
Java:
 serialVersionUID
fehlt ... hört sich für mich aber eher danach an das die Session oder der FacesContext noch nicht instanziert worden bevor du die Seite aufrufst...
 
Auf den ersten Blick würde ich sagen das die Methode
Java:
processScanCode
und die
Java:
 serialVersionUID
fehlt ... hört sich für mich aber eher danach an das die Session oder der FacesContext noch nicht instanziert worden bevor du die Seite aufrufst...
Die Methode [processScanCode] hat nur gefehlt, weil ich gerade verzweifelt herumexperimentiert habe. Die [serialVerionUID] habe ich hinzugefügt, aber leider ändert sich nichts.

Hier mal der komplette Log:
Code:
Using CATALINA_BASE:   "E:\apache-tomcat-7.0.25"
Using CATALINA_HOME:   "E:\apache-tomcat-7.0.25"
Using CATALINA_TMPDIR: "E:\apache-tomcat-7.0.25\temp"
Using JRE_HOME:        "C:\Program Files\Java\jdk1.6.0_29"
Using CLASSPATH:       "E:\apache-tomcat-7.0.25\bin\bootstrap.jar;E:\apache-tomcat-7.0.25\bin\tomcat-juli.jar"
Listening for transport dt_shmem at address: tomcat_shared_memory_id
02.02.2012 19:14:05 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.6.0_29\bin;... ...
02.02.2012 19:14:05 org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
02.02.2012 19:14:05 org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
02.02.2012 19:14:05 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 473 ms
02.02.2012 19:14:05 org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
02.02.2012 19:14:05 org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.25
02.02.2012 19:14:05 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory E:\apache-tomcat-7.0.25\webapps\docs
02.02.2012 19:14:05 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory E:\apache-tomcat-7.0.25\webapps\examples
02.02.2012 19:14:05 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory E:\apache-tomcat-7.0.25\webapps\host-manager
02.02.2012 19:14:05 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory E:\apache-tomcat-7.0.25\webapps\manager
02.02.2012 19:14:05 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory E:\apache-tomcat-7.0.25\webapps\ROOT
02.02.2012 19:14:05 org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
02.02.2012 19:14:05 org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
02.02.2012 19:14:05 org.apache.catalina.startup.Catalina start
INFO: Server startup in 587 ms
02.02.2012 19:14:07 org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor E:\apache-tomcat-7.0.25\conf\Catalina\localhost\TestApp.xml
02.02.2012 19:14:12 com.sun.faces.config.ConfigureListener contextInitialized
INFO: Mojarra 2.1.1 (FCS 20110408) für Kontext '/TestApp' wird initialisiert.
02.02.2012 19:14:12 com.sun.faces.spi.InjectionProviderFactory createInstance
INFO: JSF1048: PostConstruct/PreDestroy-Annotationen vorhanden.  Verwaltete Bean-Methoden, die mit diesen Annotationen markiert sind, lassen die entsprechenden Annotationen verarbeiten.
02.02.2012 19:14:13 org.apache.catalina.util.LifecycleBase start
INFO: The start() method was called on component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/TestApp]] after start() had already been called. The second call will be ignored.
02.02.2012 19:14:14 com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
SCHWERWIEGEND: Error Rendering View[/index.xhtml]
java.lang.IllegalStateException: Cannot create a session after the response has been committed
bla ... bla ...
 
Zuletzt bearbeitet:
Mehrere Tage sind vergangen und endlich habe ich den Fehler gefunden. Das Stand in einer navi.xhtml und verursachte den Fehler:
Code:
<tr>
                                        
   <td width="12"></td>
   <td width="157"></td>
</tr>

Wegen sowas kann Mojarra keine Session erstellen. Das ist doch lächerlich.

Mit MyFaces habe ich es auch probiert. Der o.g. Fehler ist nicht gekommen, aber da gibt es immer noch den Bug mit dem nicht supporteten Content Type text/css im IE9.

Ich gehe jetzt in die Vinothek. Morgen pfeiff ich auf die Arbeit, denn ich mag nimmer. 🙂
 
Zuletzt bearbeitet:
Zur Verdeutlichung, der Schadcode nocheinmal im Hexeditor:
attachment.php


Bevor es mich vor Wut zerreißt ... ... -> Vinothek 🙂
 
Jetzt habe ich das ganze noch gestestet mit:
- Mojarra 2.1.1 -> funktioniert nicht
- Mojarra 2.0.1 -> funktioniert

Warum interessiert sich Mojarra 2.1.x dafür, was in einem total langweiligen HtmlText steht?
 
Zuletzt bearbeitet:

Zurück
Oben