• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic