Specify a property file inside a ear file

Hi guys I have this myApplication.ear file.
All the project inside the ear file are using myProperties.properties file.
I have been told that this property file has to be inside the ear file.In websphere 7.0 ,the administrator will specify a jvm classpath like /webAS/installedApps/myApplication.ear/myProperties.properties.During runtime my code will find the property file using this class path
I am using RAD 7.5 to generate the ear file.Can some one tell me how to achieve this.Basically my ear file has to be bundled with the property file.
thanks
m

You might get better results from a RAD forum if you a havent already figured out your issue.

Similar Messages

  • Property (config) files inside an EAR

    I would like to deploy the configuration files for my application inside an EAR
    file so I do not have to modify the classpath for my server (WLS 8.1 sp2).
    My quesion is can I make all the property files available to all the EAR components
    (WAR and JAR) by putting them somewhere in the EAR or do they need to be on the
    class path?

    They don't need to be in the classpath.
    If you're on 8.1, then placing the properties file in the
    APP-INF/classes directory would make it accessible for anything in the
    EAR. I'd probably use an ApplicationLifecycleListener to read it when
    the app deployed.
    If you're using < 8.1, I'd use either a ServletContextListener or a
    load-on-startup servlet in a "fake" webapp to read the file.
    Let me know if you need more details.
    -- Rob
    Pete wrote:
    I would like to deploy the configuration files for my application inside an EAR
    file so I do not have to modify the classpath for my server (WLS 8.1 sp2).
    My quesion is can I make all the property files available to all the EAR components
    (WAR and JAR) by putting them somewhere in the EAR or do they need to be on the
    class path?

  • Changing values in property file inside a jar in an ear

    Hi,
    I have an application that contains EJB. The environment values needed for initial context of the ejb is kept in a .properties file. I have created an ear of the application. Inside the ear there is a jar which contains the .properties file. I need to deploy the ear to different environments. However before deploying I need some kind of script to change the values in the .properties file inside the jar in the ear.
    Can anyone provide some help/pointers about how can I achieve it (Using ANT/WLST)

    WLST does not have any capability to update a JAR.
    WLS 10.3 (still in tech preview) has the ability to override properties
    files inside the jar with an external properties file. This would allow you
    to deploy the same ear to different environments, and then only deploy a
    different properties file in the plan directory.
    <Rishi Shah> wrote in message news:[email protected]..
    Hi,
    I have an application that contains EJB. The environment values needed for
    initial context of the ejb is kept in a .properties file. I have created an
    ear of the application. Inside the ear there is a jar which contains the
    .properties file. I need to deploy the ear to different environments.
    However before deploying I need some kind of script to change the values in
    the .properties file inside the jar in the ear.
    Can anyone provide some help/pointers about how can I achieve it (Using
    ANT/WLST)

  • How to include a property file in ear

    I have a weblogic integration application inside which I have created java control project and processes. I am packaging the entire application using ant script (wlwBuild).
    My requirement is to include a text file inside this ear and access it from any of the java classes inside the java control project.
    Is there any way to do that?

    You can add a java project in the workshop. In that java project you can have properties files, XML files or any other file.
    These files get boundled with the application EAR and you can access them as if they are available in your classpath.
    Hope that answers your question.

  • Session sharing among multiple WAR files inside an EAR file

    Hi all,
    Is there a way where I can share my session object among multiple WAR files which are inside an EAR file?
    Please suggest.

    r035198x wrote:
    Some application servers (like Weblogic) allow to configure session sharing when you deploy the application.Sidenote: which is completely against the servlet spec.

  • Property file should be externalize and outside the archive (say ear) ?

    My team architect is suggesting me to externalize the property files like locale resources (e.g messages.en.properties ), log4j (e.g log.properties) etc .The reason is to avoid recompiling incase of changes to this resources.
    Example tomorrow if something goes wrong in production and we want to enable the debug log,then we can change the property file ,restart the server and we are good.If it was inside the archive file we have to create a brand new
    a brand new archive file ,redeploy it and restart the server again.
    In my entire work experience I never externalized this resources because they are inherent part of the archive file.Hence any changes then recreate the archive file and redeploy.
    The team architect might have some good reason.
    Please advice.
    Thanks
    m

    Manjit wrote:
    My team architect is suggesting me to externalize the property files like locale resources (e.g messages.en.properties ), log4j (e.g log.properties) etc .The reason is to avoid recompiling incase of changes to this resources.
    Example tomorrow if something goes wrong in production and we want to enable the debug log,then we can change the property file ,restart the server and we are good.If it was inside the archive file we have to create a brand new
    a brand new archive file ,redeploy it and restart the server again.
    In my entire work experience I never externalized this resources because they are inherent part of the archive file.Hence any changes then recreate the archive file and redeploy.
    The team architect might have some good reason.
    Please advice.
    Thanks
    mIf the major hurdle is changing log levels dynamically..you could look at http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PropertyConfigurator.html#configureAndWatch%28java.lang.String%29

  • Accessing the text/property file inside the root context

    Hi
              I want to access the property file lying inside the root context folder
              via plain java classes using IO.
              Could you please help me out.

    Hi
    Using this.getClass().getClassLoader().getResource("config_settings");
    In order to load the properties file, uses the classpath search mechnism.
    Basically it means that java will look for your file in the classpath.
    The defualt class path of a web server is usualy the following:
    ContextName/Web-Inf/Classes;ContextName/Web-Inf/lib
    This is why it is working for you when you put your properties file under ContextName/Web-Inf/Classes, but it doesnt work when it is under ContextName/*, as this is not a part of the classpath search.
    You have 3 options:
    1.Put you properties file under the sever defulat classpath
    (ContextName/Web-Inf/Classes;ContextName/Web-Inf/lib,if it's under lib, the file has to be inside a jar file)
    2.Add ContextName/* to your server classpath ( in tomcat->setClasspath.bat file )
    3.Instead of using "this.getClass().getClassLoader().getResource("config_settings"
    read your file directly using the java.io.* library and give it the full path to the file,
    you can store the full path in web.xml file, or using getServletContext().getRealPath("") to locate the context path and read the file from there( but then you are using the Servlet API )
    Hope it helps
    all the best
    tal

  • Specifying property file name for ant tasks

    How can I make the ant tasks look at a properties file other than
    kodo.properties?
    Thanks,
    Tom

    Tom,
    You can specify a properties file like so:
         <schematool ...>
              <config properties="my.properties"/>
         </schematool>
    -Patrick
    Tom Davies wrote:
    How can I make the ant tasks look at a properties file other than
    kodo.properties?
    Thanks,
    Tom
    Patrick Linskey [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • What are Best Practice Recommendations for Java EE 7 Property File Configuration?

    Where does application configuration belong in modern Java EE applications? What best practice(s) recommendations do people have?
    By application configuration, I mean settings like connectivity settings to services on other boxes, including external ones (e.g. Twitter and our internal Cassandra servers...for things such as hostnames, credentials, retry attempts) as well as those relating business logic (things that one might be tempted to store as constants in classes, e.g. days for something to expire, etc).
    Assumptions:
    We are deploying to a Java EE 7 server (Wildfly 8.1) using a single EAR file, which contains multiple wars and one ejb-jar.
    We will be deploying to a variety of environments: Unit testing, local dev installs, cloud based infrastructure for UAT, Stress testing and Production environments. **Many of  our properties will vary with each of these environments.**
    We are not opposed to coupling property configuration to a DI framework if that is the best practice people recommend.
    All of this is for new development, so we don't have to comply with legacy requirements or restrictions. We're very focused on the current, modern best practices.
    Does configuration belong inside or outside of an EAR?
    If outside of an EAR, where and how best to reliably access them?
    If inside of an EAR we can store it anywhere in the classpath to ease access during execution. But we'd have to re-assemble (and maybe re-build) with each configuration change. And since we'll have multiple environments, we'd need a means to differentiate the files within the EAR. I see two options here:
    Utilize expected file names (e.g. cassandra.properties) and then build multiple environment specific EARs (eg. appxyz-PROD.ear).
    Build one EAR (eg. appxyz.ear) and put all of our various environment configuration files inside it, appending an environment variable to each config file name (eg cassandra-PROD.properties). And of course adding an environment variable (to the vm or otherwise), so that the code will know which file to pickup.
    What are the best practices people can recommend for solving this common challenge?
    Thanks.

    HI Bob,
    As sometimes when you create a model using a local wsdl file then instead of refering to URL mentioned in wsdl file it refers to say, "C:\temp" folder from where you picked up that file. you can check target address of logical port. Due to this when you deploy application on server it try to search it in "c:\temp" path instead of it path specified at soap:address location in wsdl file.
    Best way is  re-import your Adaptive Web Services model using the URL specified in wsdl file as soap:address location.
    like http://<IP>:<PORT>/XISOAPAdapter/MessageServlet?channel<xirequest>
    or you can ask you XI developer to give url for webservice and username password of server

  • Error while reading a property file from a war.

    Hi,
    I am trying to read a property file which is available in the properties folder.
    The piece of code that does this read is as follows.
    InputStream is = ClassLoader.getSystemResourceAsStream("codemap.properties");
    System.out.println("Reading file:"+is);
    properties.load(is);
    The "codemap.properties" file is available in the properties folder.
    Following is my directory structure in the war file
    sample.war
    |
    |
    WEB-INF
    |
    |
    classes
    |
    |
    properties
    |
    |______ codemap.properties
    Inside the war file I have WEB-INF and properties folder.
    Inside WEB-INF i have the classes folder which has the classes
    Inside the properties folder I have the codemap.properties file.
    I am using Jboss. In the class path I have ./properties
    I have also added this classpath in the manifest file.
    Problem: The piece of code that I have written to read the property file is not able to locate the file and this it returns null.
    I am not sure what i am missing here.
    If anyone there have any solutions please let me know.
    Thanks in Advance
    Balaji.

    I think you've to change this line
    InputStream is = ClassLoader.getSystemResourceAsStream("codemap.properties");with this.
    InputStream is = ClassLoader.getSystemResourceAsStream("properties/codemap.properties");it is unable to find the path you specified. by default it'll check the WEB-INF directory. so you've to give the relative path to it.
    Diablo

  • Where to put property files used by XSLT extensions?

    Still fighting with Java XSLT extensions. I have narrowed the
    problem down: my XSLT extension cannot find its property file,
    which I use to store JDBC connect strings etc.
    What is the proper directory to put this file so the XSLT
    extension class can find it? I am using Oracle HTTP Server with
    XDK 9.0.

    Thanks for the answer, Steve!
    Depends on what call you're using in your extension function to
    read your properties.Maybe I tried a too simplistic approach. I'm just using this:
    Properties props = new Properties();
    try {
    props.load(new FileInputStream("/foo.properties"));
    etc.
    This (with the slash) works if the properties file is in the root
    directory of the filesystem, but it's a kludge.
    If you read your properties as a resource using
    getResourceAsStream(), then where the classloader expects to
    find your file depends on the resource name that you specify.So maybe I should use getResourceAsStream() then? What if I put
    the properties file inside the JAR with the extension classes?
    Or is there any way to reference the web root?
    --Jere

  • Character '\' is lost when reading a String from a property file.

    Hi all,
    I have encrypted information inside a property file, but when loading properties in my program, the String object used to store the value is changed by the lost of all �\� characters
    # EIS password saved in the property file
    password=WPLqQE0DlVF8Sg\=\=
    #Value loaded in my String object
    WPLqQE0DlVF8Sg==
    Why is this happening? I use java.util.Properties java class to store and load my properties, and it is supposed to do it with the same encoding (ISO 8859-1).
    Please, can someone explain me why this happened and how to solve it?
    Best regards.

          public static void main(String[] args) throws IOException {
               OutputStream props = new FileOutputStream("test.properties");
               Properties p = new Properties();
               p.put("password", "pass=word#is!dumb");
               p.put("user", "    I am a Dummy");
               p.store(props, "Java forum demo props file");
               props.close();
               /* Properties file after store
                * user=\    I am a Dummy
                * password=pass\=word\#is\!dumb
               Properties post = new Properties();
               post.load(new FileInputStream("test.properties"));
               for(Iterator it = post.entrySet().iterator(); it.hasNext();)
                System.out.println(it.next());
                * After load from test.properties
                * user=    I am a Dummy
                * password=pass=word#is!dumb
          }Notice that the special chars are only in the file, not actually in the props. If you think otherwise, I don't know what to say. The \ is a special character that is used to escape other special chars, including itself. You can't create a string in java containing only one backslash, as java assumes the next char is being escaped. when you create a string in Java with one backslash, you have to have 2 backslashes. If you are storing data in the property file using something other than store, than you need to ensure that you are escaping all special charachters that the store method does
    ~Tim

  • How to find my own property file in a war in soloaris

    Hi, there;
    I have a question whcih bothers me quite long. I packaged a property file in a
    war file and use console to uploaded. I can access to the servlet through browser
    and the servlet reference another class which looks like
    try {
    InputStream is = getClass().getResourceAsStream "/data_ctrmw.properties");
    error +="InputStream property file 1nd try: "+is;
    if(is==null){
    is = getClass().getResourceAsStream("data_ctrmw.properties");
    System.err.println("data_ctrmw.properties found! ");
    error +=" InputStream property file 2nd try: "+is;
    Same code works on windows wls6.1, but not on soloris machine.
    One other question:
    How can I write out to a log file? I am unable to write out to a log file.
    Thanks a lot

    Sorry;
    Yesterday, I finally found that my web.xml had an error. I didn't define .properties
    as MIME extension type. I change property file type to .txt and put in MIME type.
    It works!
    Thanks
    "raymond" <[email protected]> wrote:
    >
    Hi, Chala;
    Thanks for your good suggestion. However, it seems still not working,
    I also tried
    getResourceAsStream("/") trying to find from app context root. By the
    way, in
    this function, the arg is
    String path, right now, I am just add the param-name element in web.xml
    for a
    specific servlet. But actuall, I want the properties to be exposed to
    the application.
    Also, I tried context-param element in web.xml, it even can't be uploaded
    to jrun
    or weblogic.
    I guess, it might be possible to warp it in an .ear file and put these
    in sth
    like application.xml
    Any suggestion?
    Thanks lot
    "Arjuna Chala" <[email protected]> wrote:
    Have you tried using
    ServletConfig.getServletContext().getResourceAsStream().
    "raymond" <[email protected]> wrote in message
    news:3c5f0b20$[email protected]..
    Hi, there;
    I have a question whcih bothers me quite long. I packaged a propertyfile
    in a
    war file and use console to uploaded. I can access to the servlet
    through
    browser
    and the servlet reference another class which looks like
    try {
    InputStream is = getClass().getResourceAsStream"/data_ctrmw.properties");
    error +="InputStream property file 1nd try: "+is;
    if(is==null){
    is = getClass().getResourceAsStream("data_ctrmw.properties");
    System.err.println("data_ctrmw.properties found! ");
    error +=" InputStream property file 2nd try: "+is;
    Same code works on windows wls6.1, but not on soloris machine.
    One other question:
    How can I write out to a log file? I am unable to write out to a logfile.
    Thanks a lot

  • Property file usage help please !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1

    hi there
    i need some help on using property file, please. i have a package that contains many directories and classes. in one the directory, there is a property file: properties. and some of the classes need to access information in the file. how can i use ResourceBundle or Property objects to read the file? this is my guessing :
    //code....................................
    ResourceBundle.getBundle("D:\\tomc\\wowExchangeProject\\soaptest\\src\\com\\wowgao\\uddi\\db\\properties.properties").getString("implementation");
    and:
    //code....................................
    File f=new File( configFile );
    if( f.exists()) {
    Properties props=new Properties();
    props.load( new FileInputStream(f));
    DBClassName = props.getProperty("implementation");
    i must use absolute path for the file. what if i need to distribute the package on other machine that does not have D drive. how can change it so that i can deploy it on any machine? thanks

    hi there
    i need some help on using property file, please. i
    have a package that contains many directories and
    classes. in one the directory, there is a property
    file: properties. and some of the classes need to
    access information in the file. how can i use
    ResourceBundle or Property objects to read the file?
    this is my guessing :
    //code....................................
    ResourceBundle.getBundle("D:\\tomc\\wowExchangeProject\
    soaptest\\src\\com\\wowgao\\uddi\\db\\properties.proper
    ies").getString("implementation");
    and:
    //code....................................
    File f=new File( configFile );
    if( f.exists()) {
    Properties props=new Properties();
    props.load( new FileInputStream(f));
    DBClassName =
    ame = props.getProperty("implementation");
    i must use absolute path for the file. what if i need
    to distribute the package on other machine that does
    not have D drive. how can change it so that i can
    deploy it on any machine? thanksHi!
    Let�s say you have the following structure:
    - com/props/props.properties
    You can use any class inside the classloader that loaded this package to do the following:
    InputStrean in = <classname>.class.getResourceAsStream("/com/props/props.properties");
    Properties props = new Properties();
    props.load(in);
    Hope this can help you. Any doubts just ask!
    MSB

  • How to read values from Property file into BPEL process local variable?

    I would like to use a Property file with some parameters e.g.
    <myparm1>12345</myparm1>
    How can I read from a BPEL process such a Property file and assign it into e.g. local variable "intparm1"?
    Where (in which directory) should I put this XML Property file to have it always available for reading?
    Peter

    Hi,
    You can also use
    ora:readFile( ) function as follow :
    ora:readFile(xml file location (ex. "file:///D:\\SOA\\FileAdapters\\readFile\\test\\test.xml"),xsd file location (ex."file:///D:\\SOA\\FileAdapters\\readFile\\test\\test.xsd"))
    inside the assign activity and assign this to the variable you want.
    regards
    arababah
    Edited by: arababah on Aug 10, 2009 12:55 AM

Maybe you are looking for