Use properties file out of EAR
HI All,
Generally we create an EAR file with all the property files embedded in it. Here the problem is as and when we change the property files we need to build a new ear file and redeploy to J2EE stack.
Is there any way that this properties file is out of EAR application and changes done to the property file reflects in EAR? So that, no need to redeploy the application again and again. Means dynamic reflecting of property changes to already deployed EAR application. How it can be done?
Actually this is our client requirement also...
Hope am clear.
Regards,
Satish.
Hi,
There are ways to achieve this.
I guess you can try following.
You can define properties file in another project (like java project) and then include that project as a reference in your EAR application.
Ashutosh
Similar Messages
-
Hi,
I want to use properties file in my application. I have kept properties file inside a directory called properties which is inside myProject(which is the parent directory of my project) i.e "myProject/properties".
My java file where i want to call this properties file is inside the myProject/WEB-INF/src/java.
How can i call the properties file from myProject/WEB-INF/src/java/PropertyReader.java
I wrote java program in myProject/WEB-INF/src/java/PropertyReader.java like:::::
ResourceBundle resBun = ResourceBundle.getBundle("Test", Locale.getDefault()); // Test.properties is inside myProject/properties
resBun..getString("name");
After running the program i am getting the following errors:::::
Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name Test, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:836)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:805)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:576)
at PropertiesReader.main(PropertiesReader.java:4)
What is the issue? How to use properties file?
Waiting for reply.
ThanksStill getting same exception. As you explained i tried like the below:::
1. I am using ant as build tool.
2. My properties file is for database configuration
My properties file is::
database.properties (inside myProject/properties)
JDBCDriver=org.gjt.mm.mysql.Driver
JDBCConnectionURL=jdbc:mysql://pmdbmysql:3306/bandwidthshaper?user=admin&password=admin
My java package structure is
WEB-INF/src/java
WEB-INF/src/classes
For build WEB-INF is the base directory and build.xml is inside the src directory
In my build.xml i wrote the following lines for compilation::
<target name="compile" >
<javac srcdir="src" destdir="src/classes" debug="true" debuglevel="lines,vars,source">
<classpath refid="class.path"/>
</javac>
<copy todir = "src/classes" >
<fileset dir = "../properties" />
</copy>
<jar jarfile="lib/${project.jar.file}" basedir="src/classes"/>
</target>
I am copying properties file to the classes directory.
Now in java file which is inside /WEB-INF/src/java, I wrote::
try {
Properties programProps = new Properties();
InputStream is = getClass().getResourceAsStream("/database.properties");
if(is == null)
throw new IllegalStateException("Properties file missing ");
programProps.load(is);
System.out.println("driver name::::::: "+programProps.getProperty("JDBCDriver"));
is.close();
} catch(Exception e) {
e.printStackTrace();
After compilation in my classes directory i am getting database.properties file and my java file with package.
At the time of running i am getting "java.lang.IllegalStateException: Properties file missing"
Now tell me where is the fault. Why again i am getting exception.
Thanks -
Using property files into an EAR Project? How?
Hi there,
I'm pretty new to j2ee development, so i hope i'm not asking a silly question.
So what I have done / wanna do:
- I created a ejb module project with several ejbs and several java classes in it
- I created an ear application project to deploy the ejb module project
- I am succesfully deploying my ear on my j2ee server
So after all, I want to load different properties of some java classes through properties files (*.properties). How do I do that in this situation? Is there a way to use properties files altough the whole ejb project (containing the properties files) is packed into one file (the ear file)?
I hope someone can help me an I'm pleased for every message
Thank you all.
Regards
Danielpoissble with:
getResourceAsStream(String)
Regards -
Hi i read about properties file in java .. i didn't get much more..
how can we use this in program.. what is the benefit..
anyone know any examples in site.please let me know about thatint count=getGoogleSearchCount();
public int getGoogleSearchCount(){
search keyword="http://www.google.co.ke/search?hl=en&q=java+properties+class&btnG=Google+Search";
// missing code
return count;
System.out.println(count);i ran the above code snipplet and guess the output?
291,000 results.
DONT BE LAZY. -
How to use .properties files in Webdynpro Java code?
Hi all,
I want to use a logon.properties file when I initial a JCO connection pool in my webdynpro DC (JCO.addClientPool()),but I found when I deployed this DC to the server, it always giv e me an FileNotFoundException. So I donot know how to deploy a .properties file to the server and how to access this file in my Java code?
Thans and Best regards
DeyangHi,
1) put .properties file to your packege under src\packages folder (src\packages\com\sdn\properties\jco.properties)
2) load property:
final InputStream is = getClass().getClassLoader().getResourceAsStream("com/sdn/properties/jco.properties");
final Properties properties = new Properties();
try
properties.load(is);
catch(Exception e)
wdComponentAPI.getMessageManager().reportException(new WDNonFatalException(e), false);
Regatds Maxim R. -
Using .properties file in web dynpro
Hi,
I am having a requirement. I have to create a .properties file and I have to use it in my web dynpro application. How can I do that? Any help...
Thanks & Regards,
RajHi,
Go to the navigator view...select src\Components\<ComponentName> and create create a .properties file.
You can read the configuration file in your webdynpro app as follows
IWDConfiguration configuration =
WDConfiguration.getConfigurationByName(
wdComponentAPI.getDeployableObjectPart(),
"<<>>");
http://help.sap.com/saphelp_nw04/helpdata/en/b8/aa343e32ff1033e10000000a114084/frameset.htm
Regards, Anilkumar
Message was edited by:
Anilkumar Vippagunta -
How to read multiple files at multiple locations using properties file
hi all ,
in my code i take configuration input from a properties file ,it was really easy but what if there are multiple files ? how can i take configuration input (file path etc) from properties file in that case ? any suggestion ?thanks :) ..i am doing like this :
String fName[]=new String[10];
String choice[]=new String[10];
String Delim[]=new String[10];
ResourceBundle a = ResourceBundle.getBundle("input");
String n=a.getString("NOF");
try
for(int i=0;i<Integer.parseInt(n);i++)
fName=a.getString("PATH"+(i+1));
choice[i]=a.getString("HEADER"+(i+1));
Delim[i]=a.getString("DELIMITER"+(i+1));
putData(fName[i],choice[i],Delim[i]);//to put data in database
catch (NumberFormatException e)
System.out.println("Number of files are invalid");
hope this method would be fine ....again thanks for the advice :) :) -
Use properties file in Struts framework
I develop a websit with struts, web ap is tomcat5.0, and I have a conf.properties file
this file is different from ApplicationResource.properties, conf.properties in the /MySite/conf/ directory, not in src directory
When I Use the conf.properties file in a Common Java Class that not extends any super class
it will occur a FileNotFoundException exception
How to make it
public class Environment
private static Properties prop = new Properties();
private static FileInputStream in = null;
public static String getVariable(String key)
try
in = new FileInputStream(new File("\\conf\\config.properties"));
prop.load(in);
return prop.getProperty(key, null);
catch (Exception e)
e.printStackTrace();
return null;
finally
try
in.close();
catch(Exception e)
e.printStackTrace();
}Your class cannot find the file in the location tht u have given. The path (\\conf\\config.properties) is relative to the location where your source (Environment class) is kept.
Try to hard code the path & see if your source can find the prop file ... -
On navigating into any web application there wil be some .proeprties file (build.proeprties, applicationResources.properties etc..) and some .xml files(web.xml, struts-config.xml). Why .properties file why not all in XML ??
The question should be: why XML and why not a properties file? XML is lots of overhead for simple tasks.
-
How to use cab files in jsp & ear
I have a jsp page and a cab file which helps change printer settings.. I have embedded the activex control(cab file) as follows.. Is this ok?
<object id="factory" style="display:none" viewastext
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
codebase="ScriptX.cab#Version=5,60,0,375">
</object>
Also where do I place the cab file? I want that the file should be downloaded the first time the user visits the jsp page.You should be able to just bring the files into DreamWeaver. It should edit the HTML part of the JSP just fine.
-
Hello,
I am wondering if an application (java classes for instance) can read a .properties file inside the ear package, when the application is deployed ?
(only reading of course)
Thank youI'd recommend using ClassLoader.getResourceAsStream to access the properties file.
This means the file needs to be in the resource path of your classloader. In WLS, an easy way to do this is to have it in the APP-INF/classes directory of your EAR file.
-- Rob
WLS Blog http://dev2dev.bea.com/blog/rwoollen/ -
I have a main method which i am using to call a servlet located in the same Development Component. Until recently i had the servlet location hard coded and it was working without issues. Now i decided to make the location configurable. For this i created an sap.application.global.properties file in the EAR DC which contains the WAR of this DC.
The contents of the above file are as follows:
SAP application properties
SERVLET.LOCATION=http://<server-name>/ControllerServlet/servlet/com.nike.xapps.eqptsp.swem.controller.ControllerServlet
The code i am using in the main method to call this properties file and access the property is as follows:
Context ctx = new InitialContext();
ApplicationConfigHandlerFactory cfgHdlr = (ApplicationConfigHandlerFactory)ctx.lookup("ApplicationConfiguration");
Properties props = cfgHdlr.getApplicationProperties();
String servlet = props.getProperty("SERVLET.LOCATION");
contained in a try...catch block.
On dubugging i get a NoInitialContextException repeatedly in the statement where the lookup is performed.
These are all the additions i have made for reading this properties file. Does anyone know if there is anything more that needs to be done for this to work.
Thanks,
Murtaza.thank for the help mangst. i guess the IO approach is also applicable ^^; i changed my code to:
configFile.load( new FileInputStream( ".\\resources\\config.properties" ) );but i had a little trouble in debugging it since it starts the file search from the main project directory. however it works fine upon deployment. ^^; thanks again.
Edited by: xnofate on Sep 23, 2008 6:21 PM -
.properties file in servlet classpath
I have a servlet that I trying to run under OC4J/Orion here at
Oracle. The servet is trying to load it's property file
with:
InputStream is =
ClassLoader.getSystemResourceAsStream("ipruntime.properties");
But the inputStream is always null no matter where I put the
properties file in the classpath (I've tried putting it in
jars or in a directory). The servlet is invoking methods in
other java classes just fine, so there is not a problem with
the classpath.
Any clues of what might be wrong?
The same servlet with it's property file in the classpath runs
under Apache/Jserv just fine.InputStream in =
this.getClass().
getClassLoader().
getResourceAsStream("theFile.properties");
I think the general advice is to use 'this.getClass()' to make
sure which ClassLoader is being called.
This may not be a problem, but try it?
If you're deploying on OC4J you might also want to try one of the
'newer' methods of 'using properties files', ie: put it in
web.xml and look it up.
Cheers,
Malte -
Character encoding problem with german umlaut in propertie files
Hi,
I use propertie files to translate application to multiple languages.
These files contains german umlaut (e.g.: Wareneingänge).
If I rebuild my application then this files are copied from ../src/view to ../classes/view.
The file in ../classes/view contains "Wareneing\ufffdnge" instead of "Wareneingänge" which is displayed as "Wareneing�nge".
My browser-, project- and application settings are UTF8.
Previously the settings for project and application where "Windows-1252"
I have found an workarounds but maybe this is a bug in Jdeveloper TP4.
Therefore I post this problem. Maybe someone can confirm this behaviour.
Workaround:
Replace "Wareneingänge" with "Wareneing\u00e4nge" in the ../src/view file
(Zaval JRC Editior does this for you :-) )
regards
PeterHi,
I think to remember that the same was required for properties in 10.1.3 as well. Not sure if this is an issue in JDeveloper 11. I'll take anot and have a look though
Frank -
Can I use properties files with bpel (if can how it does?)
for tune some region optionsYou could write a custom xpath function and plug-in to the bpel engine to do this job.
The custom xpath function can read a property file and convert into a xml element and use that xml element inside bpel.
The tricky part is to map the properties file into a xml schema and convert the properties file into xml document. Inside bpel, the variables refer to xml elements.
Another easy solution is to use java <exec> to do the same.
-read file
-change your mail/portal data inside the java exec using setVariableData() function.
Maybe you are looking for
-
Is there something that is like the Gallery with MobileMe on iCloud? I like to post pics for family etc and Gallery was perfect for that.
-
How to get the instance id of BPEL in OSB
We have the process in OSB which will invoke the BPEL ansync process and returns success once the BPEL is invoked. Can we refer/get the BPEL instance id in OSB by anymeans?
-
Hello All, We are using TMG2010 (SP2, rollup4) for publishing Exchange 2010 OWA sites. The issue is that after every 10-24 hrs , the TMG server stops logging in OWA sites and start giving below error. Then we have to restart the server one two times
-
hi frenz... I'm trying to install golden gate on oracle 11g but when i try to run the script @/oradata/gg/marker_setup.sql it asks for golden gate schema.. after entering schema name the command prompt does'nt show anything plzz tell me wheres the pr
-
10.4.6 failed installation, but successful?
During all attempted installations of 10.4.6 (both the Software Update downloaded package and the Combo package), installation has failed. The installer fails with such wonderful error messages such as the following: brackenridge% sudo installer -ver