[ 
https://issues.apache.org/jira/browse/OLINGO-312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14016489#comment-14016489
 ] 

Chandan V.A commented on OLINGO-312:
------------------------------------

Hi,
Instead of JPA processor internally reading the mapping XML based on different 
runtime environments (including OSGI) what if the applications provide the 
mapping XML as Input stream to JPA Processor through callback mechanism.

For Example JPAEdmExtension Interface will have an additional method say 
"loadMappingModel". Applications shall implement this method to read the 
Mapping XML and provide the XML as input stream. JPA processor while 
constructing the EDM model will make a call to this method to see if there is 
any input stream available else would fallback to loading it via Class Loader 
(current implementation) .

So in your use case you might have to implement this callback method.

I hope this solves your issue which very specific to Websphere platform and 
also would solve issues arising from other platforms (say OSGI).

Thanks
Kind Regards
Chandan

> Reading resource via Classloader
> --------------------------------
>
>                 Key: OLINGO-312
>                 URL: https://issues.apache.org/jira/browse/OLINGO-312
>             Project: Olingo
>          Issue Type: Bug
>          Components: odata2-jpa
>    Affects Versions: V2 1.2.0
>            Reporter: Giacomo Pati
>            Assignee: Chandan V.A
>
> While many servlet-containers tested by me work fine with construct below, 
> WebSphere 8 doesn't like it and returns null for the resources path requested 
> (it's actually outside of Classloader managed filesystem area, which I would 
> consider being bad practice):
> {code}
> InputStream is = 
> JPAEdmMappingModelService.class.getClassLoader().getResourceAsStream("../../" 
> + mappingModelName);
> {code}
> As the class in question (JPAEdmMappingModelService) doesn't have access to 
> the servlet context to properly read a file from the web space area I'd 
> suggest (also for backwards compatibility reasons) to add this to the code as 
> shown in the following patch:
> {code}
> @@ -195,6 +195,9 @@ public class JPAEdmMappingModelService implements 
> JPAEdmMappingModelAccess {
>    protected InputStream loadMappingModelInputStream() {
>      InputStream is = 
> JPAEdmMappingModelService.class.getClassLoader().getResourceAsStream("../../" 
> + mappingModelName);
> +      if(is == null) {
> +          is = 
> JPAEdmMappingModelService.class.getClassLoader().getResourceAsStream(mappingModelName);
> +      }
>      return is;
> {code}
> which would alternatively allow to put the mapping file into the 
> WEB-INF/classes folder.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to