openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Watler <wat...@wispertel.net>
Subject Re: [ANN] OpenJPA Maven Plugin 1.0 Released
Date Tue, 03 Mar 2009 17:03:46 GMT
Adam,

I was able to successfully use the <absolute path>#<pu name> 
successfully, even with multiple persistence units defined.

I am wondering if you can try specifying a ${basedir}/src/main/resources 
path to specify the target persistence.xml file? I am concerned that the 
test resources may not be available in the process-classes phase where 
the plugin is invoked. I was unable to use a resource path to specify 
the persistence.xml file, so I believe there are unresolved classpath or 
build phase deps that might be contributing to the confusion here.

If you have a sample persistence.xml file, that might help as well... 
perhaps it is ignoring your persistence.xml for some reason?

Randy

Adam Hardy wrote:
> I am using toolProperties to specify the persistence.xml and 
> persistence unit.
>
> The syntax:
>
> <toolProperties>
>   <property>
>     <name>properties</name>
>     <value>
>   ${build.testOutputDirectory}/META-INF/persistence.xml#OpenJpaTest
>     </value>
>   </property>
> </toolProperties>
>
> means "use the persistence-unit 'OpenJpaTest' in the file 
> persistence.xml", where 'OpenJpaTest' is what I named the XML 
> persistence-unit node in the file - and I have several in one 
> persistence.xml.
>
> I have seen it mentioned on the openjpa list:
>
> http://article.gmane.org/gmane.comp.apache.openjpa.user/3499
>
> where it is done like this on the command line (for javaagent - 
> different, I know):
>
> -javaagent:C:/eclipse.workspaces/3.2.2/openjpa-1.2.0/openjpa-all/target/openjpa-1.2.0.jar=pu=OpenJPAPU

>
>
> The code from svn gave this exception:
>
> <openjpa-1.2.0-r422266:683325 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:1567)

>
>         at 
> org.apache.openjpa.meta.MetaDataRepository.endConfiguration(MetaDataRepository.java:1558)

>
>         at 
> org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:505)

>
>         at 
> org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:430)

>
>         at 
> org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:103)
>         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:863)

>
>         at 
> org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4457)
>         at 
> org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4439)
>         at 
> org.apache.openjpa.enhance.PCEnhancer$1.run(PCEnhancer.java:4409)
>         at 
> org.apache.openjpa.lib.conf.Configurations.launchRunnable(Configurations.java:708) 
>
>         at 
> org.apache.openjpa.lib.conf.Configurations.runAgainstAllAnchors(Configurations.java:693)

>
>         at 
> org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4404)
>         at 
> org.codehaus.mojo.openjpa.OpenJpaEnhancerMojo.enhance(OpenJpaEnhancerMojo.java:125) 
>
>
>
> but if I try specifying the persistence-unit name some other way, e.g. 
> as a toolProperties property 'pu', it ignores me and throws this 
> exception (OpenJpaTest was the one I was aiming for):
>
> [INFO] [openjpa:enhance]
> 203  AtomicNoDB  INFO   [main] openjpa.Tool - No targets were given.  
> Running on all classes in your persistent classes list, or all 
> metadata files in classpath directories if you have not listed your 
> persistent classes.  Use -help to display tool usage information.
> 224  AtomicNoDB  WARN   [main] openjpa.Tool - Found no class to enhance.
> 44  OpenJpaTest  INFO   [main] openjpa.Tool - No targets were given.  
> Running on all classes in your persistent classes list, or all 
> metadata files in classpath directories if you have not listed your 
> persistent classes.  Use -help to display tool usage information.
> WARNING: Found unrecognized persistence provider 
> "org.hibernate.ejb.HibernatePersistence" in place of OpenJPA 
> provider.  This provider's properties will not be used.
> [INFO] 
> ------------------------------------------------------------------------
> [ERROR] FATAL ERROR
> [INFO] 
> ------------------------------------------------------------------------
> [INFO] 
> /home/adam/projects/atomic/target/test-classes/META-INF/persistence.xml#HibernateTest

>
> [INFO] 
> ------------------------------------------------------------------------
> [INFO] Trace
> java.util.MissingResourceException: 
> /home/adam/projects/atomic/target/test-classes/META-INF/persistence.xml#HibernateTest

>
>         at 
> org.apache.openjpa.lib.conf.ProductDerivations.load(ProductDerivations.java:309) 
>
>         at 
> org.apache.openjpa.lib.conf.Configurations.populateConfiguration(Configurations.java:337)

>
>         at 
> org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4438)
>         at 
> org.apache.openjpa.enhance.PCEnhancer$1.run(PCEnhancer.java:4409)
>         at 
> org.apache.openjpa.lib.conf.Configurations.launchRunnable(Configurations.java:708) 
>
>         at 
> org.apache.openjpa.lib.conf.Configurations.runAgainstAllAnchors(Configurations.java:698)

