1. OpenJPA
  2. OPENJPA-2102

URLs which contains spaces are not properly handled by OpenJPA.


    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.3, 2.1.2, 2.2.0
    • Fix Version/s: 2.1.2, 2.3.0
    • Component/s: None
    • Labels:


      Take the following lines of code in AbstractCFMetaDataFactory:

      if (puUrlString != null && urlString.indexOf(puUrlString) != -1)

      When either 'urlString' of puUrlString is encoded, and the other is not, the 'indexOf' will fail even if the URLs are the same if both are either encoded or decoded. Let me explain:
      The 'urlString' is effectively obtained from the ClassLoader, and the puUrlString is obtained from the OpenJPA configuration. If the user's URL path contains spaces in it (' '), the URL may be encoded with '%20' (see the URL and URI javadoc). The Classloader is likely to return encoded URLs. However, given that the two URLs come from different places, it is not guaranteed that both URLs will be encoded. If one URL is encoded (e.g. encoded with a %20 for spaces) and the other URL is not encoded (e.g. the URL contains spaces), the above 'indexOf' will fail even though technically the two URLs may ultimately represent the same location when both are encoded (or decoded). When the 'indexOf' fails the URL is not added to the list of URLs to process which has downstream effects in that necessary meta data is missing. For example, in the issue I'm working I saw the following exception due to missing meta data:

      Caused by: org.apache.openjpa.persistence.ArgumentException: Type       
      "class testcases.res.ejb.subscriber.SubscriberBehavior" loaded by    [appwar:RES Test      
         Local ClassPath: .......                         
      does not have persistence metadata.     
       at org.apache.openjpa.jdbc.meta.MappingTool.getMapping(                                                               
       at org.apache.openjpa.jdbc.meta.MappingTool.buildSchema(                                                               
       at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(                                            
       at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(                                            
       at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(                                            
       at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(                                        
       at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(                                      
       at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(                  


      Heath Thomann


        Heath Thomann created issue -
        Heath Thomann made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.1.2 [ 12317142 ]
        Fix Version/s 2.3.0 [ 12319463 ]
        Resolution Fixed [ 1 ]
        Heath Thomann made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        155d 8h 51m 1 Heath Thomann 31/May/12 14:48
        Resolved Resolved Closed Closed
        9s 1 Heath Thomann 31/May/12 14:48


          • Assignee:
            Heath Thomann
            Heath Thomann
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: