[
https://issues.apache.org/jira/browse/OPENJPA-328?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12522000
]
Henry Lai commented on OPENJPA-328:
-----------------------------------
changed the persistent.xml to specify <mapping-file>orm.xml</mapping-file>
instead of <mapping-file>ptp/test/issue5/orm.xml</mapping-file>.
received the following:
0 TRACE [main] openjpa.Runtime - Default configuration information couldn't
be loaded from any configuration provider.
15 test TRACE [main] openjpa.Runtime - Setting the following properties from
"file:/C:/workspace/jpatest/TestOpenJPA/bin/ptp/test/issue5/persistence.xml"
into configuration: {openjpa.jdbc.SchemaFactory=native(ForeignKeys=true),
openjpa.jdbc.SynchronizeMappings=buildSchema(ForeignKeys=true),
openjpa.ConnectionUserName=petclinic, openjpa.ConnectionPassword=petclinic,
openjpa.Log=DefaultLevel=TRACE, openjpa.MetaDataFactory=jpa(Resources=orm.xml),
javax.persistence.provider=org.apache.openjpa.persistence.PersistenceProviderImpl,
openjpa.ConnectionURL=jdbc:oracle:thin:@localhost:1521:xe,
openjpa.ConnectionDriverName=oracle.jdbc.driver.OracleDriver, openjpa.Id=test}
62 test 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.
62 test TRACE [main] openjpa.MetaData - Scanning resource "orm.xml" for
persistent types.
62 test TRACE [main] openjpa.MetaData - Scanning resource "META-INF/orm.xml"
for persistent types.
62 test TRACE [main] openjpa.MetaData - parsePersistentTypeNames() found [].
531 test TRACE [main] openjpa.MetaData - Found 0 classes with metadata in
469 milliseconds.
531 test WARN [main] openjpa.Tool - Found no class to enhance.
Usage: java org.apache.openjpa.enhance.PCEnhancer
[-properties/-p <properties file or resource>]
[-<property name> <property value>]*
[-directory/-d <output directory>]
[-addDefaultConstructor/-adc <true/t | false/f>]
[-jdoEnhance/-jdo <true/t | false/f>]
[-enforcePropertyRestrictions/-epr <true/t | false/f>]
[-tmpClassLoader/-tcl <true/t | false/f>]
<class name | .java file | .class file | .jdo file>+
Also the [previous attached file of PCEnhancer with the modified run method
solved the problem
with the mapping of mapping-file>ptp/test/issue5/orm.xml</mapping-file>
were you able to reproduce the same result?
> PCEnhancer does not enhance classes specified in the mapping files declared
> in the persistence xml
> --------------------------------------------------------------------------------------------------
>
> Key: OPENJPA-328
> URL: https://issues.apache.org/jira/browse/OPENJPA-328
> Project: OpenJPA
> Issue Type: Bug
> Components: build / infrastructure
> Affects Versions: 1.0.0
> Reporter: Henry Lai
> Attachments: ptpissue5.zip
>
>
> running
> org.apache.openjpa.enhance.PCEnhancer -p ptp/test/issue5/persistence.xml
> did not do the class file enhancement, result in The class does not have
> metadata - enhanced as persistence-aware.
> The message are
> 250 test TRACE [main] openjpa.MetaData - Finished parsing metadata
> resource "file:/C:/workspace/jpatest/TestOpenJPA/bin/ptp/test/issue5/orm.xml".
> 250 test TRACE [main] openjpa.MetaData - Parsing class
> "ptp.test.issue5.T5Entity".
> 250 test TRACE [main] openjpa.Enhance - Enhancing type "class
> ptp.test.issue5.T5Entity".
> 250 test WARN [main] openjpa.Enhance - Type "class
> ptp.test.issue5.T5Entity" has no metadata; enhancing as persistence aware. If
> you intended for "class ptp.test.issue5.T5Entity" to be persistence-capable,
> then this means that OpenJPA could not find any metadata for "class
> ptp.test.issue5.T5Entity". This can happen if the directory containing your
> metadata is not in your CLASSPATH, or if your metadata files are not named
> properly. See the documentation on metadata placement for more information.
> 250 test TRACE [main] openjpa.Tool - The class does not have metadata -
> enhanced as persistence-aware.
> modify the following method of the PCEnhancer to get it to work
> /**
> * Enhance the given classes.
> */
> public static boolean run(OpenJPAConfiguration conf, String[] args,
> Flags flags, MetaDataRepository repos, BytecodeWriter writer,
> ClassLoader loader)
> throws IOException {
> if (loader == null)
> loader = conf.getClassResolverInstance().
> getClassLoader(PCEnhancer.class, null);
> if (flags.tmpClassLoader)
> loader = new TemporaryClassLoader(loader);
> if (repos == null) {
> repos = conf.newMetaDataRepositoryInstance();
> repos.setSourceMode(MetaDataRepository.MODE_META);
> }
> Log log = conf.getLog(OpenJPAConfiguration.LOG_TOOL);
> Collection classes;
> String [] persistentTypeNames = args;
> if (args.length == 0) {
> log.info(_loc.get("running-all-classes"));
> classes = repos.getPersistentTypeNames(true, loader);
> if (classes == null) {
> log.warn(_loc.get("no-class-to-enhance"));
> return false;
> }
> persistentTypeNames = new String [ classes.size() ];
> classes.toArray( persistentTypeNames );
> }
> ClassArgParser cap = conf.getMetaDataRepositoryInstance().
> getMetaDataFactory().newClassArgParser();
> cap.setClassLoader(loader);
> classes = new HashSet();
> for (int i = 0; i < persistentTypeNames.length; i++)
>
> classes.addAll(Arrays.asList(cap.parseTypes(persistentTypeNames[i])));
>
>
> Project project = new Project();
> BCClass bc;
> PCEnhancer enhancer;
> int status;
> for (Iterator itr = classes.iterator(); itr.hasNext();) {
> Object o = itr.next();
> if (log.isTraceEnabled())
> log.trace(_loc.get("enhance-running", o));
> if (o instanceof String)
> bc = project.loadClass((String) o);
> else
> bc = project.loadClass((Class) o);
> enhancer = new PCEnhancer(conf, bc, repos, loader);
> if (writer != null)
> enhancer.setBytecodeWriter(writer);
> enhancer.setDirectory(flags.directory);
> enhancer.setAddDefaultConstructor(flags.addDefaultConstructor);
> status = enhancer.run();
> if (status == ENHANCE_NONE) {
> if (log.isTraceEnabled())
> log.trace(_loc.get("enhance-norun"));
> } else if (status == ENHANCE_INTERFACE) {
> if (log.isTraceEnabled())
> log.trace(_loc.get("enhance-interface"));
> } else if (status == ENHANCE_AWARE) {
> if (log.isTraceEnabled())
> log.trace(_loc.get("enhance-aware"));
> enhancer.record();
> } else
> enhancer.record();
> project.clear();
> }
> return true;
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.