openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henry Lai (JIRA)" <j...@apache.org>
Subject [jira] Created: (OPENJPA-328) PCEnhancer does not enhance classes specified in the mapping files declared in the persistence xml
Date Wed, 22 Aug 2007 21:30:30 GMT
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.


Mime
View raw message