7 Replies Latest reply on Apr 12, 2007 5:51 PM by Jim Hazen

    I get a exception

    Konstantin Kauz Novice

      Please help, i get a exception.

      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
       xmlns:s="http://jboss.com/products/seam/taglib"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:c="http://java.sun.com/jstl/core"
       xmlns:rich="http://richfaces.ajax4jsf.org/rich"
       xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
       template="templates/temp.xhtml">
      
      
      
       <ui:define name="main">
      
       <s:div style="margin-top:5px">
       <a4j:form>
      
       <s:validateAll>
      
       <rich:panel>
       <h:panelGroup id="frms">
       <h:panelGrid columns="3">
      
       <h:outputText value="Fabrikat: "/>
      
       <h:panelGroup style="display:block">
       <a4j:region renderRegionOnly="false">
       <h:selectOneMenu id="hrs" value="#{kfz.hersteller}" required="true" converter="#{fahrzeugin.converter4Her}">
       <s:selectItems value="#{herstellerList}" var="her" label="#{her.bezeichnung}" noSelectionLabel="Bitte waehlen..." />
       <a4j:support event="onchange" action="#{fahrzeugin.setKmodel}"
       reRender="modelsel" />
       </h:selectOneMenu>
       </a4j:region>
       </h:panelGroup>
       <h:message for="hrs" />
      
       <h:outputText value="Modell:" />
       <h:panelGroup style="display:block" id="modelsel" >
       <a4j:region renderRegionOnly="false">
       <h:selectOneMenu value="#{kfz.kfzmodel}" required="true" converter="#{fahrzeugin.modConverter}">
       <s:selectItems value="#{kfz.hersteller.kfzmodel}" var="md" label="#{md.bezeichnung}" noSelectionLabel="Bitte waehlen..." />
       </h:selectOneMenu>
       </a4j:region>
       </h:panelGroup>
       <h:message for="modelsel" />
      
       <h:outputText value="Filiale:" />
       <h:selectOneMenu id="fillsel" value="#{kfz.filliale}" required="true" converter="#{fahrzeugin.converter}">
       <s:selectItems value="#{fillLists}" var="md" label="#{md.bezeichnung}" noSelectionLabel="Bitte waehlen..." />
       </h:selectOneMenu>
       <h:message for="fillsel" />
      
       </h:panelGrid>
       </h:panelGroup>
      
       </rich:panel>
       <rich:panel style="margin-top:5px">
      
       <h:panelGrid columns="3">
       <h:outputText id="catsel" value="Kategorie"/>
       <h:selectOneMenu value="#{kfz.category}" required="true" >
       <f:selectItem itemValue="cabrio" itemLabel="Cabrio/Roadster"/>
       <f:selectItem itemValue="gelaendewagen" itemLabel="Gelaendewagen/Pickup"/>
       <f:selectItem itemValue="kleinwagen" itemLabel="Kleinwagen"/>
       <f:selectItem itemValue="limousine" itemLabel="Limousine"/>
       <f:selectItem itemValue="sportwagen" itemLabel="Sportwagen/Coupe"/>
       <f:selectItem itemValue="combi" itemLabel="Combi"/>
       <f:selectItem itemValue="van" itemLabel="Van/Kleinbus"/>
       <f:selectItem itemValue="transporter" itemLabel="alle Transporter/LKW"/>
       <f:selectItem itemValue="andere" itemLabel="Andere"/>
       </h:selectOneMenu>
       <h:message for="catsel" />
      
       <h:outputText value="Leistung"/>
       <h:panelGroup><h:inputText id="lstxt" value="#{kfz.leistung}" required="true" />
       <h:selectOneMenu value="#{kfz.kw}">
       <f:selectItem itemValue="true" itemLabel="KW"/>
       <f:selectItem itemValue="false" itemLabel="PS"/>
       </h:selectOneMenu>
       </h:panelGroup>
       <h:message for="lstxt" />
      
       <h:outputText value="Getriebe"/>
       <h:selectOneMenu id="gtsel" value="#{kfz.getriebe}" >
       <f:selectItem itemValue="beliebig" itemLabel="Beliebig"/>
       <f:selectItem itemValue="handschaltung" itemLabel="Handschaltung"/>
       <f:selectItem itemValue="halbaut" itemLabel="Halbautomatik"/>
       <f:selectItem itemValue="auto" itemLabel="Automatik"/>
       </h:selectOneMenu>
       <h:message for="gtsel" />
      
       <h:outputText value="Kraftstoffart"/>
       <h:selectOneMenu value="#{kfz.kraftstoffart}" required="true">
       <f:selectItem itemValue="beliebig" itemLabel="Beliebig"/>
       <f:selectItem itemValue="benzin" itemLabel="Benzin"/>
       <f:selectItem itemValue="diesel" itemLabel="Diesel"/>
       <f:selectItem itemValue="autogas" itemLabel="Autogas"/>
       <f:selectItem itemValue="erdgas" itemLabel="Erdgas"/>
       <f:selectItem itemValue="elektro" itemLabel="Elektro"/>
       <f:selectItem itemValue="hybrid" itemLabel="Hybrid"/>
       <f:selectItem itemValue="wasserstoff" itemLabel="Wasserstoff"/>
       </h:selectOneMenu>
       </h:panelGrid>
      
       </rich:panel>
      
       <rich:panel style="margin-top:5px">
       <h:outputText id="catsel1" value="Ausstattung: "/>
       <h:panelGrid columns="6">
       <h:selectBooleanCheckbox title="Allradantrieb" value="#{kfz.allradantrieb}" /><h:outputText value="Allradantrieb"/>
       <h:selectBooleanCheckbox title="Lederausstattung" value="#{kfz.lederausstattung}" /><h:outputText value="Lederausstattung"/>
       <h:selectBooleanCheckbox title="Stabilitaetskontrolle" value="#{kfz.stabkontrolle}" /><h:outputText value="Stabilitaetskontrolle"/>
       <h:selectBooleanCheckbox title="Anhaengerkupplung" value="#{kfz.anhaengerkupplung}" /><h:outputText value="Anhaengerkupplung"/>
       <h:selectBooleanCheckbox title="Behindertengerecht" value="#{kfz.behindertengerecht}" /><h:outputText value="Behindertengerecht"/>
       <h:selectBooleanCheckbox title="Einparkhilfe" value="#{kfz.einparkhilfe}" /><h:outputText value="Einparkhilfe"/>
       <h:selectBooleanCheckbox title="Elek. Wegfahrsperre" value="#{kfz.elWegfahrsperre}" /><h:outputText value="Elek. Wegfahrsperre"/>
       <h:selectBooleanCheckbox title="Leichtmetallfelgen" value="#{kfz.leichtmetallfelgen}" /><h:outputText value="Leichtmetallfelgen"/>
       <h:selectBooleanCheckbox title="Navigationssystem" value="#{kfz.navigationssystem}" /><h:outputText value="Navigationssystem"/>
       <h:selectBooleanCheckbox title="Partikelfilter" value="#{kfz.partikelfilter}" /><h:outputText value="Partikelfilter"/>
       <h:selectBooleanCheckbox title="Schiebedach" value="#{kfz.schiebedach}" /><h:outputText value="Schiebedach"/>
       <h:selectBooleanCheckbox title="Sitzheizung" value="#{kfz.sitzheizung}" /><h:outputText value="Sitzheizung"/>
       <h:selectBooleanCheckbox title="Standheizung" value="#{kfz.standheizung}" /><h:outputText value="Standheizung"/>
       <h:selectBooleanCheckbox title="Taxi" value="#{kfz.taxi}" /><h:outputText value="Taxi"/>
       <h:selectBooleanCheckbox title="Tempomat" value="#{kfz.tempomat}" /><h:outputText value="Tempomat"/>
       <h:selectBooleanCheckbox title="Xenonscheinwerfer" value="#{kfz.xnwerfer}" /><h:outputText value="Xenonscheinwerfer"/>
       </h:panelGrid>
       </rich:panel>
       </s:validateAll>
      
       <s:div style="margin-top:5px">
       <s:button value="Zurueck" view="/fahrzeug" />
       <h:commandButton value="Aendern" action="#{fahrzeugin.updateKfz()}" />
       <h:commandButton action="#{fahrzeugin.inserKfz}" value="Inserieren" rendered="#{kfz.free4 == false}" />
       <h:commandButton action="#{fahrzeugin.deinserKfz}" value="Deinserieren" rendered="#{kfz.free4 == true}" />
      
       <h:commandButton value="Loeschen" action="#{fahrzeugin.delKfz}" />
      
      
      
       </s:div>
      
       </a4j:form>
       </s:div>
       </ui:define>
      </ui:composition>
      
      



      Session:
      public class FahrzeugIn implements FahrzeuginInterface{
      
       @In
       private FacesMessages facesMessages;
      
      
       @PersistenceContext
       private EntityManager em;
      
       @In
       private Context sessionContext;
      
       @In(required=false)
       @Out(required=false)
       private Kfz kfz;
      
       @DataModel
       private List<Kfz> kfzsList;
      
       @DataModel
       private List<Hersteller> herstellerList;
      
      
       @DataModel
       private Set<Filliale> fillLists;
      
       @DataModelSelection("kfzsList")
       private Kfz selectedKfz;
      
       private Converter converter;
      
       private List<Kfzmodel> list4select;
      
      
      
       @Factory("herstellerList")
       @Begin(join=true)
       public void setherstellerList(){
      
       herstellerList = em.createQuery("select h from Hersteller h")
       .getResultList();
       }
      
       public void setKmodel(){
       list4select = kfz.getHersteller().getKfzmodel();
       }
      
       @Factory("kfzsList")
       @Begin(join=true)
       public void setkfzsList(){
       Usr usr = (Usr) sessionContext.get("usr");
       kfzsList = em.createQuery("from Kfz k where k.usr.id = :id")
       .setParameter("id",usr.getId())
       .getResultList();
       }
      
       public String delKfz(){
      
       Usr usr = (Usr) sessionContext.get("usr");
       String usrname = usr.getBname();
       Usr usr1 = (Usr) em.createQuery("from Usr where bname like :bname")
       .setParameter("bname",usrname)
       .getSingleResult();
       usr1.getKfz().remove(this.kfz);
       em.merge(usr1);
      
       Filliale fill = (Filliale) em.find(Filliale.class,this.kfz.getFilliale().getId());
       fill.getKfz().remove(this.kfz);
       em.merge(fill);
      
       Hersteller her = (Hersteller) em.find(Hersteller.class,this.kfz.getHersteller().getId());
       her.getKfz().remove(this.kfz);
       em.merge(her);
      
       Kfzmodel km = (Kfzmodel) em.find(Kfzmodel.class,this.kfz.getKfzmodel().getId());
       km.getKfz().remove(this.kfz);
       em.merge(km);
      
      
       long id = this.kfz.getId();
       this.kfzsList.remove(this.kfz);
       Kfz kfz1 = (Kfz) em.find(Kfz.class,id);
       this.kfz = null;
       em.remove(kfz1);
       kfz1 = null;
      
       return "/fahrzeug";
       }
      
      
       @Factory("fillLists")
       public void setFList(){
       Usr usr = (Usr) sessionContext.get("usr");
       String usrname = usr.getBname();
       Usr usr1 = (Usr) em.createQuery("from Usr where bname like :bname")
       .setParameter("bname",usrname)
       .getSingleResult();
       fillLists = usr1.getFill();
       }
       public String editKfz() {
       kfz = selectedKfz;
       list4select = kfz.getHersteller().getKfzmodel();
       return "/editkfz";
       }
       @End
       public String updateKfz(){
       em.merge(kfz);
       return "/fahrzeug";
       }
       @End
       public String saveKfz() {
       Usr usr = (Usr) sessionContext.get("usr");
       Usr usr1 = em.find(Usr.class,usr.getId());
       usr1.addKfz(kfz);
       em.merge(usr1);
       return "/fahrzeug";
       }
       public String inserKfz() {
       Kfz kfz = em.find(Kfz.class,this.kfz.getId());
       kfz.setFree4(true);
       em.merge(kfz);
       em.flush();
       return "/fahrzeug";
       }
       public String deinserKfz() {
       Kfz kfz = em.find(Kfz.class,this.kfz.getId());
       kfz.setFree4(false);
       em.merge(kfz);
       em.flush();
       return "/fahrzeug";
       }
      




      Entity Bean Kfz:

      public class Kfz implements Serializable{
      
       @Id @GeneratedValue
       private Long id;
      
       @ManyToOne
       @JoinColumn(name="hersteller_id")
       private Hersteller hersteller;
      
       @ManyToOne
       @JoinColumn(name="kfzmodel_id")
       private Kfzmodel kfzmodel;
      
       @ManyToOne
       @JoinColumn(name="usr_id")
       private Usr usr;
      
       @ManyToOne
       @JoinColumn(name="fillial_id")
       private Filliale filliale;
      
       @OneToMany(mappedBy="kfz",cascade=CascadeType.ALL, fetch=FetchType.EAGER)
       private Set<Reservierung> reservierung = new HashSet();
      



      The Exception:


      
      20:22:26,587 ERROR [SeamPhaseListener] uncaught exception
      org.jboss.seam.TransactionException: Could not commit transaction
       at org.jboss.seam.jsf.AbstractSeamPhaseListener.commitOrRollback(AbstractSeamPhaseListener.java:323)
       at org.jboss.seam.jsf.TransactionalSeamPhaseListener.handleTransactionsAfterPhase(TransactionalSeamPhaseListener.java:45)
       at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:112)
       at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersAfter(PhaseListenerManager.java:89)
       at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:345)
       at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
       at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:60)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:96)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:220)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
      Caused by: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=kostja-mobil/468, BranchQual=, localId=468] status=STATUS_NO_TRANSACTION; - nested throwable: (javax.persistence.EntityNotFoundException: deleted entity passed to persist: [kk.rentform.entity.Kfz#<null>])
       at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:372)
       at org.jboss.tm.TxManager.commit(TxManager.java:240)
       at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:140)
       at org.jboss.seam.jsf.AbstractSeamPhaseListener.commitOrRollback(AbstractSeamPhaseListener.java:313)
       at org.jboss.seam.jsf.TransactionalSeamPhaseListener.handleTransactionsAfterPhase(TransactionalSeamPhaseListener.java:45)
       at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:112)
       at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersAfter(PhaseListenerManager.java:89)
       at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:345)
       at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
       at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:60)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:96)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:220)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      Caused by: javax.persistence.EntityNotFoundException: deleted entity passed to persist: [kk.rentform.entity.Kfz#<null>]
       at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:631)
       at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:524)
       at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1491)
       at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1110)
       at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:324)
       at org.jboss.tm.TxManager.commit(TxManager.java:240)
       at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:140)
       at org.jboss.seam.jsf.AbstractSeamPhaseListener.commitOrRollback(AbstractSeamPhaseListener.java:313)
       at org.jboss.seam.jsf.TransactionalSeamPhaseListener.handleTransactionsAfterPhase(TransactionalSeamPhaseListener.java:45)
       at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:112)
       at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersAfter(PhaseListenerManager.java:89)
       at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:345)
       at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
       at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:60)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
      
      


      If the "<h:commandButton value="Loeschen" action="#{fahrzeugin.delKfz}" />" action fired