Alex Ander
2013-02-08 13:09:21 UTC
Alex Ander [https://community.jboss.org/people/figwam] created the discussion
"read file (resource) from archive (WAR)"
To view the discussion, visit: https://community.jboss.org/message/796740#796740
--------------------------------------------------------------
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
[https://community.jboss.org/message/796740#796740]
Start a new discussion in Beginner's Corner at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075]
"read file (resource) from archive (WAR)"
To view the discussion, visit: https://community.jboss.org/message/796740#796740
--------------------------------------------------------------
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
[https://community.jboss.org/message/796740#796740]
Start a new discussion in Beginner's Corner at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075]