Where to store a custom properties file in an EJB 3 deployment

In a web application I can store my own properties file in WEB-INF. However a EJB 3 deployment does not have such a directory.
Where is the correct place within [an ejb 3 jar file] to store my properties file, and how do I retrieve it. (Do I need an absolute url or just a url that checks the classpath?)
Thanks,
nat

For JBoss they use something like :
String filename = System.getProperty("jboss.server.home.dir") + "/conf/application.properties";
It will be located in jboss/server/[server-name]/conf/application.properties

Similar Messages

  • Custom properties files in enterprise project

    Hi,
    I created a enterprise application containing 3 projects:
    - EAR project
    - EJB project
    - Web project
    And I added a properties file in :
    -EAR project/EarContent/APP-INF/afile.properties
    The content of this file is :
    Host=<path to host>
    Port=389
    And I have a .jar file that uses this properties file that is located in :
    -EAR project/EarContent/APP-INF/lib/afile.jar
    Then I add .jar file, through EAR project --> Right click --> Properties --> Deployment Assembly --> Add --> Archives from workspace
    It is then shown under EAR porject - Deployment Descriptor - Bundled Libraries - Library Directory
    When running the application, the JAR file executes as it should, but it cant find the properties file.
    In the .jar file I have a java file that locates the properties file and elements like this :
    private static final String BROKER_PROPERTY_NAME = "afile";
    brokerResources = PropertyResourceBundle.getBundle(BROKER_PROPERTY_NAME);
    String host = brokerResources.getString("host");
    int port = Integer.parseInt(brokerResources.getString("port"));
    Anyone know where to put the properties file to be able to get this to work?
    Regards, reZer

    Hi, thanks, it works :)
    After Clean, and Publish, and restart , remove, add it runs :)
    Is the Classes directory available when deploying to an production environment? So that I can change the content without the need for å redeployment?
    I could figure out where Weblogic stores deploymentfiles in my domain, EAR, WAR, EJB files, and lib and classes dir.
    -regards reZer

  • Editing log4j.properties file of ear while deploying ear file.

    Hi,
    Can i edit log4j.properties file of ear while deploying ear file.
    ~ Dhiraj.

    javainstead:
    >>is MyFolder in the root? else you mite wanna try giving the entire path starting from the root
    No the "MyFolder" is not in the root. Normally if we give the file name alone, it will store in a directory. Instead of storing in that directory, i want to have create another subfolder under that directory and storing the file in it. This is my need.
    OS: Windows 2000.
    zakir_sh:
    log4j.rootCategory=DEBUG,myproj
    log4j.appender.myproj=org.apache.log4j.RollingFileAppender
    log4j.appender.myproj.File=/u3/logs/myproj_webapp_logs/dev_region/mylogfile.log......
    I gave relative path like this and got the file not found error.
    log4j.appender.myproj.File=/MyFolder/error_file.log
    Thanks,
    Manikandan

  • 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!

  • Where to include the jpos.properties file?

    Hi,
    We have a code that needs to be run. I have used the netbeans to do it. I understand that netbeans has its own environment variables that makes the application independent. The code works in netbeans but when i try to run it in the command line, this appears:
    "jpos/res/jpos.properties not found"
    As i had traced it, the directory(where jpos.properties resides) which i added in the Libraries was not copied in the dist folder. It says that it "...is a directory or can't be read. Not copying the libraries."
    It is very important that this jpos.properties be copied since there are a lot of abstract classes used in the code.
    Does anyone know where i should include this jpos.properties file?
    thanks. :)

    I've already made it run through the command line. I just included the jpos.properties in the jar package.
    Thanks to all the replies.
    Apology to someone who was bugged due to my crosspost.

  • Where to store the servlet class files ?

    If, I store the class files for servlets under WEB-INF/classes folder,
              i get file not found exception while using WL 6.1 sp2. But, if i store
              the class file under DefaultWebApp folder, it works fine.
              Any help about where to store the class files for servlets would be
              great help.
              Thanks.
              hiren
              

    Copy Servlet in DefaultWebApp/Web-Inf/classes directory.
              Configure Servlet in web.xml deployment descriptor.
              <servlet>
              <servlet-name></servlet-name>
              <servlet-class></servlet-class>
              </servlet>
              <servlet>
              <servlet-name></servlet-name>
              <servlet-class></servlet-class>
              </servlet>
              <servlet-mapping>
              <servlet-name></servlet-name>
              <url-pattern></url-pattern>
              </servlet-mapping>
              hiren dossani wrote:
              > If, I store the class files for servlets under WEB-INF/classes folder,
              > i get file not found exception while using WL 6.1 sp2. But, if i store
              > the class file under DefaultWebApp folder, it works fine.
              > Any help about where to store the class files for servlets would be
              > great help.
              >
              > Thanks.
              >
              > --
              > hiren
              

  • Where should I place my properties file

    Hello,
    I am working with eclipse. I have created a class that reads a set of properties from a .properties file. Do you know in which folder should I place my file in order it gets read by my class.
    Sitomania

    I have created a class that reads a set of properties from
    a .properties file. Do you know in which folder should I place my
    file in order it gets read by my class.Anywhere in the classpath.

  • Where does the System's Properties file locate?

    I have searched it in the path : Java_Home\jre\lib
    But i couldn't found.
    I want to add some Properties to it but i don't want to do it at runtime by using System.setProterty().

    You can define preferences. But using these are more complex than system properties.
    No matter how you define the System properties in the end setProperty or setProperties needs to be called at runtime. These properties are runtime settings.

  • Where to store customized modelsuppo​rt2 and reportgen*​.seq files

    We currently put all customized model and front end sequences under c:\Documents and Settings\...\TestStand 4.1\Models etc. We have since customized modelsupport2.* and reportgen*.seq files found in Program Files\NI\TestStand 4.1\Components\Models\TestStandModels. Question is where to store these customized files. There is an assortment of subfolders under Documents and Settings\All Users\Documents\NI\TestStand 4.1.
    Solved!
    Go to Solution.

    What version of Windows do you have?
    The file structure in All Users\Documents\NI\TestStand 4.1 should be similar to that in Program Files\NI\TestStand 4.1.  Essentially they are equal.  The key is TestStand looks in the All Users Directory first.  If it doesn't find it there then it goes into the Program Files one.  You can verify this by opening your search directories (Configure>>Search Directories).  Look for a item in the list called Public components directory.  Look at the path for that.  The very next entry should be TestStand components directory.  Look at the path for that.  They both have Subdirs checked.  If you were to switch those around (meaning TestStand components directory before Public components directory) then TestStand would grab the default files and not the ones you modified.
    So you should put modelsupport2 in Documents and Settings\All Users\Documents\NI\TestStand 4.1\Components\Models\TestStandModels\modelsupport​2.*
    reportgen*.seq should go in the same folder.
    If those folders don't exist then create them.  You can probably get away without creating them and just placing it all in the base dir (Documents and Settings\All Users\Documents\NI\TestStand 4.1) but I recommend structuring it the same so you don't get confused and it has the same look and feel.
    Hope this helps!
    jigg
    CTA, CLA
    teststandhelp.com
    ~Will work for kudos and/or BBQ~

  • Accessing .properties file from java code

    Hi,
    I want my java code in a Tomcat Web Application to access values in a custom .properties file.How can i do it.
    Any sample code / suggestions welcome.
    Thanks
    Vignesh.

    ResourceBundle vResourceBundle = ResourceBundle.getBundle("database", Locale.ENGLISH);
            sDriverName = vResourceBundle.getString("database.DriverName");
            sDbURL = vResourceBundle.getString("database.DriverUrl");
            sDbUser = vResourceBundle.getString("database.UserName");
            sDbPasswd = vResourceBundle.getString("database.PassWord");Where "database" is the name of the property file. ie., database.properties.
    the content of the database.properties file
    # Properties to access dabase                 
    database.UserName = scott
    database.PassWord = tiger
    database.DriverName = oracle.jdbc.driver.OracleDriver
    database.DriverUrl = jdbc:oracle:thin:@nn.nn.nn.nn:port:orartgnull

  • How to configure Java Properties File location in WLW

    How do we tell Workshop 7.0 where to look for Java properties files (loaded by
    PropertyResouceBundle in code) ?
    Thanks,
    Ray

    Ray,
    The build number indicates that you have not upgraded to Service Pack 2 of
    version 7.0. I will strongly recommend you to do so. That will shield you
    from the issues which were fixed in the 2 service packs.
    Regards,
    Anurag
    "Ray Yan" <[email protected]> wrote in message
    news:[email protected]...
    >
    Raj,
    We are using WebLogic Workshop Build 7.0.1.0.0829.0 on Windows 2000.
    We shut down the WebLogic Server on Solaris 2.6, log off, log back on,startWebLogic
    in production nodebug mode, and re-run jwsCompile on the same source code.The
    error does not occur anymore. Everything seems to be fine now.
    Thanks,
    Ray
    "Raj Alagumalai" <[email protected]> wrote:
    Hello Ray,
    Can you let me know if you are using the GA version of WebLogic Workshop
    or
    if you have the latest Service Pack.
    Thank You,
    Raj Alagumalai
    WebLogic Workshop Support
    "Ray Yan" <[email protected]> wrote in message
    news:[email protected]...
    Anurag:
    Thanks for your response!
    By moving the property files to WEB-INF/classes from WEB-INF, we arealmost there.
    But we have a follow up problem. We use a static initializer to loadthe
    log4j
    property file like this:
    static {
    try {
    ClassLoader cl= (new Log()).getClass().getClassLoader();
    InputStream is = cl.getResourceAsStream(logfile);
    Properties props = new Properties();
    props.load(is);
    PropertyConfigurator.configure(props);
    } catch (Exception e) {
    e.printStackTrace();
    When we run jwsCompile, we keep getting this:
    Compiling: com/****/TestWS.jws
    weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[weblogic.management.Admin
    may only be used on the Server ]
    at weblogic.management.Admin.getInstance(Admin.java:104)
    at
    weblogic.security.internal.ServerPrincipalValidatorImpl.getSecret(ServerPrin
    cipalValidatorImpl.java:79)
    at
    weblogic.security.internal.ServerPrincipalValidatorImpl.sign(ServerPrincipal
    ValidatorImpl.java:59)
    at
    weblogic.security.service.PrivilegedActions$SignPrincipalAction.run(Privileg
    edActions.java:70)
    at java.security.AccessController.doPrivileged(Native Method)
    at
    weblogic.security.service.SecurityServiceManager.createServerID(SecurityServ
    iceManager.java:1826)
    at
    weblogic.security.service.SecurityServiceManager.getServerID(SecurityService
    Manager.java:1839)
    at
    weblogic.security.service.SecurityServiceManager.sendASToWire(SecurityServic
    eManager.java:538)
    at
    weblogic.security.service.SecurityServiceManager.getCurrentSubjectForWire(Se
    curityServiceManager.java:1737)
    at weblogic.rjvm.RJVMImpl.getRequestStream(RJVMImpl.java:434)
    at
    weblogic.rmi.internal.BasicRemoteRef.getOutboundRequest(BasicRemoteRef.java:
    88)
    at
    weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java
    :255)
    at
    weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java
    :230)
    at
    weblogic.jndi.internal.ServerNamingNode_WLStub.lookup(Unknown
    Source)
    atweblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:337)
    atweblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:332)
    at javax.naming.InitialContext.lookup(InitialContext.java:345)
    at weblogic.knex.bean.EJBGenerator$1.run(EJBGenerator.java:101)
    at
    weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManage
    r.java:780)
    atweblogic.knex.bean.EJBGenerator.lookupAdminHome(EJBGenerator.java:84)
    atweblogic.knex.bean.EJBGenerator.ensureAdminHome(EJBGenerator.java:122)
    at weblogic.knex.bean.EJBGenerator$6.run(EJBGenerator.java:660)
    at
    weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManage
    r.java:821)
    atweblogic.knex.bean.EJBGenerator.generateJar(EJBGenerator.java:482)
    at
    weblogic.knex.dispatcher.DispJar.generateJar(DispJar.java:401)
    atweblogic.knex.dispatcher.DispCache.ensureDispUnit(DispCache.java:695)
    atweblogic.knex.compiler.JwsCompile.compileJws(JwsCompile.java:872)
    at
    weblogic.knex.compiler.JwsCompile.compile(JwsCompile.java:619)
    at weblogic.knex.compiler.JwsCompile.main(JwsCompile.java:109)
    ejbc successful.
    Generating EAR ...
    The EAR was generated and we can even deploy it on Solaris. But whatdoes
    the
    AssertionError mean?
    Thanks,
    Ray
    "Anurag Pareek" <[email protected]> wrote:
    Ray,
    ResourceBundle looks for the properties file in the current thread's
    classpath.
    Since a Workshop webservice's project is nothing but a webapp, the
    properties files can be kept in the WEB-INF/classes directory, which
    is part
    of the webapp classpath.
    You can also use
    Thread.currentThread().getContextClassLoader().getResourceAsStream("MyProp
    s
    properties"); to get access to the properties file.
    Thanks,
    Anurag
    "Ray Yan" <[email protected]> wrote in message
    news:[email protected]...
    How do we tell Workshop 7.0 where to look for Java properties files(loaded by
    PropertyResouceBundle in code) ?
    Thanks,
    Ray

  • WEB-INF and properties files

    okay, this may be really naive and maybe i'm missing some key piece of
    documentation, but i'm missing something regarding the file structure with
    iplanet enterprise 4.1 on solaris.
    in my /usr/local/netscape/suitespot there's a docs directory that is the
    default docs directory.
    I've created a /WEB-INF directory under docs and a /classes directory under
    that. I've placed a jay.properties file in the /WEB-INF/classes directory,
    but when I try to access that through a servlet instantiated bean, I get an
    error from the ResourceBundle call, telling me that it can't load that
    properties file.
    I have two questions:
    1. did i build the WEB-INF directory in the correct place (ie - is this the
    standard way of working under the iplanet server) - this doesn't seem to be
    supported by the admin server in the sense that i can browse this directory,
    when i'd expect that iplanet would build in some basic security around the
    WEB-INF directory
    2. what do i name and where do i put the properties file? should it be
    jay_en.properties? i've tried a number of different scenarios with no luck.
    thanks...
    jay

    Why would you create a WEB-INF directory on the web tier?
    WEB-INF is a directory with a special meaning to the web container. All
    of your properties files and such will need to be placed on the
    application server tier, in the WEB-INF directory that was automatically
    created there. And you can do that just be properly placing them in the
    WAR file.
    David
    Jay Wright wrote:
    > okay, this may be really naive and maybe i'm missing some key piece
    > of documentation, but i'm missing something regarding the file
    > structure with iplanet enterprise 4.1 on solaris.
    >
    > in my /usr/local/netscape/suitespot there's a docs directory that is
    > the default docs directory.
    >
    > I've created a /WEB-INF directory under docs and a /classes
    > directory under that. I've placed a jay.properties file in the
    > /WEB-INF/classes directory, but when I try to access that through a
    > servlet instantiated bean, I get an error from the ResourceBundle
    > call, telling me that it can't load that properties file.
    >
    > I have two questions: 1. did i build the WEB-INF directory in the
    > correct place (ie - is this the standard way of working under the
    > iplanet server) - this doesn't seem to be supported by the admin
    > server in the sense that i can browse this directory, when i'd
    > expect that iplanet would build in some basic security around the WEB-INF
    > directory
    >
    > 2. what do i name and where do i put the properties file? should it
    > be jay_en.properties? i've tried a number of different scenarios
    > with no luck.
    >
    > thanks... jay
    >
    >
    >

  • Setting up .properties file

    Hello
    I would like to know if theres any particular rules for setting up the .properties file. Like in my application i have four *.properties files
    1)log4j.properties 2) mapping.properties and so on
    the mapping.properties file have jsps mapping..so basically it says
    (key) add.project.param = (value)add_project.jsp
    project = project.jsp
    I am trying to understand how response.sendRedirect sends the appropriate link to project.jsp (view page) from add_project.jsp
    In add_project.jsp, response.sendRedirect is simply written as
    response.sendRedirect("tsaa.go?param=view&oid=" + parent + "&type=" + ptype);in my servlet dispatcher class; there are various functions two of them are
    1) void processRequest(HttpServletRequest request, HttpServletResponse response) { }
    2) String getForwardPage(HttpServletRequest request, HttpServletResponse response) { }
    and i think these classes take care of forwarding the request to appropriate page.
    If there are certain rules for setting up the mapping.properties file, do i have to set my new jsp pages in mapping.properties file as:
    quality.control.param = quality_control.jsp
    quality.control.results = quality_control_results.jsp
    (rite now i am using qc.results = quality_control_results.jsp and that doesnt seem to work)
    somehow response.sendRedirect("tsaa.go?param=view&oid=" + parent + "&type=" + ptype) doesn't seem to work in my quality_control.jsp page. Without the above line i can atleast move till quality_control.jsp page from home.jsp....but with response.sendRedirect().....i am on home.jsp after a refresh.
    if u know any links where i can read abt .properties file please let me know. googling gave me build.properties file but nothing for jsp mappings
    Any help is appreciated
    Thanx

    i got the solution
    please ignore the posting
    thanx

  • I18n JSTL / How to connect to new JAR holding new properties file?

    Hi there
    This is concering i18n and how (on earth;) JSTL knows where to find the according properties files that hold all the textual information.
    Okay. I have a piece of software that works fine and has the i18n mechanism running very nicely.
    I found the properties files in WEB-INF/lib/i18n.jar in a folder 'resources/bundle/'. They all prefix 'i18n' so JSTL makes use of them like this:
         <fmt:bundle basename="resources/bundles/i18n">
              <fmt:message var="thumbnailText" key="thumbnail.label" />
    So, we work on a new project right now based on this software. How can I add new project-related properties files?
    What I did:
    1) I created a new properties files having new textual information on new labels, etc.
    2) Put this in a folder of the new project JAR, which is in WEB-INF/lib now.
    3) Referenced the basename of fm:bundle according to this folder (including correct file prefix).
    -> Doesn't work.
    Is it that by convention all i18n information will be searched for in a JAR that must be named 'i18n.jar'?
    I'd greatly appreciate any hints
    Cheers
    André

    First, a sidenote to the SUN team: Before beeing able to reply, the forum denied me access unless I comitted to a screen name. Using my 'AndreKuhn' screen name got me 'Already in use'. Yes, of course. By me! So I had to pick AndreKuhn2 which is a little annoying. There seems to be something wrong with your system.
    Okay, back to the issue.
    Thanks evnafets for your notions! I have 2 JARs having i18n information. One had already been in use (successfully) by the underlying system. It's the one mentioned above ('i18n.jar'). Now there is a second one. Actually used the same way (technically) with different folders and namings. It goes like this:
    <fmt:bundle basename="resources/i18n/bdficp">
              <fmt:message var="titleText" key="publishLink.config.title" />
    With additional i18n information in 'WEB-INF/lib/<PROJECT-NAME>.jar'. Precisely in a file 'resources\i18n\bdficp_de.properties' having the line:
    publishLink.config.title=Just\ another\ title.
    Which should be the one referenced in the snippet above. Still the app gives me: ???publishLink.config.title???
    Any clue? I'd greatly praise your name across the rooms here!
    Cheers
    André

  • How can configure .properties file and  log4j on weblogic 8.1 SP5

    Hi,
    I know this is not right forum for post this question.But I hope I'll get my perfect answer here.
    I have 2 questions.
    1. Where I'll keep my .properties file in weblogic 8.1 SP 5. means I have one own .properties file which is contains some proxy settings and this .properties resides on .war file(now), But I want move this propeties file outside .war file. So Where I'll keep in weblogic 8.1 SP 5.
    2. How can we configure log4j in weblogic?
    Please reply me.
    Regards,
    Pattanaik

    You can add your.properties and log4j.properties to the classpath cant you?
    You just need to edit setEnv.cmd (if i remember correctly) in your weblogic server folder to add the folder containing the properties files to the classpath variable.

Maybe you are looking for

  • How do i get my purchased music back on my iphone ?

    I recently just backed up my iphone on my laptop, however i was moving music over from my lap top onto my phone and it didnt like it. so i was prompted to restore my phone. which i did. however now i have lost all  the music i brought on my iphone wh

  • Printer doesn't print

    My iMac g5 iSight has a history of random restarts. It has been in for service, but it would not misbehave for them. When I got it back, I used SuperDuper to restore my most recent backup from my external drive. After restoring, I used my DVD install

  • DTP Full/Delta loads

    I am loading data from one DSO to another. The change log of the source DSO has been deleted for any request before 20 days. I want to do a full load from active table and then start the delta loads from change log. But the problem is the load is pic

  • Can't sign in to VS because IE is blocked at our company

    Hi all, I can't sign in to VS Express 2013 to update my trial license. The problem seems to be that when I try to sign in there opens a striped down IE window with an error message that it can't connect to the internet so I can't login to my outlook

  • Image file upload code

    Hi, I'm trying to track down where, i.e. by which code, image files are saved into the wiki. I've traced the route to the wiki.js file which creates the dialogue that posts the form to the server but I've run into a wall. I can't establish the name o