Location of application-specific properties files
I am using Tomcat 4.0.3 under WinXP Pro, and I am trying to get my
application to "find" an application-specific properties file. I am having problems trying to determine which directory to put this file in.
Here is the Java code I am using for this class:
import java.util.Properties;
import java.io.FileInputStream;
public class ForumProperties extends Properties {
private static final String DEFAULT_FILENAME = "/WEB-INF/classes/mystuff.properties";
private static ForumProperties globalProps;
private ForumProperties() {
private ForumProperties(String fileName) throws Exception {
this();
load(new FileInputStream(fileName));
public static ForumProperties getInstance() throws Exception {
try {
if (globalProps == null)
globalProps = new ForumProperties(DEFAULT_FILENAME);
} catch (Exception ex) {
ex.printStackTrace(System.out);
throw new Exception("Error loading properties file");
return globalProps;
}I have put the properties file in just about every directory I can think of to try and find out where it's supposed to be, but I can't get it to work. I can put the file into the "user.home" System property (which turns out to be C:\Documents and Settings\Administrator) and have it pick it up, but I would prefer to put the file into the path of the application.
I have tried four different methods to load this file:
1. load(new FileInputStream(fileName)); (same as above)
2. load(Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName));
3. load(this.getClassLoader().getResourceAsStream(fileName));
4. load(getServletContext().getResourceAsStream(fileName));
All of them fail for not finding the file except #4, but that's not the
optimal solution as it requires a servlet context, which for "genericness of code reasons", I DON'T want to do.
As an aside, I pulled the "java.class.path" from the System properties to see where it's pointing, and all it has in it is
"<CATALINA_HOME>\bin\bootstrap.jar" with no other paths included.
Is there an attribute or something in the server.xml or web.xml file I am forgetting to set, or another approach I should be taking?
Bob
See if this code fragment helps.
String MAIN_FILE_PATH = "./BlueGnome/demos/Properties/DemoPropertiesFile.properties";
java.net.URL url = ClassLoader.getSystemClassLoader().getResource(MAIN_FILE_PATH);
System.out.println("PATH: resolved name = " + url);
// Get the file.
// We could just use FileInputStream here. Then we would have
// to provide a path that was meaningful to the system like
// c:\java\BlueGnome\demos\Properties\DemoPropertiesFile.properties
// Doing it this way allows us to use generic directory
// seperators and allows for it to search for the file using
// the CLASSPATH. That also allows for it to be in a jar file.
java.io.InputStream is;
is = ClassLoader.getSystemClassLoader().getResourceAsStream(MAIN_FILE_PATH);
if (is == null)
throw new Exception("Resource File "
+ MAIN_FILE_PATH + " not found.");
aProperties.load(is);
Similar Messages
-
Application specific properties file
Hello
Can any body help me how to build application specific properties file
so that we can have independent application specific server with its own
java class path environment.I read the procedure in beasys manuals but i
could'nt understand clearly.
Setting application-specific properties
The weblogic.properties file is only accessible by WebLogic; that is,
you can't add application-specific properties to the weblogic.properties
file and expect that they will be read at startup time. However, you can
set properties for your own application by creating a separate
properties file. This file can be created and used in two ways:
Put your application-specific properties file in the same directory as
your weblogic.properties file. You can then use the following code to
access the properties:
Properties props = new Properties();
String propertiesName = "myapp.properties";
T3ServicesDef services =
T3Services.getT3Services();
String location =
services.config().getProperty("weblogic.system.home") +
java.io.File.separator + propertiesName;
props =
props.load(new DataInputStream(new FileInputStream(location)));
Thanks in advance
Ravi
Hi, Ravi.
I think I am "WeiG".
Basically, you can not put your own properties on weblogic.properties. Every
property in weblogic.properties managed by WLAS is pre-registered in WLAS
internally. WLAS will print "Fund undefined property ...." messages for the
un-registered property in weblogic.properties files.
To use your application-specific properties, the paragraph you read suggests
you create your own file, put it in $WL_HOME, and use the example code to
read your own file.
Hope it helps.
Cheers - Wei
Ravi <[email protected]> wrote in message
news:[email protected]...
> Hi Purdy
>
> Who is WeiG,can you tell me please
>
> Thanks
> Ravi
>
> Cameron Purdy wrote:
>
> > I know that WeiG has answered this before ... try to ask Wei directly.
> >
> > --
> >
> > Cameron Purdy
> > http://www.tangosol.com
> >
> > "Ravi" <[email protected]> wrote in message
> > news:[email protected]...
> > > Hello
> > >
> > > Can any body help me how to build application specific properties file
> > > so that we can have independent application specific server with its
own
> > > java class path environment.I read the procedure in beasys manuals but
i
> > > could'nt understand clearly.
> > >
> > > ************************
> > > Setting application-specific properties
> > > The weblogic.properties file is only accessible by WebLogic; that is,
> > > you can't add application-specific properties to the
weblogic.properties
> > > file and expect that they will be read at startup time. However, you
can
> > > set properties for your own application by creating a separate
> > > properties file. This file can be created and used in two ways:
> > >
> > > Put your application-specific properties file in the same directory as
> > > your weblogic.properties file. You can then use the following code to
> > > access the properties:
> > >
> > > Properties props = new Properties();
> > > String propertiesName = "myapp.properties";
> > >
> > > T3ServicesDef services =
> > > T3Services.getT3Services();
> > > String location =
> > > services.config().getProperty("weblogic.system.home") +
> > > java.io.File.separator + propertiesName;
> > > props =
> > > props.load(new DataInputStream(new FileInputStream(location)));
> > >
> > > ****************************
> > >
> > >
> > >
> > >
> > > Thanks in advance
> > > Ravi
> > >
>
-
How to create an application-specific policy file?
Hi Everybody:
I'm a .NET developer with C #. I have a few applications currently running on my computer using the ODP 10.1
Two weeks ago I installed on my computer the ODP 10.2 Release & now my previous applications have stopped working: when I try to make the connection to the database gives me this exception:
OraOLEDB (0x80004005)
ORA-12154: TNS: could not resolve the connect identifier specified
In FAQ section for ODP.NET I found the next:
Q: I have two .NET applications on the same machine running two different versions of ODP.NET. How do I ensure both these applications use the correct ODP.NET version?
A: Beginning with ODP.NET 10.1.0.3, the Oracle installer will register the following publisher policy DLLs in the Global Assembly Cache (GAC) that redirect 9.2, 10.1 and 10.2 ODP.NET applications to use the last installed version of ODP.NET: Policy.9.2.Oracle.DataAccess.dll and Policy.10.1.Oracle.DataAccess.dll.
ODP.NET 9.2 includes just the first policy DLL above. These policy files ensure that all your ODP.NET applications use the most recently installed version of ODP.NET.
You may undo the redirection manually. Policy DLLs can be de-installed through gacutil.exe using the /u option. Another approach is to navigate to the GAC directory (i.e. C:\WINNT\assembly) through the Windows Explorer and delete the policy folders. That will eliminate any policy enforcement for all your ODP.NET applications.
If you have applications on the same machine using different ODP.NET versions, you should create an application-specific policy file.
I'm trying to do that, but I don't know what is an application-specific policy file. Someone can give me an example of How can I create and application-specific policy file???
RegardsHi,
Binding redirection is a ".net thing" as opposed to a "odp.net thing", see if this helps:
http://msdn.microsoft.com/en-us/library/7wd6ex19(VS.71).aspx
Hope it helps,
Greg -
How do I use a MessageSelector with application-specific properties
According to a couple of JMS references (Sun, Oreilly) and the oracle documentation (under the heading "Using Oracle Java Messaging Service (JMS) to Access AQ", page 102 of 1082 , Application Developers Guide - Advanced Queuing, Release 2 (8.1.6))
Standard JMS Features
"Message selection based on message header fields/properties"
Is there a special syntax for using application-specific (user defined) JMS message properties as message selectors in Oracle 8.1.7?
I've tried to create a message selector based on a custom property that I set, i.e. "username != 'William'". (example from O'Reilly JMS book, pg. 44)
I always get a JMS-159: Invalid selector Selector Parse error unless the property is a JMS-Defined property. i.e., " JMSMessageID = 'ID:9789D65E215B3613E034080020B1456E' " works fine.
From the docs and the oter examples, I figure application-specific (user-defined) properties are legal.
Thans for any help in advance.Well I found an article in another forum that states in oracle 8i, message selectors are only supported on JMSCorrelationID and JMSMessageID
(9i will have/has the full JMS spec support for message selectors , or so the response to the message says)
Thanks anyway
(Aricle Is In Products > Database > Oracle Advanced Queueing
Title is JMS AQ: selector in createReceiver does not work) -
How do I use a JMS MessageSelector with application-specific properties
According to a couple of JMS references (Sun, Oreilly) and the oracle documentation (under the heading "Using Oracle Java Messaging Service (JMS) to Access AQ", page 102 of 1082 , Application Developers Guide - Advanced Queuing, Release 2 (8.1.6))
Standard JMS Features
"Message selection based on message header fields/properties"
Is there a special syntax for using application-specific (user defined) JMS message properties as message selectors in Oracle 8.1.7?
I've tried to create a message selector based on a custom property that I set, i.e. "username != 'William'". (example from O'Reilly JMS book, pg. 44)
I always get a JMS-159: Invalid selector Selector Parse error unless the property is a JMS-Defined property. i.e., " JMSMessageID = 'ID:9789D65E215B3613E034080020B1456E' " works fine.
From the docs and the oter examples, I figure application-specific (user-defined) properties are legal.
Thans for any help in advance.Well I found an article in another forum that states in oracle 8i, message selectors are only supported on JMSCorrelationID and JMSMessageID
(9i will have/has the full JMS spec support for message selectors , or so the response to the message says)
Thanks anyway
(Aricle Is In Products > Database > Oracle Advanced Queueing
Title is JMS AQ: selector in createReceiver does not work) -
Application setting - properties files, user settings - Preferences API
HI!
I have 2 rules:
1. All application settings (e.g. debug level, path to resources - icons, images, path to localization resources) I store in properties files.In other words all information that user CAN NOT change I store use a properties files.
2. All user settings (e.g. language, skin and so on) I store with Preferences API. In other words all information that user CAN change I store a use Preferences API.
Is this a good rules?a_subscriber wrote:
HI!
I have 2 rules:
1. All application settings (e.g. debug level, path to resources - icons, images, path to localization resources) I store in properties files.In other words all information that user CAN NOT change I store use a properties files.
2. All user settings (e.g. language, skin and so on) I store with Preferences API. In other words all information that user CAN change I store a use Preferences API.
Is this a good rules?Sounds good. -
Non-application specific static files not visible in shared components
Hello,
We recently upgraded to APEX 4.0.2.00.07. In the past we have uploaded a number of static files with no specific application linked to them.
Now, when I search on these files using Shared Components -> Static Files, I don't find them back.
But, if I directly query the view APEX_WORKSPACE_FILES (using the APEX schema owner), I see all the files. They have APPLICATION_ID = 0 and APPLICATION_NAME is empty.
Is this a bug? I couldn't reproduce this with newly added static files, whether I specify an application or not.
Matthias
Edited by: mhoys on Mar 1, 2011 11:40 AMOwen:
Excellent idea/perspective...I did not think of that. Each of our forms/screens has a seperate class file. Each class file has a CreateForm() routine that is called when an instance of the class is intiated behind the menu selection.
Here is a block of code In Main.vb I use to execute a menu selection:
Case "MPA"
'8/30/07 EJD - Work Order Parameters Screen
If GetFormCount(G_MPAMaint_Form_Type).ToString = "0" Then
Dim MPAForm As New MPA
BubbleEvent = False
Else
UpdateStatus("Another MPA maintenance screen is already open", SAPbouiCOM.BoStatusBarMessageType.smt_Error)
BubbleEvent = False
End If
So, I can utilize this code in the case statement where I was doing the ActivateMenu if I hear you right. Now, can you help me with how I would pass the
variables instead of making them Public Shared in the Main class? Or is it ok to expose them that way?
I Appreciate the help,
Ed -
Hi,
I have a java DC which should be able to read some application properties like
mdm.servername
mdm.repositoryname
mdm.username
I have tried using the ApplicationConfigHandler class in which I created a EAR and Web Module DC and when I run this web module dc as standalone, the properties file "sap.application.global.properties" gets loaded successfully.
But when I call this webmodule Dc's method to load properties from a Java DC , all the properties are null.
Is there any other way that I can load properties in java DC which can be modified without having to redeploy the java dc.
Thanks
MLSHi
Use [configuration services |https://help.sap.com/saphelp_nw04/helpdata/en/b8/aa343e32ff1033e10000000a114084/frameset.htm] in order to created application-specific properties that can be modified at run-time.
Good luck,
Ola -
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 -
WSAD : loading properties file from EBJ project
Hi,
I am trying to load properties file contains database parameters into my EJB project. I am using WSAD as IDE tool
can you please help me with following.
1. where to place the .properties file physically ?
2.how to load the file to my EJB/DAO classes
3.can i use the same location to place log4j.properties file as well ?
I have tried doing in different ways but none is working.
thank you
Narendragot it working , for information pl go to the following page and section "Using log4j in an EJB Application"
i have followd same steps for loading my properties file .
http://sys-con.com/story/?storyid=43413&DE=1 -
Can I programatically read the wls properties file
I'd like to set my own application specific properties in the properties
file and then read them programmatically. Can I do this?
thanks for any help,
Edwin Marcial
http://homepage.beasys.com/denali/classdocs/javadocs/weblogic/common/ConfigServicesDef.html#getProperty(java.lang.String)
Yes, you can programmatically get this information with the help of a t3
client. I am sure there is documentation on the web on how to do this.
-- Prasad
Edwin Marcial wrote:
> I'd like to set my own application specific properties in the properties
> file and then read them programmatically. Can I do this?
>
> thanks for any help,
>
> Edwin Marcial
-
Properties file for a servlet at netbeans
I want to make a servlet to use a properties file. The file name is passed as a initialization parameter. I�m developing with netbeans, where should I put this properties file?
And if I want to deploy this to an independent tomcat server?
Thanks in advance,It's an arbitrary decision by you where you want to put it. If it contains sensitive data, you should consider putting it outside the web root. (Note that if you do that, JAR/WAR/EAR/ZIP, etc. your application, the properties file won't be implicitly included.)
This is where the suggestion for JNDI could be useful, because as far as the app is concerned, it doesn't matter where the properties file is physically located. -
Properties file not deploys the path correctly
Hello,
I am deploying a Web dynpro application with properties file.
One of the properties contains a path that I am later using in my app, something like this:
PATH =
myserver
folder1
folder2
The problem is that after deployment I see this property in the config tool with one backwards slash like this:
PATH = \myserver
older1\folder2\
And I need it with
in my app.
Even after applying a custom value: "
myserver
folder1
folder2
" and clearing the cache it doesn't seem to work.
I know that in java \ states that the char afterwards is special so
realy means \ so I even tried to deploy this : PATH =
myserver
folder1
folder2
but got the same behaviour.
Any idea why is this happening?Hi,
Since you have already tried using four slashes and it didnt work.
I thot putting space in between will give different result.
For me, the four slash option shud have worked.
Ashu -
Setting Application Specific Classpaths
Good afternoon,
I am trying to figure out a way to set classpaths to application specific jar files with several other applications running on the same JVM. Is there a way to do this within the main configuration files?
Thanks,
GaryHi,
in OC4j or Oracle Application Server, orion-web.xml should be the place to look for. You can set multiple occurences of
<classpath path="<path to jar>" />
Frank -
Can't locate .properties file on Visual Admin
Hello,
I have created an RID.properties file inside a DynPro application under src/packages/... and I am able to load it and get it's attributes from the DynPro code.
So far so good...
As far as I know this properties file can be viewd and modifed on the Visual Admin under:
Configuration Adapter -> webdynpro...
I've browsed all the folders at this location and couldn't locate my .properties file. So where is it...?
Royi think you only want to access and maintain the properties on server side...
ok, check out
http://help.sap.com/saphelp_nw04/helpdata/en/b8/aa343e32ff1033e10000000a114084/content.htm
for an example how to access the properties from your wdp app.
i suggest loading all props into a specific context node and corresponding attributes. perhaps there are better ways.
Now sth. uncomfortable:
Be careful when you redeploy your app. All properties are overwritten with the ones you defined locally.
you also cant delete the config on local side, it would be deleted on server, too. (at least i think so)
Maybe you are looking for
-
Music app won't sort albums by artist
On my iPad 3rd Gen, after the 8.0 update, the "Group By Album Artist" check box in the Settings no longer works. It used to group the albums in the Music app by the associated Artist, but now it just alphabetizes them regardless of the artist. I've
-
Error Warning MSG in Process Chain
Hi PPl, I created a PC which loads from APO into ODS and then into an INFOCUBE. But when i check the PC it says the following error msg. A type "Update ODS Object Data (Further Update)" process cannot precede process "Execute InfoPackage" var.
-
Reg: Layout size & position
Dear All, iam very new to development of Adobe PDF forms i had encountered with one issue while setting the size of master page in CM by default its resetting it to INCHES give me proper input to change from INCHES to CM Highly Appreciated Regards Ja
-
Why is Firefox updated so often - can't get the software right first time?
I don't see improvements but it updates so frequently.
-
hi all, We use Service now as out IT Support tool, which is web based an uses frames and I want to use it from my iPad (3). Apparently the two finger gesture to scroll down lists the frames doesn't work in this tool - at least it doesn't for me. Doe