2012-06-27 2 views
0

Maven을 사용하여 Guice-persist를 사용하여 내 데이터 객체를 Eclipse에서 MySQL로 다시 매핑하는 GWT (GWT-Platform, 정확하게) 프로젝트를 구성하려고합니다. 나는 운이 없다.Maven Hibernate with Guice-Persist

저는 GWTP 기본 샘플의 Maven 구성을 기반으로 코드를 작성했습니다.이 코드는 작동 할 수있었습니다. pom.xml 파일에 Hibernate 종속성을 추가 했으므로 성공적으로 다시 실행하지 못하는 것 같습니다. 같은 인젝터를 설정할 때 내 PersistModule을 만들

1) Error injecting constructor, javax.persistence.PersistenceException: No Persistence provider for EntityManager named myappdb 
    at com.gwtplatform.samples.basic.server.ApplicationInitializer.<init>(ApplicationInitializer.java:8) 
    while locating com.gwtplatform.samples.basic.server.ApplicationInitializer 

: 현재, 나는 다음과 같은 오류를 받고 있어요

<persistence xmlns="http://java.sun.com/xml/ns/persistence" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
     http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0"> 

    <persistence-unit name="myappdb" transaction-type="RESOURCE_LOCAL"> 
     <provider>org.hibernate.ejb.HibernatePersistence</provider> 

     <class>com.gwtplatform.samples.basic.shared.Bird</class> 
     <exclude-unlisted-classes>true</exclude-unlisted-classes> 
     <properties> 
      <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/> 
      <property name="hibernate.connection.url" value="jdbc:mysql://mydbserver.com/mydbname"/> 
      <property name="hibernate.connection.username" value="test123" /> 
      <property name="hibernate.connection.password" value ="password123" /> 

      <property name="show_sql" value="true" /> 
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" /> 

      <!-- Default is false for backwards compatibility. Should be used on all 
       new projects --> 
      <property name="hibernate.id.new_generator_mappings" value="true" /> 

     </properties> 
    </persistence-unit> 
</persistence> 
:

Injector inject = Guice.createInjector(new ServerModule(), 
      new DispatchServletModule(), new JpaPersistModule("myappdb")); 
inject.getInstance(ApplicationInitializer.class); 

내 파일은 다음과 같습니다 지속

