openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marina Vatkina <Marina.Vatk...@Sun.COM>
Subject Re: [jira] Commented: (OPENJPA-328) PCEnhancer does not enhance classes specified in the mapping files declared in the persistence xml
Date Thu, 23 Aug 2007 01:38:48 GMT
Pinaki,

The <mapping-file> location according to the spec (see 6.2.1.6 mapping-file, 
jar-file, class, exclude-unlisted-classes) is "present anywhere on the class path.

Regards,
-marina

Pinaki Poddar (JIRA) wrote:
>     [ https://issues.apache.org/jira/browse/OPENJPA-328?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12521983
] 
> 
> Pinaki Poddar commented on OPENJPA-328:
> ---------------------------------------
> 
> content of <mapping-file> in persistence.xml is resolved relative to location of
persistence.xml itself. So, for exaple, if persistence.xml and orm.xml reside in the same
directory, then persistence.xml should need to specify
> <mapping-file>orm.xml</mapping-file>
> 
> Or nothing because, by default, OpenJPA will look for a orm.xml file. 
> 
> The attached content shows that  <mapping-file>ptp/test/issue5/orm.xml</mapping-file>.
That is why OpenJPA is not finding the metadata/mapping info for Entity class. 
> 
> 
> 
> 
> 
>>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;
>>    }
> 
> 

Mime
View raw message