首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >DataNucleus,Maven,schema-创建失败

DataNucleus,Maven,schema-创建失败
EN

Stack Overflow用户
提问于 2015-02-22 14:14:04
回答 1查看 1.9K关注 0票数 2

我正在尝试使用DataNucleus和MySQL创建一个maven项目。然而,当我试图构建和mvn datanucleus:schema-create项目时,我会失败。我搞不懂为什么。

下面是persistence.xml类,它存在于构建项目的classes/META-INF文件夹中:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8" ?>
<persistence 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"
    version="2.0">

    <!-- JDO tutorial "unit" -->
    <persistence-unit name="Tutorial">
        <class>hello.Counter</class>
        <exclude-unlisted-classes>true</exclude-unlisted-classes>
        <properties>
            <property name="javax.jdo.option.ConnectionURL" value="jdbc:mysql://localhost/glu" />
            <property name="javax.jdo.option.ConnectionDriverName"
                value="com.mysql.jdbc.Driver" />
            <property name="javax.jdo.option.ConnectionUserName" value="root" />
            <property name="javax.jdo.option.ConnectionPassword" value="root" />

            <property name="datanucleus.schema.autoCreateAll" value="true" />
            <property name="datanucleus.schema.validateTables" value="true" />
            <property name="datanucleus.schema.validateConstraints"
                value="true" />
            <property name="javax.jdo.PersistenceManagerFactoryClass"
                value="org.datanucleus.api.jdo.JDOPersistenceManagerFactory" />
        </properties>
    </persistence-unit>
</persistence>

这是我正在尝试使用的pom.xml

代码语言:javascript
复制
<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>ru.sf0.one</groupId>
    <artifactId>two</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>glu</name>


    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.2.1.RELEASE</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>com.jayway.jsonpath</groupId>
            <artifactId>json-path</artifactId>
            <!-- <version>1.2.0</version> -->
        </dependency>


        <dependency>
            <groupId>javax.jdo</groupId>
            <artifactId>jdo-api</artifactId>
            <version>3.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-core</artifactId>
            <!-- scope>runtime</scope -->
            <version>4.0.4</version>
        </dependency>
        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-api-jdo</artifactId>
            <version>4.0.4</version>
        </dependency>


        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-rdbms</artifactId>
            <scope>runtime</scope>
            <version>4.0.4</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-accessplatform-jdo-rdbms</artifactId>
            <version>4.0.4</version>
            <type>pom</type>
        </dependency>


    </dependencies>


    <build>

        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <!-- <version>3.2</version> -->
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.datanucleus</groupId>
                <artifactId>datanucleus-maven-plugin</artifactId>
                <version>4.0.0-release</version>


                <configuration>
                    <api>JDO</api>
                    <persistenceUnitName>Tutorial</persistenceUnitName>
                    <log4jConfiguration>${basedir}/src/main/resources/log4j.properties</log4jConfiguration>
                    <verbose>false</verbose>
                </configuration>
                <executions>
                    <execution>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>enhance</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>


        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-releases</id>
            <url>https://repo.spring.io/libs-release</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>spring-releases</id>
            <url>https://repo.spring.io/libs-release</url>
        </pluginRepository>
    </pluginRepositories>
</project>

我得到的错误是:

代码语言:javascript
复制
~>2015-02-23 00:26:55 DEBUG MetaData:58 - Class "hello.Counter" field "count" : Adding Meta-Data for field since it didnt appear in the Meta-Data definition.
~>2015-02-23 00:26:55 DEBUG MetaData:58 - Initialising all MetaData ...
~>2015-02-23 00:26:55 DEBUG MetaData:58 - Class "hello.Counter" : Initialising Meta-Data
~>2015-02-23 00:26:55 DEBUG MetaData:58 - MetaData Management : Load of Metadata complete
~>2015-02-23 00:26:55 DEBUG Datastore:58 - Creating StoreManager for datastore
~>2015-02-23 00:26:55 ERROR Datastore:125 - Exception thrown creating StoreManager. See the nested exception
There is no available StoreManager of type "jdbc". Make sure that you have put the relevant DataNucleus store plugin in your CLASSPATH and if defining a connection via JNDI or DataSource you also need to provide persistence property "datanucleus.storeManagerType"
org.datanucleus.exceptions.NucleusUserException: There is no available StoreManager of type "jdbc". Make sure that you have put the relevant DataNucleus store plugin in your CLASSPATH and if defining a connection via JNDI or DataSource you also need to provide persistence property "datanucleus.storeManagerType"
    at org.datanucleus.NucleusContextHelper.createStoreManagerForProperties(NucleusContextHelper.java:223)
    at org.datanucleus.PersistenceNucleusContextImpl.initialise(PersistenceNucleusContextImpl.java:433)
    at org.datanucleus.store.schema.SchemaTool.getNucleusContextForMode(SchemaTool.java:693)
    at org.datanucleus.store.schema.SchemaTool.main(SchemaTool.java:286)
~>2015-02-23 00:26:55 ERROR SchemaTool:125 - Error creating NucleusContext
There is no available StoreManager of type "jdbc". Make sure that you have put the relevant DataNucleus store plugin in your CLASSPATH and if defining a connection via JNDI or DataSource you also need to provide persistence property "datanucleus.storeManagerType"
org.datanucleus.exceptions.NucleusUserException: There is no available StoreManager of type "jdbc". Make sure that you have put the relevant DataNucleus store plugin in your CLASSPATH and if defining a connection via JNDI or DataSource you also need to provide persistence property "datanucleus.storeManagerType"
    at org.datanucleus.NucleusContextHelper.createStoreManagerForProperties(NucleusContextHelper.java:223)
    at org.datanucleus.PersistenceNucleusContextImpl.initialise(PersistenceNucleusContextImpl.java:433)
    at org.datanucleus.store.schema.SchemaTool.getNucleusContextForMode(SchemaTool.java:693)
    at org.datanucleus.store.schema.SchemaTool.main(SchemaTool.java:286)
