Buggy code:
itr . hasNext ( ) ; ) { url = ( ( URL ) ( itr . next ( ) ) ) ; if ( "file" . equals ( url . getProtocol ( ) ) ) { File file = AccessController . doPrivileged ( J2DoPrivHelper . getAbsoluteFileAction ( new File ( url . getFile ( ) ) ) ) ; if ( ( ( files ) != null ) && ( files . contains ( file ) ) ) { continue ; } else if ( AccessController . doPrivileged ( J2DoPrivHelper . isDirectoryAction ( file ) ) . booleanValue ( ) ) { if ( log . isTraceEnabled ( ) ) log . trace ( AbstractCFMetaDataFactory . _loc . get ( "scanning-directory" , file ) ) ; scan ( new FileMetaDataIterator ( file , newMetaDataFilter ( ) ) , cparser , names , true , file ) ; continue ; } } if ( ( "jar" . equals ( url . getProtocol ( ) ) ) && ( url . getPath ( ) . endsWith ( "!//" ) ) ) { if ( log . isTraceEnabled ( ) ) log . trace ( AbstractCFMetaDataFactory . _loc . get ( "scanning-jar-url" , url ) ) ; scan ( new org . apache . openjpa . lib . meta . ZipFileMetaDataIterator ( url , newMetaDataFilter ( ) ) , cparser , names , true , url ) ; } else if ( url . getPath ( ) . endsWith ( ".jar" ) ) { if ( log . isTraceEnabled ( ) ) log . trace ( AbstractCFMetaDataFactory . _loc . get ( "scanning-jar-at-url" , url ) ) ; try { InputStream is = ( ( InputStream ) ( AccessController . doPrivileged ( J2DoPrivHelper . openStreamAction ( url ) ) ) ) ; scan ( new org . apache . openjpa . lib . meta . ZipStreamMetaDataIterator ( new ZipInputStream ( is ) , newMetaDataFilter ( ) ) , cparser , names , true , url ) ; } catch ( PrivilegedActionException pae ) { throw ( ( IOException ) ( pae . getException ( ) ) ) ; } } else { if ( log . isTraceEnabled ( ) ) log . trace ( AbstractCFMetaDataFactory . _loc . get ( "scanning-url" , url ) ) ; clss = cparser . parseTypeNames ( new URLMetaDataIterator ( url ) ) ; List < String > newNames = Arrays . asList ( clss ) ; if ( log . isTraceEnabled ( ) ) log . trace ( AbstractCFMetaDataFactory . _loc . get ( "scan-found-names" , newNames , url ) ) ; names . addAll ( newNames ) ; mapPersistentTypeNames ( url , clss ) ; } } } if ( ( rsrcs ) != null ) { String rsrc ; MetaDataIterator mitr ; for ( Iterator itr = rsrcs . iterator ( ) ; itr . hasNext ( ) ; ) { rsrc = ( ( String ) ( itr . next ( ) ) ) ; if ( rsrc . endsWith ( ".jar" ) ) { url = AccessController . doPrivileged ( J2DoPrivHelper . getResourceAction ( loader , rsrc ) ) ; if ( url != null ) { if ( log . isTraceEnabled ( ) ) log . trace ( AbstractCFMetaDataFactory . _loc . get ( "scanning-jar-stream-url" , url ) ) ; try { InputStream is = ( ( InputStream ) ( AccessController . doPrivileged ( J2DoPrivHelper . openStreamAction ( url ) ) ) ) ; scan ( new org . apache . openjpa . lib . meta . ZipStreamMetaDataIterator ( new ZipInputStream ( is ) , newMetaDataFilter ( ) ) , cparser , names , true , url ) ; } catch ( PrivilegedActionException pae ) { throw ( ( IOException ) ( pae . getException ( ) ) ) ; } } } else { if ( log . isTraceEnabled ( ) ) log . trace ( AbstractCFMetaDataFactory . _loc . get ( "scanning-resource" , rsrc ) ) ; mitr = new ResourceMetaDataIterator ( rsrc , loader ) ; <START_BUG> URL puUrl = repos . getConfiguration ( ) . getPuRootUrl ( ) ; <END_BUG> String puUrlString = ( puUrl == null ) ? null : puUrl . toString ( ) ; if ( log . isTraceEnabled ( ) ) log . trace ( AbstractCFMetaDataFactory . _loc . get ( "pu-root-url" , puUrlString ) ) ; List < URL > urls = new ArrayList < URL > ( 3 ) ; while ( mitr . hasNext ( ) ) { url = ( ( URL ) ( mitr . next ( ) ) ) ; String urlString = url . toString ( ) ; if ( log . isTraceEnabled ( ) ) log . trace ( AbstractCFMetaDataFactory . _loc . get ( "resource-url" , urlString ) ) ; if ( puUrlString != null ) { if ( ( urlString . indexOf ( puUrlString ) ) != ( - 1 ) ) urls . add ( url ) ; } else urls . add ( url ) ; } mitr . close ( ) ; for ( Object obj : urls ) { url = ( ( URL ) ( obj ) ) ; clss = cparser . parseTypeNames ( new URLMetaDataIterator ( url ) ) ; List < String > newNames = Arrays . asList ( clss ) ; if ( log . isTraceEnabled ( ) ) log . trace ( AbstractCFMetaDataFactory . _loc . get ( "scan-found-names" , newNames , rsrc ) ) ; names . addAll ( newNames ) ; mapPersistentTypeNames ( url , clss ) ; } } } } if ( ( cpath ) != null ) { String [ ] dirs = ( ( String [ ] ) ( cpath . toArray ( new String [ cpath . size ( ) ] ) ) ) ;

Fix:
URL puUrl = repos . getConfiguration ( ) . getPersistenceUnitRootUrl ( ) ;