>
>         at 
> org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4404)
>         at 
> org.codehaus.mojo.openjpa.OpenJpaEnhancerMojo.enhance(OpenJpaEnhancerMojo.java:125) 
>
>
>
>
> So basically you need to get that persistence-unit name to the 
> PCEnhancer or it looks like it processes all the persistence-units.
>
> Thanks
> Adam
>
> Mark Struberg on 28/02/09 22:03, wrote:
>> Hi!
>>
>> @Randy, txs 4 the patch, good catch.
>>
>> As I also commented in JIRA: A few points are still open
>>
>> 1.) using a different configuration XML (other than persistence.xml) 
>> should
>> be provided as own plugin attribute (and not in the 'additional 
>> properties'
>> list).
>>
>> 2.) using a different configuration XML must also work for the 
>> openjpa:sql
>> and openjpa:schema mojos.
>>
>> I will implement this after I'm back from vacation next week.
>>
>> @Adam: Can you please checkout the latest from SVN and try it with this
>> version?
>>
>> svn co https://svn.codehaus.org/mojo/trunk/mojo/openjpa-maven-plugin
>>
>> Do you have other wishes? So we can plan to make a 1.1 with ~ end of 
>> march.
>>
>> txs and LieGrue, strub
>>
>>
>>
>> --- Randy Watler <watler@wispertel.net> schrieb am Sa, 28.2.2009:
>>
>>> Von: Randy Watler <watler@wispertel.net> Betreff: Re: [ANN] OpenJPA 
>>> Maven
>>> Plugin 1.0 Released An: users@openjpa.apache.org Datum: Samstag, 28.
>>> Februar 2009, 5:38 Mark/Adam,
>>>
>>> I have filed a JIRA ticket with a patch for this issue: 
>>> http://jira.codehaus.org/browse/MOJO-1309
>>>
>>> I am not sure why Adam is specifying the 'properties' property, but 
>>> we use
>>> it to ensure the enhancement is processing based off of a specific 
>>> project
>>> persistence.xml file... there are multiple persistence.xml files on the
>>> classpath. I feel this is a fairly important bug to fix since I 
>>> think it is
>>> generally a regression from the 1.0-alpha version.
>>>
>>> HTH,
>>>
>>> Randy Watler Apache Portals Jetspeed2 Committer
>>>
>>> Mark Struberg wrote:
>>>> Adam,
>>>>
>>>> For what I've seen the 'properties'
>>> property specifies a file which contains the configuration.
>>>> So I'm honestly a bit confused about the value: 
>>>> META-INF/persistence.xml#OpenJpaTest
>>>>
>>>> Can you please tell me what you like to achieve and
>>> how your config file really looks like (including real filename).
>>>>
>>>> Please note that the ant tasks imho calls the
>>> PCEnhancer only via spawning an own java cmd. So any error occurring 
>>> may
>>> not get to your eyes there.
>>>>
>>>> txs, strub
>>>>
>>>> --- Mark Struberg <struberg@yahoo.de> schrieb am
>>> Fr, 27.2.2009:
>>>>
>>>>> Von: Mark Struberg <struberg@yahoo.de> Betreff: Re: [ANN] OpenJPA

>>>>> Maven
>>>>> Plugin 1.0
>>> Released
>>>>> An: users@openjpa.apache.org Datum: Freitag, 27. Februar 2009, 
>>>>> 0:11 Thanks for the response Adam! I will try to create an 
>>>>> integration test
>>>>> based on
>>> your
>>>>> info.
>>>>>
>>>>> LieGrue, strub
>>>>>
>>>>>
>>>>> --- Adam Hardy <adam.sql@cyberspaceroad.com>
>>> schrieb
>>>>> am Do, 26.2.2009:
>>>>>
>>>>>
>>>>>> Von: Adam Hardy
>>> <adam.sql@cyberspaceroad.com>
>>>>>> Betreff: Re: [ANN] OpenJPA Maven Plugin 1.0
>>> Released
>>>>>> An: users@openjpa.apache.org Datum: Donnerstag, 26. Februar 2009,
>>>>>> 0:59 Mark Struberg on 25/02/09 09:49, wrote:
>>>>>>
>>>>>>> The Maven team is pleased to announce the
>>> release
>>>>>>>
>>>>> of
>>>>>
>>>>>> the
>>>>>>
>>>>>>> openjpa-maven-plugin-1.0
>>>>>>>
>>>>>>>
>>>>>>> The plugin documentation can be found
>>> here:
>>>>>>>
>>> http://mojo.codehaus.org/openjpa-maven-plugin/
>>>>>>>
>>>>>> I gave it a test run and I have an error.
>>> After
>>>>>>
>>>>> looking
>>>>>
>>>>>> thro the docs, the source and looking at the
>>> debug, I
>>>>>>
>>>>> still
>>>>>
>>>>>> can't figure it out. I get this error:
>>>>>>
>>>>>> org.apache.openjpa.lib.util.ParseException:
>>>>>>
>>>>>>
>>> org.apache.openjpa.conf.OpenJPAConfigurationImpl@52dd4e95.properties
>>>>>
>>>>>> = META-INF/persistence.xml#OpenJpaTest at
>>>>>>
>>>>>>
>>> org.apache.openjpa.lib.util.Options.setInto(Options.java:237)
>>>>>
>>>>>> at
>>>>>>
>>>>>>
>>> org.apache.openjpa.lib.util.Options.setInto(Options.java:181)
>>>>>
>>>>>> at
>>>>>>
>>>>>>
>>> org.apache.openjpa.lib.conf.Configurations.populateConfiguration(Configurations.java:357)