An error was encountered creating a PersistenceManagerFactory : There is no available StoreManager of type "jdbc". Make sure that you have put the relevant DataNucleus store plugin in your CLASSPATH and if defining a connection via JNDI or DataSource you also need to provide persistence property "datanucleus.storeManagerType" - please consult the log for more information.

UPD如果从datanucleus-rdbms中删除<scope>runtime</scope>限制,将得到以下错误:

代码语言:javascript
复制
~>2015-02-23 12:07:34 DEBUG MetaData:58 - Class "hello.Counter" field "count" : Adding Meta-Data for field since it didnt appear in the Meta-Data definition.
~>2015-02-23 12:07:34 DEBUG MetaData:58 - Initialising all MetaData ...
~>2015-02-23 12:07:34 DEBUG MetaData:58 - Class "hello.Counter" : Initialising Meta-Data
~>2015-02-23 12:07:34 DEBUG MetaData:58 - MetaData Management : Load of Metadata complete
~>2015-02-23 12:07:34 DEBUG Datastore:58 - Creating StoreManager for datastore
~>2015-02-23 12:07:34 ERROR Datastore:125 - Exception thrown creating StoreManager. See the nested exception
Error creating transactional connection factory
org.datanucleus.exceptions.NucleusException: Error creating transactional connection factory
    at org.datanucleus.store.AbstractStoreManager.registerConnectionFactory(AbstractStoreManager.java:219)
    at org.datanucleus.store.AbstractStoreManager.<init>(AbstractStoreManager.java:163)
    at org.datanucleus.store.rdbms.RDBMSStoreManager.<init>(RDBMSStoreManager.java:288)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at org.datanucleus.plugin.NonManagedPluginRegistry.createExecutableExtension(NonManagedPluginRegistry.java:606)
    at org.datanucleus.plugin.PluginManager.createExecutableExtension(PluginManager.java:301)
    at org.datanucleus.NucleusContextHelper.createStoreManagerForProperties(NucleusContextHelper.java:193)
    at org.datanucleus.PersistenceNucleusContextImpl.initialise(PersistenceNucleusContextImpl.java:433)
    at org.datanucleus.store.schema.SchemaTool.getNucleusContextForMode(SchemaTool.java:693)
    at org.datanucleus.store.schema.SchemaTool.main(SchemaTool.java:286)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at org.datanucleus.plugin.NonManagedPluginRegistry.createExecutableExtension(NonManagedPluginRegistry.java:606)
    at org.datanucleus.plugin.PluginManager.createExecutableExtension(PluginManager.java:330)
    at org.datanucleus.store.AbstractStoreManager.registerConnectionFactory(AbstractStoreManager.java:205)
    ... 12 more
Caused by: java.lang.NullPointerException
    at org.datanucleus.store.rdbms.ConnectionFactoryImpl.initialiseDataSources(ConnectionFactoryImpl.java:110)
    at org.datanucleus.store.rdbms.ConnectionFactoryImpl.<init>(ConnectionFactoryImpl.java:82)
    ... 19 more
Nested Throwables StackTrace:
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at org.datanucleus.plugin.NonManagedPluginRegistry.createExecutableExtension(NonManagedPluginRegistry.java:606)
    at org.datanucleus.plugin.PluginManager.createExecutableExtension(PluginManager.java:330)
    at org.datanucleus.store.AbstractStoreManager.registerConnectionFactory(AbstractStoreManager.java:205)
    at org.datanucleus.store.AbstractStoreManager.<init>(AbstractStoreManager.java:163)
    at org.datanucleus.store.rdbms.RDBMSStoreManager.<init>(RDBMSStoreManager.java:288)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at org.datanucleus.plugin.NonManagedPluginRegistry.createExecutableExtension(NonManagedPluginRegistry.java:606)
    at org.datanucleus.plugin.PluginManager.createExecutableExtension(PluginManager.java:301)
    at org.datanucleus.NucleusContextHelper.createStoreManagerForProperties(NucleusContextHelper.java:193)
    at org.datanucleus.PersistenceNucleusContextImpl.initialise(PersistenceNucleusContextImpl.java:433)
    at org.datanucleus.store.schema.SchemaTool.getNucleusContextForMode(SchemaTool.java:693)
    at org.datanucleus.store.schema.SchemaTool.main(SchemaTool.java:286)
Caused by: java.lang.NullPointerException
    at org.datanucleus.store.rdbms.ConnectionFactoryImpl.initialiseDataSources(ConnectionFactoryImpl.java:110)
    at org.datanucleus.store.rdbms.ConnectionFactoryImpl.<init>(ConnectionFactoryImpl.java:82)
    ... 19 more
EN

回答 1

Stack Overflow用户

发布于 2015-02-23 07:41:39

错误消息Make sure that you have put the relevant DataNucleus store plugin in your CLASSPATH表示您真正需要知道的所有信息。数据核-rdbms插件不在CLASSPATH中.您对runtime的范围限制

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28658794

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档