I got ZipException to read Jndi.Properties file

hello friends,
here i got ZipException to get Jndi.Properties file.
i place Jndi.Properties file in my directory and i set classpath to weblogic.jar&Jndi.Properties file.
but i didn't get InitialContext obj.though i got zipException.
jvm displays Jndi.Properties file is not read.

To try out I pasted the code given by u in my application as a demo
     private static Connection connect() throws Exception{
     InputStream in = QueryTest.class.getResourceAsStream("JDBC.properties");
          Properties props = new Properties();
          props.load(in);
          //in.close();
          String driver = props.getProperty("JDBC.driver");
          System.out.println(driver);
          String url = props.getProperty("JDBC.url");
          System.out.println(url);
          String user = props.getProperty("JDBC.user");
          System.out.println(user);
          String pwd = props.getProperty("JDBC.password");
          System.out.println(pwd);
          in.close();
          Class.forName(driver);
          return DriverManager.getConnection(url, user, pwd);
     public static void main(String[] args) throws Exception{
          Connection con = connect();
          //Put your code here
JDBC.properties file is
     url = jdbc:mysql://localhost:3306/mysql
          user= root
               password =password
               driver=com.mysql.jdbc.Driver
And the error messages are
null
null
null
null
Exception in thread "main" java.lang.NullPointerException
     at java.lang.Class.forName0(Native Method)
     at java.lang.Class.forName(Unknown Source)
     at Generic.QueryTest.connect(QuerryTest.java:28)
     at Generic.QueryTest.main(QuerryTest.java:35)

Similar Messages

  • What needs to be in my jndi.properties file to get oracle accessed by a jndi client

    I am trying to write a connection pool class that use jndi
    to locate the data base. I use "bindds" bind my OracleDataSource
    object with the name of 'test/jdbc/test'. I should then be able to do a lookup like: OracleDataSource ods =
    (OracleDataSource) ctx.lookup (test/jdbc/test)
    All Oracle code examples use (Context.INITIAL_CONTEXT_FACTORY,
    "com.sun.jndi.fscontext.RefFSContextFactory");
    Is this correct? And what other things should be in my jndi.properties file to access the naming service with comes with
    Oracle (Jserver)? For example to I need to include a Context.PROVIDER_URL value. I would think Oracle would have some
    standard way of accessing its own Naming service. Thanks David

    This implies that ODP.NET does NOT need to be installed on a client. However, I cannot find OraOPs9.dll on a machine with Client Release 9.2 installed. Should OraOps?.dll automatically come with a Client installation of 9.2 or higher?
    ODP.NET needs to be installed on the client. OraOps9.dll is part of ODP.NET, not the Oracle Client.
    Also, if an application is built with the 10g ODP.NET, can it be run from a machine with OraOps9.dll?
    If an application is built with 10g ODP.NET, it can be run with 9.2 ODP.NET as long as you do not use any 10g APIs. The new features in 10g ODP.NET are included in the doc and the ODP.NET FAQ for your reference.

  • Read a Properties File in a Static Floating Block

    I am trying to read a properties file in a static floating block:
       static
          try
             Properties p = new Properties();  
             String path = "/WEB-INF/classes";
             InputStream is = getClass().getResourceAsStream( path + "artimus_message_MessagInboxConfig.properties" );
             p.load(is); // load the stream into the Properties object
             WEBSITE_HOME = p.getProperty( "WEBSITE_HOME" );
             setWebSiteHome( WEBSITE_HOME );
          catch { ......}
       }I got a compilation error saying that the non-static method getClass() cannot be referenced from a static context. There is almost no way to make this static floating block non-static. What should I do?

    Thanks for the reply. But, huh... I do not quite
    understand. Which class is MyClass?It's a generic placeholder for whichever class your put that block into. You wouldn't put it there literally--replace it with the name of the actual class. If that block is in Foo.java, then use Foo.class instead of MyClass.class.
    >
    Okay, this static floating block is in a class called
    MessageInboxConfig.java. Then use MessageInboxConfig.class.getResourceAsStream(...)
    And inside this static
    floating block, I am reading a properties file and
    this properties file is in the
    ContextRoot/WEB-INF/classes/artimus_message_MessagInbox
    onfig.propertiesHow do I read this properties file?
    Properties p = new Properties();  
    InputStream is = MessageInboxConfig.class.getResourceAsStream("artimus_message_MessagInboxConfig.properties" );
    ... etc. ...You shouldn't need to specify "WEB-INF/classes," since it should be in your classpath. What you pass to getResource is a path relative to a directory in your classpath.

  • JNDI Properties file

    Hi,
    Im having trouble setting up my first J2EE EJB and client program. I have managed to pinpoint the problem to be with the selection of the JNDI service provider (keep getting a NoInitialContextException).
    Both client and EJB are on the same machine, and Im using Sun's app server v8 . Could someone tell me what I should have in the jndi.properties file, and where this file should be put. I have tried hard-coding the details into the program, but w/o success.
    I assume that using the jndi.properties file will assign a provider globally across all applications in this server - is this true?
    Thanks.

    I read somewhere that the standard j2ee.jar file (which I have in my classpath) contains a default jndi.properties file to allow basic JNDI access.
    If this is true, then the problem is not with these properties. Heres what I have:
    I compiled the classes using javac, no problems (j2ee.jar is in the classpath).
    I am trying to run the client using java -classpath ClientApp.jar FirstClient, where ClientApp.jar is the stubs/skeletons produced at deployment. This method keeps throwing a NoInitialContextException.: need to specify class name . . .
    I also tried using appclient, but that threw even more errors (not entirely sure whats going on here).
    I have checked over my code, and as far as I can see the problem is not in there - Im sure its something to do with the classpath or something - is there a classpath I should be adding to get the client working?
    Why is J2EE so hard to learn? I find myself struggling more with footery errors than I do actuially reading and learning about how to use it.
    Thanks.

  • How do I read a properties file in WEB-INF without hard-coding a path?

    Hello,
    How do I read a properties file in WEB-INF without hard-coding a path?
    I tried:
    Properties properties = new Properties();
    properties.load(new FileInputStream("db.properties"));
    driver = properties.getProperty("driver");
    but it cannot find the db.properties file.
    Thanks for the help.
    Frank

    Don't use a File to read those properties.
    Better to use the servlet context and
    getResourceAsStream() method to get the InputStream.
    It'll look for any file in the CLASSPATH. If you put
    that properties file in the WEB-INF/classes directory
    you'll have no problems, even if you deploy with a
    WAR file.Completely agree with this approach. Just have to mention the following for completeness
    according to the API,
    "This method is different from java.lang.Class.getResourceAsStream, which uses a class loader. This method allows servlet containers to make a resource available to a servlet from any location, without using a class loader. "
    So using this method, the resource can be anywhere under your web context, not just in the classpath.
    Cheers,
    evnafets

  • Reading a properties file in a servlet and passing its contents to a JSP pa

    Hi all,
    I'm totally new to Servlet pgmg n JSP. Please can ne1 tell how to read a simple properties file (in a servlet) and pass its contents to a JSP page.Actually the reason is to fill a combo box in a JSP page with the contents of a properties file.If calling a servlet for the same is d best way to do that, plz can ne1 tell me :
    1> whether to override the doPost method in the servlet in which to read d file using FileInputStream
    2> Putting the contents in an array and then how to pass this array to the JSP page.
    Thanks,
    deepthy.

    I'm using a properties file to let my web application know what the name of the database is. I'm using an abstract class GeneralDao which will be extended by all the DAO's (Data Access Objects or java classes containing SQL statements).
    Here's the code :
    protected Connection getDatabaseConnection()
              throws Melding
         Connection dbconn = null;     
         ResourceBundle resBundle;
         try
         Class.forName("com.mysql.jdbc.Driver").newInstance();
         resBundle = ResourceBundle.getBundle("gcoConfig");
         String dbConnectie = resBundle.getString("databaseconnection");
         gcoLogger.debug("lezen databaseconnection in resourceBundle " );
         dbconn = DriverManager.getConnection(dbConnectie);
         } catch (InstantiationException exc)The ResourceBundle is used to read the properties file, named gcoConfig.properties.
    With the getString() command I read the content of the string named databaseconnection.
    The gcoConfig.properties file is placed inside the folder C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\gco\WEB-INF\classes
    The GeneralDao is placed in the folder C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\gco\WEB-INF\classes\org\gertcuppens\cluifDao.
    So this class is placed some folder below the WEB-INF\classes folder of gcoConfig.properties.
    And the content of the properties file is just one line :
    databaseconnection=jdbc:mysql://localhost/cluif
    If you want to let the JSP know what's inside the properties file, wrap the content in a Javabean, put it in the request or even the session and pass the control to the JSP.

  • Java.lang.NullPointerException   in the code to read a properties file

    I have written the following code to read a properties file...........
    <b>
    public Property(String fileName)
        try
           InputStream is = MyClassName.class.getClass().getClassLoader().getResourceAsStream(fileName);     
           prop.load(is);
           is.close();
        catch (Exception ex)
            System.out.println("The Exception is:        " + ex.getMessage());
            ex.printStackTrace();
    </b>
    But this code is giving <b> java.lang.NullPointerException </b> at <b> prop.load(is) </b>
    please help me....
    regards
    Brahmachaitanya

    hi,
        If you are loading a resource (property) file from a jar file you can use
    getResourceAsStream("com/test/test.properties").
        if the propery file is in outside of your jar file . you can use
    Property portalProps = new Property ();
    try {
                   FileInputStream fileInputStream = new FileInputStream("<FilePath + FileName>");
                   portalProps.load(fileInputStream);
                   fileInputStream.close();
              } catch (IOException e) {
                   //Log the error
    refer the following link for more details
    http://www.javaworld.com/javaworld/javaqa/2003-08/01-qa-0808-property.html

  • How to read the properties file available in Server File structure in webdy

    hi all,
    I have developed one webdynpro application. In this application i need to access mdm server to continue. For getting the connection i need to pass the IP addresses.
    Can i have code  how to read the properties file which is residing in the server file. with out included along with the application. keeping some where in the file structure in the server. I want to read that properties file by  maintain the iP addresses and users in  properties file based on the key i want to read like below.
    servername="abcServer"
    username="john"
    password="test123"
    Please send me the code how to read this properties file from the file structure and how to read this values by key  in webdynpro application
    Regards
    Vijay

    Hi Vijay,
    You can try this piece of code too:
    Properties props = new Properties();
    //try retrieve data from file
    //catch exception in case properties file does not exist
    try {
             props.load(new FileInputStream("c:\property\Test.properties")); //File location
             String serverName = props.getProperty("servername"); //Similarly, you can access the other properties
             if(serverName==null)
               //....do appropriate handling
         }     catch(IOException e)
                   e.printStackTrace();
    Regards,
    Alka.

  • How to read from properties file

    Hi,
    I am using JSR 168.
    while creating a new portlet, a folder gets created with the name as "portlet". Under which is resource package and <PortletName>Bundle.java.
    pls tell me how to read from .properties file.
    waiting eagerly for some reply
    Thanks & Regards,
    HP
    Edited by: user9003827 on Apr 13, 2010 3:42 AM

    I think i have mixed it up :)
    I have looked at it again and believe you are using regular JSP portlets.
    Can you tell what you want to achieve by reading .properties file. Are you meaning the preferences of the portlet or what exactly are you trying to do?
    Reading propertie files is easy:
    // Read properties file.
    Properties properties = new Properties();
    try {
        properties.load(new FileInputStream("filename.properties"));
        String myKey = properties.getProperty("yourKey");
    } catch (IOException e) {
    }Edited by: Yannick.O on 13-Apr-2010 05:52

  • Doubts in reading a '.properties' file

    Hi All,
    I have a doubt regarding properties file from which I am reading some key-values. Now I have few different keys (4-5) having same value .e.g.
    key1=value1
    key2=value1
    key3=value1
    key4=value1
    key5=value1
    Now I need to read these keys from different places and I also need to update the value to say 'value2' for all the keys e.g.
    key1=value2
    key2=value2
    key3=value2
    key4=value2
    key5=value2
    Now, since i need to update the values of all the keys, I am thinking of having another key-value pair (e.g. key=value1) in the same property file, and using the value of this key as value for all the keys displayed above. So that when I update the value of this key ( key=value2), I dont need to update the values of all the keys, since those keys will be reading the values from this key's value.
    I hope i am clear with this explanation.... ;-)
    My first question is, 'IS IT POSSIBLE' ???
    If yes, then how????
    Thanks in advance
    Inder Jeet Singh

    The following little class is from my old bag of tricks:import java.util.Properties;
    public class XProperties extends Properties {
         public static final String BEG= "${";
         public static final String END= "}";
         public XProperties() { super(); }
         public XProperties(Properties def) { super(def); }
         public String getRawProperty(String key) { return getRawProperty(key, null); }
         public String getRawProperty(String key, String def) {
              return super.getProperty(key, def);
         public String process(String val) {
              for (int i, j, n= val.length(); n >= 0 && (i= val.lastIndexOf(BEG, n)) >= 0 &&
                (j= val.indexOf(END, i)) >= 0; ) {
                   String pat= val.substring(i+BEG.length(), j);
                   String sub= super.getProperty(pat);
                   if (sub != null) {
                        val= val.replaceAll("\\Q"+BEG+pat+END+"\\E", sub);
                        n= val.length();
                   else
                        n= i-1;
              return val;
         public String getProperty(String key) { return getProperty(key, null); }
         public String getProperty(String key, String def) {
              String val= super.getProperty(key);
              return val == null?def:process(val);
    }If you use an XProperties object instead of a Properties object
    you can do the following in your .properties file:key= value1
    key1= ${key}
    key2= ${key}
    key3= ${key}
    key4= ${key}
    key5= ${key}... if you want to change the value, all you have to do is change the
    value of the 'key=value1' line.
    kind regards,
    Jos

  • How to read a properties file

    hi
    I have a properties file.
    I am using load method to load the properties file but i have encountered a problem here.
    the properties file has space like
    FIRST PROP=xyz
    SECOND PROP=abc
    my question is how to read the file
    thank u

    Either format it properly--I think a \ before the space will work--or write your own method to use in place of Properties.load.
    (Or, I suppose, you could inject your own InputStram that translates the lines on the fly to include the \, but that would probably be more trouble than it's worth.)

  • Help: Servlet can't read from properties file

    I am working on a web application running in Tomcat on Linux.My java source file reads some parameters from a properties file (data.properties)in the same directory. This works well in a simple application. However, if it is used in the Tomcat environment, it can't be read by a servlet file (LoginServlet.java). I put both the "LoginServlet.class" and "data.properties" in the following directory: /webapps/myapp/WEB-INF/classes. When I run the web application in Tomcat, the error is "data.properties not found". What is the problem? Do I need to modify my "web.xml" and/or Tomcat's "server.xml"? If so, how to modify them?
    This web application contains a lot of serlets. So I don't want to hardcode the parameters into the servlet codes.
    Any info will be appreciated. Thanks in advance!:)

    Putting the properties file in webapps/myapp may or may not help.
    My assumption is that you are trying to open the file by brute force, with something like
    InputStream propis = new FileInputStream ("data.properties");
    Properties props = new Properties ( );
    props.load (propis);
    What you want is to have the class loader find a file in the same place as the class file, and give you back an input stream reading from that file, which you can then pass to the Properties.load(InputStream) method. This is called a "resource," and the way to do it is:
    InputStream propis = getServletContext().getResourceAsStream("data.properties");
    // remaining code as above
    This will cause the class loader for the servlet context (a/k/a the Web application) to find the file in the same manner as it might find a class, but instead of treating it as compiled JVM code, and loading it, it simply passes you back an InputStream from which you do whatever you want.
    Cheers!
    Jerry Oberle
    perl -e 'printf "mailto%cg%s%cearthlink%cnet\n", 58, "oberle", 64, 46;'

  • Read resourceBundle properties file from KM

    Hi,
    I have a properties file called com.mycomp.apps.phonebook.properties in the KM Content of the portal in KM Content => root => mycomp => apps => phonebook => customizing
    Now I'm developing a new LinkCommand service for the UserDetails.
    http://help.sap.com/saphelp_nw04/helpdata/en/65/29b24053c13f5fe10000000a155106/frameset.htm
    The already existing LinkCommand "Send E-mail..." is read from the original resourceBundle com.sap.ip.collaboration.gwui.api.wdf.mail.SendTo
    For my new LinkCommand I would like to use the existing properties file. How do I have to define this file in the uicommand xml or properties xml sheet?
    Can anybody help me?
    With the local project resourceBundle it's working, but I would like to use the file in the KM. Andy ideas?
    Regards,
    Stefan

    Hi Praven,
    Copying all existing SendTo properties file to my project would be an option but I wouldn't win anything.
    I'm quite happy with the existing SAP collaboraton properties files using e.g. for "Send e-mail".
    I won't change this existing ones. I created a new LinkCommand. And for this new LinkCommand I'm looking for a solution how I can handle the translation for it.
    I would prefer e using my existing file which is located in the KM. The reason why it's located in the KM is, if I need to change a translation or add a new translation properties file I only need to change it in the KM. If it's a part of the project I need by every change to deploy the project new.

  • Read a properties file

    hi all,
    i do have a java class, it's a WebService in fact, coded in java. I must add something, and as i learned by myself java there some things i don't know.
    my class must access to a properties file to store data like server, dbs path etc... this file will also be changeable by an administrator on the machine
    i'have seen that with java.util.Properties there is a method to save the properties into an outputstream (consequently into a file i guess), but i have never dealed with output and files, so i'm a bit lost, could someone give me some clues, or a link to some code ?
    regards

    Here is some code. These methods just override methods in java.util.Properties with a new instance of a Properties-like class called MyProperties. To make an instance of this class, just pass in the file name into the constructor. THIS CODE WON'T WORK BY ITSELF AND YOU WILL NEED TO MAKE MODIFICATIONS! It's just some old code i pulled down from an old app i wrote. A better way to do this would be just extending from java.util.Properties, but i don't have time to fix it.
    public MyProperties (String name) throws FileNotFoundException,IOException {
              this.name = name;
    //creates input stream of the file you passed in
              inFile = new BufferedInputStream(new FileInputStream(name));
    //instance of java.util.properties
              prop = new Properties();
              prop.load(inFile);
         //containsKey wrapper
         public boolean containsKey(String key) {                                   //'key' is the key you search for in the 'name' file
              return prop.containsKey(key);
         //saves the passed value to the specified key (writes to the file). Define 'header' to add a header message at the beginning of the file.
         public void store(String header) throws IOException {
    //your output file...in this case, it's also the input file     
    BufferedOutputStream outFile = new BufferedOutputStream(new FileOutputStream(name));
              prop.store(outFile,header);
              return;
         // setProperty
         public void setProperty(String key, String attribute) {                    //sets the key 'key' to the value 'attribute'
    //before writing to the file, YOU should check whether the user has admin privileges!     
    prop.setProperty(key, attribute);
         // getProperty
         public String getProperty(String key) {                                        //gets the value of the key 'key'
         String theAttribute = prop.getProperty(key);
         return theAttribute;

  • Reading a properties file from BPEL Process (jar)

    Hello,
    I've created a .jar in which i have various classes and a xml file where i keep certain properties.
    I have a BPEL Process in which i've embedded java code to access the classes in the jar.
    I've created a folder in <ORACLE_HOME>/MyLibrary and added the jar. After, i've included this path to the domain.xml located in <ORACLE_HOME>/soasuite/bpel/domains/default/config into the property: "bpelcClasspath".
    When i try to run the process, i get a "<BPELExecution::BPELProcess1> executing <exec> at line 251
    java.lang.NullPointerException
         at java.util.Properties.loadFromXML(Properties.java:700)
         at com.gepe.ldap.LDAPConfiguration.readConfig(LDAPConfiguration.java:26)".
    Apparently the properties file is not being found, am i correct?
    How can i solve this?
    Thank's in advance,
    César

    Put your class files and proerties files here:
    $ORACLE_HOME/bpel/system/classes
    marc
    http://orasoa.blogspot.com

Maybe you are looking for

  • Accounting document not created for the  billing document in CIN

    Hi Experts, I have made conditon records for BED, CESS, Edu Cess and VAT. I hve defined the accounts in both excise transactions and VKOA Settings even then the accounting document is not getting created. I am getting the following error. No account

  • Getting CD or dvd to play

    hi all I have been working on this for a couple of hours, looked thru this forum, the MAC support and i can find the solution. I have never used my cd player on my macbook. today i needed to play an instructional CD (american heart assoc cd) for work

  • AdobeEdge - Using variables within a symbol

    I am completely new to Adobe edge, but I do have a little development experience (VB, VBA, C#). I would like to create a global variable when the animation starts (strClicked = "No" - or similar).  When one of the buttons is clicked on I would like t

  • CCM 2.0 standard XSD file ?

    hello... we have upgraded from CCM 1.0 to CCM 2.0. While upgrading we are facing some issues regarding schema definition. Becuase in CCM 1.0 we have used our custom program to convert input in to XML file using Z programs. Now these Z programs are no

  • Debug a FM call with DESTINATION

    Hi, how it is possible to debug a Function Module which is called in the BACKEND (with DESTINATION ). If I set a breakpoint in the backend and call the FM frem outside (SAP SRM) the debugger doesn't stop there. Regards ertas