Announcement Announcement Module
Collapse
No announcement yet.
Roo / Glassfish Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Roo / Glassfish

    Hi all,

    I've played a lot with "mvn tomcat:run" but I am now trying to test my newapp in a Glassfish container.

    I took clinic.roo which came with our favorite tool and I made a little change:

    Code:
    //persistence setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY
    persistence setup --provider HIBERNATE --database MYSQL --jndiDataSource jdbc/petclinic
    In Glassfish (v3) I had already create my connection pool (petclinicPool) and my jdbc resource (jdbc/petclinic)
    My database is already created too, and 'pingable' in glassfish admin console.

    The problem is that I'm unable to access my database.

    I think that I have to change my transaction-type to JTA in my persitence.xml

    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
    
        <persistence-unit name="persistenceUnit" transaction-type="JTA">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <jta-data-source>jdbc/petclinic</jta-data-source>
            <properties>
                <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
                <property name="hibernate.hbm2ddl.auto" value="create"/>
                <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/>
            </properties>
        </persistence-unit>
    </persistence>
    1. Do I have something to change in applicationContext.xml?
    2. What did I missed?


    Thanks for your help.

  • #2
    What is the exception you're getting?

    Just out of curiosity, any particular reason you're using Glassfish? Roo doesn't mind, I'm just trying to understand if there's a special requirement we should think about from a Roo perspective in the future.

    Comment


    • #3
      lowercase / uppercase

      Hello Ben,

      for Glassfish:
      I have to try Spring / Roo / Glassfish / Mysql or Postgresql for a future dev in which we could rely on Glassfish for its scalability and we hope to have the need of its clustering properties too.
      In my case I must admit that I used Roo for a learning purpose, to become more familiar with the Spring Framework and AOP.

      for my problem:
      I've made a lot of googling, here I am:
      Code:
      Internal Error
      
      Sorry, we encountered an internal error.
      
      Details
      -Exception Message
      Internal Exception: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 'petclinic.PET' doesn't exist Error Code: 1146 Call: SELECT id AS id1, WEIGHT AS WEIGHT2, NAME AS NAME3, SENDREMINDERS AS SENDREMINDERS4, version AS version5, TYPE AS TYPE6, OWNER_id AS OWNER_id7 FROM PET LIMIT ?, ? bind => [0, 10] Query: ReadAllQuery(referenceClass=Pet sql="SELECT id AS id1, WEIGHT AS WEIGHT2, NAME AS NAME3, SENDREMINDERS AS SENDREMINDERS4, version AS version5, TYPE AS TYPE6, OWNER_id AS OWNER_id7 FROM PET LIMIT ?, ?")
      IMO the most revelant is that there is a problem with uppercase/lowercase characters as we can see in the exception message :

      Internal Exception: com.mysql.jdbc.exceptions.MySQLSyntaxErrorExceptio n: Table 'petclinic.PET' doesn't exist Error Code: 1146 Call: SELECT id AS id1, WEIGHT AS WEIGHT2, NAME AS NAME3, SENDREMINDERS AS SENDREMINDERS4, version AS version5, TYPE AS TYPE6, OWNER_id AS OWNER_id7 FROM PET LIMIT ?, ? bind => [0, 10] Query: ReadAllQuery(referenceClass=Pet sql="SELECT id AS id1, WEIGHT AS WEIGHT2, NAME AS NAME3, SENDREMINDERS AS SENDREMINDERS4, version AS version5, TYPE AS TYPE6, OWNER_id AS OWNER_id7 FROM PET LIMIT ?, ?")

      sometimes all is in upper, sometimes in lower and it could be both!?! I really don't know where I could act!

      Thanks for you help.

      Comment


      • #4
        how to reproduce

        here are my sources so as to to reproduce the problem

        my petclinic.roo
        Code:
        project --topLevelPackage com.springsource.petclinic
        
        //persistence setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY
        persistence setup --provider HIBERNATE --database MYSQL --jndiDataSource jdbc/petclinic
        
        enum type --class ~.reference.PetType
        enum constant --name Dog
        enum constant --name Cat
        enum constant --name Bird
        
        enum type --class ~.reference.Specialty
        enum constant --name Cardiology
        enum constant --name Dentistry
        enum constant --name Nutrition
        
        entity --class ~.domain.Pet --testAutomatically
        entity --class ~.domain.Visit --testAutomatically
        entity --class ~.domain.AbstractPerson --abstract
        entity --class ~.domain.Vet --extends ~.domain.AbstractPerson --testAutomatically
        entity --class ~.domain.Owner --extends ~.domain.AbstractPerson --testAutomatically
        
        field string --fieldName firstName --sizeMin 3 --sizeMax 30 --class ~.domain.AbstractPerson
        field string --fieldName lastName --notNull --sizeMin 3 --sizeMax 30
        field string --fieldName address --notNull --sizeMax 50 --sizeMin 1
        field string --fieldName city --notNull --sizeMax 30
        field string --fieldName telephone --notNull
        field string --fieldName homePage --sizeMax 30
        field string --fieldName email --sizeMax 30 --sizeMin 6
        field date --fieldName birthDay --type java.util.Date --notNull
        
        field string --fieldName description --sizeMax 255 --class ~.domain.Visit
        field date --fieldName visitDate --type java.util.Date --notNull --past
        field reference --fieldName pet --type ~.domain.Pet --notNull
        field reference --fieldName vet --type ~.domain.Vet
        
        field boolean --fieldName sendReminders --notNull --primitive --class ~.domain.Pet
        field string --fieldName name --notNull --sizeMin 1
        field number --fieldName weight --type java.lang.Float --notNull --min 0
        field reference --fieldName owner --type ~.domain.Owner
        field enum --fieldName type --type ~.reference.PetType --notNull
        
        field date --fieldName employedSince --type java.util.Calendar --notNull --past --class ~.domain.Vet
        field enum --fieldName specialty --type ~.reference.Specialty --notNull false
        
        field set --class ~.domain.Owner --fieldName pets --element ~.domain.Pet --mappedBy owner --notNull false --cardinality ONE_TO_MANY
        
        finder add --finderName findPetsByNameAndWeight --class ~.domain.Pet
        finder add --finderName findPetsByOwner
        finder add --finderName findPetsBySendRemindersAndWeightLessThan
        finder add --finderName findPetsByTypeAndNameLike
        
        finder add --finderName findVisitsByDescriptionAndVisitDate --class ~.domain.Visit
        finder add --finderName findVisitsByVisitDateBetween
        finder add --finderName findVisitsByDescriptionLike
        
        controller all --package ~.web
        
        selenium test --controller ~.web.OwnerController
        selenium test --controller ~.web.PetController
        selenium test --controller ~.web.VetController
        selenium test --controller ~.web.VisitController
        
        logging setup --level DEBUG
        
        //perform tests
        perform eclipse
        my applicationContext.xml
        Code:
        <?xml version="1.0" encoding="UTF-8" standalone="no"?>
        <beans xmlns="http://www.springframework.org/schema/beans"
        	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
        	xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
        	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        	xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd   http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd   http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd   http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd   http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
        
        	<context:property-placeholder location="classpath*:META-INF/spring/*.properties" />
        	<context:spring-configured />
        	<context:component-scan base-package="com.springsource.petclinic">
        		<context:exclude-filter expression=".*_Roo_.*"
        			type="regex" />
        		<context:exclude-filter expression="org.springframework.stereotype.Controller"
        			type="annotation" />
        	</context:component-scan>
        
        
        	<jee:jndi-lookup id="dataSource" jndi-name="jdbc/petclinic" />
        
        	<jee:jndi-lookup id="entityManagerFactory" jndi-name="persistence/petclinicPU" />
        
        	<tx:jta-transaction-manager />
        	<tx:annotation-driven mode="aspectj"
        		transaction-manager="transactionManager" />
        
        </beans>
        my persistence.xml
        Code:
        <?xml version="1.0" encoding="UTF-8" standalone="no"?>
        <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
        
        <persistence-unit name="petclinicPU" transaction-type="JTA">
        	<jta-data-source>jdbc/petclinic</jta-data-source>
        </persistence-unit>
        
        </persistence>
        my web.xml in version 2.5
        Code:
        <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        	version="2.5">
        ...
        	<persistence-unit-ref>
        		<persistence-unit-ref-name>persistence/petclinicPU</persistence-unit-ref-name>
        		<persistence-unit-name>petclinicPU</persistence-unit-name>
        	</persistence-unit-ref>
        ...
        thx

        Comment

        Working...
        X