How can i locate the properties files within a ejb container?

when i develop servlet+javabean structure application,in order to imploement decoupling,i
would like to write the config information in the properties files(key-value pair),in
servlet,i use "getResourceAsStream(String relativePath)" method to retrieve the
configuration information from the properties files(i even write the SQL clause
in the files),it alwsys works well.
now,i want to implement such function within the ejb container,that is to read
a properties file from session bean,but i don't know how can i locate the file
within the ejb container by using relative path,i wonder if there is the same
method within ejb container as "getResourceAsStream(.......)" method within servlet
container?
thanks for any helps!
the code snippet is appreciated!

In general, you should look at using environment entries (variables) in the
deployment descriptors (both the war and EJB jar rather than properties
files for configuring J2EE applications. The reasons for this are many:
1. This is the official way to do it according to the spec. Properties
files are the J2SE way of doing things
2. As you note, that it's not obvious how you would (legally) read a
properties file inside an EJB.
3. It's consistent between the web and EJB part of your code
4. the weblogic console and tools have good capabilities to edit these
fields.
Kent
"zhebincong" <[email protected]> wrote in message
news:[email protected]..
>
when i develop servlet+javabean structure application,in order toimploement decoupling,i
would like to write the config information in the propertiesfiles(key-value pair),in
servlet,i use "getResourceAsStream(String relativePath)" method toretrieve the
configuration information from the properties files(i even write the SQLclause
in the files),it alwsys works well.
now,i want to implement such function within the ejb container,that is toread
a properties file from session bean,but i don't know how can i locate thefile
within the ejb container by using relative path,i wonder if there is thesame
method within ejb container as "getResourceAsStream(.......)" methodwithin servlet
container?
thanks for any helps!
the code snippet is appreciated!

Similar Messages

  • How can i locate the resource file in the weblogic?

    hello
    in struts, i can leave some parameter in a resource file (such as "Application.properties")outside of my code,and get them in the "Action" class by the "getResource" method.
    in my data access tier,i still want to use such a machanism but i can't use the "getResource()" method,for example,there is a ConnectionPool class,i want to read some parameters from a resource file ("param.properties") that is under the same directory as the ConnectionPool class,the following is the code snippet:
    public static void init(DataSource ds){
    myself=new ConnectionPool(ds);
    java.util.Properties prop=new java.util.Properties();
    try{
    java.io.FileInputStream fin=new java.io.FileInputStream("./param.properties");
    prop.load(fin);
    }catch(Exception e){
    e.printStackTrace();
    System.out.println(prop.get("help.create"));
    the "ConnectionPool" class is in the "com.jhtop.task.forum.db.util" package,the "param.properties" is in the same package (com.jhtop.task.forum.db.util),
    but when i execute the program,it tell me that it can't find the file.if i use the absolute path,it works.
    i wonder how can i locate the file path in the weblogic,or what's my current path,or how may i setup my work directory?
    in tomcat,my current directory is bin directory,how about weblogic?
    who can help me?thank you!

    My english is bad and I'm not sure I've well understood your problem.
    How have you created your file ?
    Why do you put it in such a directory and not an other ?

  • How can we locate the property file and read from it in .js page?

    HI
    I am having an static html page where in the url is hardcoded,so i wanted to read it from a property file and which can be done by using .js files
    i wanted to know how to deal with property files in .js?
    Thankx

    I assume you know that Java and JavaScript only share a name and they are both programming languages but little else.
    You can load JavaScript in Java 6. However for questions on what the JavaScript should do I suggest you try a javascript forum.

  • How can I access the properties of Microsoft files (excel, ppt, and word)

    Hi,
    How can I access the properties of common Microsoft file formats (Excel, Word, and Powerpoint) from a Java program. You can access/modify the properties of each document type using File->Properties in each MS application. The properties are essentially name/value pairs.
    Basically, I need to write a java program that scans a directory and accesses the properties in each of the MS files in the directory.
    thanks,
    -john

    By api. That is only way to establish a contract with the MS programs you want to interface with, unless you write an api yourself! I've used POI and it was an awesome way to use Excel in java. I created an excel spreadsheet from the results of a sql query from a batch program and then it was automatically emailed using javamail to my client. I had a lot of VBA experience with Excel, Word, and Outlook and it didn't take me long to get used to using Jakarta-POI.
    Now I see there is Jakarta-POI-HWPF which works with MS Word documents. Go to: http://jakarta.apache.org/poi/

  • I have downloaded a music file through a downloader . But the file is not found in the captured in music player . How can I locate the physical location and move the file . I cannot do via itunes also .

    I have downloaded a music file through a downloader . But the file is not found in the captured in music player . How can I locate the physical location and move the file . I cannot do via itunes also .

    Exactly what do you mean by a 'downloader'?
    Thanks
    Pete

  • How can I locate the file /Library/Keychains/FileVaultMaster.cer to reset my master password? Thanks!

    How can I locate the file /Library/Keychains/FileVaultMaster.cer to reset my master password? Thanks!

    The files that weren't inside the media folder on the original machine need to be copied over to exactly the same paths as they had on the source machine. See this thread for an ongoing discussion of a similar problem. See also this post on migrating the iTunes library.
    tt2

  • How can I locate the original .CR2 /  Raw file from Photos in finder?

    How can I locate the original .CR2 /  RAW file from Photos in the finder window? I would like to know a easier way to open my files and use them in Photoshop than having to go to the Pictures folder, right clicking "show packaged contents", and manually searching for my CR2's / RAW's. It is also ridiculous to have to export the RAW file to my desktop, and then take it into Photoshop or another photo editing program.  I was able to do this in iPhoto and find I cannot do so in Photos. Please help? Can you please consider adding a right click function that says "Show Original file in Finder". That would make it so much easier and better for those of us who want a simple way to access the original files and use them in other editing programs. At least with iPhoto you could go to the top menu / preferences and find your items.

    http://www.apple.com/feedback/macosx.html is the place for feature requests and feedback
    Rather than use the 'Show package Contents route, the supported and safer way is to export the unmodfied original.

  • How can I Locate the correct filepath in a jsp page?

    In http://localhost:8080/myweb/a.jsp, I will call a java bean file which is locate in http://localhost:8080/myweb/WEB-INF/classes/haha/DBConnection.class. This java file requires to read an external file which locates in http://localhost:8080/myweb/WEB-INF/classes/haha/db.txt
    My question is how can I get the correct filepath in this environment?
    inputStream = new BufferedReader(new FileReader(????????));
    Only this will work
    inputStream = new BufferedReader(new FileReader("D:\Program Files\Apache Software Foundation\Tomcat 5.5\db.txt"));
    But no one will place the file here, and it is impossible to do this when upload to 3rd party hosting.
    Any suggestion? thx.

    Thx all, in a jsp page, calling this method is fine.
    ServletContext s = getServletContext();
    String a = s.getRealPath("/");
    In a Servlet file, below method is ready to use:
    String b = getServletConfig().getServletContext().getRealPath("/");
    My problem is, I have a jsp page, which initialize a java bean , this java file is responsible for Database Connection, which will read the external text file to get the login, password and database name. So I won't need to recompile this file every time when I place in different platform with different configuration. I only need to edit the text file is ok.
    But How can I get the absolute file path when that jsp page initialize that java bean file? Below is my error, any suggestions are thx.
    package sql;
    import java.sql.*;
    import java.util.ArrayList;
    import java.io.FileReader;
    import java.io.BufferedReader;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class DBConnection extends HttpServlet{
    public String sql = null;
    public Connection con = null;
    public Statement statement = null;
    public ResultSet rs = null;
    private BufferedReader inputStream = null;
    private static ArrayList<String> arr = new ArrayList<String>();
      public DBConnection(){
        String fs = System.getProperty("file.separator");
        ServletContext s = getServletContext();
        String realpath = s.getRealPath("/");
        String filepath = realpath + "WEB-INF"+fs+"Properties"+fs+"db.txt";
        try{
          inputStream = new BufferedReader(new FileReader(filepath));
          String l;
          while ((l = inputStream.readLine()) != null) {
            arr.add(l);
          Class.forName("com.mysql.jdbc.Driver");
          this.con = DriverManager.getConnection("jdbc:mysql://localhost:3306/"+arr.get(0)+"?user=" +arr.get(1)+ "&password="+arr.get(2)+"&useUnicode=true&characterEncoding=utf-8");
          this.statement = this.con.createStatement();
        }catch (Exception e){
          System.err.println(e.getMessage());
        }finally{
    }java.lang.NullPointerException
         javax.servlet.GenericServlet.getServletContext(GenericServlet.java:159)
         sql.DBConnection.<init>(DBConnection.java:20)
         html.ShowCategory.<init>(ShowCategory.java:17)
         org.apache.jsp.left_jsp._jspService(left_jsp.java:66)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

  • How can we cretae the DBC file?

    Hi all,
    I am attempting to run the test_fwktutorial.jsp within the toolbox.jws/Tutorial.jpr project in Jdeveloper . We have to provide the Oracle application DB connection in the project properties ( we have to provide this as a DBC file) . How can we create the dbc file from the Database connection ? i tried to export the DB connection in Jdev , but it is getting exported to xml file rather than dbc file . Please help to fix this

    Yes, you can do that.
    Put both the DBC files under dbc_files\secure folder.
    You can change the dbc files from project settings and point to the desired file.
    I am not sure, but maybe you need to stop JDevloper and start again for the new DBC file to take effect.

  • How can we create the DBC file?

    Hi all,
    I am attempting to run the test_fwktutorial.jsp within the toolbox.jws/Tutorial.jpr project in Jdeveloper . We have to provide the Oracle application DB connection in the project properties ( we have to provide this as a DBC file) . How can we create the dbc file from the Database connection ? i tried to export the DB connection in Jdev , but it is getting exported to xml file rather than dbc file . Please help to fix this.

    Yes, you can do that.
    Put both the DBC files under dbc_files\secure folder.
    You can change the dbc files from project settings and point to the desired file.
    I am not sure, but maybe you need to stop JDevloper and start again for the new DBC file to take effect.

  • How can i access the jsp file in a asp file

    Hi every one..
    we have two projects one is developed in ASP and one is developed in JSP both are running in two different locations.
    now i want to include a jsp file from one project to ASP file in the other project.
    please tell me how can i insert the JSP file in ASP application.
    thanx in advance.

    Wouldn't that be an ASP question for an ASP forum?

  • I have converted a pdf to word. How can I access the Word file from my online account?

    I have converted a pdf to word. How can I access the Word file from my online account? When it says 'download the converted file' I choose a location on my PC and click, but nothing happens. It seems that it can only save the converted file to my online account. I went to my online account but I see no way to look for the file

    Hey Fabrizio,
    You might need to sign up at "https://cloud.acrobat.com/exportpdf" using your Adobe ID credentials to convert your PDF file to Word.
    Do you get the 'download' prompt?
    Also, you can find the converted files by clicking at the 'Files' tab. 
    Please try the same using a different browser and check.
    Hope to hear from you.
    Regards,
    Anubha

  • Exporting photos for UHDTV or Native 4K TV, what are the best settings ? (File: Quality File: Color Space, Image Sizing and resolution)   Or in other words; How can I get the smallest files but keep good quality for display on new UHDTV

    Exporting photos for UHDTV or Native 4K TV, what are the best settings ? (File: Quality File: Color Space, Image Sizing and resolution)   Or in other words; How can I get the smallest files but keep good quality for display on new UHDTV

    You're welcome, and thank you for the reply.
    2) Yesterday I made the subclips with the In-Out Points and Command-U, the benefit is that I've seen the clip before naming it. Now I'm using markers, it's benefit is that I can write comment and (the later) clip name at once, the drawback is that I have to view to the next shot's beginning before knowing what the shot contains.
    But now I found out that I can reconnect my clips independently to the format I converted the master clip to. I reconnected the media to the original AVI file and it worked, too! The more I work with, the more I'm sold on it... - although it doesn't seem to be able to read and use the date information within the DV AVI.
    1) Ok, I tried something similar within FCE. Just worked, but the file size still remains. Which codec settings should I use? Is the export to DV in MOV with a quality of 75% acceptable for both file size and quality? Or would be encoding as H.264 with best quality an option for archiving, knowing that I have to convert it back to DV if I (maybe) wan't to use it for editing later? Or anything else?
    Thank's in advance again,
    André

  • When I move a RAW file from IPhoto to my desktop or Photoshop it changes to a jpeg and reduces in size. How can I get the Raw file across?

    When I move a RAW file from IPhoto on my macbook pro to desktop or Photoshop it changes to a jpeg and reduces in size. How can I get the Raw file to move across?

    I create separate folders based on the year and then the actual date of when I take images. You can make those folders anywhere on any hard drive that is connected to your Mac whether internal or external. I also use the Photoshop Photo Downloader that is included with Photoshop/Bridge and it will create the date folder so all I do is create a Year folder.
    Open Bridge or click on the Bridge icon in PS and in the File menu item in Bridge select "Get photos from Camera". It can be a camera connected to your Mac or a memory card from a camera. A window will open and you then select the camera or memory card. Set the location they will be downloaded to, just the folder and you can Browse to a folder that you created, then in the "Create  Subfolders drop down select what date stamp you want to use or or custom name or not to create subfolders at all.
    I've never cared for iPhoto one bit. I tried it but found it way to restrictive. It likes to have full control over how you interact with your images.

  • How can i check the license file installed on the server CCM 6.1.4

    Hi;
    i have installed the CCM 6.1.4; and now i want to upgrade to 8.5, but i don't remenber witch type license i have uploaded ( normal or Hospitality).
    how can i check the license file installed on this server???
    thanks.

    Hi Matthew,
    I think your idea should work just fine, but you will need to work with;
    [email protected]
    To put together the proper license file due to this change called the "License MAC"
    Customer Impact from New Licensing Procedures
    Cisco Unified Communications Manager on VMware on Cisco UCS B-Series Blade Servers uses a different licensing model than Cisco Unified Communications Manager on an MCS server. The MAC address of the NIC card is no longer used to associate the license to the server.
    Instead, the license gets associated to a license MAC, which is a 12 digit HEX value created by hashing the following parameters that you configure on the server:
    •Time zone
    •NTP server 1 (or "none")
    •NIC speed (or "auto")
    •Hostname
    •IP Address (or "dhcp")
    •IP Mask (or "dhcp")
    •Gateway Address (or "dhcp")
    •Primary DNS (or "dhcp")
    •SMTP server (or "none")
    •Certificate Information (Organization, Unit, Location, State, Country)
    This hash of these fields is called the LICENSE MAC
    Note : Once there is a change in any of the parameters that creates the License MAC, it will
    give you 30 day grace period to generate a new license file for the CM based on new license
    MAC.
    http://www.cisco.com/en/US/docs/voice_ip_comm/cucm/install/8_0_2/install/cmins802.html#wp584709
    Cheers!
    Rob

Maybe you are looking for

  • Crashes on Welcome screen when I click Organizer

    I have Photoshop 11, running it on Windows 7.  It has worked for about 18 months, but now system crashes on the welcome screen every time I click on the Organizer button

  • Sorting the data of control block in oracle form 10g

    I have two block....both are the control block.. in first block i select the date and in second block the data of that date is populated.but the data is populated using cursor in when-button-pressed trigger of that first block button... in cursor the

  • Strange errors in logs

    hi anyone knows what this error in log files means and how doo i fix it ? Processing HTTP request to servlet [dispatcher] finished with error. The error is: com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: The connection is closed. Except

  • Using older receiver with no optical input

    Hello my older dlp has gone out so have decided to buy a new one. I want a a 50 + inch tv, think i have decided on plasma because led's are still to high for me. My problem is I have a Kenwood KR-V8040 receiver that has no HDMI or Optical audio input

  • Database toolkit and LV8.5

    Hello All, I upgraded to LV8.5 and tried to run code from LV8.2 and am encountering the following error: "The Governing Library for this node is broken.  At least one component VI is missing or broken." The problem is in the "DB Tools Fetch Table Dat