0 Replies Latest reply on Jul 3, 2012 10:49 AM by mperdikeas

    How to go about debuggin an apparent JPA failure

      I am deploying a dead-simple application to JBoss AS7.1 (mostly with a view to evaluate some tools) and I ran into what appears to be a JPA failure but which I ran out of options to investigate further. I won't get into the particulars as the question is not "what is wrong with my application" (at least not yet), but rather "how does one investigate this type of things in JBoss". So I have a simple List.xhtml where entities of class "B" are listed (drawn from database table "B") and a "destroy" button which allows me to delete one of the said entities.

      Here's the .xhtml segment:

       

      <h:dataTable value="#{bController.items}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_o\
          dd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">                                                                           
                                <h:column>                                                                                                       

                                      ... stuff that prints field values for each row (ommited)
                                </h:column>                                                                                                      
                                <h:column>                                                                                                       
                                    <h:commandLink action="#{bController.destroy}" value="destroy"/>                          
                                </h:column>                                                                                                      
      </h:dataTable>              

       

      The BController.destroy() method ultimately does a :

       

                getFacade().remove(current);

       

      And inside the Facade we have a :

       

      public void remove(T entity) {                                                                                                       
               getEntityManager().remove(getEntityManager().merge(entity));                                                                     
      }  

       

      I am sure all this chain works because after turning on JPA logging and setting the JBoss console log level to TRACE I can see in the output (critical line in bold)

       

      17:15:59,014 DEBUG [org.jboss.as.jpa] (http--172.31.129.33-8888-2) http--172.31.129.33-8888-2:[transaction scoped EntityManager]: created entity manager session TransactionImple < ac, BasicAction: 0:ffff7f000101:4f09af08:4ff2fd87:5f status: ActionStatus.RUNNING >
      17:15:59,021 TRACE [org.jboss.as.jpa] (http--172.31.129.33-8888-2) merge entityClass 'mperdikeas.ab.B' took 7ms
      17:15:59,021 DEBUG [org.jboss.as.jpa] (http--172.31.129.33-8888-2) http--172.31.129.33-8888-2:[transaction scoped EntityManager]: reuse entity manager session already in tx TransactionImple < ac, BasicAction: 0:ffff7f000101:4f09af08:4ff2fd87:5f status: ActionStatus.RUNNING >
      17:15:59,022 TRACE [org.jboss.as.jpa] (http--172.31.129.33-8888-2) remove entityClass 'mperdikeas.ab.B' took 1ms
      17:15:59,023 DEBUG [org.jboss.as.jpa] (http--172.31.129.33-8888-2) http--172.31.129.33-8888-2:[transaction scoped EntityManager]: closing entity managersession

       

      So, JBoss AS and JPA appear to be deleting the entity. However the database table remains unchanged (no row is deleted). Hence, my question: how do investigate this further? I was hoping to see the actual SQL executed against the database or see some message that indicates that the removal was rolled-back or something but having set the logging level to the lowest possible and still not getting enough information I am out of options. In general what kind of misconfiguration in JBoss persistance.xml or postgres-ds.xml (I am deploying the datasource packed in the war) could lead to such a silent failure to delete an entity? Or maybe some wrong annotation. I should add that no exception stack trace is ever produced and the application even reports that the record was successfull deleted. For the record I also attach the sources (mainly to allow you to see the project structure and the kind of XML files and settings I've added).