schmutterer / gradle-openjpa

gradle-plugin that enhances entity-classes with OpenJPA code
Apache License 2.0
5 stars 2 forks source link

Build fails due to MetaDataException: MetaDataFactory could not be configured #7

Open lucabixio opened 8 years ago

lucabixio commented 8 years ago

Hi, firstly I have to say that the plugin is very useful. Unfortunately, I couldn't make it working. When I run the build task I obtain the following exception:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':com.mycompany.persistence.demo.provider:openjpaEnhance'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: <openjpa-2.4.0-r422266:1674604 fatal user error> org.apache.openjpa.util.MetaDataException: MetaDataFactory could not be configured (conf.newMetaDataFactoryInstance() returned null). This might mean that no configuration properties were found. Ensure that you have a META-INF/persistence.xml file, that it is available in your classpath, or that the properties file you are using for configuration is available. If you are using Ant, please see the <properties> or <propertiesFile> attributes of the task's nested <config> element. This can also occur if your OpenJPA distribution jars are corrupt, or if your security policy is overly strict.
    at org.apache.openjpa.meta.MetaDataRepository.initializeMetaDataFactory(MetaDataRepository.java:1943)
    at org.apache.openjpa.meta.MetaDataRepository.endConfiguration(MetaDataRepository.java:1924)
    at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:533)
    at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:458)
    at org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:121)
    at org.apache.openjpa.conf.MetaDataRepositoryValue.instantiate(MetaDataRepositoryValue.java:68)
    at org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83)
    at org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:967)
    at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4852)
    at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4834)
    at org.apache.openjpa.enhance.PCEnhancer$1.run(PCEnhancer.java:4804)
    at org.apache.openjpa.lib.conf.Configurations.launchRunnable(Configurations.java:762)
    at org.apache.openjpa.lib.conf.Configurations.runAgainstAllAnchors(Configurations.java:747)
    at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4799)
    at at.schmutterer.oss.gradle.openjpa.OpenJpaPlugin$_apply_closure1.doCall(OpenJpaPlugin.groovy:44)
    at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:554)
    at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:535)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    ... 14 more

Here is my build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'at.schmutterer.oss.gradle:gradle-openjpa:0.2.0'
    }
}

apply plugin: 'openjpa'

openjpa {
        persistenceXmlFile = file('<full_path_to_my>/persistence.xml')

}

and here is my persistence.xml

<?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">

    <persistence-unit name="com.mycompany.persistence.example" transaction-type="JTA"> <!-- transaction-type="RESOURCE_LOCAL" -->
        <jta-data-source>
            osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=xa-com.mycompany.persistence.example)     
        </jta-data-source>

        <non-jta-data-source>
            osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=com.mycompany.persistence.example)     
        </non-jta-data-source>

        <class>com.mycompany.persistence.demo.MyEntity</class>
        <exclude-unlisted-classes>true</exclude-unlisted-classes>

        <properties>
            <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
            <!-- <property name="openjpa.MetaDataFactory" value="jpa"/> --> // it doesn't affect the build
        </properties>
    </persistence-unit>
</persistence>

@ChristophGr, @centic9 do you have any idea to get it working?

Thank you very much.

Cheers,

Luca