Help with  running sun jndi tutorial example LookUp.class

I am learning JNDI,and when I run LookUp.java available in JNDI TUTORIAL ,souce code here:
* @(#)Lookup.java     1.3 99/08/12
* Copyright 1997, 1998, 1999 Sun Microsystems, Inc. All Rights
* Reserved.
* Sun grants you ("Licensee") a non-exclusive, royalty free,
* license to use, modify and redistribute this software in source and
* binary code form, provided that i) this copyright notice and license
* appear on all copies of the software; and ii) Licensee does not
* utilize the software in a manner which is disparaging to Sun.
* This software is provided "AS IS," without a warranty of any
* kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
* WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE
* HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE
* FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING,
* MODIFYING OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN
* NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
* CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
* CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT
* OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS
* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* This software is not designed or intended for use in on-line
* control of aircraft, air traffic, aircraft navigation or aircraft
* communications; or in the design, construction, operation or
* maintenance of any nuclear facility. Licensee represents and warrants
* that it will not use or redistribute the Software for such purposes.
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Hashtable;
class Lookup {
public static void main(String[] args) {
     // Check that user has supplied name of file to lookup
     if (args.length != 1) {
     System.err.println("usage: java Lookup <filename>");
     System.exit(-1);
     String name = args[0];
     // Identify service provider to use
     Hashtable env = new Hashtable(11);
     env.put(Context.INITIAL_CONTEXT_FACTORY,
     "com.sun.jndi.fscontext.RefFSContextFactory");
     try {
     // Create the initial context
     Context ctx = new InitialContext(env);
     // Look up an object
     Object obj = ctx.lookup(name);
     // Print it out
     System.out.println(name + " is bound to: " + obj);
     // Close the context when we're done
     ctx.close();
     } catch (NamingException e) {
     System.err.println("Problem looking up " + name + ": " + e);
after I compiled it sucessfully,I typed
java LookUp d:/test.java ,error message shown following:
Problem looking up LookUp.java: javax.naming.NoInitialContextException: Cannot i
nstantiate class: com.sun.jndi.fscontext.RefFSContextFactory [Root exception is
java.lang.ClassNotFoundException: com.sun.jndi.fscontext.RefFSContextFactory]
please help me!

Read the Preparations chapter of the tutorial.
It tells you to download and install the file
system service provider from
http://java.sun.com/products/jndi/#download

Similar Messages

  • Help with SUN JNDI tutorial example

    HI guys there's an example of how to bound an object along with its codebase in the sun jndi tutorial
    import javax.naming.*;
    import javax.naming.directory.*;
    import java.util.Hashtable;
    * Demonstrates how to bind a Serializable object to a directory
    * with a codebase.
    * (Use Unbind to remove binding.)
    * usage: java SerObjWithCodebase <codebase URL>
    class SerObjWithCodebase {
    public static void main(String[] args) {
         if (args.length != 1) {
         System.err.println("usage: java SerObjWithCodebase <codebase URL>");
         System.exit(-1);
         String codebase = args[0];
         // Set up environment for creating initial context
         Hashtable env = new Hashtable(11);
         env.put(Context.INITIAL_CONTEXT_FACTORY,
         "com.sun.jndi.ldap.LdapCtxFactory");
         env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=JNDITutorial");
         try {
         // Create the initial context
         DirContext ctx = new InitialDirContext(env);
         // Create object to be bound
         Flower f = new Flower("rose", "pink");
         // Perform bind and specify codebase
         ctx.bind("cn=Flower", f, new BasicAttributes("javaCodebase", codebase));
         // Check that it is bound
         Flower f2 = (Flower)ctx.lookup("cn=Flower");
         System.out.println(f2);
         // Close the context when we're done
         ctx.close();
         } catch (NamingException e) {
         System.out.println("Operation failed: " + e);
    So in therory you should be able to retrieve an object in through doing a look up, and then cast it... but in this approach the client that performs the look up shouldn't need to include the class definition of the object that is being retrieved, because it's being included in the code base of the context, but then how do you avoid compilation errors such:
    SerObjWithCodebase.java:73: cannot resolve symbol
    symbol : class Flower
    location: class SerObjWithCodebase
    Flower f2 = (Flower)ctx.lookup("cn=Flower");
    in the client code that is attepting to perform the look up?... is there a work-around for this problem? please let me know, thanks in advance.

    As far as I am aware, there is no possible way to compile or execute code without the client knowing it's definition.
    The client will always need the class definition if it want's to use it.
    If you don't want this coupling, then you could look at using an EJB container (which still requires the client to have skeleton code) or using something like web services

  • Run client execution problem  when running Sun J2EE tutorial example

    Hi,
    I'm trying to run the Sun J2EE tutorial example, CartApp.
    When come to run the client application I got the following error:
    The command:
    E:\Dev\src\J2EE_J2EE_tutorial\examples\ears>runclient -client CarApp.ear -name CartClient -textauth
    The error:
    Application threw an exception:java.io.IOException: CarApp.ear does not exist
    The deployment complete without error.
    I tried to the the APPCPATH to :
    set APPCPATH=E:\Dev\src\J2EE_J2EE_tutorial\examples\ears\CartAppClient.jar
    set APPCPATH=CartAppClient.jar
    On both set, it gave the same error above.
    Did someone known the problem I have ?
    Thnaks

    hi ,
    I think u have given other disply name to your J2EE client ,
    Anyway check disply name of J2EE client through deploytool.
    u have to use that display name to access the j2ee client .
    suppose ur j2ee client displyname is testclient, u can use:
    runclient -client ConverterApp.ear -name testclient
    hope this will help u,
    babu.

  • Looking for com.sun.jndi.toolkit.url.Uri.class

    Does anybody have any idea where I can find com.sun.jndi.toolkit.url.Uri.class?

    Ah well...I found it. Not seperate from the provider classes but I did finally find it. It is in the providerutil.zip that is included with the LDAP Service Provider download. The download is available at: http://java.sun.com/products/jndi/#download

  • Help with running multiple threads

    I'm new to programming with threads. I want to know how to run
    multiple threads at the same time. Particularly for making games
    in Java which I'm also begining to learn. For running multiple
    threads at the same time, do you have to put two run() methods
    in the source? If not then how do you make two threads or more
    run at the same time?
    Thanks for helping.

    For running multiple
    threads at the same time, do you have to put two run()
    methods
    in the source? Hi there,
    Each thread is presumably performing a task. You may be performing the same task multiple times or be performing different tasks at once. Either way, each task would typically be contained within the run() method of a class. This class would either be a subclass of java.lang.Thread (extends Thread) or would be an implementation of java.lang.Runnable (implements Runnable). In either case, you would define a method with signature (public void run()...). The difference comes into play when you wish to actually perform one of these tasks. With a subclass of Thread, you would simply perform:
    new MyTask().start();
    With an implementation of Runnable, you would do this:
    new Thread(new MyTask()).start();
    This assumes you don't need to monitor the threads, won't be sending any messages to your tasks or any such thing. If that were the case, you would need to tuck away those returns to new MyTask() for later access.
    In order to launch two threads simultaneously, you would have something along the lines of:
    new MyTask().start();
    new MyOtherTask().start();
    Now it is perfectly possible that MyTask() would complete before MyOtherTask() managed to start in which case it wouldn't appear as if you had actually had multiple threads running, but for non-trivial tasks, the two will likely overlap. And of course, in a game, these tasks would likely be launched in response to user input, which means that you wouldn't have any control over when or in what order they executed.
    Anyhow, it's as simple as that. You should also consider following the Java Threading trail which shows a simple example of using multiple threads. You can find it at:
    http://java.sun.com/docs/books/tutorial/essential/threads/index.html
    Regards,
    Lynn

  • Help with EJB and JNDI, please

    Hello. My name is Santiago, and i am a student from the University of Valladolid, in Spain. I am newcome in the world of EJB, I have done the first EJB from de Sun tutorial (I�m using the Sun Java System Application Server PE 8.2) and now I am trying to improve it in that way: I have the EJB and the client in diferent machines conected.
    I am trying to understand how to use JNDI, but i have not good results :( I have read about using ldap but i dont know if it is apropiated, or if it is installed automaticaly with the sun aplication, or if i have to download and install it... i am not sure about anything :)
    This is my client�s code (part of it)
    Hashtable envirom = new Hashtable();
    envirom.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    envirom.put("java.naming.factory.url.pkgs","com.sun.enterprise.naming");
    envirom.put(Context.PROVIDER_URL,"iiop://Santiago:389");
    envirom.put(Context.PROVIDER_URL,"ldap://192.168.1.101:389");
    envirom.put(Context.SECURITY_AUTHENTICATION,"none");
    InitialContext ctx = new InitialContext(envirom);
    Object objref = ctx.lookup("java:comp/env/ejb/Multiplica");
    When I try to connect in local mode (client and EJB in the same machine) i get something like that:
    javax.naming.CommunicationException: 192.168.1.101:389 [Root exception is java.n
    et.ConnectException: Connection refused: connect]
    at com.sun.jndi.ldap.Connection.<init>(Connection.java:204)
    at com.sun.jndi.ldap.LdapClient.<init>(LdapClient.java:118)
    at com.sun.jndi.ldap.LdapClient.getInstance(LdapClient.java:1578)
    at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2596)
    at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:283)
    It is even worse when i try it in different machines:
    10-mar-2006... com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImp1<init>
    ADVERTENCIA: "IOP00410201: <COMM_FAILURE> Fallo de conexion: Tipo de socket: IIOP_CLEAR_TEXT;
    name of host: portatil; puerto: 3700"
    org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code:201 completed:No
    Both SSOO are XP and I have disabled Firewalls.
    PLEASE, if you colud help me It would fantastic, because I am in that trouble, i have tryed 1000 solutions but i am not able to understand it.
    Hoping you can help me.
    Santiago.

    This thread is now being followed up in:
    http://swforum.sun.com/jive/thread.jspa?threadID=64092

  • Is it a bug in Sun's Tutorial example!!!!

    Hello everybody! I donno whether the following Tutorial example code is buggy or not but it won't run under j2sdk 1.4.2 and also under 1.5 as smoothly as Tutorial says(only the 1st line prints but not all). You can find the code:
    http://java.sun.com/docs/books/tutorial/essential/io/dataIO.html
    And the file name is:
    DataIODemo
    Does anyone know how to make it work?
    Thanks.
    --DM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    The author made a "bonehead" error - s/he hardcoded a newline character ('\n') when writing the invoice1.txt file. Since this is a UNIX/Linux character, it will not cause an error when run there - BUT - when run on an OS that doesn't use that convention - Windows, etc - it results in an incorrectly written file.
    This illustrates a code portability problem; don't hardcode!
    I leave as an exercise for the reader the correction of the format of the total dollar amount.
    A corrected copy is below. //********* preceeds changes. Compare with the original to see the differences.
    import java.io.*;
    public class DataIODemo
        public static void main(String[] args)
            throws IOException
            // write the data out
            DataOutputStream out  = new DataOutputStream(new
                FileOutputStream("invoice1.txt"));
            double[] prices       = {19.99, 9.99, 15.99, 3.99, 4.99};
            int[] units           = {12, 8, 13, 29, 50};
            String[] descs        = {"Java T-shirt",
                "Java Mug",
                "Duke Juggling Dolls",
                "Java Pin",
                "Java Key Chain"};
            char lineSep          = System.getProperty("line.separator").charAt(0);
            for (int i = 0; i < prices.length; i++)
                out.writeDouble(prices);
    out.writeChar('\t');
    out.writeInt(units[i]);
    out.writeChar('\t');
    out.writeChars(descs[i]);
    out.writeChar(lineSep);
    out.close();
    // read it in again
    DataInputStream in = new DataInputStream(new
    FileInputStream("invoice1.txt"));
    double price;
    int unit;
    StringBuffer desc;
    double total = 0.0;
    try
    while (true)
    price = in.readDouble();
    in.readChar();
    // throws out the tab
    unit = in.readInt();
    in.readChar();
    // throws out the tab
    char chr;
    desc = new StringBuffer(20);
    while ((chr = in.readChar()) != lineSep)
    desc.append(chr);
    System.out.println("You've ordered " +
    unit + " units of " +
    desc + " at $" + price);
    total = total + unit * price;
    } catch (EOFException e)
    System.out.println("For a TOTAL of: $" + total);
    in.close();

  • Help with running bonjour

    I can't get bonjour to run on my computer. I have tried uninstalling, installing the previous version and downloading bonjour for windows from apple.The service starts normally and is running but the IE plugin shows "bonjour service not available", running the printing wizard shows the same. I ran the dns-sd which shows
    c:\>dns-sd -V
    DNSServiceGetProperty failed -65537
    c:\>dns-sd -I
    Registering Service Test.testtxt.tcp.local.
    DNSService call failed -65537
    I have itunes 8 installed, haven't found the need to use bonjour before so would usually uninstall it. Don't know much about bonjour, tried searching the forums but couldn't come up with anything. Can anyone help with this?

    I get into the same situation consistently after switching the network connection from Ethernet LAN to Wireless LAN. The only fix I know of is to restart the PC.

  • Help with parse... see example

    Hey,
    I need some help with this, i'm writing a program which reads from a database and when it does, It does some validation.
    My problem is this: I need to convert it from a date to string (or string to date, it doesn't matter). I get an error saying it is an undefined data type. please see the examples of my code
    So for example, cost works, when i convert to int. For parseInt illustrated here
         //Cost
         public void setCost(String sCostA) throws Exception {
              try{
                   Validation.IsValid(sCostA + "","N","M","","","0","");
                   iCost = Integer.parseInt(sCostA);
              }catch (Exception e){
                   throw new Exception("Cost Invalid:\n"+e);
         public void setCost(int iCostA) throws Exception {
              try{
                   Validation.IsValid(iCostA + "","N","M","","","0","");
                   iCost = iCostA;
              }catch (Exception e){
                   throw new Exception("Cost Invalid:\n"+e);
         }While if i try date, it doesn't work. Here is my code...
         //Expire_Date
         public void setExpire_Date(String sExpire_DateA) throws Exception {
              try{
                   Validation.IsValid(sExpire_DateA + "","D","O","","","0","");
                   dtExpire_Date = Date.parseDate(sExpire_DateA);
              }catch (Exception e){
                   throw new Exception("Date_Given Invalid:\n"+e);
         public void setExpire_Date(Date dtExpire_DateA) throws Exception{
              try{
                   Validation.IsDate(dtExpire_DateA + "O");
                   dtExpire_Date = dtExpire_DateA;
              }catch (Exception e){
                   throw new Exception ("Expire_Date is an Invalid Date:\n"+e);
         }I know there should be a way to fix this, i hope someone can help me
    If there is any more info you require please let me know
    Thanks in advance
    Lutty182

    I don't quite understand what you are doing but converting between a data and a string you might want to look at SimpleDateFormat.

  • Need Help with running expect script on MAC OS

    Hi Guys,
    I'm having an issue with running an expect script on my Mac Mini with Mac OS x 10.7.5. I think the script is correct but the not sure why its not working.
    The script is as below and also teh error from Xtern or terminal when i try to run it.
    #!/usr/bin/expect
    set telnetAddr "172.22.22.254"
    set telnetAddr1 "172.22.22.252"
    set username "ww"
    set passwords "ww"
    set enablepassword "ww"
    spawn  telnet $telnetAddr
    expect "Username: "
    send "username\r"
    expect "Password: "
    send "$passwords\r" 
    expect "Orange-ISRGW>"
    send "enable\r"
    expect "Password: "
    send "$enablepassword\r"
    expect "Orange-ISRGW#"
    send "sh flash\r"
    expect "Orange-ISRGW#"
    send "delete flash:c1140-k9w7-tar.default.JAR\r"
    expect "Delete flash:/c1140-k9w7-tar.default.JAR? [confirm]"
    send  "\r"
    expect "Orange-ISRGW#"
    send "exit/r"
    interact
    here is what happens when i try to run it. This is just a test script before i re-write it to do what i intened to use it for.
    sh-3.2# ls -al Text-Script.txt
    -rwxrwxrwx@ 1 root  wheel  592 Dec  6 08:36 Text-Script.txt
    sh-3.2# more Text-Script.txt
    #/!/usr/bin/expect -f
    set telnetAddr "172.22.22.254"
    set username "ww"
    set passwords "ww"
    set enablepassword "ww"
    spawn telnet $telnetAddr
    expect "Username: "
    send "username\r"
    expect "Password: "
    send "$passwords\r" 
    expect "Orange-ISRGW>"
    send "enable\r"
    expect "Password: "
    send "$enablepassword\r"
    expect "Orange-ISRGW#"
    send "term length 0\r"
    expect "Orange-ISRGW#"
    send "sh flash\r"
    expect "Orange-ISRGW#"
    send "delete flash:c1140-k9w7-tar.default.JAR\r"
    expect "Delete flash:/c1140-k9w7-tar.default.JAR? [confirm]"
    send  "\r"
    expect "Orange-ISRGW#"
    send "exit/r"
    sh-3.2#
    sh-3.2# pwd
    /usr/bin
    sh-3.2# Text-Script.txt
    /usr/bin/Text-Script.txt: line 8: spawn: command not found
    couldn't read file "Username: ": no such file or directory
    /usr/bin/Text-Script.txt: line 10: send: command not found
    ": no such file or directory:
    /usr/bin/Text-Script.txt: line 12: send: command not found
    ": no such file or directorySRGW>
    /usr/bin/Text-Script.txt: line 14: send: command not found
    couldn't read file "Password: ": no such file or directory
    /usr/bin/Text-Script.txt: line 16: send: command not found
    ": no such file or directorySRGW#
    /usr/bin/Text-Script.txt: line 18: send: command not found
    ": no such file or directorySRGW#
    /usr/bin/Text-Script.txt: line 20: send: command not found
    ": no such file or directorySRGW#
    /usr/bin/Text-Script.txt: line 22: send: command not found
    ": no such file or directorylash:/c1140-k9w7-tar.default.JAR? [confirm]
    /usr/bin/Text-Script.txt: line 24: send: command not found
    ": no such file or directorySRGW#
    /usr/bin/Text-Script.txt: line 26: send: command not found
    sh-3.2#
    sh-3.2#
    sh-3.2# ./Text-Script.txt
    ./Text-Script.txt: line 8: spawn: command not found
    couldn't read file "Username: ": no such file or directory
    ./Text-Script.txt: line 10: send: command not found
    ": no such file or directory:
    ./Text-Script.txt: line 12: send: command not found
    ": no such file or directorySRGW>
    ./Text-Script.txt: line 14: send: command not found
    couldn't read file "Password: ": no such file or directory
    ./Text-Script.txt: line 16: send: command not found
    ": no such file or directorySRGW#
    ./Text-Script.txt: line 18: send: command not found
    ": no such file or directorySRGW#
    ./Text-Script.txt: line 20: send: command not found
    ": no such file or directorySRGW#
    ./Text-Script.txt: line 22: send: command not found
    ": no such file or directorylash:/c1140-k9w7-tar.default.JAR? [confirm]
    ./Text-Script.txt: line 24: send: command not found
    ": no such file or directorySRGW#
    ./Text-Script.txt: line 26: send: command not found
    sh-3.2#

    Works like a Charm after making the change suggested ..
    macminiserver:ExpectScript Tola$ more Text-Script.txt
    #! /usr/bin/expect -f
    set telnetAddr "172.22.22.254"
    set username "ww"
    set passwords "ww"
    set enablepassword "ww"
    spawn telnet $telnetAddr
    expect "Username: "
    send "$username\r"
    expect "Password: "
    send "$passwords\r" 
    expect "Orange-ISRGW>"
    send "enable\r"
    expect "Password: "
    send "$enablepassword\r"
    expect "Orange-ISRGW#"
    send "term length 0\r"
    expect "Orange-ISRGW#"
    send "sh flash\r"
    expect "Orange-ISRGW#"
    send  "delete flash:c1140-k9w7-tar.default.JAR\r"
    send  "\r"
    expect "Orange-ISRGW#"
    send "sh flash\r"
    interact
    macminiserver:ExpectScript Tola$ ./Text-Script.txt
    spawn telnet 172.22.22.254
    Trying 172.22.22.254...
    Connected to 172.22.22.254.
    Escape character is '^]'.
    User Access Verification
    Username: ww
    Password:
    Orange-ISRGW>enable
    Password:
    Orange-ISRGW#term length 0
    Orange-ISRGW#sh flash
    -#- --length-- -----date/time------ path
    2         1440 Oct 24 2013 11:23:26 -07:00 vlan.dat
    3     63714548 May 3 2010 11:49:40 -07:00 c2800nm-adventerprisek9_ivs_li-mz.151-1.T.bin
    5     67871024 Nov 9 2012 19:05:24 -08:00 c2800nm-adventerprisek9-mz.151-4.M5.bin
    124751872 bytes available (131600384 bytes used)
    Orange-ISRGW#delete flash:c1140-k9w7-tar.default.JAR
    Delete flash:/c1140-k9w7-tar.default.JAR? [confirm]
    %Error deleting flash:/c1140-k9w7-tar.default.JAR (File not found)
    Orange-ISRGW#sh flash
    -#- --length-- -----date/time------ path
    2         1440 Oct 24 2013 11:23:26 -07:00 vlan.dat
    3     63714548 May 3 2010 11:49:40 -07:00 c2800nm-adventerprisek9_ivs_li-mz.151-1.T.bin
    5     67871024 Nov 9 2012 19:05:24 -08:00 c2800nm-adventerprisek9-mz.151-4.M5.bin
    124751872 bytes available (131600384 bytes used)
    Orange-ISRGW#

  • Unsupported Version error when trying to run Web Services Tutorial example

    Hi there,
    I'm trying to run the first example from the Java Web Services Tutorial and get the following error when I type 'asant build' in my Command Window.
    Buildfile: build.xml
    BUILD FAILED
    java.lang.UnsupportedClassVersionError: com/sun/tools/ws/ant/WsImport (Unsupport
    ed major.minor version 49.0)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
    at org.apache.tools.ant.loader.AntClassLoader2.defineClassFromData(AntCl
    assLoader2.java:76)
    When I do a java -version I see my version is Java 1.5, and I'm not sure why the build is still trying to use Java 1.4. I do not want to delete the 1.4 from my machine as it is used for something else.
    C:\jwstutorial20\examples\jaxws\helloservice>java -version
    java version "1.5.0_09"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b03)
    Java HotSpot(TM) Client VM (build 1.5.0_09-b03, mixed mode, sharing)
    Could you please help me with this problem?
    Thanks in advance.
    Azeem.

    Hi Azeem.
    Check out values specified for JAVA_HOME, PATH and CLASSPATH under environment variable. Was facing the same problem. Changed the values to point to jdk1.5 and it is working now.
    BTW.
    You don't have to uninstall jdk1.4.
    Cheers!!!

  • Running Oracle ADF tutorial example to weblogic server

    Hi all,
    I am following the tutorial at [Developing RIA Web Applications with Oracle ADF|http://st-curriculum.oracle.com/obe/jdev/obe11jdev/ps1/ria_application/developriaapplication_long.htm] . However, I did something new here. I deployed the finished sample to weblogic admin server, and it went fine. But when I tried to access the page DeptEmpPage.jspx, I got exception:
    oracle.jbo.DMLException: JBO-26061: Error while opening JDBC connection.
    and also
    java.sql.SQLException: ORA-01005: null password given; logon denied
    Looks like the user hr was not logged in. I tried to give explicit plaintext password in the file connections.xml as following
    <SecureRefAddr addrType="password">
    <Contents>hr</Contents>
    </SecureRefAddr>
    , but this also did not work.
    Could you please let me know how to make it working? I know for security concerns, we may need to have a log in form to do authentication. But for the quick-fix and pedagogic purpose, could anyone here please help?
    Many thanks.

    Dou you need to change the bc4j.xcfg content to reference the JNDI connection created in the deployment. Note that the deployed EAR creates a HrDS JDBC connnection with the credentials and Security user and associations, see the JNDI url in your app, for example, for "jdbc/HrDSDS", the entry to be added to the config file must be <Custom JDBCDataSource="java:comp/env/jdbc/HrDSDS"/>
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <BC4JConfig version="11.1" xmlns="http://xmlns.oracle.com/bc4j/configuration">
    <AppModuleConfigBag ApplicationName="lt.andrejusb.model.HrModule">
    <AppModuleConfig name="HrModuleLocal" ApplicationName="lt.andrejusb.model.HrModule" DeployPlatform="LOCAL" jbo.project="lt.andrejusb.model.Model">
    <Database jbo.TypeMapEntries="OracleApps"/>
    <Security AppModuleJndiName="lt.andrejusb.model.HrModule"/>
    *<Custom JDBCDataSource="java:comp/env/jdbc/HrDSDS"/>*
    </AppModuleConfig>
    <AppModuleConfig name="HrModuleShared" ApplicationName="lt.andrejusb.model.HrModule" DeployPlatform="LOCAL" jbo.project="lt.andrejusb.model.Model">
    <AM-Pooling jbo.ampool.maxpoolsize="1" jbo.ampool.isuseexclusive="false"/>
    <Database jbo.TypeMapEntries="OracleApps"/>
    <Security AppModuleJndiName="lt.andrejusb.model.HrModule"/>
    <Custom JDBCDataSource="java:comp/env/jdbc/HrDSDS"/>
    </AppModuleConfig>
    </AppModuleConfigBag>
    </BC4JConfig>

  • Help with running Ant

    In a quest to teach myself all about Java Servlets, I'm currently working my way through The Java Web Services Tutorial. However, I have become stuck as I try the command:
    ant build
    I recieve this message:
    Exception in thread 'main' java.lang.NoClassDefFoundError: and
    I don't know what is wrong. I have been throught the setting up steps 3 times and cant find any errors.
    What tests can I do to isolate the error?
    I really need help on this, I can't continue with learning until ant is working.
    Thank-you,
    Paul
    PS. When I'm checking my PATH variables in XP, I find it very annoying. When editing them, I can only use the very small input box provided. Is there any other way to edit them?

    crostar:
    If you run "java" from the command line, it will use the first java.exe found on the %PATH% variable (win os). Double check that the java.exe doesn't exist earlier in the %PATH%. Also, I've made the mistake where my environment variables aren't up to date because I opened a command window and then changing environment variables via the control panel.
    AliaAtreides:
    You'll need to post the full exception in order for others to determine what might be wrong. More specifically, we need to see the exception in order to determine what class can't be found.
    Also, make sure to set the JAVA_HOME and JWSDP_HOME environment variables. please be careful to note that the examples that came with the java web services dev pack have ant build.xml files that depend upon the jswdp.home variable being set. You'll need to set the variable in either the control panel, or in a separate build.properties file.
    Oh, one more thing, veramkovich's example sets JAVA_HOME to point to 1.4.1 whereas i think you're previous posts implied that you had a different path, 1.3.1

  • Need help with running a Java program on Linux

    I am trying to get a Java program to run on a Linux machine. The program is actually meant for a Mac computer. I want to see if someone with Java experience can help me determine what is causing the program to stall. I was successful in getting it installed on my Linux machine and to partially run.
    The program is an interface to a database. I get the login screen to appear, but then once I enter my information and hit enter the rest of the program never shows, however, it does appear to connect in the background.
    Here is the error when I launch the .jar file from the command screen:
    Exception in thread "main" java.lang.IllegalArgumentException: illegal component position
    at java.awt.Container.addImpl(Unknown Source)
    at java.awt.Container.add(Unknown Source)
    I am not a programmer and I am hoping this will make some sense to someone. Any help in resolving this is greatly appreciated!

    Well, without knowing a little bit about programming, and how to run your debugger, I don't think you're going to fix it. The IllegalArgumentException is saying that some call does not like what it's getting. So you'll have to go in an refactor at least that part of the code.

  • Help with Upload file to Server Examples

    I have been working with the examples for how to upload a file to the server. Though i got the example to work. there is one more thing i need to do. i need to allow the user to be able to select multiple files.  In the example when you click on Upload, it opens a MS window to allow you to select a file. This example does not allow you to select more then one file though. I found another example for selecting multiple files but this one differs very much in that the person who make it "Ryan Favro" created a whole new GUI window to select multiple files. those his example works great, i dont want a special window to select files, i want the MS window to do it.
    Is there a way to make the original example that uses the MS window to allow the user to select multiple files ?
    I have attached the example that uses the MS window.

    Hi,
    Use this code. May be it helps u.
    fileuploadapp.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:com="test.*" layout="absolute"
        creationComplete="initApp()" viewSourceURL="srcview/index.html">
        <mx:Script>
            <![CDATA[
                import mx.controls.Alert;
                private const _strDomain:String = new String("http://localhost:8400/");
                private const _strUploadScript:String = new String(_strDomain + "ProcessFileUp/UploadFile");
                // Initalize
                private function initApp():void {
                    Security.allowDomain(_strDomain);
            ]]>
        </mx:Script>
        <mx:Canvas width="400" height="300" horizontalCenter="0" verticalCenter="0">
            <com:FileUpload
                width="100%" height="100%"
                uploadUrl="{_strUploadScript}"
                uploadComplete="Alert.show('File(s) have been uploaded.', 'Upload successful')"
                uploadIOError="Alert.show('IO Error in uploading file.', 'Error')"
                uploadSecurityError="Alert.show('Security Error in uploading file.', 'Error')"/>
        </mx:Canvas>
    </mx:Application>
    fileuoload.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:com="*"
        layout="vertical" width="100%" minWidth="400" height="100%" minHeight="200"
        title="Upload Files" creationComplete="initCom()">
        <mx:Metadata>
            [Event(name="uploadComplete", type="flash.events.Event")]
            [Event(name="uploadProgress", type="flash.events.ProgressEvent")]
            [Event(name="uploadCancel", type="flash.events.Event")]
            [Event(name="uploadIOError", type="flash.events.IOErrorEvent")]
            [Event(name="uploadSecurityError", type="flash.events.SecurityErrorEvent")]
        </mx:Metadata>
        <mx:Script>
            <![CDATA[
                import mx.controls.*;
                import mx.managers.*;
                import mx.events.*;
                import flash.events.*;
                import flash.net.*;
                private var _strUploadUrl:String;
                private var _refAddFiles:FileReferenceList;   
                private var _refUploadFile:FileReference;
                private var _arrUploadFiles:Array;
                private var _numCurrentUpload:Number = 0;           
                // Set uploadUrl
                public function set uploadUrl(strUploadUrl:String):void {
                    _strUploadUrl = strUploadUrl;
                // Initalize
                private function initCom():void {
                    _arrUploadFiles = new Array();               
                    enableUI();
                    uploadCheck();
                // Called to add file(s) for upload
                private function addFiles():void {
                    _refAddFiles = new FileReferenceList();
                    _refAddFiles.addEventListener(Event.SELECT, onSelectFile);
                    _refAddFiles.browse();
                // Called when a file is selected
                private function onSelectFile(event:Event):void {
                    var arrFoundList:Array = new Array();
                    // Get list of files from fileList, make list of files already on upload list
                    for (var i:Number = 0; i < _arrUploadFiles.length; i++) {
                        for (var j:Number = 0; j < _refAddFiles.fileList.length; j++) {
                            if (_arrUploadFiles[i].name == _refAddFiles.fileList[j].name) {
                                arrFoundList.push(_refAddFiles.fileList[j].name);
                                _refAddFiles.fileList.splice(j, 1);
                                j--;
                    if (_refAddFiles.fileList.length >= 1) {               
                        for (var k:Number = 0; k < _refAddFiles.fileList.length; k++) {
                            _arrUploadFiles.push({
                                name:_refAddFiles.fileList[k].name,
                                size:formatFileSize(_refAddFiles.fileList[k].size),
                                file:_refAddFiles.fileList[k]});
                        listFiles.dataProvider = _arrUploadFiles;
                        listFiles.selectedIndex = _arrUploadFiles.length - 1;
                    if (arrFoundList.length >= 1) {
                        Alert.show("The file(s): \n\n• " + arrFoundList.join("\n• ") + "\n\n...are already on the upload list. Please change the filename(s) or pick a different file.", "File(s) already on list");
                    updateProgBar();
                    scrollFiles();
                    uploadCheck();
                // Called to format number to file size
                private function formatFileSize(numSize:Number):String {
                    var strReturn:String;
                    numSize = Number(numSize / 1000);
                    strReturn = String(numSize.toFixed(1) + " KB");
                    if (numSize > 1000) {
                        numSize = numSize / 1000;
                        strReturn = String(numSize.toFixed(1) + " MB");
                        if (numSize > 1000) {
                            numSize = numSize / 1000;
                            strReturn = String(numSize.toFixed(1) + " GB");
                    return strReturn;
                // Called to remove selected file(s) for upload
                private function removeFiles():void {
                    var arrSelected:Array = listFiles.selectedIndices;
                    if (arrSelected.length >= 1) {
                        for (var i:Number = 0; i < arrSelected.length; i++) {
                            _arrUploadFiles[Number(arrSelected[i])] = null;
                        for (var j:Number = 0; j < _arrUploadFiles.length; j++) {
                            if (_arrUploadFiles[j] == null) {
                                _arrUploadFiles.splice(j, 1);
                                j--;
                        listFiles.dataProvider = _arrUploadFiles;
                        listFiles.selectedIndex = 0;                   
                    updateProgBar();
                    scrollFiles();
                    uploadCheck();
                // Called to check if there is at least one file to upload
                private function uploadCheck():void {
                    if (_arrUploadFiles.length == 0) {
                        btnUpload.enabled = false;
                        listFiles.verticalScrollPolicy = "off";
                    } else {
                        btnUpload.enabled = true;
                        listFiles.verticalScrollPolicy = "on";
                // Disable UI control
                private function disableUI():void {
                    btnAdd.enabled = false;
                    btnRemove.enabled = false;
                    btnUpload.enabled = false;
                    btnCancel.enabled = true;
                    listFiles.enabled = false;
                    listFiles.verticalScrollPolicy = "off";
                // Enable UI control
                private function enableUI():void {
                    btnAdd.enabled = true;
                    btnRemove.enabled = true;
                    btnUpload.enabled = true;
                    btnCancel.enabled = false;
                    listFiles.enabled = true;
                    listFiles.verticalScrollPolicy = "on";
                // Scroll listFiles to selected row
                private function scrollFiles():void {
                    listFiles.verticalScrollPosition = listFiles.selectedIndex;
                    listFiles.validateNow();
                // Called to upload file based on current upload number
                private function startUpload():void {
                    if (_arrUploadFiles.length > 0) {
                        disableUI();
                        listFiles.selectedIndex = _numCurrentUpload;
                        scrollFiles();
                        // Variables to send along with upload
                        var sendVars:URLVariables = new URLVariables();
                        sendVars.action = "upload";
                        var request:URLRequest = new URLRequest();
                        request.data = sendVars;
                        request.url = _strUploadUrl;
                        request.method = URLRequestMethod.POST;
                        _refUploadFile = new FileReference();
                        _refUploadFile = listFiles.selectedItem.file;
                        _refUploadFile.addEventListener(ProgressEvent.PROGRESS, onUploadProgress);
                           _refUploadFile.addEventListener(Event.COMPLETE, onUploadComplete);
                        _refUploadFile.addEventListener(IOErrorEvent.IO_ERROR, onUploadIoError);
                          _refUploadFile.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onUploadSecurityError);
                        _refUploadFile.upload(request, "file", false);
                // Cancel and clear eventlisteners on last upload
                private function clearUpload():void {
                    _refUploadFile.removeEventListener(ProgressEvent.PROGRESS, onUploadProgress);
                    _refUploadFile.removeEventListener(Event.COMPLETE, onUploadComplete);
                    _refUploadFile.removeEventListener(IOErrorEvent.IO_ERROR, onUploadIoError);
                    _refUploadFile.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, onUploadSecurityError);
                    _refUploadFile.cancel();
                    _numCurrentUpload = 0;
                    updateProgBar();
                    enableUI();
                // Called on upload cancel
                private function onUploadCanceled():void {
                    clearUpload();
                    dispatchEvent(new Event("uploadCancel"));
                // Get upload progress
                private function onUploadProgress(event:ProgressEvent):void {
                    var numPerc:Number = Math.round((event.bytesLoaded / event.bytesTotal) * 100);
                    updateProgBar(numPerc);
                    var evt:ProgressEvent = new ProgressEvent("uploadProgress", false, false, event.bytesLoaded, event.bytesTotal);
                    dispatchEvent(evt);
                // Update progBar
                private function updateProgBar(numPerc:Number = 0):void {
                    var strLabel:String = (_numCurrentUpload + 1) + "/" + _arrUploadFiles.length;
                    strLabel = (_numCurrentUpload + 1 <= _arrUploadFiles.length && numPerc > 0 && numPerc < 100) ? numPerc + "% - " + strLabel : strLabel;
                    strLabel = (_numCurrentUpload + 1 == _arrUploadFiles.length && numPerc == 100) ? "Upload Complete - " + strLabel : strLabel;
                    strLabel = (_arrUploadFiles.length == 0) ? "" : strLabel;
                    progBar.label = strLabel;
                    progBar.setProgress(numPerc, 100);
                    progBar.validateNow();
                // Called on upload complete
                private function onUploadComplete(event:Event):void {
                    _numCurrentUpload++;               
                    if (_numCurrentUpload < _arrUploadFiles.length) {
                        startUpload();
                    } else {
                        enableUI();
                        clearUpload();
                        dispatchEvent(new Event("uploadComplete"));
                // Called on upload io error
                private function onUploadIoError(event:IOErrorEvent):void {
                    clearUpload();
                    var evt:IOErrorEvent = new IOErrorEvent("uploadIoError", false, false, event.text);
                    dispatchEvent(evt);
                // Called on upload security error
                private function onUploadSecurityError(event:SecurityErrorEvent):void {
                    clearUpload();
                    var evt:SecurityErrorEvent = new SecurityErrorEvent("uploadSecurityError", false, false, event.text);
                    dispatchEvent(evt);
                // Change view state
                private function changeView():void {
                    currentState = (currentState == "mini") ? "" : "mini";
            ]]>
        </mx:Script>
        <mx:states>
            <mx:State name="mini">
                <mx:SetProperty name="height" value="60"/>
                <mx:SetProperty name="minHeight" value="60"/>
                <mx:SetStyle target="{btnView}" name="icon" value="@Embed('assets/application_put.png')"/>
            </mx:State>
        </mx:states>
        <mx:transitions>
            <mx:Transition fromState="*" toState="*">
                <mx:Resize target="{this}" duration="1000"/>
            </mx:Transition>
        </mx:transitions>
        <mx:Canvas width="100%" height="100%">
            <mx:DataGrid id="listFiles" left="0" top="0" bottom="0" right="0"
                allowMultipleSelection="true" verticalScrollPolicy="on"
                draggableColumns="false" resizableColumns="false" sortableColumns="false">
                <mx:columns>
                    <mx:DataGridColumn headerText="File" dataField="name" wordWrap="true"/>
                    <mx:DataGridColumn headerText="Size" dataField="size" width="75" textAlign="right"/>
                </mx:columns>
            </mx:DataGrid>
        </mx:Canvas>
        <mx:ControlBar horizontalAlign="center" verticalAlign="middle">
            <mx:Button id="btnAdd" toolTip="Add file(s)" click="addFiles()" icon="@Embed('assets/add.png')" width="26"/>
            <mx:Button id="btnRemove" toolTip="Remove file(s)" click="removeFiles()" icon="@Embed('assets/delete.png')" width="26"/>
            <mx:ProgressBar id="progBar" mode="manual" label="" labelPlacement="center" width="100%"/>
            <mx:Button id="btnCancel" toolTip="Cancel upload" icon="@Embed('assets/cancel2.png')" width="26" click="onUploadCanceled()"/>
            <mx:Button label="Upload" toolTip="Upload file(s)" id="btnUpload" click="startUpload()" icon="@Embed('assets/bullet_go.png')"/>
            <mx:Button id="btnView" toolTip="Show/Hide file(s)" icon="@Embed('assets/application_get.png')" width="26" click="changeView()"/>
        </mx:ControlBar>   
    </mx:Panel>
    Regards,
         Shivang

Maybe you are looking for