Ошибка кода JOOQ в Linux, java.lang.ClassNotFoundException: org.postgresql.Driver - PullRequest
0 голосов
/ 24 апреля 2018

Сегодня я пытался сгенерировать классы jooq для моего нового проекта, но получал эту ошибку:

Apr 24, 2018 1:39:11 PM org.jooq.tools.JooqLogger info
INFO: Initialising properties  : jooq-configuration.xml
Apr 24, 2018 1:39:11 PM org.jooq.tools.JooqLogger error
SEVERE: Cannot read jooq-configuration.xml. Error : org.postgresql.Driver
java.lang.ClassNotFoundException: org.postgresql.Driver
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at org.jooq.util.GenerationTool.loadClass(GenerationTool.java:704)
        at org.jooq.util.GenerationTool.run(GenerationTool.java:259)
        at org.jooq.util.GenerationTool.generate(GenerationTool.java:203)
        at org.jooq.util.GenerationTool.main(GenerationTool.java:175)

Поэтому я обновил библиотеки jooq и драйвер jdbc postgresql до последних версий, ноошибка все еще сохраняется.

Теперь вот мой файл jooq-configuration.xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration>
    <!-- Configure the database connection here -->
    <jdbc>
        <driver>org.postgresql.Driver</driver>
        <url>jdbc:postgresql://localhost/vodic</url>
        <user>postgres</user>
        <password>local</password>

        <!-- You can also pass user/password and other JDBC properties in the optional properties tag: -->
        <properties>
            <property><key>user</key><value>postgres</value></property>
            <property><key>password</key><value>local</value></property>
        </properties>
    </jdbc>

    <generator>
        <database>
            <!-- The database dialect from jooq-meta. Available dialects are
                 named org.util.[database].[database]Database.

                 Natively supported values are:

                     org.jooq.util.ase.ASEDatabase
                     org.jooq.util.cubrid.CUBRIDDatabase
                     org.jooq.util.db2.DB2Database
                     org.jooq.util.derby.DerbyDatabase
                     org.jooq.util.firebird.FirebirdDatabase
                     org.jooq.util.h2.H2Database
                     org.jooq.util.hsqldb.HSQLDBDatabase
                     org.jooq.util.informix.InformixDatabase
                     org.jooq.util.ingres.IngresDatabase
                     org.jooq.util.mariadb.MariaDBDatabase
                     org.jooq.util.mysql.MySQLDatabase
                     org.jooq.util.oracle.OracleDatabase
                     org.jooq.util.postgres.PostgresDatabase
                     org.jooq.util.sqlite.SQLiteDatabase
                     org.jooq.util.sqlserver.SQLServerDatabase
                     org.jooq.util.sybase.SybaseDatabase

                 This value can be used to reverse-engineer generic JDBC DatabaseMetaData (e.g. for MS Access)

                     org.jooq.util.jdbc.JDBCDatabase

                 This value can be used to reverse-engineer standard jOOQ-meta XML formats

                     org.jooq.util.xml.XMLDatabase

                 You can also provide your own org.jooq.util.Database implementation
                 here, if your database is currently not supported -->
            <name>org.jooq.util.postgres.PostgresDatabase</name>

            <!-- All elements that are generated from your schema (A Java regular expression.
                 Use the pipe to separate several expressions) Watch out for
                 case-sensitivity. Depending on your database, this might be
                 important!

                 You can create case-insensitive regular expressions using this syntax: (?i:expr)

                 Whitespace is ignored and comments are possible.
                 -->
            <includes>.*</includes>

            <!-- All elements that are excluded from your schema (A Java regular expression.
                 Use the pipe to separate several expressions). Excludes match before
                 includes, i.e. excludes have a higher priority -->
            <excludes>
                UNUSED_TABLE                # This table (unqualified name) should not be generated
                | PREFIX_.*                   # Objects with a given prefix should not be generated
                | SECRET_SCHEMA\.SECRET_TABLE # This table (qualified name) should not be generated
                | SECRET_ROUTINE              # This routine (unqualified name) ...
            </excludes>

            <!-- The schema that is used locally as a source for meta information.
                 This could be your development schema or the production schema, etc
                 This cannot be combined with the schemata element.

                 If left empty, jOOQ will generate all available schemata. See the
                 manual's next section to learn how to generate several schemata -->
            <inputSchema>public</inputSchema>
        </database>

        <generate>
            <!-- Generation flags: See advanced configuration properties -->
            <daos>true</daos>
            <pojos>true</pojos>
        </generate>

        <target>
            <!-- The destination package of your generated classes (within the
                 destination directory)

                 jOOQ may append the schema name to this package if generating multiple schemas,
                 e.g. org.jooq.your.packagename.schema1
                      org.jooq.your.packagename.schema2 -->
            <packageName>com.PSNJ.vodic.generated.jooq</packageName>

            <!-- The destination directory of your generated classes -->
            <directory>src/main/java</directory>
        </target>
    </generator>
</configuration>

Я нахожусь на Antergos Linux (на основе Arch), я использовал команду codegen:

java -classpath jooq-3.10.6.jar:jooq-meta-3.10.6.jar:jooq-codegen-3.10.6.jar:postgresql-42.2.2.jar.jar:. org.jooq.util.GenerationTool jooq-configuration.xml

Все требуемые файлы .jar находятся в рабочем каталоге, из которого я запускаю команду.

1 Ответ

0 голосов
/ 25 апреля 2018

Я набрал .jar 2 раза, когда ссылался на мой драйвер jdbc в команде.

...