Добро пожаловать в форум, Guest  >>   Войти | Регистрация | Поиск | Правила | В избранное | Подписаться
Все форумы / Java Новый топик    Ответить
 Ошибка Unable to create requested service  [new]
f68
Member

Откуда:
Сообщений: 78
Добрый день.
В NetBeans 12.1 создаю тестовый проект. (java-hibernate-firebird)
Добавляю jaybird-full-3.0.9.jar, hibernate-core-5.4.23.Final.jar и все зависимые jar - ники.
Прописываю hibernate.cfg.xml
Запускаю и все отлично.

Но если создаю проект Maven, добавляю те же файлы.
В pom.xml добавляю эти же зависимости, то при запуске выдает ошибку:

org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

В чем может быть дело?

Firebird 3

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.mycompany</groupId>
    <artifactId>mavenproject4</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>    
        <!-- https://mvnrepository.com/artifact/org.firebirdsql.jdbc/jaybird -->
        <dependency>
            <groupId>org.firebirdsql.jdbc</groupId>
            <artifactId>jaybird</artifactId>
            <version>3.0.8</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.4.23.Final</version>
            <type>jar</type>
        </dependency>
    </dependencies>

</project>


hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration">
<hibernate-configuration>
  <session-factory>
    <property name="hibernate.dialect">org.hibernate.dialect.FirebirdDialect</property>
    <property name="hibernate.connection.driver_class">org.firebirdsql.jdbc.FBDriver</property>                                                       
    <property name="hibernate.connection.url">jdbc:firebirdsql:localhost:jzakaz</property>    
    <property name="hibernate.connection.username">SYSDBA</property>
    <property name="hibernate.connection.password">masterkey</property>
    <property name="hibernate.connection.encoding">WIN1251</property>
    <property name="hibernate.show_sql">false</property>        
    <mapping class="com.mycompany.mavenproject4.Setup"/>

  </session-factory>
</hibernate-configuration>


public class HibernateUtil {
    private static SessionFactory sessionFactory = null;
    static {
        try {
                sessionFactory = new Configuration().configure().buildSessionFactory();
        } catch (HibernateException e ) {
            
            System.out.println("-->" + e);
        }
    }
    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    } 
}
11 ноя 20, 17:21    [22230289]     Ответить | Цитировать Сообщить модератору
 Re: Ошибка Unable to create requested service  [new]
WGA
Member

Откуда:
Сообщений: 408
Требуется привести полный стектрейс исключения.
12 ноя 20, 15:44    [22230841]     Ответить | Цитировать Сообщить модератору
 Re: Ошибка Unable to create requested service  [new]
f68
Member

Откуда:
Сообщений: 78
Scanning for projects...

--------------------< com.mycompany:mavenproject4 >---------------------
Building mavenproject4 1.0-SNAPSHOT
--------------------------------[ jar ]---------------------------------
The artifact org.firebirdsql.jdbc:jaybird:pom:3.0.8 has been relocated to org.firebirdsql.jdbc:jaybird-jdk18:pom:3.0.8

--- exec-maven-plugin:1.5.0:exec (default-cli) @ mavenproject4 ---
нояб. 13, 2020 11:36:39 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate ORM core version 5.4.23.Final
нояб. 13, 2020 11:36:40 AM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
нояб. 13, 2020 11:36:40 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!)
-->org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Exception in thread "main" java.lang.NullPointerException
	at com.mycompany.mavenproject4.IOSetup.getSetup(IOSetup.java:34)
	at com.mycompany.mavenproject4.NewMain.main(NewMain.java:19)
Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
    at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:404)
    at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
    at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:764)
    at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:711)
    at org.codehaus.mojo.exec.ExecMojo.execute (ExecMojo.java:289)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time:  2.995 s
Finished at: 2020-11-13T11:36:40+03:00
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.5.0:exec (default-cli) on project mavenproject4: Command execution failed.: Process exited with an error: 1 (Exit value: 1) -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
13 ноя 20, 11:38    [22231316]     Ответить | Цитировать Сообщить модератору
 Re: Ошибка Unable to create requested service  [new]
Basil A. Sidorov
Member

Откуда:
Сообщений: 10762
Английским же по фону написано:
 Command execution failed.
org.apache.commons.exec.ExecuteException:
Process exited with an error: 1
Код 1 это "неверное использование" - передали слишком мало/много аргументов или неправильные аргументы.
И дальше, что характерно, даётся подсказка как получить полный стек-трейс.
13 ноя 20, 12:11    [22231339]     Ответить | Цитировать Сообщить модератору
 Re: Ошибка Unable to create requested service  [new]
f68
Member

Откуда:
Сообщений: 78
<dependency>
            <groupId>org.firebirdsql.jdbc</groupId>
            <artifactId>jaybird</artifactId>
            <version>3.0.8</version>
            <type>pom</type>
        </dependency>


Нашел ошибку.
Нужно было не pom, а jar.
16 ноя 20, 12:55    [22232807]     Ответить | Цитировать Сообщить модератору
Все форумы / Java Ответить