JBoss Community

read file (resource) from archive (WAR)

created by Alex Ander in Beginner's Corner - View the full discussion

Hi @ll,

 

i have a development problem, that sounds pretty simple:

 

Following file structure:

 

application.war

|- css

|-style.css

|- index.xhtml (refers to css/style.css)

|-WEB-INF

     |-classes

          x.y.z.ResourceReaderBean.class

 

Now I try to read the style.css in ResourceReaderBean bean. That seems to be not that

easy in Jboss 7.

 

This tries didn't work:

InputStream is = ResourceReaderBean.class.getResourceAsStream("/css/style.css");

InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("/css/style.css").getPath();

 

I tried much more, and googeled at least for 4 hours. But now I gave up. I dont have any idea how

to read the Resource in the bean.

 

It works perfect from outside the WAR. But i dont want to duplicate the style.css (DRY Principle). It

should be possible to read the file from WAR.

 

Do some of you have any idea?

 

Thanks

reagrds

Alex

Reply to this message by going to Community

Start a new discussion in Beginner's Corner at Community