0

I've been trying to configure JPA in many ways in different enviroments and I'm slowly becoming desperate. Can anyone tell me what I'm missing?

Exceptions:

Exception in thread "main" org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
etc.
Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.dialect.MySSQL5Dialect] as strategy [org.hibernate.dialect.Dialect]
etc...
    ... 37 more
Caused by: org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [org.hibernate.dialect.MySSQL5Dialect]
etc...
    ... 47 more
Caused by: java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.dialect.MySSQL5Dialect


etc...
    ... 48 more

persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
    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_2_0.xsd">

    <persistence-unit name="BoatsPU" transaction-type="RESOURCE_LOCAL">

        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
        <class>com.dante.jpa.Boat</class>

        <properties>

            <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/boats" />
            <property name="javax.persistence.jdbc.password" value="4dm1n" />
            <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
            <property name="javax.persistence.jdbc.user" value="boats_admin" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySSQL5Dialect"/>
            <property name="hibernate.hbm2ddl.auto" value="create.drop"/>

        </properties>

    </persistence-unit>
</persistence>

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>

    <groupId>com.dante</groupId>
    <artifactId>JPATest2</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>
        <!-- JPA implementation. -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>5.4.0.Final</version>
        </dependency>

        <!-- Driver for desired SQL server. -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.13</version>
        </dependency>

    </dependencies>
</project>

Whole app currently consists of Main with transaction and model class...

I can't even paste all exception code because stackoverflow says i have to add some more details -_-

SDamnation
  • 41
  • 3
  • Possible duplicate of https://stackoverflow.com/questions/42768265/unable-to-create-requested-service-org-hibernate-engine-jdbc-env-spi-jdbcenvir – Ramesh Kotha Jan 07 '19 at 22:21
  • `java.lang.ClassNotFoundException: Could not load requested class`. Which is nothing to do with JPA and everything to do with basic java. Put the class in the classpath, or fix the name –  Jan 08 '19 at 10:24

2 Answers2

0

The class name is MySQL5Dialect, not MySSQL5Dialect

stdunbar
  • 16,263
  • 11
  • 31
  • 53
0

java.lang.ClassNotFoundException mean that your class name is wrong. The exactly name is MySQL5InnoDBDialect. So, you should change your xml to:

<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>

Long
  • 83
  • 8
  • That assumes that the user is using `InnoDB` which is certainly possible but not indicated in original post. – stdunbar Jan 08 '19 at 22:43