How to specify class name in environment or system property

Hi,
Iam learning ejb. I was practicing the stateless session bean. I wrote a sample hello world application. While executing the client am getting the following error.
{color:#ff0000}Exception in thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at hw.HelloClient.main(HelloClient.java:20){color}
My Client program:
{color:#3366ff}package hw;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.*;
import java.util.*;
public class HelloClient {
public static void main(String[] args)throws Exception {
Properties prop = System.getProperties();
Context ctx= new InitialContext(prop); {color:#800000}// {color}{color:#800000}(Line no :20) here only error is pointing{color}
Object obj = ctx.lookup("HelloHome");
HelloHome home = (HelloHome)javax.rmi.PortableRemoteObject.narrow(obj,HelloHome.class);
Hello hello = home.create();
System.out.println(hello.hello());
hello.remove();
}{color}
please suggest me a solution.
note: iam using eclipse ganymede and jboss app server
Edited by: Arun_ece on Mar 10, 2009 1:13 AM

Hi,
You need to create a ejb-jar.xml and jboss.xml files to deploy the application on the servers.
Also, put these lines of codes after getting System Properties.
prop.put(Context.PROVIDER_URL, "iiop://localhost:[port_no]");Thanks,
Srikant

Similar Messages

  • Javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial

    Hi!
    I got this error message at runtime.
    After adding value to the Intialcontext by adding the following code snippet:
    Properties p = new Properties();
    p.put("java.naming.factory.initial",
    "com.sun.jndi.cosnaming.CNCtxFactory");
    p.put("java.naming.provider.url",
    "iiop://127.0.0.1:9010");
    initContext = new javax.naming.InitialContext(p);
    After this i am getting different error message:
    org.omg.CORBA.COMM_FAILURE:
    minor code: 1 completed: Maybe at om.sun.corba.se.internal.iiop.IIOPConnection.purge_calls(Unknown Source)
    at com.sun.corba.se.internal.iiop.ReaderThread.run(Unknown Source)
    Looking forward a proper solution
    for this problem.
    Thanks in advance.
    Regards,
    James Arun

    I have find the code to specify the naming context property to access another host
    Properties props = new Properties();
    props.setProperty("java.naming.factory.initial",
    "com.sun.enterprise.naming.SerialInitContextFactory");
    props.setProperty("java.naming.factory.url.pkgs",
    "com.sun.enterprise.naming");
    props.setProperty("java.naming.factory.state",
    "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
    // optional. Defaults to localhost. Only needed if web server is running
    // on a different host than the appserver
    props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
    // optional. Defaults to 3700. Only needed if target orb port is not 3700.
    props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");

  • Javax.naming.NoInitialContextException: Need to specify class name...

    Hello,
    I am trying to use a Database Connection Pool.
    Here is the test class am using to verify the connection pool:
    public static void main(String[] args) { Connection connection = null; try { InitialContext initialContext = new InitialContext(); DataSource dataSource = (DataSource)initialContext.lookup("jdbc/<alias>"); connection= dataSource.getConnection(); } catch (SQLException e) { //   TODO Auto-generated catch block e.printStackTrace(); } catch (NamingException e) { //   TODO Auto-generated catch block e.printStackTrace(); } Statement stmt = null; try { String query = ""; stmt = connection.createStatement(); ResultSet resultSet = null; query = "SELECT <column> ...'"; resultSet = stmt.executeQuery(query); while(resultSet.next()){ System.out.println(resultSet.getString(<column>)); } stmt.close();   stmt = null; connection.close(); connection = null; } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); }finally{ if (stmt != null) {   try {   stmt.close();   } catch (SQLException sqlex) {   // ignore -- as we can't do anything about it here   }   stmt = null;   }   if (connection != null) {   try { connection.close();   } catch (SQLException sqlex) {   // ignore -- as we can't do anything about it here   } connection = null;   } } }
    I get following exception..
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243) at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280) at javax.naming.InitialContext.lookup(InitialContext.java:347) at com.internal.test.TestRun.main(TestRun.java:53) java.lang.NullPointerException at com.internal.test.TestRun.main(TestRun.java:66) Exception in thread "main"
    The exception points to
    DataSource dataSource = (DataSource)initialContext.lookup("jdbc/OrderStatus");
    Is this the correct way to test...?
    Thanks
    Srinivas

    java_2006 wrote:
    You can't access a jdbc pool like that (simply with a main method).
    The Database connection pool must be managed by a container (a servlet or application server) like tomcat.
    That is not entirely true but it certainly helps and is generally the only way it is used anyway so one might as well do it.

  • How to specify alias name in system property while making 2way SSL con ?

    Hi All,
    I am tring to run a java client with 2way SSL which uses CAC card as keystore for the client. I have addded the following system property in my client program to make it work and change the java.security file to add pcks11 provider.
    System.setProperty("javax.net.ssl.keyStoreType", "pkcs11");
    System.setProperty("javax.net.debug", "ssl");
    The program works fine and handshake is successfully done . But the problem is when i have more than one trusted certificate in the CAC card, it take a default certificate. I want to specify the certificate that should be used to do the client auth maybe specify the alias name . I didnt find any system property to do so.
    Please let me know how to specify alias name as system property so that the 2way SSL used the specified alias for the client auth or is there any other way to specify the alias name. As in case i acccess the server URL from any browser i get a certificate selection prompt and the connection is established with the selected certificate.
    Thanks in advanced,
    Ruhul

    I didn't find any system property to do so.There isn't one.
    Please let me know how to specify alias name as system propertyYou can't.
    You would have to write a custom KeyManager. See the JSSE Reference Guide.

  • KSLD how to specify kernel name when run ksld command on host

    I am trying to use KSLD v1.0 and I could not reproduce similar result shown on KSLD User Guide. I followed almost everything on KSLD User Guide except I don't know how to specify kernel name when running ksld command. Here is what I have tried.
    #ksld -t debug /ksld-space/slo8/proto/root_sparc/platform/sun4u/kernel/sparcv9/unix 99
    I can only get unix and krtld read in. (ksld_dbx)modules could not show any modules *.o
    When I use this
    #ksld -t debug /ksld-space/slo8/proto/root_sparc/platform/sun4u/kernel/sparcv9/genunix 99
    then I can only read on genunix.
    Example on KSLD User Guide use unix.281, what is unix.281 created or obtained from target.
    I noticed some SUN Tachnical Support Guru are online to answer questions, thank you for your quick reply.

    I am having the same problem, did you get a solution?
    Thanks,
    I am trying to use KSLD v1.0 and I could not reproduce
    similar result shown on KSLD User Guide. I followed
    almost everything on KSLD User Guide except I don't
    know how to specify kernel name when running ksld
    command. Here is what I have tried.
    #ksld -t debug
    /ksld-space/slo8/proto/root_sparc/platform/sun4u/kernel
    sparcv9/unix 99
    I can only get unix and krtld read in.
    (ksld_dbx)modules could not show any modules *.o
    When I use this
    #ksld -t debug
    /ksld-space/slo8/proto/root_sparc/platform/sun4u/kernel
    sparcv9/genunix 99
    then I can only read on genunix.
    Example on KSLD User Guide use unix.281, what is
    unix.281 created or obtained from target.
    I noticed some SUN Tachnical Support Guru are online
    to answer questions, thank you for your quick reply.

  • How to specify realm name when calling weak( ) method on ServletAuthentication class?

    I've created a bunch of custom realms and for a specific user logon (form based "uname" and "pword"), the system knows exactly which custom realm to look up against. However, in using ServletAuthentication class, one can only specify realm name in strong(req, res, realmName), not the weak() method. Any clue?
    -john

    Hi John,
    Did you find the answer to this question? I'm having a similar problem when calling the ServletAuthentication.assertIdentity() method.
    Cheers,
    Vidar

  • How to specify table name using xdoclet

    Hi
    I'm trying to specify a table name using xdoclet 1.2.
    I've tried the @sql.table, but that ain't working (no table mapping name is
    writen to the *.jdo)
    I've tried using the @jdo.class-vendor-extension with key=table and
    value=tablename, but that ain't working either.
    I guess number two approach ain't working because kodo want table name
    extension inside another extension like this:
    <extension vendor-name="kodo" key="jdbc-class-map" value="base">
    <extension vendor-name="kodo" key="table" value="tablename"/>
    </extension>
    But, how do I specify the above using xdoclet?
    Regards
    Jesper

    Ok.
    Is it possible somehow to just tell kodo to use another table name without
    having to create mapping extensions for collections and stuff. Even better
    if one could specify a table name prefix to be used on all tables.
    My problem is that I need use kodo on an existing database having tables
    names that conflict with kodo's auto-generated tables names. The schematool
    will then try alter these tables :-(
    Regards
    Jesper
    "Stephen Kim" <[email protected]> wrote in message
    news:[email protected]...
    When you use metadata mapping extensions, you should not generate
    .mapping files as all that info is stored in the .jdo file. You should
    instead set kodo.jdbc.MappingFactory to metadata.
    Jesper Ladegaard wrote:
    Thanks.
    However, I still can't get it to work.
    I've created a java class named Role with xdoclet like this:
    * @jdo.persistence-capable
    * @jdo.class-vendor-extension
    * vendor-name="kodo" key="jdbc-class-map" value="base"
    * @jdo.class-vendor-extension
    * vendor-name="kodo" key="jdbc-class-map/table" value="BW_ROLE"
    * @jdo.class-vendor-extension
    * vendor-name="kodo" key="jdbc-class-map/pk-column" value="JDOID"
    Xdoclet generates a jdo file like this:
    <jdo>
    <package name="dk.pine.users.services.model">
    <class name="Role"
    identity-type="datastore"
    <!-- end class tag --><extension vendor-name="kodo"
    key="jdbc-class-map"
    value="base">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-class-map/table"
    value="BW_ROLE">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-class-map/pk-column"
    value="JDOID">
    </extension>
    <field name="users"
    default-fetch-group="true"
    <!-- end field tag --><collection
    element-type="dk.pine.users.services.model.User"
    embedded-element="false"
    <!-- end collection tag --></collection>
    <extension vendor-name="kodo"
    key="inverse-owner"
    value="roles">
    </extension>
    </field>
    </class>
    </package>
    </jdo>
    Now I run the mappingtool (with option refresh) and it generates a
    mapping
    file like this:
    <mapping>
    <package name="dk.pine.users.services.model">
    <class name="Role">
    <jdbc-class-map type="base" pk-column="JDOID"
    table="dbo.ROLE0"/>
    <jdbc-version-ind type="version-number"column="JDOVERSION"/>
    <jdbc-class-ind type="in-class-name" column="JDOCLASS"/>
    <field name="description">
    <jdbc-field-map type="value" column="DESCRIPTION"/>
    </field>
    <field name="name">
    <jdbc-field-map type="value" column="NAME0"/>
    </field>
    <field name="systemRole">
    <jdbc-field-map type="value" column="SYSTEMROLE"/>
    </field>
    <field name="users">
    <jdbc-field-map type="many-many"
    element-column.JDOID="JDOID" ref-column.JDOID="ROLES_JDOID"
    table="dbo.USER0_ROLES"/>
    </field>
    </class>
    </package>
    </mapping>
    I expected it to create a BW_ROLE, but it create a ROLE0 table????
    "Stephen Kim" <[email protected]> wrote in message
    news:[email protected]...
    You can use slashes to denote sub extensions.
    See the example near the bottom of this link:
    http://solarmetric.com/Software/Documentation/3.0.3/docs/ref_guide_integrati
    on_xdoclet.html
    Jesper Ladegaard wrote:
    Hi
    I'm trying to specify a table name using xdoclet 1.2.
    I've tried the @sql.table, but that ain't working (no table mapping
    name
    >>
    is
    writen to the *.jdo)
    I've tried using the @jdo.class-vendor-extension with key=table and
    value=tablename, but that ain't working either.
    I guess number two approach ain't working because kodo want table name
    extension inside another extension like this:
    <extension vendor-name="kodo" key="jdbc-class-map" value="base">
    <extension vendor-name="kodo" key="table" value="tablename"/>
    </extension>
    But, how do I specify the above using xdoclet?
    Regards
    Jesper
    Steve Kim
    [email protected]
    SolarMetric Inc.
    http://www.solarmetric.com
    Steve Kim
    [email protected]
    SolarMetric Inc.
    http://www.solarmetric.com

  • How to get class name of a object in run time, from its accessible context.

    Hi,
    I need to get the class name of a java object in run-time, given the AccessibleContext of that object.
    I gone through the AccessibleContext api documentation. but there is not way to get the class name for a java object using its AccessibleContext object.
    Do any one have any idea how to get the class name of an java object, given its accessible object Accessible.
    Thanks
    Timberlake

    816311 wrote:
    Please try to provide a solution for my requirement and avoid evaluating a requirement.
    I am a curious guyit's great to be curious. however, in this situation, the requirement makes no sense in the given context. so, in an effort to be helpful, the people on this forum are asking you the reason behind the requirement. the reason we do this is because we have experience answering questions on this forum and, more often than not, requirements which don't make sense are the result of misunderstandings or confusion on the part of the person making the requirement. if we can figure out why you want to do what you want to do, we may be able to point you in a direction which makes more sense.

  • HOW TO GIVE CLASS NAME DYNAMICALLY???

    Hi all!
    I want to give class name dynamically to my statment
    <jsp:useBean id="myBean" scope="session" class="myPackage.myClass"/>
    now here i want to pass a String as class name how can i do it?
    Jiaa:):):)

    Hi,
    You can't assign dynamically a classname in the instruction jsp:useBean
    S�b

  • How to get CLASS name for the generic item?

    Hi,
    I wrote following method to create a service instance.
    public static <IType> IType GetServiceInstance()
           IType type=null;
            try
            InitialContext ic=new InitialContext();
    //ERROR:      type=   ic.lookup(IType.class.getName());
            catch(Exception ex)
            //do handle
            return type;
        }please see the //Error: here its giving error, also i m not getting "class" variable in IDE!!!
    i want use like this;
    IUserService userService=ServiceFactory.GetServiceInstance<IUserService>();so how can i do this?
    Edited by: Manikandan.Java on Oct 31, 2007 3:02 AM

    I don't know if I understand your question, but you cannot find the class name because it is in run time just an object. You can, however, check if it is an instanceof.
    if (genericType instanceof MyType) {
         doMyThing();
    }

  • How to get Class Name given along with java.exe

    Hi friends,
    I am Mukesh, currently facing one problem
    On command prompt to execute any java program we give :
    C : \.-- > java ClassName
    This ClassName I need in my application, I want to do some post processing on that.
    Actually see what I want :
    public class Base
    static Base object;
    public static void main(String[] args) throws Exception
    object=(Base)Class.forName("Derived Class Name").newInstance();
    void main()
    public class Derived extends Base
    void main()
    System.out.println("Hello World");
    I am trying to Run Derived Class, since there is no entry point found, default JVM invoke the Base class's entry point, there I want to load
    Derived Class, but I am not getting any identity of derived class in Base class.
    I found one temporary solution to this problem :
    C: \ -- >java Derived Derived
    & in Base class, I have loaded class
    object=Class.forName(args[0]).newInstance();
    But I dont want to write the same thing twise just to know the Class name which is given along with java.exe.
    Is there any way to get the ClassName supplied with java.exe
    I have tried a lot, still I am trying !!!
    If any one knows the answer, help me.
    Regards.
    Mukesh.

    Multiple post. Please continue in other thread
    http://forum.java.sun.com/thread.jspa?threadID=5196980&tstart=0

  • How to get class name and method name within a class method?

    Hi,
    In a java class, is it possible to get its class name and the class method?
    Please advise.
    Thank you.

    I mean whether there's any built-in command that will
    return the class name instead of code it ourself, for
    easier maintenance.
    Possible?
    this.getClass().getName();

  • Cannot specify non-default KDC port using system property krb5.kdc

    For testing / debug it's very useful to be able to run the KDC on a non-default port. This can be specified in Kerberos config file by appending the port number to the KDC host name, delimited with a colon.
    The java.security.krb5.kdc property can be used to locate the KDC - Unfortunately in Config.java in the sun.security.krb5 package, when parsing the property the colon is used as a delimiter for multiple KDCs. The config object String.replace()s the colons with space chars. Then the KrbKdcReq.java module, when testing for a non-default port in the KDC string from the config object, looks for the colon delimiter - but this has been zapped. So it seems that it's not possible to specify the non-default port via the property.
    The workaround is to use the config file approach instead, but this is inconvenient and limits programmability (especially when using configuration reload) - Is there a prospect that the config parser might be adjusted backwards compatible (say, to recognise a double colon or an escape char) to fix this?
    regards
    Ted Hayes

    Greetings
    I'm sorry to dig this thread up, but I could really use some help concerning this. I need to set up ApacheDS in a remote machine, but I'm not allowed to have root access to it, which means I can't make ApacheDS to run its KDC at port 88. Port 88 is a reserved port in *nix machines, so I can't make ApacheDS to list on that port without admin previledges.
    On the other hand, I already have a client/server demo program that can connect to a kdc (which can be found at http://thejavamonkey.blogspot.com/2008/04/clientserver-hello-world-in-kerberos.html), but I don't know how to set it up to run on any other port. I noticed that teddy_salad mentioned something about a config file approach, but I don't know what he is referring to.
    At this point I should mention that its my first time trying to use JGSS, but I'm also running out of time to make the ApacheDS work. I'm supposed to make some benchmarking tests for my masters degree dissertation, and the deadline is approaching :\
    I only need to know how to change hte default port to which that application connects to. Thanks in advance to anyone who replies to this.

  • How to specify file name while invoking the GET_ZIP_BUNDLE service

    Hello.
    The GET_ZIP_BUNDLE service by default generate zip file with name "Bundle". I wanted to change this name runtime, that is while invoking this service. How can I do it?
    The class ziprenditions.ZipRenditionsHandler most probably handle this service by the method createRenditionBundle.
    There I saw a line:
    downloadName = LocaleResources.getString("csZipRenditionBundleName", this.m_service);I have tried to print the value of csZipRenditionBundleName and I got "Bundle". I am wondering is there any way to set a value to this message key?
    I have tried this idoc function:
    <$createRenditionBundle='some_name'$>before invoking the service. But this didn't work.
    Also I have tried to change it from Java class, and for that I have defined a custom service and did:
    LocaleUtils.encodeMessage("csZipRenditionBundleName", null, "JYM");But this also not working.
    What I want is to get the zip file with the name which is the same to the files it is archiving.
    For more information, here is how I am invoking the GET_ZIP_BUNDLE service:
    I have defined a form element:
    <form action="/cs/idcplg" method="POST" id="zipBundleForm" name="zipBundleForm">
       <input type="hidden" value="GET_ZIP_BUNDLE" name="IdcService">
       <input type="hidden" value="pkg:dDocName,pkg:dID,pkg:Rendition,pkg:RevisionSelectionMethod,pkg:AuxRenditionType" name="bundleKeys">                            
    </form>And I have a button with id downloadContent and I have attached the following JavaScript with it:
    $('#downloadContent').click(function (event){
       event.preventDefault();
       var formId = "zipBundleForm";
       var counter = 0;
       var renditionType = "";
       $("#zipBundleForm").find(":hidden").each(function() {
          if($(this).attr("name").startsWith("pkg:"))
             $(this).remove();     
       $("#downloadContentForm").find('input:checkbox:checked').each(function() {
          renditionType = $(this).val();
          $(".thumbnails").find('input:checkbox:checked').each(function() {
             if($(this).attr('data-type') == 'image'){
                createHiddenInputElement(formId, "pkg:dDocName" + counter, $(this).attr("name"));
                createHiddenInputElement(formId, "pkg:dID" + counter, $(this).attr("id"));
                createHiddenInputElement(formId, "pkg:Rendition" + counter, renditionType)
                createHiddenInputElement(formId, "pkg:RevisionSelectionMethod" + counter, "Specific");                                             
                counter++;     
       $("#zipBundleForm").submit();     
    var createHiddenInputElement = function(formId, elementName, elementValue){
       var newElement = document.createElement("input");
       newElement.setAttribute("type", "hidden");
       newElement.setAttribute("name", elementName);
       newElement.setAttribute("value", elementValue);
       $("#"+formId).append(newElement);
    }Thanks in advance.

    if you want a fixed bundle name other than "bundle", you can override the localization string entry 'csZipRenditionBundleName' in a component.

  • How to specify dataschema name for oracle data source?

    hi all,
    I've a following problem:
    we have specified 2 Oracle dataschemas into a one Oracle SID, choosing of dataschema depends on user login name. So, if I use SQL/Plus then I successful connect with proeprietary database schema, and when I specify this user in "data-sources.xml" for datasource definition, however connection estabished with a default dataschema.
    And so question: how can I choose proeprietary database schema defined in one Oracle SID? There is any settings for this purpose in data-sources.xml?
    thanx in advance,
    Val.

    sorry, it works! was my error.

Maybe you are looking for

  • How do I set Preview to be the PDF defult reader?

    How do I set Preview to be the PDF defult reader?

  • ArrayCollection vs. Array in HTTPService sending

    Hi, I want to send the content of an ArrayCollection as one of the parameters in an HTTPService. However, Flex concatenates the collection's values into one long string and sends it as the value of a single parameter. Doing this with arrays work just

  • HUGE problem installing FCP 7 -- Please HELP

    I know that the people in this forum are ridiculously smart -- I REALLY need some help! For the past six days I have been trying to install FCP 7.  I had a version of Final Cut Studio 2 and I wanted to upgrade to FCP 3.  So I put the install discs in

  • What happened to the chess picture?

    I liked the chess picture in Vista for Start menu and User picture, that was my favorite. Any way to get it installed in Windows 7?

  • WS-C2924-XL and port mirroring!

    Does anybody know if one can do port monitoring on a 2924 XL? I have done it on 3500's and 1900's but can't seem to find any document that shows how on a 2924. If so, please point how it can be done. The CatOS is 12.0(5). Thanks!