3

アプリケーションを Openshift.com にデプロイする際に問題があります。

Tomcat で単純な Java JPA アプリケーションを作成したいと考えています。アプリケーションはローカルで起動しますが、Openshift.com にデプロイすると次のエラーが発生します。

javax.persistence.PersistenceException: 
No Persistence provider for EntityManager named testpersist

私のpom.xml:

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>testradioapp</groupId>
    <artifactId>testradioapp</artifactId>
    <packaging>war</packaging>
    <version>1.0</version>
    <name>testradioapp</name>
    <repositories>
        <repository>
            <id>eap</id>
            <url>http://maven.repository.redhat.com/techpreview/all</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>eap</id>
            <url>http://maven.repository.redhat.com/techpreview/all</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.6</maven.compiler.source>
        <maven.compiler.target>1.6</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.2-1003-jdbc4</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.25</version>
        </dependency>        
         <dependency>  
            <groupId>javax.persistence</groupId>  
            <artifactId>persistence-api</artifactId>  
            <version>1.0</version>  
        </dependency>     
    </dependencies>
    <profiles>
        <profile>
            <!-- When built in OpenShift the 'openshift' profile will be used when 
                invoking mvn. -->
            <!-- Use this profile for any OpenShift specific customization your app 
                will need. -->
            <!-- By default that is to put the resulting archive into the 'webapps' 
                folder. -->
            <!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
            <id>openshift</id>
            <build>
                <finalName>testradioapp</finalName>
                <plugins>
                    <plugin>
                        <artifactId>maven-war-plugin</artifactId>
                        <version>2.1.1</version>
                        <configuration>
                            <outputDirectory>webapps</outputDirectory>
                            <warName>ROOT</warName>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

私のpersistance.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
    <persistence-unit name="testpersist">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

        <class>pl.mirkofm.model.Author</class>
        <class>pl.mirkofm.model.Played</class>
        <class>pl.mirkofm.model.Rate</class>
        <class>pl.mirkofm.model.Song</class>
     <properties>
      <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
      <property name="javax.persistence.jdbc.url" value="jdbc:mysql://xx:3306/xx" />
      <property name="javax.persistence.jdbc.user" value="xx"/>
      <property name="javax.persistence.jdbc.password" value="xx"/>
    </properties>
    </persistence-unit>
</persistence>

私の web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app metadata-complete="false" version="3.0"
 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_3_0.xsd">
 <welcome-file-list>
  <welcome-file>/index.jsp</welcome-file>
 </welcome-file-list>
</web-app>

私のアプリツリー:

├───.openshift
│   ├───action_hooks
│   ├───config
│   ├───cron
│   │   ├───daily
│   │   ├───hourly
│   │   ├───minutely
│   │   ├───monthly
│   │   └───weekly
│   └───markers
├───.settings
├───src
│   └───main
│       ├───java
│       │   ├───META-INF
│       │   └───pl
│       │       └───mirkofm
│       │           ├───main
│       │           └───model
│       ├───resources
│       └───webapp
│           ├───images
│           └───WEB-INF
├───target
│   ├───classes
│   │   ├───META-INF
│   │   └───pl
│   │       └───mirkofm
│   │           ├───main
│   │           └───model
│   ├───m2e-wtp
│   │   └───web-resources
│   │       └───META-INF
│   │           └───maven
│   │               └───testradioapp
│   │                   └───testradioapp
│   └───test-classes
└───webapps

助けてください。ありがとう。

4

2 に答える 2