그리고 내 pom.xml 파일은 다음과 같습니다.

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <parent> 
     <groupId>com.gwtplatform</groupId> 
     <artifactId>gwtp-samples</artifactId> 
     <version>0.7</version> 
    </parent> 

    <artifactId>gwtp-sample-basic</artifactId> 
    <packaging>war</packaging> 
    <name>GWTP Samples - basic</name> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>gwt-maven-plugin</artifactId> 
       <configuration> 
        <logLevel>INFO</logLevel> 
        <style>${gwt.style}</style> 
        <server>com.google.appengine.tools.development.gwt.AppEngineLauncher</server> 
        <hostedWebapp>${webappDirectory}</hostedWebapp> 
        <copyWebapp>true</copyWebapp> 
        <appEngineVersion>${gae.version}</appEngineVersion> 
        <appEngineHome>${gae.home}</appEngineHome> 
        <runTarget>Gwtpsample.html</runTarget> 
        <module>com.gwtplatform.samples.basic.Gwtpsample</module> 
       </configuration> 
      </plugin> 

      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-eclipse-plugin</artifactId> 
       <configuration> 
        <useProjectReferences>false</useProjectReferences> 
      <warSourceDirectory>war</warSourceDirectory> 
       <webXml>src/main/webapp/WEB-INF/web.xml</webXml> 
        <additionalBuildcommands> 
         <buildcommand>com.google.gwt.eclipse.core.gwtProjectValidator</buildcommand> 
        </additionalBuildcommands> 
        <additionalProjectnatures> 
         <projectnature>com.google.appengine.eclipse.core.gaeNature</projectnature> 
         <projectnature>com.google.gwt.eclipse.core.gwtNature</projectnature> 
        </additionalProjectnatures> 
       </configuration> 
       <dependencies> 
        <dependency> 
         <groupId>com.gwtplatform</groupId> 
         <artifactId>gwtp-build-tools</artifactId> 
         <version>${project.version}</version> 
        </dependency> 
       </dependencies> 
      </plugin> 

     </plugins> 
    </build> 

    <dependencies> 
     <!-- Google Web Toolkit dependencies --> 
     <dependency> 
      <groupId>com.google.gwt</groupId> 
      <artifactId>gwt-user</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>com.google.gwt</groupId> 
      <artifactId>gwt-servlet</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>com.google.gwt</groupId> 
      <artifactId>gwt-dev</artifactId> 
     </dependency> 

     <!-- AppEngine dependencies 
     <dependency> 
      <groupId>com.google.appengine</groupId> 
      <artifactId>appengine-api-1.0-sdk</artifactId> 
     </dependency> --> 

     <!-- DI dependencies --> 
     <dependency> 
      <groupId>com.google.inject</groupId> 
      <artifactId>guice</artifactId> 
      <version>3.0</version> 
     </dependency> 
     <dependency> 
      <groupId>com.google.inject.extensions</groupId> 
      <artifactId>guice-persist</artifactId> 
      <version>3.0</version> 
     </dependency> 
     <dependency> 
      <groupId>com.google.inject.extensions</groupId> 
      <artifactId>guice-servlet</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>com.google.inject.extensions</groupId> 
      <artifactId>guice-assistedinject</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>com.google.gwt.inject</groupId> 
      <artifactId>gin</artifactId> 
     </dependency> 

     <dependency> 
      <groupId>mysql</groupId> 
      <artifactId>mysql-connector-java</artifactId> 
      <version>5.1.10</version> 
     </dependency> 

     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-core</artifactId> 
      <version>3.5.6-Final</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-entitymanager</artifactId> 
      <version>3.5.6-Final</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-c3p0</artifactId> 
      <version>3.5.6-Final</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-annotations</artifactId> 
      <version>3.5.6-final</version> 
     </dependency>  
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-api</artifactId> 
      <version>1.5.6</version> 
     </dependency> 
     <!-- concrete Log4J Implementation for SLF4J API--> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-log4j12</artifactId> 
      <version>1.5.6</version> 
     </dependency> 


    </dependencies> 

    <profiles> 
     <profile> 
      <!-- Activate this profile to compile the sample 
      including just the adequate GWTP dependencies --> 
      <id>default-samples</id> 
      <activation> 
       <property><name>!gwtp-all</name></property> 
      </activation> 
      <dependencies> 
       <dependency> 
        <groupId>${project.groupId}</groupId> 
        <artifactId>gwtp-mvp-client</artifactId> 
       </dependency> 
       <dependency> 
        <groupId>${project.groupId}</groupId> 
        <artifactId>gwtp-dispatch-client</artifactId> 
       </dependency> 
       <dependency> 
        <groupId>${project.groupId}</groupId> 
        <artifactId>gwtp-dispatch-server-guice</artifactId> 
       </dependency> 
      </dependencies> 
     </profile> 

     <profile> 
      <!-- Activate this profile to compile the sample 
      using the compound GWTP dependency (gwtp-all) --> 
      <id>gwtp-all-samples</id> 
      <activation> 
       <property><name>gwtp-all</name></property> 
      </activation> 
      <dependencies> 
       <dependency> 
        <groupId>${project.groupId}</groupId> 
        <artifactId>gwtp-all</artifactId> 
       </dependency> 
      </dependencies> 
     </profile> 
    </profiles> 
</project> 

보시다시피 단위 이름이 일치합니다. 또한 persistance.xml 파일을 프로젝트의 src/main/webapp/META-INF 디렉토리에 저장했습니다. 나는 /target/에 일치하는 디렉터리뿐만 아니라 /src/main/webapp/ 디렉터리를 war 파일의 기반으로 사용하여 프로젝트를 실행하려고 시도하지 않았으며이 오류를 극복 할 수 없습니다.

모든 포인터가 크게 감사하겠습니다! 나는 2 일 동안 이것을 꼼짝 않고 바라 보았다.

+2

'persistence.xml' 파일을'src/main/resources/META-INF'에 넣으려고 했습니까? – condit

+0

예, persistence.xml의 위치가 잘못되었습니다. user463324가 지시 한대로'src/main/resources/META-INF'에 있어야합니다. –

+0

@ user463324 답을 작성하면 동의하겠습니다. –

답변

0

src/main/resources/META-INF에 persistance.xml 파일을 저장하십시오.