Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Issue with ClassLoader

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,

I have one EAR project say 'EARProject' and this project contains one directory named 'resources'. This 'resources' directory consists of 3 xsd files required for xml validations.
Now in my application, I have a statement in one of the source files as follows:

ClassLoader cl = Thread.currentThread().getContextClassLoader();

java.net.URL url = cl.getResource(xsdSchema) ;

where xsdSchema holds the name of the xsd file which is present in 'resources' directory as stated above.

But, url is being returned as null. This is due to the fact that ClassLoader doesn't have the path to 'resources' directory. I verified this by keeping a watch on the ClassLoader variable 'cl'. The private variable 'localClassPath' of ClassLoader stores the semi-colon separated paths of various required projects and jar files in an application. But this variable has everything except the path to 'resources' folder.

Can anyone let me know why this is happening? Does anyone have any idea how the localClassPath variable of ClassLoader is populated? I guess it populates from the 'Class-Path' attribute in the Manifest.mf files of every project in the EAR. I even tried adding 'resources' path in the Manifest.mf file of the EARProejct; but it did not work.

Please help those who have even a subtle idea of this problem.

Thanks in advance,
Pankaj
 
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Now in my application, I have a statement in one of the source files as follows:


Which application is it? An EJB application, a Web application..?


The private variable 'localClassPath' of ClassLoader stores the semi-colon separated paths of various required projects and jar files in an application. But this variable has everything except the path to 'resources' folder.


What all have you got in your EAR? What do you see in this variable?
 
You can't expect to wield supreme executive power just because
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic