• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

JBOSS 5.1.0 issue with props folder in an EAR.

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello friends,

This happens to be my first post here, but was around from quite some time. Today I decided to register and start interacting with all you knowledgeable people. I am very new to world of programming and know nothing much. I have recently migrated an application from JBoss 4.4.2 to 5.1.0. I have configured the queues and ports correctly. The app. is getting deployed correctly. But the issue is with reading a props folder(Contains property files) which resides in the EAR bundle. In JBoss 4.2.2 it was running fine because this.Class.getResource() was getting it from tmp folder, here the EAR is getting expanded. But I have noticed that in newer version i.e 5.1.0 the props folder isnt getting expanded. Its trying to read from the EAR bundle itself and throws a FileNotFound Exception. I deployed the EAR in Exploded format and the it works fine. I wanted to know the best way to overcome this scenario. One option is to read EAR using JarFile, JarEntry but I guess that is not a good practice. That would mean code changes in an application which is well tested. Can someone suggest a better way to overcome this scenario??

Thanks.
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Viren, welcome to Java Ranch!

Exactly where is you properties file located within your EAR file? If within a JAR or WAR within the EAR, where is that JAR/WAR, and where in that is the properties file.

Also post the code you are using to access the properties file and provide the values of any variables used (the value passed to getResources() is the most critical piece.)

Also, please see you private messages regarding an important administrative matter.
 
Vijendra Prakash
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Peter,

There is a props folder which contains all the property files which is just inside the EAR. It’s not in jar or war within the EAR. “Application.ear/props/” is where all the property files reside. Then we have “Application.ear/ABC.war/” and then “Application.ear/META-INF/” and “Application.ear/elib/”(All jars are placed here in elib folder).
And the code for reading the property file is:



All I need is to read the file from “Application.ear/props/<FileName>.registry”.

Thanks.
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I recall correctly, the base directory of an EAR file is no longer automatically in the classpath for the EAR. You will have to place the properties file into a JAR file and place that in the lib directory within the ear.
 
Vijendra Prakash
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Peter,

Many thanks for taking efforts and replying.

I tried doing that. I put that props folder in the jar and placed that in the lib directory within the ear. But still it doesn't seem to be finding it. Sir, as I said I am new to this programming world. I know that I am doing it the wrong way. Can you please provide a code snippet to read property files??
Lets forget the structure of my EAR bundle. Suppose we are making a new application and we have a lot of property files to be read at run time by our application. What is the ideal way of doing that? Can you please provide a sample EAR structure and a few lines of code to read those property files? Also it should be done in such a way that the bundle would work on all versions of JBoss and even on others like WebLogic.

Thanks.
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using ClassLoader.getResource(), or any of its variations, is the correct way to load a resource. But be aware that naming a resource is like naming a class; that is, you don't use directory names with slashes, but rather package names with dots.

For example, a file within a JAR at props/my.properties would be accessed as "props.my.properties".

Here are some more details:
https://coderanch.com/t/89900/JBoss/reading-properties-file
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic