1
votes

I started working on a projet, and i'm using windows. Basically i could generate a Jar file using maven, but when i try to run my Jar file it doesn't work well. Sounds like it doesn't find hibernate properties.

My error:

2017-01-15 16:03:12.454  INFO 19012 --- [main] org.hibernate.Version                    : 
    HHH000412: Hibernate Core    {5.0.11.Final} 
2017-01-15 16:03:12.473  INFO 19012 --- [main] org.hibernate.cfg.Environment            : 
    HHH000206: hibernate.properties not found 
2017-01-15 16:03:12.480  INFO 19012 --- [main] org.hibernate.cfg.Environment            : 
    HHH000021: Bytecode provider name : javassist 
2017-01-15 16:03:13.122  INFO 19012 --- [main] o.hibernate.annotations.common.Version   : 
    HCANN000001: Hibernate Commons Annotations {5.0.1.Final} 
2017-01-15 16:03:16.112  WARN 19012 --- [main] o.h.e.j.e.i.JdbcEnvironmentInitiator     : 
    HHH000342: Could not obtain connection to query metadata : Access denied for user root 'root'@'localhost' (using password: YES) 
2017-01-15 16:03:16.135  WARN 19012 --- [main] ationConfigEmbeddedWebApplicationContext : 
    Exception encountered during context initialization - cancelling refresh attempt: 
        org.springframework.beans.factory.BeanCreationException: 
            Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: 
                Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: 
                    Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] 
2017-01-15 16:03:16.149  INFO 19012 --- [main] o.apache.catalina.core.StandardService   : 
    Stopping service Tomcat    
2017-01-15 16:03:16.234  WARN 19012 --- [main] o.s.boot.SpringApplication               : 
    Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]:    
        BeanPostProcessor before instantiation of bean  failed; nested exception is org.springframework.beans.factory.BeanCreationException: 
            Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': 
                Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: 
                    No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' is defined)
2017-01-15 16:03:16.275 ERROR 19012 --- [main] o.s.boot.SpringApplication               : 
    Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: 
        Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: 
            Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1583) ~[spring-beans-4.3.3.RELEASE.jar !/:4.3.3.RELEASE]
                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.3.3.RELEASE.jar!/:    4.3.3.RELEASE]
                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
                at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
                at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
                at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
                at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
                at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1076) ~[spring-context-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
                at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:851) ~[spring-context-4.3.3.RELEASE.jar!/:4 .3.3.RELEASE]
                at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) ~[spring-context-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
                at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.1.RELEASE.jar!/:1.4.1.RELEASE]
                at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.1.RELEASE.jar!/:1.4.1.RELEASE]
                at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.1.RELEASE.jar!/:1.4.1.RELEASE]
                at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.1.RELEASE.jar!/:1.4.1.RELEASE]
                at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.1.RELEASE.jar!/:1.4.1.RELEASE]
                at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.1.RELEASE.jar!/:1.4.1.RELEASE]
                at com.SimonSaysApplication.main(SimonSaysApplication.java:32) [classes!/:0.0.1-SNAPSHOT]
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_77]
                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_77]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_77]
                at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_77]
                at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [simonsays-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
                at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [simonsays-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
                at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [simonsays-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
                at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58) [simonsays-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] 
            Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
                at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:264) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:228) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:207) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:207) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:847) ~[hibernate-entitymanager-5.0.11.Final.jar!/:5.0.11.Fin al]
                at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:874) ~[hibernate-entitymanager-5.0.11.Final.jar!/:5.0.11.Final]
                at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) ~[spring-orm-4 .3.3.RELEASE.jar!/:4.3.3.RELEASE]
                at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353) ~[spring-orm-4.3.3.RE LEASE.jar!/:4.3.3.RELEASE]
                at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:373) ~[spring-orm-4.3.3.RELEASE.jar!/:4 .3.3.RELEASE]
                at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:362) ~[spring-orm-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1642) ~[spring-beans-4.3.3.RELEASE. jar!/:4.3.3.RELEASE]
                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1579) ~[spring-beans-4.3.3.RELEASE.jar !/:4.3.3.RELEASE]            
                ... 24 common frames omitted 
            Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
                at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:100) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:54) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:137) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]
                at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:254) ~[hibernate-core-5.0.11.Final.jar!/:5.0.11.Final]            
                ... 40 common frames omitted

My hibernate config is located on \src\main\resources\application.properties

db.driver = com.mysql.jdbc.Driver
db.url = jdbc:mysql://localhost:3306/simonsays?characterEncoding=UTF-8&useSSL=false
db.username = root
db.password = 1234

#Hibernate configuration
hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
hibernate.show_sql = false
hibernate.hbm2ddl.auto = update
entitymanager.packagesToScan = com

How can i handle it?

[UPDATE]

I could get a different result when running using mvn spring-boot:run

  • Instead of the old error, i could see my database but i'm getting a weird error when it's turning up the tomcat:

    Description:

    The Tomcat connector configured to listen on port 444 failed to start. The port may already be in use or the connector may be misconfigured.

    Action:

    Verify the connector's configuration, identify and stop any process that's listening on port 444, or configure this application to listen on another port.

4

4 Answers

1
votes

Looks like your DB is rejecting the connection as per error Access denied for use r 'root'@'localhost' (using password: YES). Can you try to login using MySQL CLI or MySQL Workbench to your database using the same credentials as in application.properties?

0
votes

Your log says db is refusing connection :

  HHH000342: Could not obtain connection to query metadata : 
Access denied for user root 'root'@'localhost' (using password: YES) 

so please try to hit DB with the credential that you have provided in your application and if its correct then please bind it with 127.0.0.1 or the IP of your local system instead of localhost as said by Alex Roig.

0
votes

Ok, i think i got the problem solved:

first, i was trying to build a jar to run after, it wasn't working well because wasn't loading my configurations, then i got a better result using:

mvn spring-boot:run

But i got a tomcat error because the SSL, then i just had to disable SSL and change port to 8080 as usual and it's running

0
votes

Properties you have mentioned in application.properties file are not understood by spring-boot. Use the following properties to assign database details

spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/simonsays?characterEncoding=UTF-8&useSSL=false
spring.datasource.username=root
spring.datasource.password=1234
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect