7 Replies Latest reply on Jul 27, 2007 6:11 PM by Newsgroup_User

    Java/Hibernate backend with FDS: issues

    -=Wintermute=-
      Hi everyone, I'm quite new to the Flex world but I'm so excited about all of it that I decided to make a Flex app in order to get my degree. So, I started by building my own app (which is a management system for a library) starting from the great example posted by Marcel Boucher on his blog. I run my app on JBoss 4.2.0-GA.

      I'm actually using DB2 8.2 with 6 tables: USER, CUSTOMER, IDCARD, LOAN, BOOK, AUTHOR.

      Hibernate-wise, there should be a one-to-one association between CUSTOMER and IDCARD (that is every customer has one and only one idcard), a many-to-many association between IDCARD and LOAN (that is many idcards can do many loans), a many-to-one between LOAN and BOOK and a many-to-one between BOOK and AUTHOR.

      The problem is that as long as I implement single POJOs (user.java, customer.java...), correctly mapped with their configuration file user.hbm.xml and hibernate.cfg.xml, and respective destinations configured in data-management-config.xml, BUT WITHOUT SPECIFYING ANY ASSOCIATION, it all runs and works correctly.

      As soon as I complete the database's tables mapping by adding all the association mappings (I dont know how to exactly map associations between fds destinations as well) it suddenly goes all wrong and I keep getting this error in JBoss console:

      GRAVE: Servlet /flex threw load() exception
      flex.messaging.config.ConfigureException: Unable to create service 'flex.data.DataService' for 'data-service' due to the following error: Error instantiating application scoped instance of type 'flex.data.assemblers.HibernateAssembler' for destination 'user.hibernate'...

      Hope someone can help me with this.

      Cheers,

      Riccardo
        • 1. Re: Java/Hibernate backend with FDS: issues
          -=Wintermute=- Level 1
          Anyone have any suggestions for this?

          Please someone help me! I'm going crazy...
          • 2. Re: Java/Hibernate backend with FDS: issues
            Level 7
            Do you get more information in the error? What about if you turn on debug
            level logging in /WEB-INF/flex/services-config.xml and ensure you have the
            Configuration pattern included in the target category filters for logging
            - it would be useful to see a stacktrace too.

            Another thing to consider is trying to move to LCDS 2.5.1?
            See: http://www.adobe.com/go/trylivecycle_dataservices/


            • 3. Java/Hibernate backend with FDS: issues
              -=Wintermute=- Level 1
              Here's the JBoss log file: JBoss log

              And here are all the files involved:

              User pojo
              User hbm

              Customer pojo
              Customer hbm

              Idcard pojo
              Idcard hbm

              Loan pojo
              Loan hbm

              Book pojo
              Book hbm

              Author pojo
              Author hbm

              Hibernate cfg

              Data-management-config

              Currently the mapped associations are bidirectional CUSTOMER to IDCARD (one-to-one) and bidirectional AUTHOR to BOOK (one-to-many/many-to-one). LOAN is not currently mapped because I'm still thinking about how to do it. Don't mind if you see "italian" names inside the files, I called the entities with english names here to make it all more understandable.

              Actually what's driving me crazy is that if I map only USER, CUSTOMER and AUTHOR (which are kinda "boundary" entities, meaning they exist without any association) as hibernate.cfg.xml resources (and with their respective destinations in data management), it all works perfectly. As soon as I complete the mapping this error suddenly comes up :(
              • 4. Re: Java/Hibernate backend with FDS: issues
                -=Wintermute=- Level 1
                INFO: Hibernate 3.1.3
                INFO: hibernate.properties not found
                INFO: using CGLIB reflection optimizer
                INFO: using JDK 1.4 java.sql.Timestamp handling
                INFO: configuring from resource: /hibernate.cfg.xml
                INFO: Configuration resource: /hibernate.cfg.xml
                INFO: Reading mappings from resource: fdspack/Autore.hbm.xml
                INFO: Mapping class: fdspack.Autore -> AUTORE
                INFO: Reading mappings from resource: fdspack/Libro.hbm.xml
                INFO: Mapping class: fdspack.Libro -> LIBRO
                INFO: Reading mappings from resource: fdspack/Prestito.hbm.xml
                INFO: Mapping class: fdspack.Prestito -> PRESTITO
                INFO: Reading mappings from resource: fdspack/Tessera.hbm.xml
                INFO: Mapping class: fdspack.Tessera -> TESSERA
                INFO: Reading mappings from resource: fdspack/Cliente.hbm.xml
                INFO: Mapping class: fdspack.Cliente -> CLIENTE
                INFO: Reading mappings from resource: fdspack/Utente.hbm.xml
                INFO: Mapping class: fdspack.Utente -> UTENTE
                INFO: Configured SessionFactory: null
                INFO: Mapping collection: fdspack.Autore.libri -> LIBRO
                INFO: Mapping collection: fdspack.Libro.lprestiti -> PRESTITO
                INFO: Mapping collection: fdspack.Tessera.tprestiti -> PRESTITO
                2003-07-26 01:25:23,609 ERROR [STDERR] 26-lug-2003 1.25.23 org.apache.catalina.core.ApplicationContext log
                GRAVE: StandardWrapper.Throwable
                flex.messaging.config.ConfigurationException: Unable to create service 'flex.data.DataService' for 'data-service' due to the following error: Error instantiating application scoped instance of type 'flex.data.assemblers.HibernateAssembler' for destination 'autore.hibernate'..


                The error comes just after "Mapping collection: fdspack.Tessera.tprestiti -> PRESTITO"

                Where could this come from???
                • 5. Re: Java/Hibernate backend with FDS: issues
                  Level 7
                  An error occurred while instantiating your autore.hibernate destination,
                  so it is likely something that has gone wrong while using hibernate to read
                  in your configuration.

                  I would have expected the logs to show much more information if "Debug" level
                  logging was turned on. I'm not overly familiar with the HibernateAssembler
                  itself, but if you could set your logging settings in /WEB-INF/flex/services-config.xml
                  to something like this it may help get even more information:


                  <logging>
                  <target class="flex.messaging.log.ConsoleTarget" level="Debug">
                  <properties>
                  <prefix>[Flex] </prefix>
                  <includeDate>false</includeDate>
                  <includeTime>false</includeTime>
                  <includeLevel>false</includeLevel>
                  <includeCategory>false</includeCategory>
                  </properties>
                  <filters>
                  <pattern>Endpoint.*</pattern>
                  <pattern>Service.*</pattern>
                  <pattern>Configuration</pattern>
                  </filters>
                  </target>
                  </logging>

                  If you already have this setup, let me know. I'll ask a few others who are
                  more familiar with the HibernateAssembler what they suggest.


                  • 6. Re: Java/Hibernate backend with FDS: issues
                    -=Wintermute=- Level 1
                    Many thanks for the help, I modified the services-config.xml file and got deeper into the loggin, finally managing to get single explained hibernate exceptions. Now my app deploys without errors.

                    But when I try to add a record via Flex client I get this:

                    2003-09-27 03:18:20,671 INFO [STDOUT] [Flex] Exception when invoking service: data-service
                    with message: Flex Message (flex.data.messages.DataMessage)
                    operation = transacted
                    id = null
                    clientId = 2B667D83-E00F-3981-D71B-AD0802C0458B
                    correlationId =
                    destination = utente.hibernate
                    messageId = C1273D88-B211-40D6-DB7B-E09FF192D1A9
                    timestamp = 1064625500640
                    timeToLive = 0
                    hdr(DSEndpoint) = my-rtmp
                    exception: flex.data.DataServiceException: Unable to access UserTransaction in DataService.
                    2003-09-27 03:18:20,671 INFO [STDOUT] [Flex] Error handling rtmp message: flex.data.DataServiceException: Unable to access UserTransaction in DataService.
                    incomingMessage: Flex Message (flex.data.messages.DataMessage)
                    operation = transacted
                    id = null
                    clientId = 2B667D83-E00F-3981-D71B-AD0802C0458B
                    correlationId =
                    destination = utente.hibernate
                    messageId = C1273D88-B211-40D6-DB7B-E09FF192D1A9
                    timestamp = 1064625500640
                    timeToLive = 0
                    hdr(DSEndpoint) = my-rtmp
                    errorReply: Flex Message (flex.messaging.messages.ErrorMessage)
                    clientId = null
                    correlationId = C1273D88-B211-40D6-DB7B-E09FF192D1A9
                    destination = utente.hibernate
                    messageId = 2B667DCF-8F08-A433-5C94-3BE332BA4913
                    timestamp = 1064625500671
                    timeToLive = 0
                    body = null
                    code = Server.Processing
                    message = Unable to access UserTransaction in DataService.
                    details = null
                    rootCause = java.lang.ClassCastException: org.jboss.tm.usertx.client.ServerVMClientUserTransaction cannot be cast to javax.transaction.UserTransaction
                    body = null
                    extendedData = null
                    2003-09-27 03:18:20,671 INFO [STDOUT] [Flex] cause=java.lang.ClassCastException: org.jboss.tm.usertx.client.ServerVMClientUserTransaction cannot be cast to javax.transaction.UserTransaction type=class java.lang.ClassCastException
                    java.lang.ClassCastException: org.jboss.tm.usertx.client.ServerVMClientUserTransaction cannot be cast to javax.transaction.UserTransaction


                    I can't figure out that ClassCastException...
                    • 7. Re: Java/Hibernate backend with FDS: issues
                      Level 7
                      That's strange, since ServerVMClientUserTransaction is supposedly an implementation
                      of javax.transaction.UserTransaction.

                      Perhaps your web application classloader is not the same as the classloader
                      that loaded the javax.transaction.UserTransaction interface?

                      I'm not that familiar with JBoss's classpath, but you could try to use a
                      JSP page to get information on which classloader loaded these two Classes
                      in the context of your web application.