Accessing JNDI from Standalone JAVA application

Hi,
I want to access the JNDI tree from my
standalone java application. (ie I have
one weblogic server contains all my ejbs and client - swing - application which accesses that. )
Here I don't want to ship weblogic.jar
file to the client with swing application
because it is of ~ 20 MP.
Any other way to specify the INITIAL_CONTEXT_FATORY class.
My code is
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL, DTEConfig.PROVIDER_URL);
But since I don't want to give the
weblogic.jar bundle to my client, how he
could manage this with out weblogic.jndi.WLInitialContextFactory
with him to get the initialContext ?
-Rajan Kumar

You can strip out the jndi related classes from the weblogic.jar which can be distributed
to the client installation. I don't think you will be violating any bea licensing
policies with this.
Rajan Kumar <[email protected]> wrote:
Hi,
I want to access the JNDI tree from my
standalone java application. (ie I have
one weblogic server contains all my ejbs and client - swing - application
which accesses that. )
Here I don't want to ship weblogic.jar
file to the client with swing application
because it is of ~ 20 MP.
Any other way to specify the INITIAL_CONTEXT_FATORY class.
My code is
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL, DTEConfig.PROVIDER_URL);
But since I don't want to give the
weblogic.jar bundle to my client, how he
could manage this with out weblogic.jndi.WLInitialContextFactory
with him to get the initialContext ?
-Rajan Kumar

Similar Messages

  • How to open browser window from standalone Java Application???

    Is it possible to start Internet Explorer from non-applet application?

    Something like that could maybe help:
    Runtime.getRuntime.exec("iexplore http://www.google.com");
    but it's not platform independent + I couldn't let it work in that way. It only worked with Runtime.getRuntime.exec("c:\\windows\\....\\iexplore.exe http://www.google.com");
    But it's surely not platform independent.
    So the answer is in fact 'I don't know'.
    And if you ask why am I writing all that then, the answer is 'I don't know' too.
    And if you ask why...

  • What should be done in certmap.conf for 2-way SSL support from a standalone Java application to an SSL enabled LDAP Server

    To support certficate based client authentication using 2-way SSL from a standalone java application which uses JNDI and JSSE1.0.2 to connect to an SSL enabled LDAP Server how do we configure the certmap.conf?Is there any additional setup required at the LDAP Server side apart from enablinf SSL with the option"Required Client Authentication" enabled.The 2 way SSL handshake goes through but the access log file (After configuring the certmap.conf for the issuer DN of the client certficate etc..)shows SSL failed to LDAP DN?But inspite of this access log error the Java client does get an SSL Connection object with which it is able to connect to the LDAP.IS the certmap.conf file being looked up by the LDAP Server at all?

    have you out.flush() and out.close() before you call connection.getInputStream()?

  • How to get Portal user from a standalone Java application

    Hi,
    I have a standalone Java application from where I need to fetch the Portal User Information like userid and email id.
    I am using the below line of code
    iUser = UMFactory.getUserFactory().getUserByLogonID("e017939");
    I have included the jar file com.sap.security.api , But it was giving me the below exception
    java.lang.NoClassDefFoundError: com/sap/tc/logging/Location
         at com.sap.security.api.UMFactory.<clinit>(UMFactory.java:55)
         at com.am.wcas.java.mailscheduler.kmaccess.FetchDataFromKM.getiUser(FetchDataFromKM.java:29)
         at com.am.ScheduleEmails.main(ScheduleEmails.java:89)
    and I am getting a pop Up message from the Java Virtual Machine Launcher, saying a Fatal Exception has occured and the Program will exit.
    Then I went throught he SDN threads and they asked me to include the
    logging.jar and com.sap.security.perm.api .
    I Included them, then also, it is giving me Exception
    java.lang.NoClassDefFoundError: com/sap/engine/lib/logging/LoggingHelper
         at com.sap.security.api.UMFactory.<clinit>(UMFactory.java:56)
         at com.am.FetchKMData.main(FetchKMData.java:30)
    Exception in thread "main"
    and I am getting a pop Up message from the Java Virtual Machine Launcher, saying a Fatal Exception has occured and the Program will exit.
    Kindly let me know if it is possible to access the User info using UMFactory in a standalone Java application. If yes kindly let me know where i am going wrong.
    Regards,
    Shilpa B.V

    Hi Shilpa,
    1. Check that you have added com.sap.security.api within the Your Project>Libraries folder (under navigation tab) and also added jars in the build path of the Your Project under project>properties>Build Path.
    2. In case you have a DC instead of Web Dynpro Project then you have to add the com.sap.security.api under Your DC>Used DCs and have compile time and runtime dependency added.
    Here java.lang.NoClassDefFoundError is caused basically due to only build time dependency added and reference to the jar missing at runtime. Rest the code to retrieve the current user id using UME API and getUserByLogOnID("....") method with/without portal environment would not be an issue at all.
    Regards,
    Tushar SInha

  • How can access MS Outlook Calender information  from my Java application.

    People schedule meeting with some data on regular basis.
    I need to access the Exchange server from my Java application and get the meeting dates along with other data pertaining to meeting.

    I had the same problem, and I dont think (as far as my knowledge goes) there is any freeware that will enable Java to access Exchange server. But there are some commercial products that are available.
    Chk this link as an example: http://www.compoze.com/products_hme_desc.html
    good luck in the research
    -kms

  • Accessing custom Portal service from a java application

    We have a custom portal service that connects to BW using xmla. How do you access this portal service from a java application. Not from web dynpro, jsp or servlet but from the java code.
    Can we use the INITIAL_CONTEXT_FACTORY to get access to the portal service.
    Thank You
    D.K

    Now I tried the following:
    I've added the prtapi.jar and the service's jar to the additional-lib folder and added the appropriate entries to library.txt and reference.txt.
    Now I can obtain now the PortalRuntime, but this is not initialized.
    Has anybody a solution for this problem? Help would be high appreciated!
    Regards,
    Matthias

  • Report Engine SDK - Rbean usage in standalone java application

    Post Author: Berndb
    CA Forum: JAVA
    In BOXI the rebean sdk is available in the Report Engine SDK.
    I remember that in the 6.5 world one could use RBEAN interface in a standalone java application.
    Is this still possible in BOXI R2?
    If yes can you supply a sample classpath which shows all libraries that needs to be assigned.
    Thanks in advance.
    bernd

    Post Author: datahog
    CA Forum: JAVA
    Ted's right, but for fun, take what you need from:
    <installation drive>:\Program Files\Business Objects\Tomcat\webapps\businessobjects\enterprise115\desktoplaunch\WEB-INF\lib
    and de-reference what's not needed when your project's done, but be careful.
    I've actually done some standalone Swing-based webi report renderers using https://xhtmlrenderer.dev.java.net/ + docHTMLView.getStringpart + TagSoup

  • Can we call a webservice  using standalone java application  ?

    Hi friends,
                   Can we call configurd webservice in xi , using standalone java application by just giving url of webservice ?
                  OR
                  Only by means of WEBDynapro we can call  ?
                    Can you please tell me the answer for this .
    Regards .,
    V.Rangarajan

    HI Ranga Rajan
    well, If at all if you have webservice...you can import that werbserivce as External definition in to IR.
    How to import:
    1) Go to IR and and move to your requied component and there you can see the option called imported objects...select on imported objects where you can give the name and you can select the webservices which you want to use it.
    2) Hope you are aware of that a werbservice will have the request and response.
    3) Create the mapping program accroding to your requirement.
    Go through blogs of Bhavesh and Naveen which talks about calling webservice in a specific condition:
    Webservice Calls From a User Defined Function - /people/bhavesh.kantilal/blog/2006/11/20/webservice-calls-from-a-user-defined-function
    Consuming/Calling webservices from DataBases - /people/sap.user72/blog/2005/10/20/consumingcalling-webservices-from-databases
    Also check this help file on Web Services:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/336365d3-0401-0010-9884-a651295aeaa9
    Cheers..
    Vasu
    <i>** Reward Points if found useful **</i>

  • NameNotFoundException when looking up datasource jndi from standalone clien

    Hi,
    I'm trying to lookup datasource jndi from standalone client, but always get exceptions.
    I configured an oralce datasource with jndi name "oracleDataSource". When looking it up in servlet, I can get connection.
    In order to test it from standalone client, I created following code:
    public class DataSourceTest
    * Attempt to authenticate the user.
    public static void main(String[] args)
    String datasource = null;
    if (args.length == 1 ) {
    datasource = args[0];
    System.out.println("datasource = "+datasource);
    if(datasource == null)
    datasource = "oracleDataSource";
    try{
    Connection conn = null;
    Properties env = new Properties();
    env.put("java.naming.factory.initial","com.sun.jndi.cosnaming.CNCtxFactory");
    env.put("java.naming.provider.url", "iiop://localhost:3700");
    Context initial = new InitialContext(env);
    if(datasource != null){
    DataSource ds = (DataSource)initial.lookup(datasource);
    conn = ds.getConnection();
    if(conn != null){
    System.out.println("datasource is gotten.");
    conn.close();
    else
    System.out.println("datasource is error.");
    System.exit(0);
    } catch (Exception ex) {
    System.err.println("Caught an unexpected exception!");
    ex.printStackTrace();
    When running, I get following exception:
    [java] datasource = oracleDataSource
    [java] Caught an unexpected exception!
    [java] javax.naming.NameNotFoundException. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound
    [java] at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:34)
    [java] at org.omg.CosNaming._NamingContextExtStub.resolve(_NamingContextExtStub.java:402)
    [java] at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:368)
    [java] at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:417)
    [java] at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:395)
    [java] at javax.naming.InitialContext.lookup(InitialContext.java:350)
    [java] at com.tbcn.ceap.test.cilent.DataSourceTest.main(DataSourceTest.java:42)
    I also tried many other methods but always got exceptions. What's wrong with it? How can I lookup the datasource jndi from standalone client?
    Thanks in advance!

    Thank Tuan!
    I tried. When running, the server will read security.properties and ejb.properties. But I didn't use ejb and I didn't know how to configure ejb.properties, so I let ejb.properties empty. The security.properties is as following:
    client.sendpassword=true
    server.trustedhosts=*
    interop.ssl.required=false
    interop.authRequired.enabled=false
    interop.nameservice.ssl.required=false
    The result is:
    [java] javax.naming.CommunicationException: Can't find SerialContextProvider
    [java] at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.java:63)
    [java] at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:120)
    [java] at javax.naming.InitialContext.lookup(InitialContext.java:347)
    [java] at com.tbcn.ceap.test.cilent.DataSourceTest.main(DataSourceTest.java:42)
    Also, I tried it with ACC. In sun sample ConverterClient.java under rmi-iiop/simple, I added following code under with ACC and without ACC. With ACC, I can get connection. But without ACC, I can't get it.
    try{
              DataSource ds = (DataSource)initial.lookup("oracleDataSource");
              Connection conn = ds.getConnection();
              if(conn != null){
              System.out.println("datasource oracleDataSource gotten.");
              conn.close();
              else
              System.out.println("oracleDataSource is error.");
    Does it means that we must lookup datasource jndi with ACC?

  • Standalone java application that calls Db2

    Hi,
    I am trying to use coherence in my standalone java
    application that makes JDBC calls to Db2.
    The sql statemet is like below:
    select lastName,firstName from employee where empNo=2224;
    In the application,I would read from the flat file say
    200 account numbers and query the database.
    If I have queried the database already with the given
    account,I want to retreive from the cache.
    I am having real trouble in getting this work with
    coherence software.
    Any psudo code in this regard will help me a lot.
    Thanks
    DJon

    Hi Jon,
    Thanks for the mail.I am struck in
    implementing the coherence in the sample program.
    any help in this regard is appreciated.
    Thanks
    DJon
    Below is the sample program that works without coherence.go to db2 and get the information.
    import java.sql.*;
    import java.util.*;
    public class DB2Client
    static void printColumn(String in)
    System.out.print(in);
    System.out.print(" | ");
    public static void main(String[] args)
    Driver myDriver = null;
    Connection myConnection = null;
    try
    myDriver =
    (Driver)Class.forName("com.ibm.db2.jcc.DB2Driver").newInstance();
    myConnection =
    DriverManager.getConnection("jdbc:db2:sample","dujon","jeff");
    PreparedStatement myStatement
    = myConnection.prepareStatement("SELECT
    empno,firstnme,lastname FROM employee where empno > ?");
    myStatement.setString(1,"00");
    ResultSet
    myResults=myStatement.executeQuery();
    while (myResults.next())
    printColumn(myResults.getString("empno") + "");
    printColumn(myResults.getString("firstnme") + "");
    printColumn(myResults.getString("lastname"));
    System.out.println();
    } catch (Exception e)
    e.printStackTrace();
    } finally
    try
    if (myConnection != null)
    myConnection.close();
    } catch (Exception e)
    Now,to implement the above sample with
    coherence I have written 2 programs.
    1. TangosolDB2Cache.java
    2. TestDB2Cache.java
    import com.tangosol.net.cache.CacheStore;
    import com.tangosol.util.Base;
    import java.sql.DriverManager;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.Collection;
    import java.util.Iterator;
    import java.util.LinkedList;
    import java.util.List;
    import java.util.Map;
    * An example implementation of CacheStore
    * interface.
    * @author erm 2003.05.01
    public class TangosolDB2Cache extends
    Base implements CacheStore
    // ----- constructors
    * Constructs DBCacheStore for a given
    database table.
    * @param sTableName the db table name
    public TangosolJDBCCache(String
    sTableName)
    m_sTableName = sTableName;
    configureConnection();
         * Set up the DB connection.
         protected void configureConnection()
              try
    Class.forName("com.ibm.db2.jcc.DB2Driver");
                   m_con =
    DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD);
                   m_con.setAutoCommit(true);
              catch (Exception e)
                   throw ensureRuntimeException(e,
    "Connection failed");
         // ---- accessors
    * Obtain the name of the table this
    CacheStore is persisting to.
    * @return the name of the table this
    CacheStore is persisting to
    public String getTableName()
    return m_sTableName;
    * Obtain the connection being used to
    connect to the database.
    * @return the connection used to
    connect to the database
    public Connection getConnection()
    return m_con;
    // ----- CacheStore Interface
    * Return the value associated with the
    specified key, or null if the
    * key does not have an associated
    value in the underlying store.
    * @param oKey key whose associated
    value is to be returned
    * @return the value associated with
    the specified key, or
    * <tt>null</tt> if no value is
    available for that key
    public Object load(Object oKey)
    Integer iKey = (Integer)key;
         return query("select
    lastName,firstName from employee where empNo = " + iKey);
    * Store the specified value under the
    specific key in the underlying
    * store. This method is intended to
    support both key/value creation
    * and value update for a specific key.
    * @param oKey key to store the
    value under
    * @param oValue value to be stored
    * @throws
    UnsupportedOperationException if this implementation or the
    * underlying store is
    read-only
    public void store(Object oKey, Object
    oValue)
              mycacheTable(oKey,oValue);
    public void erase(Object oKey)
         public void eraseAll(Collection
    colKeys)
              throw new
    UnsupportedOperationException();
         public Map loadAll(Collection colKeys)
              throw new
    UnsupportedOperationException();
         public void storeAll(Map mapEntries)
              throw new
    UnsupportedOperationException();
         // ----- data members
         Hashtable mycacheTable = new Hashtable(1000);
         * The connection.
         protected Connection m_con;
         * The db table name.
         protected String m_sTableName;
         * Driver class name.
         private static final String DB_DRIVER =
    "org.gjt.mm.mysql.Driver";
         * Connection URL.
         private static final String DB_URL =
    "jdbc:db2:sample";
         * User name.
         private static final String DB_USERNAME =
    "dujon";
         * Password.
         private static final String DB_PASSWORD =
    "jeff";
    TESTING THE ABOVE PROGRAM
    import com.tangosol.net.cache.CacheStore;
    import com.tangosol.util.Base;
    import
    com.tangosol.net.cache.MapCacheStore;
    import java.sql.DriverManager;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.Collection;
    import java.util.Iterator;
    import java.util.LinkedList;
    import java.util.List;
    import java.util.Map;
    public class TestDB2Cache {
         public static void main(String args[]){
                        TangosolJDBCCache mycache = new
    TangosolDB2Cache("employee");
                        Connection
    con=mycache.configureConnection();
                        MapCacheStore cacheStuff = new
    MapCacheStore(HashMap hmap);
                        String[] employeeNumbers =
    {"000010","000020","000030","000040","000050"};
                                  // find whether it has been cached already
                                       for(int
    i=0;i<employeeNumbers.length();i++){
                                       oCurValue =
    cacheStuff.load(employeeNumbers);
                                       if(oCurValue == null){
                                            // execute SQL statement
                                            con.executeQuery(oCurKey);
                                       else
                                            //get from cache the values and return
                                            cacheStuff.load(oCurKey);

  • How can i call a jasper report from a java Application

    Hi,
    i am chiranjit , currently i working in a web based ERP project, in this project as a report building tool we are using JasperReport wih eclipse plugin . in eclipse report's are generating very well but i am unable to call that report from a java application because i have no idea about the How to call a Jasper Report from a Java Application . so please send me the necessary class names, jar files names and programe code as early as possible.
    Chiranjit

    Ahh, kind of a duplicate thread:
    http://forums.java.sun.com/thread.jspa?threadID=631642
    @OP. You could have clarified your original post and the relationship of your question to java. You did not need a new thread.
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How can i call a VB6 project from my java application using JNI

    hi
    can anyone tell me the procedure of calling a VB6 project from any java application using JNI
    if anyone does know then tell me the detail procedure of doing that. I know that i have to create a dll of that VB6 project then to call it from the java application.
    if anyone know that procedure of creating dll file of an existing VB6 project please reply
    please if anyone know then let me know

    Ahh, kind of a duplicate thread:
    http://forums.java.sun.com/thread.jspa?threadID=631642
    @OP. You could have clarified your original post and the relationship of your question to java. You did not need a new thread.
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Reading a XML file in a standalone java application

    Hi,
    What are my options if I have a standalone java application running outside any app. server and I need to read an XML file, probably read some of the attributes in the file...? Please explain clearly as I'm new to this. Appreciate your help.
    Thanks,
    Mahdad

    nope you don't need a DTD
    you have to write your Java code in a way that doesn't rely too much on the structure:
    - avoid getFirstChild().getFirstChild()... because you know that this element is first grandson of that element)
    - prefer using getElementByTagName() or some XPath() API
    but if the XML completely changes, well, yeah, you have to do some programmation: better think well your document structure in the beginning.

  • Calling a web service from a Java application

    Does anyone have sample code showing how to call a web service over from a Java application? I'm deploy to HP-UX and seeking out the most standard and reliable approach.
    Thank you in advance.

    Keith,
    Download JWSDP 1.2, look at the tutorial for JAXRPC, especially
    the client portion.

  • How do i Hyperlink to a web page from a java application?

    How do i Hyperlink to a web page from a java application using internet explorer as my default web browser?

    It's very simple.You can start any Application with the class Runtime. The command is an array consisting of the path of .exe and the file to be open.
    String [] cmd={path of IE+Filename.exe,"URL of your website"}
    try
    Runtime.getRuntime().exec(cmd);
    catch (Exception e)
    System.err.println(e.toString());
    }

Maybe you are looking for

  • Macbook No Internet Connection - full bar on airport

    having this problem today. cannot get Internet connection to work. in safari it will load a page or two but wont load anymore. The airport icon in the menubar shows full signal strength all the time. The following messages appear in safari: You are n

  • Have just bought a wireles tv all st up ok and it not showing up on my macbook where do I look for ir

    I  have just set up my new wireless television to the internet ok and is connected to my network via airport express and LAN. I am supposed to be able to view my photos and music on my TV via my macbook but am not sure how to do this any help would b

  • I'll settle for a simple Yes or No...

    Is it possible (re-)edit text in item of HTML Editor minimal type? Hi, I created a form with an item of type HTML editor minimal. After insertig tekst and saving the text to the database (varchar2(4000)-type column) and displaying it in an APEX-repor

  • Tour issues

    I have had my Tour for a little over a year now. Up until this point I have been very happy with the phone and service provided by Verizon. About a week ago I noticed the phone started freezing up. After resetting the phone multiple times, it started

  • PowerPC apps won't launch

    Ooops, let me rephrase my Mac Mini problem. PowerPC apps will not launch on my 1.66MgHz Mac Mini running 10.4.6 with 512MB ram. The app icon will bounce 1-2 times in the doc and then nothing. I have tried the following based on suggestions from folks