ResourceContext(IUser) constructor is undefined,problem of Deprecated IUser

Hi Experts,
I have created an IUser as follows:
com.sap.security.api.IUser user = UMFactory.getUserFactory().getUserByLogonID("Kmuser");
now i m using this user into the following:
IResourceContext resourceContext = new ResourceContext(user);
For this i m getting a compiler error that constructor for ResourceContext(user) doesnt exist.
I did explored and studied about the IUser then i came to know that thare are two types of IUser one is com.sapportals.wcm.util.usermanagement.IUser which is deprecated and the newer one is com.sap.security.api.IUser.
ResourceContext class has all the constructor which takes only the deprecated IUser.
So does SAP APIs provides any other ResourceContext class which Works well with com.sap.security.api.IUser?????
Or is there any way to cast com.sap.security.api.IUser to com.sapportals.wcm.util.usermanagement.IUser????
Please help me out
Help will be appreciated and rewarded

Hi,
It is clear for me that you do not want to create Service user, but just to create a ReosurceContext for the service user <b>cmadmin_service</b>
This is the code to create ReosurceContext for the service user:
Object serviceContext = null;
try {
serviceContext = AccessController.doPrivileged(new PrivilegedExceptionAction() {
public Object run() throws WcmException {
return ResourceFactory.getInstance().getServiceContext("cmadmin_service");
} catch (PrivilegedActionException e) {
logger.severe(e, "ResourceContext for the technical " + serviceUser +
" user could not be retrieved.");
IResourceContext resCtx = (IResourceContext) serviceContext;
Regards,
Praveen Gudapati

Similar Messages

  • Undefined problem when attaching swf

    Hi all,
    I am trying to complete what should be a pretty standard
    activity, but am having many problems. The basic premise is this. I
    have a container swf whose job is to load data via remoting and
    then based upon that data build other swfs and then populate them
    with that data. The container swf works fine for the first half.
    Here is the code I use to attach the movies (using test data here,
    eventually I'll use a for loop to do this many times).
    var aListings = new Array();
    var mcl = new MovieClipLoader();
    var mc = this.createEmptyMovieClip("listing" + i,
    getNextHighestDepth());
    mcl.loadClip("/Listings/AdminListingsGrid/templates/GridTemplate5Test.swf?ListID=0",
    mc);
    aListings.push(mc);
    I'm creating an array, then a movie clip loader. Creating an
    empty movie clip then loading it with an external swf, sending a
    little data along as well. The external swf is controlled by an
    actionscript class as well. Then I'm adding the clip I loaded to an
    array for easy reference when populating the data. The trouble I'm
    having is that I can't seem to access any of the public methods of
    the new object. I trace them out and they are simply not getting
    called. I've added x-ray to the container class and noticed that
    the object I'm adding keeps picking up an undefined Class property.
    It will say undefined.movieclip.object, while all other objects
    will say something like com.blah.blah.movieclip.object. Anyone run
    into this before or have ideas on what I can do? Help is
    appreciated in advance.
    Thanks
    Robert

    Pablo,
    This new message with two image files attached, was received in good order. The two photos displayed in correct size, unlike the previous messages. Since no text was included I could not confirm they were sent in Plain Text. What took place as you composed this latest message? Did the images still display small?
    Did you change to always use Plain Text in Mail Preferences/Composing before any test sending in Plain Text?
    Edit -- I now have your second email. The screenshot is odd, but nothing of the sort was seen when received. The fact that you have had Growl is likely involved here, and it likely is not compatible, yet, with the latest OSX. Are you sure you have removed everything related to Growl? In Home/Library/Mail are there any folders or files named Bundles?
    Ernie
    Message was edited by: Ernie Stamper

  • Constructor Method parameter problem

    I write my class whit this constructor method.
    public Immobile(int id, String complesso, String tipoed,double prezzo) {
    this.id = id;
    this.complesso = complesso;
    this.tipoed =tipoed;
    this.prezzo = prezzo;
    in my app i want to create an object of Immobile class:
    Immobile imm = new Immobile(1,"nuovo",null,2);
    Always is ok
    if I don't want to pass the String parameter I set it whit null.
    But if I don't want to pass an integer like first parameter, or double like prezzo parameter, How can I do this?
    I don't want to use Overloading of method because if the Immobile class have for example 30 parameter, i don't want to write 30 constructor method.
    There is any possibility?

    I think that my design is ok.Two competent developers and me disagree with you.Sign me in here. Every time I get code with methods with more than 4 parameters I shudder.
    A class with 30 constructor parameters is probably a class with 30 fields and more often than not those class fields can be refactored in smaller classes, like ...
    I think that made a class User whit parameter Name,
    Surname, address, telefon, fax is ok
    and i think that a user probably haven't a fax.
    I think that one way can be to use all the parameter
    like String, that accept null, next, casting orsome
    conversion before insert in a database
    What do you think about this?Surname, address, telephone and fax give you 30
    variables? What are you doing, show a small piece of
    relevant code....
    class ContactInfo class for tel, fax, mail, pager.
    class Adress for City, street, country, etc.
    and so on.
    I don't know if BiggDaddy 's sugestion comes in hand in any problem solution but I know that it can very easily come out of hand, I worked on a system where everything was passed down through 2 parameters, that where in fact 2 arrays of parameters.
    The system was a mess, very hard to understand and to test, and bugs popped around in production time.
    May the code be with you.

  • Implicit super constructor is undefined.

    I'm getting this error:
    Implicit super constructor WeightedMeasurement is undefined. Must explicity invoke another constructor.
    WeightedMeasurement is an abstract class in apache.commons.math. So no, it does not have a constructor as such, though it does define 2:
    WeightedMeasurement(double weight, double measuredValue)
    WeightedMeasurement(double weight, double measuredValue, boolean ignored)So I I tried to override like so:
    import org.apache.commons.math.estimation.WeightedMeasurement;
    public class MyWeightedMeasurement extends WeightedMeasurement {
         public MyWeightedMeasurement() {
              String s = new String();
         public MyWeightedMeasurement(double weight, double measuredValue, int x) {
              new MyWeightedMeasurement();
    }but no dice.
    What do I need to do?
    I searched, but didn't find any help.

    I tried the following and it works:
    public abstract class ATestConst
         int computedValue = 0;
         public ATestConst(int val1, int val2)
              computedValue = val1 * val2;
    public class TestingConst extends ATestConst
         int myComputedValue = 0;
         public TestingConst(int v1, int v2, int v3)
              super(v1, v2);
              myComputedValue = super.computedValue / v3;
              System.out.println("My Computed Value: " + myComputedValue);
         public static void main(String[] args)
              int value1 = Integer.parseInt(args[0]);
              int value2 = Integer.parseInt(args[1]);
              int value3 = Integer.parseInt(args[2]);
              new TestingConst(value1, value2, value3);
    }

  • IUser deprecated

    I am trying with this cade. when I m using ResourceContext, the passed parameter IUser deprecation problem comes... How can I solve it ??
    Which ResourceContext class I should use? or any alternative ?? Please help me to write simple application to read property from portal since I m learning..
    Thanks in Adavanced.
    import com.sapportals.wcm.repository.IResource;
    import com.sapportals.wcm.repository.IResourceContext;
    import com.sapportals.wcm.repository.ResourceContext;
    import com.sapportals.wcm.repository.ResourceFactory;
    import com.sapportals.wcm.util.uri.RID;
    import com.sapportals.wcm.util.usermanagement.WPUMFactory;
    IUser user = WPUMFactory.getUserFactory().getEP5User.request.getUser());
    //IUser user = request.getUser();
    IResourceContext ctxt = new ResourceContext(user);
    RID rid = RID.getRID("/documents");
    IResource resource = ResourceFactory.getInstance().getResource(rid, ctxt);

    Hi Mehul,
    hi Patricio,
    > IUser type is deprecated
    > but there is not information about
    > which type we should use
    There is no other class to be used. It's just a strange thing to declare things as deprecated which (at some places) have to be used. The background is that EP5 had it's own user management, and with EP6 the super layer UME came into the game, but KM still uses the old classes.
    WPUMFactory.getUserFactory().getUMEUser(ep5User);
    WPUMFactory.getUserFactory().getEP5User(ep6User);
    are the methods to get one out of the other.
    Hope it helps
    Detlev
    PS: Mehul, please consider rewarding points for helpful answers on SDN. Thanks in advance!

  • IUser problem with com.sapportals.portal.security.usermanagement

    I am trying to get the current user so I have written
    IUser user = request.getUser();
    I have imported com.sap.security.api.*;
    The compiler insists I need com.sapportals.portal.security.usermanagement.IUser
    I thought that version was deprecated or at least not the preferred method?
    It keeps saying my classpath is incomplete. Why can't it use the IUser from the com.sap.security.api?
    Any help would be greatly appreciated.
    Thanks
    Paul

    Update
    The offending line appears to be IResourceContext myContext = new ResourceContext(user);
    when this line is added it causes the above error which I can only assume is because ResourceContext(user) accepts a different kind of user object. does anyone know if there is another way to do this? Here is the rest of the code to see where i am headed:
    IUser user = req.getUser();
    RID rid = RID.getRID("/temp");
    IResourceFactory factory = ResourceFactory.getInstance();
    IUserFactory uf = UMFactory.getUserFactory();
    IResourceContext myContext = new ResourceContext(user); //this is the line causing the problems.
    IResource resource = factory.getResource(rid, myContext);
    if(resource.isCollection())
    ICollection collection = (ICollection)resource;
    IResourceList children = collection.getChildren();
    Iterator i = children.listIterator();
    the point is i am trying to get the ACL permissions on the children of the rid

  • Fix for Deprecated methods to get ResourceContext

    So I'm rolling some of my own KM API based JSP pages and AbstractPortalComponents and I found the following code to gain access to the KM:
    com.sap.security.api.IUser user=(com.sap.security.api.IUser)request.getUser();
    com.sapportals.portal.security.usermanagement.IUser epUser = WPUMFactory.getUserFactory().getEP5User(user);
    ResourceContext ctx= new ResourceContext(epUser);
    The problem is, WPUMFactory.getUserFactory().getEP5User() is deprecated.  Surely there's a non-deprecated way to achieve getting a ResourceContext object.  Unfortunately I've not found a good guide on how to use the KM API that's not over 2 years old. 
    Any thoughts?

    Check this:
    -Using the KMC Platform in Standalone Web Applications-
    I developed a multiple upload files in KM web application and I used the KM repository.
    To access without nullPointerException you need to reference KM in the web project.
    see: https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/58013557-0701-0010-2c96-cdaed53ba065
    With that reference it works fine :):)
    Don't worry about that warning when build the DC.
    WARNING: No component dependency exists for reference to "com.sap.km.application" (vendor "sap.com", type "application")
    code:
    com.sap.security.api.IUser user;
    com.sap.security.api.IUser iUser = (com.sap.security.api.IUser) user;
    com.sapportals.portal.security.usermanagement.IUser epUser = WPUMFactory.getUserFactory().getEP5User(iUser);
    ResourceContext ctx = new ResourceContext(epUser);

  • Having problem with IUser

    Hi Everyone
    I have made the login() method but i am facing the problem while making the resource context...Because in Resource Context it takes IUser of package
    com.sapportals.portal.security.usermanagement.IUser but I have got IUser of package com.sap.security.api.IUser ...while type Casting it with below code it is giving ClassCAstException.......
    public class NewSimpleServlet extends HttpServlet {
    protected void doGet(
    HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    StringBuffer s = new StringBuffer();
    try {String j_user="epuser";
    String j_password="Abcd1234";
    request.setAttribute("j_user", j_user);
    request.setAttribute("j_password", j_password);
    javax.security.auth.Subject subject;
    Set principals = UMFactory.getLogonAuthenticator().logon(request, response, "uidpwdlogon").getPrincipals();
    i have problem with getting IUser object from set of principals. In javadoc is written: "In order to get an IUser object from this subject, call Subject.getPrincipals() and iterate through the returned Set of principals." so i tried to iterate but i was not able to get that IUser with any casting. Do u know how it should be?
    IUser serviceUser = (IUser)subject.getPrincipals().iterator().next();
    Now in resource Context
    ResourceContext c = new ResourceContext(User);
    Here resource context need IUser type object as parameter...
    I also tried st like this
    loggedUser = UMFactory.getAuthenticator().getLoggedInUser(request, response);
    but loggedUser is not authenticated.
    Can Anyone Help me Out...
    Thanks
    Rupesh Khemka

    posted two times

  • Constructor undefined , while initiating model node in component controller

    Hi Team,
    I am getting constructor undefined error, when i am trying create an object of model node in component contrloller.
    i tried the solution provided in this Undefined constructor and model nodes but it is working.
    can any one suggest me?
    Regards
    Bala

    Hi Akshaya,
    here is my code.
    i am just intatiating the model node in component contrlloer.
    the below method id in component controller.
    public void wdDoInit()
        //@@begin wdDoInit()
    try {
            AnyType_Item atm = new <b>AnyType_Item()</b>
    wdContext.nodeAnyType_Item().bind(atm);
    catch (RuntimeException e) {
         // TODO Auto-generated catch block
          e.printStackTrace();
          wdComponentAPI.getMessageManager().reportWarning(e.getMessage());
    The above bold one is error, saying constructor is undefined.
    regards
    Bala

  • Problem in uploading an image into a CM repository!!

    Hi All,
         I am trying to use the Fileupload element in JSP dynpage.
         My screen has the Fileupload element and a button.
         <b>I want to upload an image into a CM repository.</b>
         I have put <hbj:form id="myFormId" encodingType="multipart/form-data" > in my jsp page.
         The <b>'onClick'</b> method is <b>'onLoadFile'</b>.
         <i><b>The following is my code:</b></i>
    public void onLoadFile(Event event)
                   FileUpload fu =
                        (FileUpload) this.getComponentByName("myfileupload");
                   if (fu != null) {
                        //    Get file parameters
                        IFileParam fileParam = fu.getFile();
                        //    Get the temporary file name
                        File f = fileParam.getFile();
                        String fileName = fileParam.getFileName();
                        //    Get the selected file name
                        String ivSelectedFileName = fu.getFile().getSelectedFileName();
                        try {
                             int len = (int) f.length();
                             byte a[] = new byte[len];
                             FileInputStream fin = new FileInputStream(f);
                             fin.read(a);
                             String FileContent = a.toString();
                             IPortalComponentRequest request =
                                  (IPortalComponentRequest) this.getRequest();
                             com.sapportals.portal.security.usermanagement.IUser user =
                                  (com.sapportals.portal.security.usermanagement.IUser) request.getUser().getUser();
                             IResourceFactory factory = ResourceFactory.getInstance();
                             IResourceContext context = new ResourceContext(user);
                             RID rid = RID.getRID("/documents/test");
                             IResource resource = factory.getResource(rid, context);
                             if (resource != null) {
                                  ICollection parent =
                                       (ICollection) ResourceFactory
                                            .getInstance()
                                            .getResource(
                                            rid,
                                            context);
                                  String out = new String(FileContent);
                                  ByteArrayInputStream data =
                                       new ByteArrayInputStream(out.getBytes());
                                  IContent content =
                                       new Content(data, "text/html", data.available());
                                  IResource fileResource =
                                       parent.createResource(fileName, null, content);
                        } catch (Exception e) {
                   <b>..... REMAINING CODE...</b>
    I uploaded <b>abc.jpg (<i>size: 2KB</i>)</b>, then, an image file with the same-name is being created in the <b>/documents/test</b> folder but the size is <b>10Bytes</b> only. <b>I am not able to see the image</b> too.
    Can any1 help me plzzzz??? Would appreciate any kind of help.
    Thanks in advance.
    <b>
    Regards,
    Sai Krishna.</b>

    I would guess that this is because of the way you try to read the file contents. Maybe you should add some debug statements to find out what you're realling setting as content. It's certainly not KM's fault.
    The following sequence of statements looks wrong:
    nt len = (int) f.length();
    byte a[] = new byte[len];
    FileInputStream fin = new FileInputStream(f);
    fin.read(a);
    String FileContent = a.toString();
    IPortalComponentRequest request =
    (IPortalComponentRequest) this.getRequest();
    com.sapportals.portal.security.usermanagement.IUser user =
    (com.sapportals.portal.security.usermanagement.IUser) request.getUser().getUser();
    IResourceFactory factory = ResourceFactory.getInstance();
    IResourceContext context = new ResourceContext(user);
    RID rid = RID.getRID("/documents/test");
    IResource resource = factory.getResource(rid, context);
    if (resource != null) {
    ICollection parent =
    (ICollection) ResourceFactory
    .getInstance()
    .getResource(
    rid,
    context);
    String out = new String(FileContent);
    ByteArrayInputStream data =
    new ByteArrayInputStream(out.getBytes());
    IContent content =
    new Content(data, "text/html", data.available());
    Why don't you just pass the FileInputStream into the Content object's constructor???
    Best regards, Julian

  • Date problems

    Guys,
    I'm getting problem with a date conversion. I don't know what's wrong, but I know that it's wrong....
    Could somebody confirm this date for me ???
    #3d2d2d2d
    dateformat = (dd/mm/yyyy hh:mm:ss.mmm am/pm)
    I'm getting 11/06/2002 04:01:01.000 am, but I should get 05/12/2002 04:01:01....
    Any help is very welcome,
    thanks
    /jcf - follow I'm sending the code that I made the conversion...
    import java.util.*;
    public class DataConv {
    public DataConv() {
    public void start() {
    String xx = new String("#3d2d2d2d");
    System.out.println("-> " + xx);
    System.out.println("-> " + Long.decode(xx));
    Date d = new Date(Long.parseLong(Long.decode(xx).toString() + "000"));
    GregorianCalendar gc = new GregorianCalendar();
    gc.setTime(d);
    System.out.println("DIA = " + gc.get(gc.DAY_OF_MONTH));
    System.out.println("MES = " + gc.get(gc.MONTH ));
    System.out.println("ANO = " + gc.get(gc.YEAR ));
    System.out.println("HORA = " + gc.get(gc.HOUR_OF_DAY ));
    System.out.println("MINUTO = " + gc.get(gc.MINUTE ));
    System.out.println("SEGUNDO = " + gc.get(gc.SECOND ));
    System.out.println("MILISECOND = " + gc.get(gc.MILLISECOND ));
    public static void main(String[] args) {
    DataConv dataConv1 = new DataConv();
    dataConv1.start();
    }

    I'm not convinced this should even run, let alone run correctly.
    For the date string you give, I get the day 11 June 2002 as well, both in java and using perl (using seconds instead of milliseconds). Are you sure that value should be 5 Dec 02?
    Secondly, Date's constructor with a String is deprecated.
    Third, apparently Date's String constructor doesn't like the string to hold milliseconds since epoch.
    Fourth, why are you turning things into strings and back again and into strings and back again?

  • Problem in executing JFCunit test case

    Hi all,
    I have problem in executing a simple test case that checks for input blank fields entered.
    Below is the code for the test class that i am trying to run, but i am unable to execute it. Please can anyone try to resolve this.
    package unittest.com.erp;
    import junit.extensions.TestSetup;
    import junit.extensions.jfcunit.*;
    import junit.extensions.jfcunit.finder.*;
    import junit.extensions.jfcunit.eventdata.*;
    import junit.framework.Test;
    import junit.framework.TestSuite;
    import junit.textui.TestRunner;
    import com.erp.client.swing.ClientLoginDialog;
    import com.erp.client.swing.workspace.ClientWorkspaceFrame;
    import com.erp.client.swing.workspace.data.LoginResults;
    import javax.swing.*;
    public class LoginScreenTest
        extends JFCTestCase {
      private ClientLoginDialog loginScreen = null;
      private JButton login = null;
      private JButton cancel = null;
      private JTextField username = null;
      private JTextField password = null;
      private JFCTestHelper helper = null;
      LoginResults loginSuccess = null;
      ClientWorkspaceFrame workspaceFrame = null;
      public LoginScreenTest() {
      public LoginScreenTest(String name) {
        super(name);
      public static Test suite() {
        return new StartApp(new TestSuite(LoginScreenTest.class));
      private static class StartApp
          extends TestSetup {
         * Construct the test decorator, which starts the application     *
         * @param test
         *          Test case.
        public StartApp(final Test test) {
          super(test);
         * Start the LoginScreenTestapplication.
        public void setUp() {
          new Thread(new Runnable() {
            public void run() {
              try {
                new LoginScreenTest().setUp();
              } catch (Exception e) {
          }).start();
          try {
            Thread.currentThread().sleep(10000);
          } catch (InterruptedException ex) {
         * Tear down the LoginScreenTest application.
        public void tearDown() {
      protected void setUp()
          throws Exception {
        super.setUp(); // Choose the text Helper
        setHelper(new JFCTestHelper()); // Uses the AWT Event Queue.
        // setHelper( new RobotTestHelper( ) ); // Uses the OS Event Queue.
        ClientWorkspaceFrame workspaceFrame = ClientWorkspaceFrame.getHandle();
        // loginScreen = new ClientLoginDialog( "LoginScreenTest: " + getName());
        loginSuccess = ClientLoginDialog.login();
        loginScreen = ClientLoginDialog.login(new JFrame(), true);
        if (loginSuccess != null && loginSuccess.isSuccess()) {
          workspaceFrame.initFrame();
          workspaceFrame.loggedInUser = loginSuccess.getName();
          workspaceFrame.loggedInFullUserName = loginSuccess.getFullLoginUserName();
          workspaceFrame.loggedInUserPassword = loginSuccess.getPassword();
          workspaceFrame.setVisible(true);
          workspaceFrame.validate();
            flushAWT();
      protected void tearDown()
          throws Exception {
        login = null;
        cancel = null;
        username = null;
        password = null;
        loginScreen = null;
        flushAWT();
        // getHelper.cleanUp( this );
        super.tearDown();
      public void testInitialState() {
        NamedComponentFinder finder = new NamedComponentFinder(JButton.class, "Cancel");
        finder.setName("Cancel");
        JButton exitButton = (JButton) finder.find(loginScreen, 0);
        assertNotNull("Could not find the Exit button", exitButton);
        NamedComponentFinder finder1 = new NamedComponentFinder(JButton.class, "Login");
        finder1.setName("Login");
        JButton enterButton = (JButton) finder1.find(loginScreen, 0);
        assertNotNull("Could not find the Enter button", enterButton);
        getHelper().enterClickAndLeave(new MouseEventData(this, enterButton));
        assertEquals("", workspaceFrame.loggedInUser);
        assertEquals("", workspaceFrame.loggedInUserPassword);
      public static void main(final String[] args) {
        TestRunner.run(LoginScreenTest.suite());
    Thanks & Regards,
    VishalMessage was edited by:
    vishal_vj
    Message was edited by:
    vishal_vj
    Message was edited by:
    vishal_vj
    Message was edited by:
    vishal_vj

    hi All,
    can any one guide me how to run the test casese in JFCunit ? as when i tried to run thru command prompt its not recognising the main class at all.
    Now i m trying with eclipse problem here is that it is showing error to this line of code
    DialogFinder dFinder = new DialogFinder(loginScreen);
    error is constructor is undefined?
    So looking for some solution.
    with regards
    kin

  • Weblogic.security.provider.PrincipalValidatorImpl deprecated

    http://edocs.bea.com/wls/docs103/javadocs/weblogic/security/provider/PrincipalValidatorImpl.html says the class is deprecated though the documentation(http://edocs.bea.com/wls/docs103/dvspisec/atn.html#wp1089150) suggests its use.
    Anyone have any knowledge of the replacement api usage (com.bea.common.security.provider.PrincipalValidatorImpl) which does not seem to have a default constructor..

    Same Problem here. It seems com.bea.common.security.provider.PrincipalValidatorImpl has no API Reference. and weblogic.security.provider.PrincipalValidatorImpl which is obviously for the WLS 8 release is deprecated.
    Where to find an API Reference or some other documentation to com.bea.common.security.provider.PrincipalValidatorImpl ?

  • Problem in using InitialContext to do a lookup of CMP EnitityBean.

    Hi,
    I am running WLS 5.1 SP6 on Windows98. I am trying to lookup a CMP entiry bean from
    Java 1.3 client. I can successfully create the InitialContext but having trouble in using it to do the lookup. I get the following error:
    jndiContext is javax.naming.InitialContext@61f24(This is line is the result of println : see code)
    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 com.titan.cabin.Client_1.main(Client_1.java:21)
    My code of the Java 1.3 client is as follows:
    package com.titan.cabin;
    import com.titan.cabin.CabinHome;
    import com.titan.cabin.Cabin;
    import com.titan.cabin.CabinPK;
    import javax.naming.InitialContext;
    import javax.naming.Context;
    import javax.naming.NamingException;
    import java.rmi.RemoteException;
    import java.util.Properties;
    import java.util.Hashtable;
    public class Client_1 {
    public static void main(String [] args){
    try {
    InitialContext jndiContext = getWeblogicInitialContext();
    System.out.println("jndiContext is " + jndiContext);
    CabinHome home = (CabinHome)(jndiContext.lookup("CabinHome"));
    Cabin cabin_1 = home.create(1);
    System.out.println("created it!");
    cabin_1.setName("Master Suite");
    cabin_1.setDeckLevel(1);
    cabin_1.setShip(1);
    cabin_1.setBedCount(3);
    CabinPK pk = new CabinPK();
    pk.id = 1;
    System.out.println("keyed it! ="+ pk);
    Cabin cabin_2 = home.findByPrimaryKey(pk);
    System.out.println("found by key! ="+ cabin_2);
    System.out.println(cabin_2.getName());
    System.out.println(cabin_2.getDeckLevel());
    System.out.println(cabin_2.getShip());
    System.out.println(cabin_2.getBedCount());
    } catch (java.rmi.RemoteException re){re.printStackTrace();}
    catch (javax.naming.NamingException ne){ne.printStackTrace();}
    catch (javax.ejb.CreateException ce){ce.printStackTrace();}
    catch (javax.ejb.FinderException fe){fe.printStackTrace();}
    public static InitialContext getWeblogicInitialContext()
    throws javax.naming.NamingException {
    InitialContext ctx = null;
    Hashtable ht = new Hashtable();
    ht.put(Context.INITIAL_CONTEXT_FACTORY, weblogic.jndi.WLInitialContextFactory.class.getName());
    ht.put(Context.PROVIDER_URL, "t3://localhost:7001");
    ht.put(Context.SECURITY_PRINCIPAL, "system");
    ht.put(Context.SECURITY_CREDENTIALS, new weblogic.common.T3User("system", "askpanch"));
    try {
    ctx = new InitialContext(ht);
    // Use the context in your program
    catch (NamingException e) {
    System.out.println("InitialContext could not be created");
    System.out.println("The explanation is " + e.getExplanation());
    e.printStackTrace();
    // a failure occurred
    finally {
    try {ctx.close();}
    catch (Exception e) {
    // a failure occurred
    return ctx;
    The message printed by System.out.println shows that InitialContext is created but exception is thrown when it is used by the lookup method.
    My classpath is as follows:
    CLASSPATH=C:\VisualCafeEE\Java\Lib\ERADPUBLIC.JAR;C:\VisualCafeEE\Java\Lib\servlet.jar;C:\VisualCafeEE\Java\Lib\server.jar;C:\VisualCafeEE\Bin\Components\templa
    tes.jar;C:\VisualCafeEE\Java\Lib\javax_ejb.ZIP;C:\VisualCafeEE\Java\Lib\jndi.jar;C:\VisualCafeEE\Bin\Components\vcejbwl.jar;C:\VisualCafeEE\Bin\sb;C:\VisualCafe
    EE\Bin\sb\classes\sb.jar;.;;C:\VisualCafeEE\Java\Lib;C:\VisualCafeEE\Java\Lib\SYMCLASS.ZIP;C:\VisualCafeEE\Java\Lib\CLASSES.ZIP;C:\VisualCafeEE\Java\Lib\COLLECT
    IONS.ZIP;C:\VisualCafeEE\Java\Lib\ICEBROWSERBEAN.JAR;C:\VisualCafeEE\Java\Lib\SYMTOOLS.JAR;C:\VisualCafeEE\JFC\SWINGALL.JAR;C:\VisualCafeEE\Bin\Components\SFC.J
    AR;C:\VisualCafeEE\Bin\Components\SYMBEANS.JAR;C:\VisualCafeEE\Java\Lib\DBAW.ZIP;C:\VisualCafeEE\Bin\Components\DBAW_AWT.JAR;C:\VisualCafeEE\Bin\Components\Data
    bind.JAR;C:\VisualCafeEE\Java\Lib\ERADTOOLS.JAR;;C:\IBMVJava\eab\runtime30;C:\IBMVJava\eab\runtime20;;.;c:\Weblogic\classes;c:\weblogic\lib\weblogicaux.jar
    Any help to solove this problem from anybody is greatly appreciated. I am including some other related articles in this newsgroup for your ready reference(see below).
    Thanks a lot,
    Ashok Pancharya
    Email: [email protected]
    Sounds like your WL config is a bit different, perhaps a classpath issue or
    a missing .properties file or a different command line. For whatever
    reason, the factory does not know what class is supposed to be used as the
    initial context.
    Peace.
    Cameron Purdy
    [email protected]
    http://www.tangosol.com
    WebLogic Consulting Available
    "Chris Solar" <[email protected]> wrote in message
    news:[email protected]...
    Hi-
    I'm running WLS 5.1 on NT 4.0 (SP6).
    For some reason, I'm unable to use the default
    constructor to get an initial context. That is,
    if I try:
    InitialContext ctx = new InitialContext();
    I get a NoInitialContextException, as in:
    "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"
    This does not happen if I pass in a HashTable or Properties
    object containing a value for the initial context factory
    (even if it's just weblogic.jndi.WLInitialContextFactory).
    Colleagues of mine seem to be able to use
    the defaut constructor without any problems.
    What am I missing?
    -Chris.

    Thanks Gene. Good solution. I could solve the problem which is explained in my another article posted just before a minute you posted this response.
    Thanks again.
    Ashok Pancharya
    "Gene Chuang" <[email protected]> wrote:
    According to your getWeblogicInitialContext(), you are putting ctxt.close() in a finally block,
    which will always get executed, and then returning ctxt. Don't think you can do any lookups with a
    closed Context.
    Gene Chuang
    Join Kiko.com!
    "Ashok Pancharya" <[email protected]> wrote in message news:[email protected]...
    Hi,
    I am running WLS 5.1 SP6 on Windows98. I am trying to lookup a CMP entiry bean from
    Java 1.3 client. I can successfully create the InitialContext but having trouble in using it todo the lookup. I get the following error:
    jndiContext is javax.naming.InitialContext@61f24(This is line is the result of println : see code)
    javax.naming.NoInitialContextException: Need to specify class name in environment or systemproperty, 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 com.titan.cabin.Client_1.main(Client_1.java:21)
    My code of the Java 1.3 client is as follows:
    package com.titan.cabin;
    import com.titan.cabin.CabinHome;
    import com.titan.cabin.Cabin;
    import com.titan.cabin.CabinPK;
    import javax.naming.InitialContext;
    import javax.naming.Context;
    import javax.naming.NamingException;
    import java.rmi.RemoteException;
    import java.util.Properties;
    import java.util.Hashtable;
    public class Client_1 {
    public static void main(String [] args){
    try {
    InitialContext jndiContext = getWeblogicInitialContext();
    System.out.println("jndiContext is " + jndiContext);
    CabinHome home = (CabinHome)(jndiContext.lookup("CabinHome"));
    Cabin cabin_1 = home.create(1);
    System.out.println("created it!");
    cabin_1.setName("Master Suite");
    cabin_1.setDeckLevel(1);
    cabin_1.setShip(1);
    cabin_1.setBedCount(3);
    CabinPK pk = new CabinPK();
    pk.id = 1;
    System.out.println("keyed it! ="+ pk);
    Cabin cabin_2 = home.findByPrimaryKey(pk);
    System.out.println("found by key! ="+ cabin_2);
    System.out.println(cabin_2.getName());
    System.out.println(cabin_2.getDeckLevel());
    System.out.println(cabin_2.getShip());
    System.out.println(cabin_2.getBedCount());
    } catch (java.rmi.RemoteException re){re.printStackTrace();}
    catch (javax.naming.NamingException ne){ne.printStackTrace();}
    catch (javax.ejb.CreateException ce){ce.printStackTrace();}
    catch (javax.ejb.FinderException fe){fe.printStackTrace();}
    public static InitialContext getWeblogicInitialContext()
    throws javax.naming.NamingException {
    InitialContext ctx = null;
    Hashtable ht = new Hashtable();
    ht.put(Context.INITIAL_CONTEXT_FACTORY,weblogic.jndi.WLInitialContextFactory.class.getName());
    ht.put(Context.PROVIDER_URL, "t3://localhost:7001");
    ht.put(Context.SECURITY_PRINCIPAL, "system");
    ht.put(Context.SECURITY_CREDENTIALS, new weblogic.common.T3User("system", "askpanch"));
    try {
    ctx = new InitialContext(ht);
    // Use the context in your program
    catch (NamingException e) {
    System.out.println("InitialContext could not be created");
    System.out.println("The explanation is " + e.getExplanation());
    e.printStackTrace();
    // a failure occurred
    finally {
    try {ctx.close();}
    catch (Exception e) {
    // a failure occurred
    return ctx;
    The message printed by System.out.println shows that InitialContext is created but exception isthrown when it is used by the lookup method.
    My classpath is as follows:
    CLASSPATH=C:\VisualCafeEE\Java\Lib\ERADPUBLIC.JAR;C:\VisualCafeEE\Java\Lib\servlet.jar;C:\VisualCafe
    EE\Java\Lib\server.jar;C:\VisualCafeEE\Bin\Components\templa
    >
    tes.jar;C:\VisualCafeEE\Java\Lib\javax_ejb.ZIP;C:\VisualCafeEE\Java\Lib\jndi.jar;C:\VisualCafeEE\Bin
    \Components\vcejbwl.jar;C:\VisualCafeEE\Bin\sb;C:\VisualCafe
    >
    EE\Bin\sb\classes\sb.jar;.;;C:\VisualCafeEE\Java\Lib;C:\VisualCafeEE\Java\Lib\SYMCLASS.ZIP;C:\Visual
    CafeEE\Java\Lib\CLASSES.ZIP;C:\VisualCafeEE\Java\Lib\COLLECT
    >
    IONS.ZIP;C:\VisualCafeEE\Java\Lib\ICEBROWSERBEAN.JAR;C:\VisualCafeEE\Java\Lib\SYMTOOLS.JAR;C:\Visual
    CafeEE\JFC\SWINGALL.JAR;C:\VisualCafeEE\Bin\Components\SFC.J
    >
    AR;C:\VisualCafeEE\Bin\Components\SYMBEANS.JAR;C:\VisualCafeEE\Java\Lib\DBAW.ZIP;C:\VisualCafeEE\Bin
    \Components\DBAW_AWT.JAR;C:\VisualCafeEE\Bin\Components\Data
    >
    bind.JAR;C:\VisualCafeEE\Java\Lib\ERADTOOLS.JAR;;C:\IBMVJava\eab\runtime30;C:\IBMVJava\eab\runtime20
    ;;.;c:\Weblogic\classes;c:\weblogic\lib\weblogicaux.jar
    Any help to solove this problem from anybody is greatly appreciated. I am including some otherrelated articles in this newsgroup for your ready reference(see below).
    Thanks a lot,
    Ashok Pancharya
    Email: [email protected]
    Sounds like your WL config is a bit different, perhaps a classpath issue or
    a missing .properties file or a different command line. For whatever
    reason, the factory does not know what class is supposed to be used as the
    initial context.
    Peace.
    Cameron Purdy
    [email protected]
    http://www.tangosol.com
    WebLogic Consulting Available
    "Chris Solar" <[email protected]> wrote in message
    news:[email protected]...
    Hi-
    I'm running WLS 5.1 on NT 4.0 (SP6).
    For some reason, I'm unable to use the default
    constructor to get an initial context. That is,
    if I try:
    InitialContext ctx = new InitialContext();
    I get a NoInitialContextException, as in:
    "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"
    This does not happen if I pass in a HashTable or Properties
    object containing a value for the initial context factory
    (even if it's just weblogic.jndi.WLInitialContextFactory).
    Colleagues of mine seem to be able to use
    the defaut constructor without any problems.
    What am I missing?
    -Chris.

  • Date contructor deprecation : Parsing a String to Date

    Hi All,
    In Java 1.5 the Date() constructor Date(String s) is deprecated. As per the API Documentation DateFormat.Parse() method is used.
    The following code from Java 1.4 version has to be upgraded to Java 1.5.
    Existing Code:
    Date dDate = new Date(sDate);
    Modified Code:
    DateFormat df = DateFormat.getDateInstance();
    Date dDate = df.parse(sDate);
    Here the DateFormat accepts a default formatting style as "Feb 01, 2007" and parses the String.
    If the String sDate belongs to any other formatting style such as "01 Feb, 2007" or "01 Feb, 07" the code piece throws unparsable date error.
    Please give your thougts on this issue to parse the string of any format..
    Thanks,
    Rajesh.

    Hi All,
    In Java 1.5 the Date() constructor Date(String s) is
    deprecated. As per the API Documentation
    DateFormat.Parse() method is used.
    The following code from Java 1.4 version has to be
    upgraded to Java 1.5.
    Existing Code:
    Date dDate = new Date(sDate);
    Modified Code:
    DateFormat df = DateFormat.getDateInstance();
    Date dDate = df.parse(sDate);
    Here the DateFormat accepts a default formatting
    style as "Feb 01, 2007" and parses the String.
    If the String sDate belongs to any other formatting
    style such as "01 Feb, 2007" or "01 Feb, 07" the code
    piece throws unparsable date error.
    Please give your thougts on this issue to parse the
    string of any format..You can't. What date is this: "08/04/24"? 8 April, 1924? 4 August, 2024?
    >
    Thanks,
    Rajesh.

Maybe you are looking for

  • Restore iPhotoLibrary specifically from EXTERNAL Hard drive  Time Machine back up?

    My laptop Photo Library is corrupted somehow. I tried to restore from a prior in Time Machine on laptop and made the mistake of not saying to keep BOTH copies,  but after trying for 3 hours of telling me it was doing it through various windows, a lit

  • Need to run a prog on 1.4 which is running on 1.5. .....using two hashtable

    hello, I've developed a program which is prefectly working on java 1.5.0 version. but when run on java1.4.0. it gives run time error in this code. first i'm getting error in second hashtable. put function where i'm using key as an integer.this is run

  • SPEED TEST: 10.0.2 faster than 10.0.3

    After a couple of weeks battering my brain switching between two identical systems with one running 10.0.2 and the other 10.0.3, I decided to do a side-by-side comparion. To my (not really) surprise, 10.0.2 was much FASTER and less beachballing than

  • IC Webclient -- "Reason" field non-editable in "Interaction Record" view

    Dear All, I am working on CRM 5.0, IC Webclient. I have created a business transaction profile, and attached "Business Activity (0010)" as the transaction type. Now in the CIC screen, after clicking the "Interaction Record" hyperlink in the navigatio

  • Latitude D810 v Macbook Pro 15.4

    Hello all. I'm attending college this fall and am in need of a laptop. I am not a hardcore gamer but World of Wacraft and Star Wars Empire at War are my favorites now. I currently have a 3.2GHZ Dell desktop with 1GB RAM, 120GB HD, 128MB ATI Radeon 98