>>>
>>>
>>>>>
>>>>>> at
>>>>>>
>>>>>>
>>> org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4438)
>>>>>
>>>>>> at
>>>>>>
>>>>>>
>>> org.apache.openjpa.enhance.PCEnhancer$1.run(PCEnhancer.java:4409)
>>>>>
>>>>>> at
>>>>>>
>>>>>>
>>> org.apache.openjpa.lib.conf.Configurations.launchRunnable(Configurations.java:708)

>>>
>>>
>>>>>
>>>>>> .... Caused by:
>>> java.lang.reflect.InvocationTargetException
>>>>>> at
>>>>>>
>>> sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>>>>>>
>>>>> Method)
>>>>>
>>>>>> at
>>>>>>
>>>>>>
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

>>>
>>>
>>>>>
>>>>>> at
>>>>>>
>>>>>>
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

>>>
>>>
>>>>>
>>>>>> at
>>>>>>
>>>>> java.lang.reflect.Method.invoke(Method.java:597)
>>>>>
>>>>>> at
>>>>>>
>>>>>>
>>> org.apache.openjpa.lib.util.Options.invoke(Options.java:401)
>>>>>
>>>>>> at
>>>>>>
>>>>>>
>>> org.apache.openjpa.lib.util.Options.setInto(Options.java:234)
>>>>>
>>>>>> ... 27 more Caused by: java.util.MissingResourceException: 
>>>>>> META-INF/persistence.xml#OpenJpaTest#null at
>>>>>>
>>>>>>
>>> org.apache.openjpa.lib.conf.ProductDerivations.load(ProductDerivations.java:272)

>>>
>>>
>>>>>
>>>>>> at
>>>>>>
>>>>>>
>>> org.apache.openjpa.lib.conf.ConfigurationImpl.setProperties(ConfigurationImpl.java:762)

>>>
>>>
>>>>>
>>>>>> ... 33 more
>>>>>>
>>>>>>
>>>>>> My config currently uses antrun, so I know I
>>> don't
>>>>>>
>>>>> have
>>>>>
>>>>>> any major issues here. This is in my pom:
>>>>>>
>>>>>> <plugin>
>>>>>>
>>>>>>
>>> <artifactId>maven-war-plugin</artifactId>
>>>>>> <configuration>
>>>>>>
>>>>>>
>>> <warName>${project.artifactId}</warName>
>>>>>> </configuration> </plugin> <plugin>
>>>>>>
>>>>>>
>>>>> <groupId>org.codehaus.mojo</groupId>
>>>>>
>>>>>>
>>>>>>
>>>>>>
>>> <artifactId>openjpa-maven-plugin</artifactId>
>>>>>
>>>>>> <executions> <execution> <id>JPA Enhance</id>
>>>>>>
>>> <phase>process-classes</phase>
>>>>>> <goals> <goal>enhance</goal> </goals> </execution>
</executions> 
>>>>>> <configuration> <toolProperties> <property>
>>>>>>
>>> <name>properties</name>
>>>>>>
>>>>>>
>>>>>>
>>> <value>META-INF/persistence.xml#OpenJpaTest</value>
>>>>>
>>>>>> </property> </toolProperties> <classes>
>>>>>>
>>>>>>
>>>>>>
>>> ${build.outputDirectory}/org/permacode/patternrepo/domain/entity/
>>>>>
>>>>>> </classes> </configuration> </plugin>
>>>>>>
>>>>>> Any idea what it could be, seeing that extra #null on the end of

>>>>>> the persistence filename?
>
>


Mime
View raw message