Wednesday 5 September 2012

Today I will write about the a problem faces in JBOSS 7 AS.
As In JBOSS 7 Some of us may find a problem to access the static resources from such as( images , videos etc.) may be used in your application, and they will be reside in our war that is not acceptable in many cases so, we have a need to locate them in a saperate folder in JBOSS itself in somewhere place.

To configure this these are the steps may you find them helpful.

Step 1.  Create a folder in standalone/deployment folder with the extension(.war).
Step 2.  Now create a WEB-INF folder in that folder and place a web.xml file in the same. and the text of web.xml will be....

<?xml version="1.0"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
      version="3.0">
 <description>My static resources</description>
 <display-name>My static resources</display-name>
<filter>
 <filter-name>ExpiresFilter</filter-name>
 <filter-class>org.apache.catalina.filters.ExpiresFilter</filter-class>
 <init-param>
    <param-name>ExpiresByType image</param-name>
    <param-value>access plus 1 month</param-value>
 </init-param>
</filter>


<filter-mapping>
 <filter-name>ExpiresFilter</filter-name>
 <url-pattern>/*</url-pattern>
 <dispatcher>REQUEST</dispatcher>
</filter-mapping>
</web-app>



Step 3. Now as the next step create an another folder in the .war extension folder(Paraller to the WEB-INF) of name such like (media etc.) in which you can store static data.
Step 4.  Now in order to deploy your .war extension folder by JBOSS you have to da a little more.
Step5.  Create a (foldername.war.dodeploye) extension file in deployments folder, so that it will force the JBOSS to deploy your folder having .war extention as a war file.

That's it........

Now you are able to access the static data from itself that war as well as from another war placed in same folder in (standalone/deployments).

No comments:

Post a Comment