我有一个应用程序部署到heroku与jaws mariadb资源。
我可以通过我的localhost:8080 with 我的persistence.xml配置。我还可以连接到本地tomcat服务器上的远程jawsdb。我也可以在heroku上运行我的应用程序,当它不访问持久层时。但是,由于某些原因,不会创建持久性提供程序。
我使用maven进行依赖关系管理。所有的零件都是分开工作的。他们就是不在一起。我错过了什么?
这是我的pom,persistence.xml,我的错误日志和屏幕截图,如果你知道任何工具或技术来获取更多信息,请告诉我。我可以访问heroku bash控制台。
聚甲醛
<?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>
<groupId>com.gerald.ryan</groupId>
<artifactId>blocks</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>blocks</name>
<url>http://maven.apache.org</url>
<properties>
<java.version>1.8</java.version>
<spring.version>5.3.5</spring.version>
<hibernate.version>5.4.1.Final</hibernate.version>
<cglib.version>2.2.2</cglib.version>
</properties>
<dependencies>
<!-- Part of the Spring MVC Maven archetype -->
<!-- Spring core & mvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<!-- CGLib for @Configuration -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>${cglib.version}</version>
<scope>runtime</scope>
</dependency>
<!-- Maven says this below was moved to one below it-->
<!-- <dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency> -->
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<!-- END of the Spring MVC Maven archetype -->
<!-- pubnub -->
<dependency>
<groupId>com.pubnub</groupId>
<artifactId>pubnub-gson</artifactId>
<version>4.35.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jetbrains/annotations -->
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>13.0</version>
</dependency>
<!-- Database Connectivity -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.23</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.2.0.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<!-- GSON For serialization -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
<!-- use in jsp -->
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/json-taglib/json-taglib -->
<dependency>
<groupId>atg.taglib.json</groupId>
<artifactId>json-taglib</artifactId>
<version>0.4.1</version>
</dependency>
<!-- use in jsp -->
</dependencies>
<repositories>
<repository>
<id>springsource-milestones</id>
<name>SpringSource Milestones Proxy</name>
<url>https://oss.sonatype.org/content/repositories/springsource-milestones</url>
</repository>
<repository>
<id>public</id>
<url>http://maven.nuxeo.org/nexus/content/repositories/public/</url>
</repository>
</repositories>
<build>
<finalName>blocks</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.heroku</groupId>
<artifactId>webapp-runner</artifactId>
<version>9.0.41.0</version>
<destFileName>webapp-runner.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.2"
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_2.xsd">
<!-- <persistence-unit name="blocks"> <class>com.gerald.ryan.blocks.entity.Block</class>
<class>com.gerald.ryan.blocks.entity.Blockchain</class> <class>com.gerald.ryan.blocks.entity.Transaction</class>
<class>com.gerald.ryan.blocks.entity.Wallet</class> <class>com.gerald.ryan.blocks.entity.User</class>
<properties> <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/blockchain?serverTimezone=UTC"
/> <property name="javax.persistence.jdbc.user" value="root" /> <property
name="javax.persistence.jdbc.password" value="root" /> <property name="javax.persistence.jdbc.driver"
value="com.mysql.jdbc.Driver" /> <property name="javax.persistence.schema-generation.database.action"
value="create" /> <property name="hibernate.show_sql" value="true" /> <property
name="hibernate.format_sql" value="true" /> </properties> </persistence-unit> -->
<persistence-unit name="blocks">
<class>com.gerald.ryan.blocks.entity.Block</class>
<class>com.gerald.ryan.blocks.entity.Blockchain</class>
<class>com.gerald.ryan.blocks.entity.Transaction</class>
<class>com.gerald.ryan.blocks.entity.Wallet</class>
<class>com.gerald.ryan.blocks.entity.User</class>
<properties>
<property name="javax.persistence.jdbc.url"
value="jdbc:mysql://u3r5w4ayhxzdrw87.cbetxkdyhwsb.us-east-1.rds.amazonaws.com:3306/f5wvp1u840cyi24e" />
<property name="javax.persistence.jdbc.user"
value="e9hhcvg1kn3ik6cr" />
<property name="javax.persistence.jdbc.password"
value="p0fhaapu58vhqvor" />
<property name="javax.persistence.jdbc.driver"
value="com.mysql.jdbc.Driver" />
<property
name="javax.persistence.schema-generation.database.action"
value="create" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
</properties>
</persistence-unit>
<!-- as config var on https://dashboard.heroku.com/apps/blocksjava/settings -->
<!-- mysql://e9hhcvg1kn3ik6cr:b5wkq1kvydnyogrp@u3r5w4ayhxzdrw87.cbetxkdyhwsb.us-east-1.rds.amazonaws.com:3306/f5wvp1u840cyi24e -->
</persistence>
package com.gerald.ryan.blocks.dbConnection;
import java.net.URI;
import java.net.URISyntaxException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
public abstract class DBConnection {
protected EntityManagerFactory emf = null;
protected EntityManager em = null;
private String pUName = "blocks";
public void connect() {
System.err.println("Persistence Provider: " + Persistence.PERSISTENCE_PROVIDER);
System.err.println("Persistence Class: " + Persistence.class);
this.emf = Persistence.createEntityManagerFactory(pUName);
this.em = emf.createEntityManager();
}
public void disconnect() {
if (this.em != null) {
em.close();
}
if (this.emf != null) {
emf.close();
}
}
Type Exception Report
Message Request processing failed; nested exception is javax.persistence.PersistenceException: No Persistence provider for EntityManager named blocks
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is javax.persistence.PersistenceException: No Persistence provider for EntityManager named blocks
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
javax.servlet.http.HttpServlet.service(HttpServlet.java:652)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Root Cause
javax.persistence.PersistenceException: No Persistence provider for EntityManager named blocks
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:85)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
com.gerald.ryan.blocks.dbConnection.DBConnection.connect(DBConnection.java:12)
com.gerald.ryan.blocks.Dao.UserDao.addUser(UserDao.java:16)
com.gerald.ryan.blocks.Service.UserService.addUserService(UserService.java:22)
com.gerald.ryan.blocks.controller.RegistrationController.registerUser(RegistrationController.java:40)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:197)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:141)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:894)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1060)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:962)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
javax.servlet.http.HttpServlet.service(HttpServlet.java:652)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
我可能缺少哪些依赖项或配置,或者哪些工具和技术可以帮助我了解更多?
jaws db dashboard-通过localhost正确连接
暂无答案!
目前还没有任何答案,快来回答吧!