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)

Similar Messages

  • Extracting and updating files inside a JAR file... from my code

    Hi.
    I need some help in the following:
    from my code, I need to search a JAR file, open it, unzipped it, then I need to search a xml and property files inside the JAR, after that I need to modify the files and finally, my code has to save the changes and update the JAR file. All that must be from my java code.
    How can I do that? I am trying to use Runtime.getRunTime().exec().... but I am not sure that it works. Besides, I don�t know what command to include in the exec() method. Is there any way to do that?
    Thanks

    The normal reason I see for this requirement is that people want to update a properties or data file. The approach I use it that I first look for the data file in a well defined location and if I find it I use it and update it as required. If I don't fine it I create it base on a template file read from the jar file using getResourceAsSrream().
    In this way I never have to update the jar file.

  • How to read and update the value of property file

    Hi,
    I am not able read the values from property file.
    Please tell me how to read and update the values from property file using Properties class
    This is my property file : - Config.properties its located in D:\newfolder
    Values
    SMTP = localhost
    Now i need to change the value of the SMTP
    New value :
    SMTP =10.60.1.9
    Pls Help me
    Thanks
    Merlin Rosina,

    Post a small (<1 page) example program that forum members can copy and run that demonstrates your problem.

  • Running a batch file inside a jar

    HI all
    I created a jar file , in which i need to run a batch file , so i wrote a main class to execute the run the batch file , but when iam running the jar it is searching for the given batch file out side the jar.
    my code is some thing like below
         public static void main(String args[])
              try
                   Runtime rt=Runtime.getRuntime();
                   Process process=rt.exec("%DIRNAME%/start.bat");
       InputStreamReader reader =
                      new InputStreamReader ( process.getInputStream () );
                   BufferedReader buf_reader =
                       new BufferedReader (  reader );
                    String line;
                    while ((line = buf_reader.readLine ()) != null)
                                 System.out.println (line);
              catch (IOException e) {
                    System.out.println (e);
         }so please help me.. is it the problem in specifing the path...?
    are does it have any other method to read the stream functions ..
    thanks in advance
    sam

    I don't think this will work. You could not go to a command line and enter, "%DIRNAME%/start.bat" if start.bat was inside a jar - the CLI doesn't know how to read a batch file inside a jar.
    I think it would work to programmatically read the lines of start.bat (when it is inside the jar) into an array of Strings and use Runtime.exec with the array as the argument.
    It would also work to extract the start.bat file, then execute it using Runtime.exec.

  • Java Files inside the jar file cannot be read or accessed through Eclpse

    The Java File inside the jar file of the eclipse cannot be accessed through the Eclipse . It shows error for the modules in the jar file .
    But when compiled with adding the jar files to the class path the compilation is successful .
    How can i browse through the files in the jar like going into the function definition .
    TIA ,
    Imran

    Open MPlayer OSX and show the playlist (command-shift-p) then drag the file into the playlist. Click the file in the playlist and click the "i"nfo button. What does it list for file, video and audio format?
    Not all of the codecs used in avi and wmv files are available for OS X so I'm guessing your file happens to be using one that isn't...

  • I am having Html help files inside my Jar file

    Dear Friends;
    i am having Html help files inside my Jar file.
    how will open the html file using Java Help.
    Thank u

    http://java.sun.com/products/javahelp/reference/docs/index.html

  • How to read some files inside the jar

    Hi,
    I have an applet that runs with JWS. The user can input some information and then I need to show this information in a web page. As the application can be run offline, I cannnot use JSP�s to generate the web page. The information is saved in a xml file, so I use a xsl parser to generate the html code. The problem is that I have to include some javascript files (.js). I put these files inside the jar, but, how can I read these files, or how can I reference these files from inside the html page ?
    Thanks !

    You can use getClass().getResource(classpath)
    to get a stream version of the data from your
    jar file. If you need to put it in a file, you
    can write that stream to a file in a temp directory.
    classpath is the classpath of your js file

  • How to read, write file inside the JAR file?

    Hi all,
    I want to read the file inside the jar file, use following method:
    File file = new File("filename");
    It works if not in JAR file, but it doesn't work if it's in a JAR file.
    I found someone had the same problem, but no reply.
    http://forum.java.sun.com/thread.jsp?forum=22&thread=180618
    Can you help me ? I have tried this for all night !
    Thanks in advance
    Leo

    If you want to read a file from the JAR file that the
    application is packaged in (rather than a separate
    external JAR file) you do it like this ...
    InputStream is =
    ClassLoader.getSystemResourceAsStream("filename");Better to use
    this.getClass().getClassLoader().getResourceAsStream();
    From a class near to where the data is. This deals with multiple classloaders properly.

  • Confused about "files inside a JAR"

    I have a program that has a Properties file which I would like to "save" into the JAR file, so it is not outside the JAR.
    I know this can be done, because I've seen some Java programs that save their configuration between sessions, but not via a file inside its directory. This leads me to believe the file is maintained within the JAR itself, which would be REALLY handy and secure.
    Is this a correct assumption? If so, how would I do it? Here's a "test program" that we can play with, how would I save MyProperties' properties field into the MyProgram JAR?
    package SBX;
    import java.util.*;
    import java.io.*;
    public class MyProgram {
        // Instance Variables
        public MyProperties myProp = new MyProperties();
        public String stringOne = "Will this be loaded?";
        public String stringTwo = "How about this one?";
        // Main Method
        public static void main(String[] args) {
            new MyProgram();
        // Constructors
        public MyProgram() {
            if ((new File("properties.txt")).exists()) {
                myProp.updateProgram(this);
            System.out.println("1) " + stringOne);
            System.out.println("2) " + stringTwo);
            myProp.updateProgram(this);
            System.out.println("3) " + stringOne);
            System.out.println("4) " + stringTwo);
            myProp.updateProperties(this);
            // Now that we've "updated" stringOne & stringTwo and "updated" myProp and saved it,
            // we should be able to get the values "ONE" and "TWO" for print outs 1 & 2 when we next
            // run the program, instead of "Will this be loaded?" and "How about this one?", as we got during the first run.
            // However, the thing I need help with is saving the Properties to the JAR file so it's not accessable
            // outside of the JAR file. How can this be done?
    class MyProperties {
        // Instance Variables
        private Properties properties;
        // Constructors
        public MyProperties() {
            Properties defaults = new Properties();
            defaults.setProperty("stringOne", "ONE");
            defaults.setProperty("stringTwo", "TWO");
            properties = new Properties(defaults);
            try {
                FileInputStream fis = new FileInputStream("properties.txt");
                properties.load(fis);
                fis.close();
            catch (Exception e) {
                System.out.println("No properties file found, ignore this; one will be saved when the program exits.");
        // Methods
        public void updateProgram(MyProgram prg) {
            prg.stringOne = properties.getProperty("stringOne");
            prg.stringTwo = properties.getProperty("stringTwo");
        public void updateProperties(MyProgram prg) {
            properties.setProperty("stringOne", prg.stringOne);
            properties.setProperty("stringTwo", prg.stringTwo);
            try {
                FileOutputStream fos = new FileOutputStream("properties.txt");
                properties.store(fos, "A header");
                fos.close();
            catch (Exception e) {
                e.printStackTrace();
    }Thanks for any help!
    PS...writing demo programs is kind of fun :)

    Fossie,
    Yup... you can jar up your properties file... you just need to add it to manifest file and jar (the program) takes care of the rest... google that there's loads of existing articles.
    BUT, I don't think you can modify the properties file in the jar... it may be possible, but I just don't know how. Instead (I think) you ship your default properties file in the jar, but still save a local properties file to the same directory as the jar (obviously won't work for applets)... then you load your defaults, and the local settings over the top.
    and PS I don't see how sticking a properties file in the jar would "secure" it in any fashion... it's just a zip file after all... would you care to elaborate?
    Cheers,
    Keith.

  • Updating an XML file inside the Jar executable

    Hello all!
    I would like to ask how can i update an XML file that is packaged inside my jar file?
    For intstance:
    I have a Java Application in NetBeans
    Inside a package i have constructed a custom .xml file.
    I can read from this file using
    .....getClass().getResourceAsStream("/.../file.xml")and after that using XPath for querying and works fine.
    I want to update an entry in my xml file so the jar contains now the newly updated file.
    Thanks everyone who spends his time to read this. Hope someone can help me.

    Even if it were possible, it would be a bad idea. A jar file is something you deploy. It can be really hard to manage ongoing maintenance if the thing you deploy changes after you've deployed it.
    Just create a file, in an appropriate place given the user's OS, to hold data that changes after the jar has been deployed. Your application will still be in a single jar; it's just that the application will happen to create additional content outside the jar.

  • 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

  • Unable to load classes from jar files inside APP-INF/lib in EAR.

    Weblogic version: 10.3.3
    Platform: Linux x86-64 bit
    We deployed an ear packaged with all the common library jars inside APP-INF/lib. Deployment was successful.
    for some reason, it is always giving ClassNotFoundException for the classes inside the jars. This does not happen
    in 10.3.2 version of weblogic.
    We tried to add them to domain/lib directory (instead of APP-INF/lib) but still it is not able to resolve the classes.
    Any pointers would be appreciated.

    try using prefer-web-inf-classes in the weblogic.xml file in your WAR file
    or using prefer-application-packages in the weblogic-application.xml file in your EAR.

  • 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

  • Can I place jar files inside ejb-jar.jar?

    Hi,
    I'm reading about the packaging rules for creating an ejb-jar.jar file, and I'm wondering whether it's possible to include a jar file (containing helper classes) inside of the ejb-jar file. A "lib" dir (for containing such helper jars) doesn't seem to be part of the ejb-jar file format.
    The EJB 3 spec has this to say (Ch 20, "Enterprise JavaBeans 3.0, Final Release):
    "The ejb-jar file must also contain, either by inclusion or by reference, the class files for all the classes and interfaces that each enterprise bean class and the home interfaces, component interfaces, and/or web service endpoints depend on, except Java EE and J2SE classes. This includes their superclasses and superinterfaces, dependent classes, and the classes and interfaces used as method parameters, results, and exceptions"
    Now, it seems that the root of the the ejb-jar file contains all the classes (in the appropriate Java package layout). But what about including JAR files? The ejb-jar spec seems to have nothing to say about a "lib" dir that can contain jars (as a WAR file can).
    Summary of questions:
    1) Can an ejb-jar file contain a jar file? If so, how/where?
    2) Can the ejb-jar file's META-INF/MANIFEST.MF file contain a reference to a JAR file?
    I'm not considering correct design at the point... I'd just like to know if these 2 scenarios are possible.
    Thank you!
    kamuifx

    Yes, I have an ear file..................
    I have an EAR file; inside the EAR I have a WAR file (web module) and an EJB-jar file (EJB module).......... the EJB need some classes placed in a jar file (a helper .jar or an util .jar)...........
    my question is: How can I use the classes of the .jar files in te EJB??????
    thanks

  • Include and call an .exe file inside my jar file

    Hi.
    I want to include an exe file and call it inside my jar file. this is the code.
    InputStream is = getClass().getResourceAsStream("/native/my.exe");
              int[] line = new int[is.available()];
              File myFile = File.createTempFile("my","exe");
              myFile.deleteOnExit();
              myFile.setExecutable(true);
              FileOutputStream out = new FileOutputStream(myFile.getAbsolutePath());
              int i = 0;
              int c;
              while((c=is.read()) != -1){
                   line=c;
                   i++;
              is.close();
              for(int j= 0;j<line.length;j++)
                   out.write(line[j]);
              out.close();
    So i store it in my temp folder. Than i run
    String myFileLocation = myFile.getAbsolutePath();
    p = rt.exec(myFileLocation);
    Everything goes fine, but the behaviour of the .exe file is not the same. I mean when i run the commands
    PrintWriter writer = new PrintWriter(p.getoutputStream());
    writer.println("command");
    the behaviour is not the same. What goes wrong.

    But to load the xml file I need to create a File objectIf this is true then you will not be able to load the XML file, since a jar entry is not a File object and cannot be represented as one.
    However if you get rid of whatever it is that loads your XML file and replace it by more standard JAXP processing, you should be able to parse an InputStream that reads from the jar entry. You know how to get that so it should not be a problem.

Maybe you are looking for

  • How to change preferences for all users in a Citrix enviroment

    Hello. I need change some preference settings for all users in my Citrix enviroment. I know change the preference settings for a user, of course, but a have 160 users and a need to change some settings configuration one time on the server for all use

  • Finder 'item info' in icon view missing

    For about the last month of so (possibly since the last update, but I didn't notice it right away, so I won't swear to this) my Finder stopped showing 'item info' in icon view, but only for images. So say I have a folder full of images, and I open it

  • Can't stop "Start new clip at each scene break"

    I have gone to Preferences/import and unchecked the box TWICE, yet when I start importing it invariably ends the clip at 19:54:06 then stops importing. If I click IMPORT again, it brings in another 19:54:06. What do i have to do so it will import wit

  • Make-To-Stock

    Hi, Could u anyone explain what is MTS? What is the Process? What is the Sales Order Type to be used? How it can be configured in the System? Regards, Gnanadoss

  • ICloud restore help!

    I recently had to remove Pages from my iPad and add it back on. Before I deleted the app, I saved all my work to my iCloud on my iPad. It shows in iCloud I have the data there. How do I restore it to my Pages App so I can see the documents again? Eve