-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Trying to setup JPA, can't get it to create the tables
PostPosted: Sun Apr 22, 2012 6:12 am 
Newbie

Joined: Sun Apr 22, 2012 6:07 am
Posts: 1
I am trying to setup a project using CDI-weld, JSF 2-mojarra, RichFaces 4, JPA-hibernate, Bean-Validation-hibernate, maven 2, Tomcat 7 and Eclipse Juno.

I thought it would be interesting to feel out the synergy of the latest stuff (except for maven, to lazy for getting into maven 3)

I got everything working like a charm except for the last piece in the puzzle, adding JPA. There's a lot of information on how to set it up and after trying for a while now I just feel very confused. I have it narrowed down to this basically:

(from this post: http://stackoverflow.com/questions/3814 ... -hibernate)

you need:
slf4j-jdk14 and hibernate-entitymanager as artifacts and that's it? I tried a bunch of different setups but I got nothing of it to work. It just won't generate the tables.

(For now i'm trying with these artifacts and I figured i'll worry about versions later)

Code:
      <dependency>
         <groupId>org.hibernate</groupId>
         <artifactId>hibernate-entitymanager</artifactId>
         <version>3.5.1-Final</version>
      </dependency>

      <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-jdk14</artifactId>
         <!-- version 1.5.8 is the latest version that will work with the slf4j-api
            that's currently bundled with hibernate-parent -->
         <version>1.5.8</version>
      </dependency>
      <dependency>
         <groupId>mysql</groupId>
         <artifactId>mysql-connector-java</artifactId>
         <version>5.1.13</version>
         <type>jar</type>
      </dependency>



persistance.xml is located here: src - main - wewbapp - WEB-INF - classes - META-INF - persistance.xml.

Tried a bunch of locations with no luck.

Content is as follows:

Code:
<?xml version="1.0" encoding="UTF-8"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://svn.apache.org/repos/asf/geronimo/components/geronimo-schema-javaee_6/trunk/src/main/xsd/persistence_2_0.xsd"
       version="2.0">
       <persistence-unit name="pu">
          <provider>org.hibernate.ejb.HibernatePersistence</provider>
          <class>com.test.User</class>
          <properties>
             <!-- Auto detect annotation model classes -->
             <property name="hibernate.archive.autodetection" value="class" />
             <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
             <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
             <property name="hibernate.hbm2ddl.auto" value="update" />
             <property name="hibernate.show_sql" value="false" />
             <property name="hibernate.format_sql" value="true" />
             <property name="hibernate.connection.username" value="root" />
             <property name="hibernate.connection.password" value="1111" />
             <property name="hibernate.connection.url" value="jdbc:mysql://localhost/woot" />
          </properties>
   
       </persistence-unit>
    </persistence>


Borrowed test Class:
Code:
    /**
     * User account that is required for logging in and posting bookmarks.
     *
     * @author Andy Gibson
     *
     */
    @Entity
    @Table(name = "USERS")
    public class User {
   
       @Id
       @GeneratedValue(strategy = GenerationType.AUTO)
       private Long id;
   
       @Column(length = 24)
       private String username;
   
       @Column(length = 24,name="userPassword")
       private String password;
   
       @Column(length = 24)
       private String firstName;
   
       @Column(length = 24)
       private String lastName;
   
       public Long getId() {
          return id;
       }
   
       public void setId(Long id) {
          this.id = id;
       }
   
       public String getUsername() {
          return username;
       }
   
       public void setUsername(String username) {
          this.username = username;
       }
   
       public String getPassword() {
          return password;
       }
   
       public void setPassword(String password) {
          this.password = password;
       }
   
       public String getFirstName() {
          return firstName;
       }
   
       public void setFirstName(String firstName) {
          this.firstName = firstName;
       }
   
       public String getLastName() {
          return lastName;
       }
   
       public void setLastName(String lastName) {
          this.lastName = lastName;
       }
   
    }


Tomcat log:

apr 21, 2012 10:58:54 EM 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: E:\Programming\Setup\Glassfish\jdk7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;E:\Programming\Setup\Glassfish\jdk7\jre\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\Microsoft Windows Performance Toolkit\;E:\Programming\Setup\Glassfish\jdk7\bin;C:\Program Files (x86)\Groovy\Groovy-1.8.0\bin;C:\Program Files (x86)\Calibre2\;E:\Programming\Setup\apache-maven-2.2.1\bin;E:\Program\SVN\bin;E:\Programming\grails-2.0.0\\bin;.
apr 21, 2012 10:58:54 EM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:woot' did not find a matching property.
apr 21, 2012 10:58:54 EM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
apr 21, 2012 10:58:54 EM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
apr 21, 2012 10:58:54 EM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 900 ms
apr 21, 2012 10:58:54 EM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
apr 21, 2012 10:58:54 EM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.22
apr 21, 2012 10:58:55 EM org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "com.sun.faces.config.ConfigureListener" is already configured for this context. The duplicate definition has been ignored.
apr 21, 2012 10:58:55 EM org.jboss.weld.bootstrap.WeldBootstrap <clinit>
INFO: WELD-000900 1.1.5 (Final)
apr 21, 2012 10:58:55 EM org.jboss.weld.bootstrap.WeldBootstrap startContainer
INFO: WELD-000101 Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
apr 21, 2012 10:58:56 EM org.jboss.weld.environment.tomcat7.Tomcat7Container initialize
INFO: Tomcat 7 detected, CDI injection will be available in Servlets and Filters. Injection into Listeners is not supported
apr 21, 2012 10:58:56 EM org.jboss.interceptor.util.InterceptionTypeRegistry <clinit>
WARNING: Class 'javax.ejb.PostActivate' not found, interception based on it is not enabled
apr 21, 2012 10:58:56 EM org.jboss.interceptor.util.InterceptionTypeRegistry <clinit>
WARNING: Class 'javax.ejb.PrePassivate' not found, interception based on it is not enabled
apr 21, 2012 10:58:56 EM com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra 2.1.7 (SNAPSHOT 20120206) for context '/rdwebref'
apr 21, 2012 10:58:58 EM com.sun.faces.spi.InjectionProviderFactory createInstance
INFO: JSF1048: PostConstruct/PreDestroy annotations present. ManagedBeans methods marked with these annotations will have said annotations processed.
apr 21, 2012 10:58:59 EM org.hibernate.validator.util.Version <clinit>
INFO: Hibernate Validator 4.0.2.GA
apr 21, 2012 10:58:59 EM org.hibernate.validator.engine.resolver.DefaultTraversableResolver detectJPA
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
apr 21, 2012 10:59:00 EM org.hibernate.validator.engine.resolver.DefaultTraversableResolver detectJPA
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
apr 21, 2012 10:59:00 EM org.richfaces.cache.CacheManager getCacheFactory
INFO: Selected fallback cache factory
apr 21, 2012 10:59:00 EM org.richfaces.cache.lru.LRUMapCacheFactory createCache
INFO: Creating LRUMap cache instance using parameters: {javax.servlet.jsp.jstl.fmt.localizationContext=resources.application, javax.faces.STATE_SAVING_METHOD=client, javax.faces.DEFAULT_SUFFIX=.xhtml}
apr 21, 2012 10:59:00 EM org.richfaces.cache.lru.LRUMapCacheFactory createCache
INFO: Creating LRUMap cache instance of 512 items capacity
apr 21, 2012 10:59:00 EM org.richfaces.application.InitializationListener onStart
INFO: RichFaces Core Implementation by JBoss by Red Hat, version v.4.2.0.Final
apr 21, 2012 10:59:00 EM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
apr 21, 2012 10:59:00 EM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
apr 21, 2012 10:59:00 EM org.apache.catalina.startup.Catalina start
INFO: Server startup in 6130 ms


I did create the database called "woot" and password and username is correct. I have gotten mysql to work with Grails 2 previously.

Hope someone can help me out here! cheers


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.