@ProtCN

Как исправить PersistenceException: Unable to resolve persistence unit root URL?

Человек, будьте добры помочь мне с этой ненастной проблемой!
Используется Spring-Framework (не boot и не web) и аннотированный JavaConfig для бинов и настройки JPA.

Я не знаю почему, но при запуске приложения у меня вылетает исключение из заголовка вопроса.
Дерево проекта не содержит никакой xml'щины (orm.xml, persistence.xml и др.), так как вроде бы это и не нужно.

Помогите избавиться от этой бинарной занозы!

JpaConfiguration.class
@Configuration
public class JpaConfiguration {

    @Bean
    public DataSource dataSource() {
        SQLBaseAuth auth = getAuth();
        MysqlDataSource dataSource = new MysqlDataSource();
        dataSource.setUrl(auth.getUrl());
        dataSource.setUser(auth.getUser());
        dataSource.setPassword(auth.getPassword());
        return dataSource;
    }

    @Bean
    public JpaTransactionManager transactionManager(EntityManagerFactory emf) {
        return new JpaTransactionManager(emf);
    }

    @Bean
    public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
        LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
        em.setDataSource(dataSource());
        em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
        em.setPackagesToScan("com.myrepo.scan_packages");
        return em;
    }
}


pom.xml
<dependencies>

        <!-- MYSQL/JDBC -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql.version}</version>
        </dependency>

        <!-- SPRING-CONTEXT -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring-framework.version}</version>
        </dependency>

        <!-- SPRING-JPA -->
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-jpa</artifactId>
            <version>${spring-jpa.version}.RELEASE</version>
        </dependency>

        <!-- HIBERNATE-CORE -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.4.22.Final</version>
        </dependency>

        <!-- JAVAX-PERSISTENCE-API -->
        <dependency>
            <groupId>javax.persistence</groupId>
            <artifactId>javax.persistence-api</artifactId>
            <version>${javax.persistence.version}</version>
        </dependency>

    </dependencies>


*логи*
[17:56:52] [Server thread/INFO]: Bean 'jpaConfiguration' of type [ru.prisonlife.spring.JpaConfiguration$$EnhancerBySpringCGLIB$$379496b4] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[17:56:53] [Server thread/WARN]: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in com.myrepo.spring.JpaConfiguration: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
[17:56:53] [Server thread/ERROR]: Error occurred while enabling PLCore v1.0.0 (Is it up to date?)
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in com.myrepo.spring.JpaConfiguration: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1794) ~[?:?]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[?:?]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[?:?]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[?:?]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[?:?]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[?:?]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[?:?]
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1109) ~[?:?]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~[?:?]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) ~[?:?]
	at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:89) ~[?:?]
	at com.myrepo.Main.launchSpring(Main.java:253) ~[?:?]
	at com.myrepo.Main.onEnable(Main.java:60) ~[?:?]
	at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
	at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:352) [spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
	at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:417) [spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
	at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugin(CraftServer.java:462) [spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
	at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugins(CraftServer.java:376) [spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
	at net.minecraft.server.v1_15_R1.MinecraftServer.a(MinecraftServer.java:457) [spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
	at net.minecraft.server.v1_15_R1.DedicatedServer.init(DedicatedServer.java:267) [spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
	at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:784) [spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_261]
Caused by: javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
	at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.determineDefaultPersistenceUnitRootUrl(DefaultPersistenceUnitManager.java:641) ~[?:?]
	at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.preparePersistenceUnitInfos(DefaultPersistenceUnitManager.java:463) ~[?:?]
	at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.afterPropertiesSet(DefaultPersistenceUnitManager.java:444) ~[?:?]
	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:328) ~[?:?]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1853) ~[?:?]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1790) ~[?:?]
	... 21 more
Caused by: java.io.FileNotFoundException: class path resource [] cannot be resolved to URL because it does not exist
	at org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:195) ~[?:?]
	at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.determineDefaultPersistenceUnitRootUrl(DefaultPersistenceUnitManager.java:637) ~[?:?]
	at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.preparePersistenceUnitInfos(DefaultPersistenceUnitManager.java:463) ~[?:?]
	at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.afterPropertiesSet(DefaultPersistenceUnitManager.java:444) ~[?:?]
	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:328) ~[?:?]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1853) ~[?:?]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1790) ~[?:?]
	... 21 more
[17:56:53] [Server thread/INFO]: [Holograms] Enabling Holograms v2.12
[17:56:53] [Server thread/INFO]: [Holograms] HologramEntityController set to: com.sainttx.holograms.nms.v1_15_R1.HologramEntityControllerImpl
[17:56:53] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
[17:56:53] [Server thread/INFO]: Done (13.387s)! For help, type "help"
  • Вопрос задан
  • 76 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы