• Post Reply Bookmark Topic Watch Topic
  • New Topic

Issue with ClassLoader

 
Pankaj Poshirkar
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • 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
 
Amol Nayak
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • 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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!