Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8836995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:37:06+00:00 2026-06-14T09:37:06+00:00

How do I load resources like images from the java code with Jboss7.1? This

  • 0

How do I load resources like images from the java code with Jboss7.1?

This used to work with Jboss4:

this.getClass().getClassLoader().getResourceAsStream("/myapp/includes/images/image1.png");

Now this returns null.

What is best practice for loading resources in java code now with Jboss7?

I did some testing:

URL url = this.getClass().getResource("");
System.out.println(url);
url = this.getClass().getResource("../../../");
System.out.println(url);
url = this.getClass().getResource("../../../../");
System.out.println(url);
url = this.getClass().getResource("../../../../../");
System.out.println(url);
url = this.getClass().getResource("includes");
System.out.println(url);

13:33:49,143 INFO  [stdout] (http--127.0.0.1-8080-1) vfs:/C:/Eclipse/apps/jboss-as-7.1.1.Final/standalone/deployments/my-ea.ear/my-web.war/WEB-INF/classes/com/xxx/yyy/beans/jsf/
13:33:49,144 INFO  [stdout] (http--127.0.0.1-8080-1) vfs:/C:/Eclipse/apps/jboss-as-7.1.1.Final/standalone/deployments/my-ea.ear/my-web.war/WEB-INF/classes/com/xxx/
13:33:49,150 INFO  [stdout] (http--127.0.0.1-8080-1) jar:file:/C:/Eclipse/apps/jboss-as-7.1.1.Final/modules/javax/activation/api/main/activation-1.1.1.jar!/com/
13:33:49,151 INFO  [stdout] (http--127.0.0.1-8080-1) file:/C:/Eclipse/apps/jboss-as-7.1.1.Final/modules/sun/jdk/main/service-loader-resources/
13:33:49,152 INFO  [stdout] (http--127.0.0.1-8080-1) null
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:37:08+00:00Added an answer on June 14, 2026 at 9:37 am

    As documented on the JBoss community wiki (without using a jboss-deployment-structure.xml file):

    1. Create a module for the configuration file (jboss-as-7/modules/com/yourcompany/configuration/main/module.xml):
    <?xml version="1.0" encoding="UTF-8"?>
    <module xmlns="urn:jboss:module:1.1" name="com.mycompany.configuration">
        <resources>
            <resource-root path="."/>
        </resources>
    </module>
    
    1. Add properties to the module:
    jboss-as-7/
       modules/
          com/
             yourcompany/
                configuration/
                   main/
                     module.xml
                     settings.properties
                     other-settings.xm
    
    1. Add the module to the CLASSPATH using a MANIFEST.MF entry:
    Manifest-Version: 1.0
    Dependencies: com.mycompany.configuration
    
    1. Load a properties file from the CLASSPATH:
    InputStream settingsStream = 
      getClass().getClassLoader().getResourceAsStream("settings.properties");
    

    I had to create a module folder called com/mycompany/main and add all the images in there. So this sits outside the WAR at least though within JBOSS_HOME. Then I could load the image using:

    URL imgUrl = this.getClass().getClassLoader().getResource("myimage.jpg");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When you load a bitmap from the resources like so: iv.setImageResource(R.drawable.image); if the bitmap
I want to load PNG-file from resources. There is a roughly MFC-way (with CResourceStream
I'm having trouble accessing springSecurityService from resources.groovy file, I'm trying to load user locale
I have seen examples containing things like this: mountSharedResource(/images/logo.gif, new ResourceReference(ImageScope.class, logo.gif).getSharedResourceKey()); mountSharedResource(/resource, Application.class.getName()
I have a C# custom control that loads images from Resources.resx. I was loading
I'm reading this question because I have to load a ton of downloaded resources
I'm going to build an app which is using AJAX to load resources as
In Expression Blend 4, it's possible to load design-time resources by editing your project
I am trying to load specific styles/script resources for a specific module within my
I need to load some resource from my DLL (i need to load them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.