The OpenShift forums have been retired, but you can still read and search them.
For the most up-to-date information about how to use OpenShift please visit

Configure Jboss 7.1 and Apache as dispatcher for static resources

Hello , i have a Cartridge with JBoss Application Server 7.1 - MySQL Database 5.1 - phpMyAdmin 3.4 gears, can i configure Jboss 7.1 and Apache as dispatcher for static resources? For example using ajp connector. Tnks for all replies. Bye Luca

Applications using JBoss cartridges do not have Apache running on the same gear, so there is no need for configuring the connector as everything is being served through JBoss.

ok thanks for your reply. Then where is the right place where i can put my static contents like immages or html?

Best regards. Luca

It can be packaged in the war file or in src/main/webapp

ok no problem for first solution (in war). But for second solution (src/main/webapp) i have problem. When i open with ssh my openshift connection i have 5 forlders: app-root git jbossas-7 mysql-5.1 phpmyadmin-3.4 i think that src/main/webapp that you say is in app-root/repo , i put a simple gif in app-root/repo/src/main/webapp/ but i don't see it. There are other operation that i don't do? Tnks Luca

Always use $env.OPENSHIFT_DATA_DIR for storing persistent content. repo dir gets refreshed across every git push hence wipes out any content stored there.

Suggestions to use OPENSHIFT_DATA_DIR for static content are in this post:

OK I had use e simple servlet like this and it work correctly. I add the source code if is useful for any other.

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String filePath = request.getRequestURI();
     File file = new File(System.getenv("OPENSHIFT_DATA_DIR") + filePath);
    InputStream input = new FileInputStream(file);
    response.setContentLength((int) file.length());
    response.setContentType(new MimetypesFileTypeMap().getContentType(file));
    OutputStream output = response.getOutputStream();
    byte[] bytes = new byte[BUFFER_LENGTH];
    int read = 0;
    while (read != -1) {
      read =, 0, BUFFER_LENGTH);
      if (read != -1) {
        output.write(bytes, 0, read);


Thanks for posting your solution!!