Standalone java class

hi, i have written a java file that works fine when i run it with a jsp file in weblogic. now i need to extract the class file as a standalone to run in a batch file. i got the following error:
Exception in thread "main" javax.naming.NoInitialContextException: Need to spec
fy class name in environment or system property, or as an applet parameter, or
n 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 myw_batch.Schedule.<init>(Schedule.java:72)
at test.main(test.java:11)
my database connection is as follow in my code:
ctx = new InitialContext();
ds = (DataSource)ctx.lookup("mydatasource");
con = ds.getConnection();
since my db data source is configured at the weblogic end, so will my standalone be able to reuse the data source? thks in advance.

Like it says, you
"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"
You can find out about it here: http://java.sun.com/products/jndi/tutorial/beyond/env/source.html
These are the default settings for weblogic.
You probably need these in a jndi.properties file
java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
java.naming.provider.url=t3://127.0.0.1:7001alternative is to try something like this:
Map env= new HashMap();
params.put("java.naming.factory.initial", "weblogic.jndi.WLInitialContextFactory");
params.put("java.naming.provider.url", "t3://127.0.0.1:7001");
ctx = new InitialContext(env);
...

Similar Messages

  • How to get user information in a standalone java class

    Is there a way to retrieve it in a stand alone java class (with no access to request object)? If so how do I get it?
    Thanks,
    Deepak

    Hi
    use this
    IWDClientUser currentUsers[]=WDClientUser.getClientUsers();
              //Displaying the count of logged on users
              wdComponentAPI.getMessageManager().reportSuccess("Number of logged on Users in the portal - "+(currentUsers.length-1));
              for(int i=0;i<currentUsers.length;i++){
                 if(currentUsers<i>!=null){
                     // Displaying the logged on users;
                     if(!currentUsers<i>.getLastName().equals("Guest")){
                          String first= currentUsers<i>.getFirstName();
                          wdComponentAPI.getMessageManager().reportSuccess("User - "currentUsers<i>.getFirstName()" "+currentUsers<i>.getLastName());
        //@@end

  • How to pass an argument to a standalone java class in JDeveloper

    To the experienced:
    In JDeveloper when you write a java class with a main() method that takes no argument, you just right click the java file and select Run to run the program. But suppose the main() method takes arguments, how do you pass your arguments to the program? This is especially a problem as I use the studio version of JDeveloper (Versions 10.1.3.4 and 11.1.1.3) that each uses the version of JDK bundled with it, rather than the JDK (which is yet another different version) installed at the OS level of the PC.
    Many thanks for your help!
    Newman

    Hi, Puthanampatti,
    Suppose a java class has a main() method:
    <pre>
    public class FormatTerm {
    public static void main(String[] args) {
    String year = args[0];
    String semester = args[1];
    </pre>
    What I want to know is how to pass the arguments when invoking FormatTerm within JDeveloper (i.e., without going out of JDeveloper to invoke FormatTerm on a command line in DOS). I would appreciate it very much if you know how to do that in JDeveloper 11g (I use Version 11.1.1.3) and could help me out.
    Thank you very much for your help!
    Newman

  • Create Standalone JAVA ClASS

    HI All,
    Can anyone help me out to create a stand-alone java classs??
    (It will call EJB Method).
    more Insight:
    We have developed one service. It is working fine in RAD 7.0. No issues in that. But as per requirements, We have to check that application as stand-alone class. we are trying to call stand alone Java class using command prompt and see if EJB gets invoked which is running on the WAS server?
    Is there any way ?

    Can anybody relook on my issue?
    HI All,
    Can anyone help me out to create a stand-alone java classs??
    (It will call EJB Method).
    more Insight:
    We have developed one service. It is working fine in RAD 7.0. No issues in that. But as per requirements, We have to check that application as stand-alone class. we are trying to call stand alone Java class using command prompt and see if EJB gets invoked which is running on the WAS server?
    Is there any way ?

  • StreamCorruptedException from Stateless Session bean to java class

    Hi all,
    We have 2 servers, a ColdFusion App server which contains suns jdk 1.4.2 and websphere appserver using Ibm jdk, 1.4.2. On Server 1, we have a standalone java class which does a stateless session bean lookup and requests a service from it. On server 2(websphere), we have a stateless session bean deployed which connects to a database using a jndi lookup, executes a query and returns back a CachedRowSet object (which populates the ResultSet from the above query.) In some cases, session bean returns back an array of objects or String objects or just plain int values.
    When the java class on server 1 invokes the methods returning CachedRowSet, we are getting a StreamCorruptedException, whereas on the server side, there is no exception. everything gets executed fine on websphere. This is the case only for CachedRowSet and not for other return types(as mentioned earlier the session bean returns an array of object in some cases which the java class on server 1 is successfully able to use).
    This is what the piece of code look like on server 1:
    // First gets a StatelessSessionBean using suns InitialContextFactory
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
    env.put(Context.PROVIDER_URL,"iiop://localhost:2809");
    System.out.println("Creating initial context");
    Context ctx = new InitialContext(env);
    System.out.println("Initial context created.");
    Object homeObj = ctx.lookup("cell/nodes/localhost/servers/server1/ejb/SSBHome");
    SSBHome eHome = (SSBHome)PortableRemoteObject.narrow(homeObj,SSBHome.class);
    System.out.println("Got Home");
    SSB eBean = eHome.create();
    CachedRowSet crs = eBean.getAccts(param1, param2);
    //This is the line of code which throws the exception.
    The stacktrace shoows as follows:
    Got Home
    java.io.StreamCorruptedException
         at com.sun.corba.se.internal.io.IIOPInputStream.inputRemoteMembersForReadFields(IIOPInputStream.java:1675)
         at com.sun.corba.se.internal.io.IIOPInputStream.readFields(IIOPInputStream.java:1595)
         at com.sun.corba.se.internal.io.InputStreamHook.readFields(InputStreamHook.java:177)
         at java.math.BigInteger.readObject(BigInteger.java:3034)
         at com.sun.corba.se.internal.io.IIOPInputStream.readObject(Native Method)
         at com.sun.corba.se.internal.io.IIOPInputStream.invokeObjectReader(IIOPInputStream.java:1298)
         at com.sun.corba.se.internal.io.IIOPInputStream.inputObject(IIOPInputStream.java:908)
         at com.sun.corba.se.internal.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:261)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:247)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:209)
         at com.sun.corba.se.internal.iiop.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1084)
         at com.sun.corba.se.internal.iiop.CDRInputStream.read_value(CDRInputStream.java:293)
         at com.sun.corba.se.internal.io.IIOPInputStream.inputObjectField(IIOPInputStream.java:1484)
         at com.sun.corba.se.internal.io.IIOPInputStream.inputClassFields(IIOPInputStream.java:1893)
         at com.sun.corba.se.internal.io.IIOPInputStream.defaultReadObjectDelegate(IIOPInputStream.java:424)
         at com.sun.corba.se.internal.io.InputStreamHook.defaultReadObject(InputStreamHook.java:163)
         at java.math.BigDecimal.readObject(BigDecimal.java:1084)
         at com.sun.corba.se.internal.io.IIOPInputStream.readObject(Native Method)
         at com.sun.corba.se.internal.io.IIOPInputStream.invokeObjectReader(IIOPInputStream.java:1298)
         at com.sun.corba.se.internal.io.IIOPInputStream.inputObjectUsingFVD(IIOPInputStream.java:1182)
         at com.sun.corba.se.internal.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:259)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:247)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:209)
         at com.sun.corba.se.internal.iiop.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:948)
         at com.sun.corba.se.internal.iiop.CDRInputStream.read_value(CDRInputStream.java:289)
         at com.sun.corba.se.internal.corba.TCUtility.unmarshalIn(TCUtility.java:266)
         at com.sun.corba.se.internal.corba.AnyImpl.read_value(AnyImpl.java:561)
         at com.sun.corba.se.internal.iiop.CDRInputStream_1_0.read_any(CDRInputStream_1_0.java:635)
         at com.sun.corba.se.internal.iiop.CDRInputStream.read_any(CDRInputStream.java:260)
         at com.sun.corba.se.internal.javax.rmi.CORBA.Util.readAny(Util.java:100)
         at javax.rmi.CORBA.Util.readAny(Util.java:90)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.read_Array(ValueHandlerImpl.java:586)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:244)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:209)
         at com.sun.corba.se.internal.iiop.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1084)
         at com.sun.corba.se.internal.iiop.CDRInputStream.read_value(CDRInputStream.java:293)
         at com.sun.corba.se.internal.io.IIOPInputStream.inputObjectField(IIOPInputStream.java:1577)
         at com.sun.corba.se.internal.io.IIOPInputStream.inputClassFields(IIOPInputStream.java:1796)
         at com.sun.corba.se.internal.io.IIOPInputStream.inputObject(IIOPInputStream.java:913)
         at com.sun.corba.se.internal.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:261)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:247)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:209)
         at com.sun.corba.se.internal.iiop.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:948)
         at com.sun.corba.se.internal.iiop.CDRInputStream.read_value(CDRInputStream.java:289)
         at com.sun.corba.se.internal.corba.TCUtility.unmarshalIn(TCUtility.java:266)
         at com.sun.corba.se.internal.corba.AnyImpl.read_value(AnyImpl.java:561)
         at com.sun.corba.se.internal.iiop.CDRInputStream_1_0.read_any(CDRInputStream_1_0.java:635)
         at com.sun.corba.se.internal.iiop.CDRInputStream.read_any(CDRInputStream.java:260)
         at com.sun.corba.se.internal.javax.rmi.CORBA.Util.readAny(Util.java:100)
         at javax.rmi.CORBA.Util.readAny(Util.java:90)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.read_Array(ValueHandlerImpl.java:586)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:244)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:209)
         at com.sun.corba.se.internal.iiop.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1084)
         at com.sun.corba.se.internal.iiop.CDRInputStream.read_value(CDRInputStream.java:293)
         at com.sun.corba.se.internal.io.IIOPInputStream.inputObjectField(IIOPInputStream.java:1577)
         at com.sun.corba.se.internal.io.IIOPInputStream.inputClassFields(IIOPInputStream.java:1796)
         at com.sun.corba.se.internal.io.IIOPInputStream.inputObject(IIOPInputStream.java:913)
         at com.sun.corba.se.internal.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:261)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:247)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:209)
         at com.sun.corba.se.internal.iiop.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1084)
         at com.sun.corba.se.internal.iiop.CDRInputStream.read_value(CDRInputStream.java:293)
         at com.sun.corba.se.internal.io.IIOPInputStream.inputObjectField(IIOPInputStream.java:1577)
         at com.sun.corba.se.internal.io.IIOPInputStream.inputClassFields(IIOPInputStream.java:1796)
         at com.sun.corba.se.internal.io.IIOPInputStream.inputObject(IIOPInputStream.java:913)
         at com.sun.corba.se.internal.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:261)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:247)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:209)
         at com.sun.corba.se.internal.iiop.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1084)
         at com.sun.corba.se.internal.iiop.CDRInputStream.read_value(CDRInputStream.java:293)
         at com.EJBProj._SSB_Stub.getAccts(_SSB_Stub.java:240)
         at com.test.Test1.getAccts(Test1.java:101)
         at com.test.Test1.<init>(Test1.java:65)
         at com.test.Test1.main(Test1.java:81)
    java.io.IOException: Unable to read value from underlying bridge : Serializable readObject method failed internally
         at com.sun.corba.se.internal.io.IIOPInputStream.throwExceptionType(Native Method)
         at com.sun.corba.se.internal.io.IIOPInputStream.defaultReadObjectDelegate(IIOPInputStream.java:446)
         at com.sun.corba.se.internal.io.InputStreamHook.defaultReadObject(InputStreamHook.java:163)
         at java.math.BigDecimal.readObject(BigDecimal.java:1084)
         at com.sun.corba.se.internal.io.IIOPInputStream.readObject(Native Method)
         at com.sun.corba.se.internal.io.IIOPInputStream.invokeObjectReader(IIOPInputStream.java:1298)
         at com.sun.corba.se.internal.io.IIOPInputStream.inputObjectUsingFVD(IIOPInputStream.java:1182)
         at com.sun.corba.se.internal.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:259)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:247)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:209)
         at com.sun.corba.se.internal.iiop.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:948)
         at com.sun.corba.se.internal.iiop.CDRInputStream.read_value(CDRInputStream.java:289)
         at com.sun.corba.se.internal.corba.TCUtility.unmarshalIn(TCUtility.java:266)
         at com.sun.corba.se.internal.corba.AnyImpl.read_value(AnyImpl.java:561)
         at com.sun.corba.se.internal.iiop.CDRInputStream_1_0.read_any(CDRInputStream_1_0.java:635)
         at com.sun.corba.se.internal.iiop.CDRInputStream.read_any(CDRInputStream.java:260)
         at com.sun.corba.se.internal.javax.rmi.CORBA.Util.readAny(Util.java:100)
         at javax.rmi.CORBA.Util.readAny(Util.java:90)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.read_Array(ValueHandlerImpl.java:586)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:244)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:209)
         at com.sun.corba.se.internal.iiop.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1084)
         at com.sun.corba.se.internal.iiop.CDRInputStream.read_value(CDRInputStream.java:293)
         at com.sun.corba.se.internal.io.IIOPInputStream.inputObjectField(IIOPInputStream.java:1577)
         at com.sun.corba.se.internal.io.IIOPInputStream.inputClassFields(IIOPInputStream.java:1796)
         at com.sun.corba.se.internal.io.IIOPInputStream.inputObject(IIOPInputStream.java:913)
         at com.sun.corba.se.internal.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:261)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:247)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:209)
         at com.sun.corba.se.internal.iiop.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:948)
         at com.sun.corba.se.internal.iiop.CDRInputStream.read_value(CDRInputStream.java:289)
         at com.sun.corba.se.internal.corba.TCUtility.unmarshalIn(TCUtility.java:266)
         at com.sun.corba.se.internal.corba.AnyImpl.read_value(AnyImpl.java:561)
         at com.sun.corba.se.internal.iiop.CDRInputStream_1_0.read_any(CDRInputStream_1_0.java:635)
         at com.sun.corba.se.internal.iiop.CDRInputStream.read_any(CDRInputStream.java:260)
         at com.sun.corba.se.internal.javax.rmi.CORBA.Util.readAny(Util.java:100)
         at javax.rmi.CORBA.Util.readAny(Util.java:90)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.read_Array(ValueHandlerImpl.java:586)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:244)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:209)
         at com.sun.corba.se.internal.iiop.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1084)
         at com.sun.corba.se.internal.iiop.CDRInputStream.read_value(CDRInputStream.java:293)
         at com.sun.corba.se.internal.io.IIOPInputStream.inputObjectField(IIOPInputStream.java:1577)
         at com.sun.corba.se.internal.io.IIOPInputStream.inputClassFields(IIOPInputStream.java:1796)
         at com.sun.corba.se.internal.io.IIOPInputStream.inputObject(IIOPInputStream.java:913)
         at com.sun.corba.se.internal.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:261)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:247)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:209)
         at com.sun.corba.se.internal.iiop.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1084)
         at com.sun.corba.se.internal.iiop.CDRInputStream.read_value(CDRInputStream.java:293)
         at com.sun.corba.se.internal.io.IIOPInputStream.inputObjectField(IIOPInputStream.java:1577)
         at com.sun.corba.se.internal.io.IIOPInputStream.inputClassFields(IIOPInputStream.java:1796)
         at com.sun.corba.se.internal.io.IIOPInputStream.inputObject(IIOPInputStream.java:913)
         at com.sun.corba.se.internal.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:261)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:247)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:209)
         at com.sun.corba.se.internal.iiop.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1084)
         at com.sun.corba.se.internal.iiop.CDRInputStream.read_value(CDRInputStream.java:293)
         at com.EJBProj._SSB_Stub.getAccts(_SSB_Stub.java:240)
         at com.test.Test1.getAccts(Test1.java:101)
         at com.test.Test1.<init>(Test1.java:65)
         at com.test.Test1.main(Test1.java:81)
    Again, everything seems to work fine on websphere server.
    Any Clue of why this is happening?
    All suggestions are greatly appreciated.
    Thanks
    Neorav
    Message was edited by:
    NeoravB

    Sorry for the confusion!
    The solution mentioned above is not the right solution.
    The above given code works fine irrespective of having corbaloc in the url, if you are working in the IBMs jvm.
    It fails if you are working in suns jvm.
    Anyone with any idea whats missing here.
    Thanks a lot for any suggestion/ideas
    Neorav

  • Using java class and variables declared in java file in jsp

    hi everyone
    i m trying to seperate business logic form web layer. i don't know i am doing in a right way or not.
    i wanted to access my own java class and its variables in jsp.
    for this i created java file like this
    package ris;
    import java.sql.*;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    public class  NewClass{
        public static void main(String args[]){
            Connection con = null;
            ResultSet rs=null;
            Statement smt=null;
            try{
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                con=DriverManager.getConnection("jdbc:mysql:///net","root", "anthony111");
                smt=con.createStatement();
               rs= smt.executeQuery("SELECT * FROM emp");
               while(rs.next()){
                String  str = rs.getString("Name");
                }catch( Exception e){
                    String msg="Exception:"+e.getMessage();
                }finally {
          try {
            if(con != null)
              con.close();
          } catch(SQLException e) {}
    }next i created a jsp where i want to access String str defined in java class above.
    <%--
        Document   : fisrt
        Created on : Jul 25, 2009, 3:00:38 PM
        Author     : REiSHI
    --%>
    <%@page import="ris.NewClass"%>
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>
            <h1><%=str%></h1>
        </body>
    </html>I wanted to print the name field extracted from database by ResultSet.
    but it gives error cannot find symbol str.
    please help me to find right way to do this.
    i am using netbeans ide.

    Very bad approach
    1) Think if your table contains more than one NAMEs then you will get only the last one with your code.
    2) Your String is declared as local variable in the method.
    3) You have not created any object of NewClass nor called the method in JSP page. Then who will call the method to run sql?
    4) Your NewClass contains main method which will not work in web application, it's not standalone desktop application so remove main.
    Better create an ArrayList and then call the method of NewClass and then store the data into ArrayList and return the ArrayList.
    It should look like
    {code:java}
    package ris;
    import java.sql.*;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    public class  NewClass{
        public static ArrayList getNames(){
            Connection con = null;
            ResultSet rs=null;
            Statement smt=null;
            ArrayList nameList = new ArrayList();
            try{
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                con=DriverManager.getConnection("jdbc:mysql:///net","root", "anthony111");
                smt=con.createStatement();
               rs= smt.executeQuery("SELECT * FROM emp");
               while(rs.next()){
                nameList.add(rs.getString("Name"));
               return nameList;
                }catch( Exception e){
                    String msg="Exception:"+e.getMessage();
                   </code><code class="jive-code jive-java"><font>return nameList;</code><code class="jive-code jive-java">
                }finally {
          try {
            if(con != null)
              con.close();
          } catch(SQLException e) {}
          </code><code>return nameList;</code>
    <code class="jive-code jive-java">    }

  • Use DataSource of weblogic in a standalone Java file

    Hi,
    We have a requirement to run a java file at a scheduled time in a day using cron scheduler on our linux server.
    We need to fetch data from the database & perform some business logic in this standalone JAVA file.
    Our application has an EAR which is deployed on Weblogic 10.3 server & in our application, we are utilizing the datasource created in that domain using Hibernate.
    Now, can we create a standealone Java file & use exisitng datasource (without Hibernate) instead of legacy JDBC code to connect to DB.
    Also, do we need to keep this JAVA file a part of this EAR, WAR or can we put the class file in anylocation outside this EAR & then utilize datasource feature.
    Please help on the same in implementation.
    Thanks,
    Uttam

    Hi Ravi,
    I did create Datasource domain & put wlclient.jar in my application classpath (Add jar in Java Build path of application), but, when I ran application, its giving below error
    Exception in thread "Main Thread" java.lang.NoClassDefFoundError: weblogic/kernel/KernelStatus
         at weblogic.jndi.Environment.<clinit>(Environment.java:78)
         at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:117)
         at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
         at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
         at javax.naming.InitialContext.init(InitialContext.java:223)
         at javax.naming.InitialContext.<init>(InitialContext.java:198)
         at TestDataSource.main(TestDataSource.java:37)
    Also, I'm putting code here as I there is no provision to attach the file here. Please let me know whats wrong here.
    Also, I've given the name of datasource as testDataSource through Admin console of the domain. Do we need to prefix the name with jdbc/ in the code or without that also it works?
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.Hashtable;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.sql.DataSource;
    public class TestDataSource {
         public static void main(String[] args)
              DataSource ds=null;
              Connection conn=null;
              Statement stmt=null;
              ResultSet rs=null;
              Context ctx=null;
              try
                   Hashtable ht = new Hashtable();
                   ht.put(Context.INITIAL_CONTEXT_FACTORY,
                   "weblogic.jndi.WLInitialContextFactory");
                   ht.put(Context.PROVIDER_URL,
                   "t3://172.19.244.180:7001");
                   System.out.println("HERE");
                   ctx=new InitialContext(ht);
                   ds=(DataSource)ctx.lookup("jdbc/testDataSource");
                   System.out.println("HERE AFER CONTEXT CREATION");
                   conn=ds.getConnection();
                   stmt=conn.createStatement();
                   rs=stmt.executeQuery("select distinct(circle) from AIRCEL_STORE_FINDER order by 1 ");
                   while (rs.next())
                        System.out.println("circle name "+rs.getString(1));
              }catch (Exception e) {
                   System.out.println("Error in Main "+e.toString());
                   e.printStackTrace();
              finally{
                   try{
                   if(rs!=null)
                        rs.close();
                   if(stmt!=null)
                        stmt.close();
                   if(conn!=null)
                        conn.close();
                   if(ds!=null)
                        ds=null;
                   if(ctx!=null)
                        ctx.close();
                   }catch (SQLException e) {
                        System.out.println("Error in SQLException Finally "+e.toString());
                   catch (NamingException e) {
                        System.out.println("Error in NamingException Finally "+e.toString());
    }

  • How to use standalone java client with an enterprise bean in J2EE 1.4

    Hi All,
    I am have deployed a stateless session bean in Sun's J2EE 1.4 Application Server. i am trying to call the bean using a standalone java client. but the client cannot access the bean.
    The error coming is:
    Jan 21, 2004 7:48:27 PM com.sun.corba.ee.impl.legacy.connection.SocketFactoryCo
    nectionImpl <init>
    WARNING: ORBUTIL.connectFailure
    org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
    at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(
    RBUtilSystemException.java:1739)
    at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(
    RBUtilSystemException.java:1757)
    at com.sun.corba.ee.impl.legacy.connection.SocketFactoryConnectionImpl.
    init>(SocketFactoryConnectionImpl.java:74)
    at com.sun.corba.ee.impl.legacy.connection.SocketFactoryContactInfoImpl
    createConnection(SocketFactoryContactInfoImpl.java:88)
    at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.begi
    Request(CorbaClientRequestDispatcherImpl.java:146)
    at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.request(Corba
    lientDelegateImpl.java:121)
    at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.is_a(CorbaCli
    ntDelegateImpl.java:212)
    at org.omg.CORBA.portable.ObjectImpl._is_a(ObjectImpl.java:112)
    at org.omg.CosNaming.NamingContextHelper.narrow(NamingContextHelper.jav
    :69)
    at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.ja
    a:58)
    at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:12
    at javax.naming.InitialContext.lookup(InitialContext.java:347)
    at StatelessSessionClient.main(StatelessSessionClient.java:17)
    Caused by: java.lang.RuntimeException: java.net.ConnectException: Connection re
    used: connect
    at com.sun.enterprise.iiop.IIOPSSLSocketFactory.createSocket(IIOPSSLSoc
    etFactory.java:390)
    at com.sun.corba.ee.impl.legacy.connection.SocketFactoryConnectionImpl.
    init>(SocketFactoryConnectionImpl.java:58)
    ... 10 more
    Caused by: java.net.ConnectException: Connection refused: connect
    at sun.nio.ch.Net.connect(Native Method)
    at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:457)
    at java.nio.channels.SocketChannel.open(SocketChannel.java:146)
    at com.sun.enterprise.iiop.IIOPSSLSocketFactory.createSocket(IIOPSSLSoc
    etFactory.java:381)
    ... 11 more
    javax.naming.CommunicationException: Can't find SerialContextProvider
    at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.ja
    a:66)
    at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:12
    at javax.naming.InitialContext.lookup(InitialContext.java:347)
    at StatelessSessionClient.main(StatelessSessionClient.java:17)
    Caused by: org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed
    No
    at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(
    RBUtilSystemException.java:1739)
    at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(
    RBUtilSystemException.java:1757)
    at com.sun.corba.ee.impl.legacy.connection.SocketFactoryConnectionImpl.
    init>(SocketFactoryConnectionImpl.java:74)
    at com.sun.corba.ee.impl.legacy.connection.SocketFactoryContactInfoImpl
    createConnection(SocketFactoryContactInfoImpl.java:88)
    at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.begi
    Request(CorbaClientRequestDispatcherImpl.java:146)
    at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.request(Corba
    lientDelegateImpl.java:121)
    at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.is_a(CorbaCli
    ntDelegateImpl.java:212)
    at org.omg.CORBA.portable.ObjectImpl._is_a(ObjectImpl.java:112)
    at org.omg.CosNaming.NamingContextHelper.narrow(NamingContextHelper.jav
    :69)
    at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.ja
    a:58)
    ... 3 more
    Caused by: java.lang.RuntimeException: java.net.ConnectException: Connection re
    used: connect
    at com.sun.enterprise.iiop.IIOPSSLSocketFactory.createSocket(IIOPSSLSoc
    etFactory.java:390)
    at com.sun.corba.ee.impl.legacy.connection.SocketFactoryConnectionImpl.
    init>(SocketFactoryConnectionImpl.java:58)
    ... 10 more
    Caused by: java.net.ConnectException: Connection refused: connect
    at sun.nio.ch.Net.connect(Native Method)
    at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:457)
    at java.nio.channels.SocketChannel.open(SocketChannel.java:146)
    at com.sun.enterprise.iiop.IIOPSSLSocketFactory.createSocket(IIOPSSLSoc
    etFactory.java:381)
    ... 11 more
    My java client uses the following code to access the bean:
    Hashtable props = new Hashtable();
    String URL="iiop://localhost:3700";
    props.put("java.naming.factory.initial","com.sun.jndi.cosnaming.CNCtxFactory");
    props.put("java.naming.provider.url", URL) ;
    InitialContext ctx = new InitialContext();
    Object ref = ctx.lookup("ejb/StatelessSessionHome");
    StatelessSessionHome home = (StatelessSessionHome)PortableRemoteObject.narrow(ref,StatelessSessionHome.class);
    StatelessSessionRemote statelessSession = home.create();
    plz help me to locate the error.
    Regards,
    Mohit

    Hi Amol,
    thanks for your suggestion.
    i have deployed the converter application in J2EE1.4 tutorial in Sun AppServer J2EE1.4. the deployment process works smoothly. but accessing the deployed converter bean using standalone client as given in the tutorial gives the following error.
    Caught an unexpected exception!
    javax.naming.NoInitialContextException: Need to specify class name in environmen
    t or system property, or as an applet parameter, or in an application resource f
    ile: java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
    40)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.jav
    a:280)
    at javax.naming.InitialContext.lookup(InitialContext.java:347)
    at ConverterClient.main(ConverterClient.java:14)
    I have set the InitialHost and InitialPort as suggested by you in the client code. the client gets successfully compiled but gives error when executed.
    The client code is:
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.rmi.PortableRemoteObject;
    import java.math.BigDecimal;
    public class ConverterClient {
    public static void main(String[] args) {
    System.setProperty("org.omg.CORBA.ORBInitialHost","localhost");
    System.setProperty("org.omg.CORBA.ORBInitialPort","3700");          
    try {
    Context initial = new InitialContext();
    Object objref = initial.lookup
    ("java:comp/env/ejb/SimpleConverter");
    ConverterHome home =
    (ConverterHome)PortableRemoteObject.narrow(objref,
    ConverterHome.class);
    Converter currencyConverter = home.create();
    BigDecimal param = new BigDecimal ("100.00");
    BigDecimal amount =
    currencyConverter.dollarToYen(param);
    System.out.println(amount);
    amount = currencyConverter.yenToEuro(param);
    System.out.println(amount);
    System.exit(0);
    } catch (Exception ex) {
    System.err.println("Caught an unexpected exception!");
    ex.printStackTrace();
    Please suggest so that i can run the standalone client successfully.
    Regards,
    Mohit Kapoor

  • Getting error while running standalone Java application related to Workflow

    Hi,
    I am using the following code
    import oracle.bpel.services.workflow.client.IWorkflowServiceClient;
    import oracle.bpel.services.workflow.task.model.Task;
    import oracle.bpel.services.workflow.client.WorkflowServiceClientFactory;
    import oracle.bpel.services.workflow.verification.IWorkflowContext;
    import java.util.List;
    public class CompleteUserTask {
         public static void main(String[] args) throws Exception{
         System.out.println("Classpath: "+System.getProperty("java.class.path","."));
         String userId = "jcooper";
         String password = "welcome1";
         String taskId = "";
         IWorkflowServiceClient wfSvcClient = WorkflowServiceClientFactory.getWorkflowServiceClient(WorkflowServiceClientFactory.JAVA_CLIENT);
         IWorkflowContext wfCtx = wfSvcClient.getTaskQueryService().authenticate(userId,password,oracle.tip.pc.services.identity.config.ISConfiguration.getDefaultRealmName(),null);
         Task task = wfSvcClient.getTaskQueryService().getTaskDetailsById(wfCtx,taskId);
         List assigneeUsers = task.getSystemAttributes().getAssigneeUsers();
         List assigneeGroups = task.getSystemAttributes().getAssigneeGroups();
    if ((assigneeUsers != null && assigneeUsers.size() > 1)
    || (assigneeGroups != null && assigneeGroups.size() > 0))
         task = wfSvcClient.getTaskService().acquireTask(wfCtx, taskId);
         task = wfSvcClient.getTaskService().updateTaskOutcome(wfCtx, task, "Approve");
    I have added wf_client_config.xml, wf_config.xml,is_config.xml to the classpath. While executing this java code, i am getting the following error
    <XMLAuthenticationService::authenticateUser> XMLAuthenticationService:: call authenticate
    <PCException::<init>> User is not found.
    <PCException::<init>> User "jcooper" is not found in realm "jazn.com"
    <PCException::<init>> Check the error stack and fix the cause of the error. Contact oracle support if error is not fixable.
    <PCException::<init>> ORABPEL-10509
    <PCException::<init>>
    <PCException::<init>> User is not found.
    <PCException::<init>> User "jcooper" is not found in realm "jazn.com"
    <PCException::<init>> Check the error stack and fix the cause of the error. Contact oracle support if error is not fixable.
    Kindly help me out.
    Thanks,
    Gomathi

    Hi,
    I am not using OID. I am using only JAZN. I copied is_config.xml and wf_config.xml to classes folder where i am running standalone application and also i referred this to the classpath. Kindly do the needful.. I am struggling with this issue for past 3 days.
    Another thing is if i am giving the user name as "jcooper" it is throwing the error. If i give "oc4jadmin", then the issue resolved.
    kindly tell me what should i do inorder to login as jcooper instead of oc4jadmin
    Thanks,
    Gomathi
    Edited by: user647559 on Sep 15, 2008 4:37 AM

  • Accessing MS Sql Server with Java classes - problem connecting to socket

    I found an example at this location which uses java classes to connected to MS Sql Server.
    http://search400.techtarget.com/tip/1,289483,sid3_gci1065992,00.html
    --bummer - it is a login location - so I will include the article
    Anyway, the example is using Websphere, but I am still on Jbuilder (will get wsad soon). So I planted the classes from the example in
    C:\Borland\JBuilder\jkd1.4\jre\lib\ext\...the classes
    Then I copied the code from the example to my jpx project and got an error that it could not connect to the socket. The only thing I changed in the code was the connection string:
    --original string from example:
    Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://1433", "");
    I was getting an error with the 2 argument version of DriverManager - and the second argument here was empty (properties argument). Here was my connection string:
    Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://Myserver:1433;User=sa;Password=");
    I am only using the 1 argument version of DriverManager. Note that the password=" is blank because my RnD workstation is standalone - no one accesses the sql server except me - so no password. I also left out the last semicolon I noticed. Any suggestions appreciated how I could fix this.
    Thanks
    source of article:
    http://search400.techtarget.com/tip/1,289483,sid3_gci1065992,00.html
    iSeries 400 Tips:
    TIPS & NEWSLETTERS TOPICS SUBMIT A TIP HALL OF FAME
    Search for: in All Tips All search400 Full TargetSearch with Google
    PROGRAMMER
    Sample code: Accessing MS SQL Server database from the iSeries
    Eitan Rosenberg
    09 Mar 2005
    Rating: --- (out of 5)
    Nowadays with the help of Java the iSeries can be integrated with other databases quite easy. This tip shows you how. The code included here uses the free Microsoft driver that can be downloaded from here. (SQL Server 2000 Driver for JDBC Service Pack 3)
    If your SQL server does not include the Northwind Sample Database you can find it here.
    http://www.microsoft.com/downloads/details.aspx?familyid=07287b11-0502-461a-b138-2aa54bfdc03a&displaylang=en
    The download contains the following files:
    msbase.jar
    mssqlserver.jar
    msutil.jar
    Those files needs to be copied to the iSeries directories (/home/r_eitan/ExternalJARs).
    Here's the directory structure (on the iSeries) for this sample:
    /home/r_eitan/ExternalJARs - Microsoft files (msbase.jar,mssqlserver.jar,msutil.jar)
    /home/r_eitan/JdbcTest02 - My code (Main.java,Main.class)
    The Java code
    import java.sql.*;
    import java.io.*;
    class Main {
    * Connect to Microsoft SQL server and download file northWind.products as tab
    * seperated file. (products.txt)
    public static void main(String args[]) {
    try {
    PrintStream outPut = new PrintStream(new BufferedOutputStream(new FileOutputStream("products.txt")));
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    //Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://1433", "");
    Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://Myserver:1433;User=sa;Password=");
    System.out.println("Connection Done");
    connection.setCatalog("northWind");
    String sqlCmdString = "select * from products";
    Statement statement = connection.createStatement();
    ResultSet resultSet = statement.executeQuery(sqlCmdString);
    ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
    int columnCount = resultSetMetaData.getColumnCount();
    // Iterate throught the rows in resultSet and
    // output the columns for each row.
    while (resultSet.next()) {
    for (int index = 1; index <=columnCount; ++index)
    String value;
    switch(resultSetMetaData.getColumnType(index))
    case 2 :
    case 3 :
    value = resultSet.getString(index);
    break;
    default :
    value = """ + resultSet.getString(index) + """;
    break;
    outPut.print(value + (index < columnCount ? "t" : ""));
    outPut.println();
    outPut.close();
    resultSet.close();
    connection.close();
    System.out.println("Done");
    catch (SQLException exception)
    exception.printStackTrace();
    catch (Exception exception)
    exception.printStackTrace();
    --------------------------------------------------------------------------------------------------

    My guess is that the server's host name isn't right. It necessarily (or even usually) the "windows name" of the computer. Try with the numeric IP address instead (type "ipconfig" to see it).
    First aid check list for "connection refused":
    - Check host name in connect string.
    - Check port number in connect string.
    - Try numeric IP address of server host in connect string, in case name server is hosed.
    - Are there any firewalls between client and server blocking the port.
    - Check that the db server is running.
    - Check that the db server is listening to the port. On the server, try: "telnet localhost the-port-number". Or "netstat -an", there should be a listening entry for the port.
    - Try "telnet serverhost the-port-number" from the client, to see if firewalls are blocking it.
    - If "telnet" fails: try it with the numeric ip address.
    - If "telnet" fails: does it fail immediately or after an obvious timeout? How long is the timeout?
    - Does the server respond to "ping serverhost" or "telnet serverhost" or "ssh serverhost"?

  • How to insert message in OC4J JMS from standalone java client.

    Hi,
    I have been following available examples for creating standalone java clients to insert messages in JMS queues.
    I am able to insert using java client when the SOA suite and the standalone java code are on same machine.
    package producerconsumerinjava;
    import javax.jms.*;
    import javax.naming.*;
    import java.util.Hashtable;
    public class QueueProducer
    public static void main(String[] args)
    String queueName = "jms/demoQueue";
    String queueConnectionFactoryName = "jms/QueueConnectionFactory";
    Context jndiContext = null;
    QueueConnectionFactory queueConnectionFactory = null;
    QueueConnection queueConnection = null;
    QueueSession queueSession = null;
    Queue queue = null;
    QueueSender queueSender = null;
    TextMessage message = null;
    int noMessages = 5;
    * Set the environment for a connection to the OC4J instance
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "oracle.j2ee.rmi.RMIInitialContextFactory");
    env.put(Context.SECURITY_PRINCIPAL, "oc4jadmin");
    env.put(Context.SECURITY_CREDENTIALS, "mypass");
    env.put(Context.PROVIDER_URL,"ormi://myserver.company.com:12402"); //12402 is the rmi port
    * Set the Context Object.
    * Lookup the Queue Connection Factory.
    * Lookup the JMS Destination.
    try
    jndiContext = new InitialContext(env);
    queueConnectionFactory =
    (QueueConnectionFactory) jndiContext.lookup(queueConnectionFactoryName);
    queue = (Queue) jndiContext.lookup(queueName);
    catch (NamingException e)
    System.out.println("JNDI lookup failed: " + e.toString());
    System.exit(1);
    * Create connection.
    * Create session from connection.
    * Create sender.
    * Create text message.
    * Send messages.
    * Send non text message to end text messages.
    * Close connection.
    try
    queueConnection = queueConnectionFactory.createQueueConnection();
    queueSession =
    queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    queueSender = queueSession.createSender(queue);
    message = queueSession.createTextMessage();
    for (int i = 0; i < noMessages; i++)
    message.setText("Message " + (i + 1));
    System.out.println("Producing message: " + message.getText());
    queueSender.send(message);
    queueSender.send(queueSession.createBytesMessage());
    catch (JMSException e)
    System.out.println("Exception occurred: " + e.toString());
    finally
    if (queueConnection != null)
    try
    queueConnection.close();
    catch (JMSException e)
    System.out.println("Closing error: " + e.toString());
    But when the SOA Suite is remote, I am struggling to get the settings correct
    Till now, here is what I have figured out from looking at blogs/tars etc on the Net:
    1. I need to use ApplicationClientInitialContextFactory instead of RMIInitialContextFactory (http://download.oracle.com/docs/cd/E14101_01/doc.1013/e13975/jndi.htm)
    2. The project should have a META-INF/application-client.xml file, which may be dummy (http://www.wever.org/java/space/Oracle/JmsTar1). Question is, my code is there in a single absolutely standalone code..how I can use this application-client.xml and where it has to be placed.
    Errors:
    When trying to run exact same code on local server that tries to enqueue JMS on remotee serverer
    Exception occurred: javax.jms.JMSException: Unable to create a connection to "xxxxxxx.yyyyyy01.dev.com/10.42.456.11:12,602" as user "null".
    Any help is greatly welcome.
    As an exercise, I copied this complete code on the server and then ran locally using a telnet client...it worked. So the problem is coming when accessing the server remotely.
    Rgds,
    Amit

    1. I need to use ApplicationClientInitialContextFactory instead of RMIInitialContextFactoryNot necessarily.
    2. The project should have a META-INF/application-client.xml fileThat's only necessary if going the ApplicationClientInitialContextFactory route.
    There are two types of JMS client applications you can write -- a pure/plain Java app, and an "AppClient". That first is your everyday run-of-the-mill Java application, nothing special. That latter is a special, complicated beast that tries to act as a part of the whole client/server/J2EE architecture which provides you with a semi-managed environment. Either can be made to work, but if all you need is JMS access (using plain OC4J JMS factory/queue names and not JMS Connector names), then the first is easier to get working (and performs a tiny bit better as well due to being a lighter-weight solution).
    I think the problem you are having might be: When you use the plain Java client solution, you do not have any type of management, and that includes user management. With no user management (and if the JMS server is not configured to allow anonymous connections) you need to include the username and password in the call to createConnection. (I think it may be that this is actually true in the AppClient case as well -- I avoid using the AppClient model as much as possible so my memory there is weaker.)
    If you prefer to go the AppClient route, I would point you to a demo I wrote which had a functioning example, but Oracle seems to have removed it (and all of the 10.1.3 demos?) from OTN. :-(
    Hmm, it seems to still be available on the wayback machine:
    http://web.archive.org/web/20061021064014/www.oracle.com/technology/tech/java/oc4j/1013/how_to/index.html
    (Just look down the page for "With OEMS JMS (In-Memory and File-Based)" -- there is an .html document with info, and there is a .zip file with source code.)
    Question is, my code is there in a single absolutely standalone code..how I can use this application-client.xml and where it has to be placed.The app client in my demo had the following directory structure:
    myjavaclient.class
    jndi.properties
    META-INF\MANIFEST.MF
    META-INF\application-client.xml
    META-INF\orion-application-client.xml
    When you use ApplicationClientInitialContextFactory I think it just looks under .\META-INF for the .xml files.
    -Jeff

  • Error in oim Role creation using Role Manager Service API from Standalone Java client

    Hi,
      Facing the following error when trying to create Role using Role Manager Service API from a standalone java client .
    Tried with the solution of changing ,
    Login into the Web Logic Admin Console --> Servers --> OIM Server --> Protocols --> Modify the Maximum Message from 100000000 to 1000000000, but still the problem persists.
    Exception in thread "main" org.omg.CORBA.BAD_PARAM:   vmcid: 0x0  minor code: 0  completed: No
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at com.sun.corba.se.impl.protocol.giopmsgheaders.MessageBase.getSystemException(Unknown Source)
    at com.sun.corba.se.impl.protocol.giopmsgheaders.ReplyMessage_1_2.getSystemException(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.getSystemExceptionReply(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.processResponse(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.invoke(Unknown Source)
    at org.omg.CORBA.portable.ObjectImpl._invoke(Unknown Source)
    at com.sun.org.omg.SendingContext._CodeBaseStub.meta(Unknown Source)
    at com.sun.corba.se.impl.encoding.CachedCodeBase.meta(Unknown Source)
    at com.sun.corba.se.impl.io.IIOPInputStream.getOrderedDescriptions(Unknown Source)
    at com.sun.corba.se.impl.io.IIOPInputStream.inputObjectUsingFVD(Unknown Source)
    at com.sun.corba.se.impl.io.IIOPInputStream.simpleReadObject(Unknown Source)
    at com.sun.corba.se.impl.io.ValueHandlerImpl.readValueInternal(Unknown Source)
    at com.sun.corba.se.impl.io.ValueHandlerImpl.readValue(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_value(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream.read_value(Unknown Source)
    at oracle.iam.identity.rolemgmt.api._RoleManager_ogut7n_RoleManagerRemoteRIntf_Stub.createx(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:85)
    at $Proxy2.createx(Unknown Source)
    at oracle.iam.identity.rolemgmt.api.RoleManagerDelegate.create(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at Thor.API.Base.SecurityInvocationHandler$1.run(SecurityInvocationHandler.java:68)
    at weblogic.security.subject.SubjectProxy.doAs(SubjectProxy.java:64)
    at weblogic.security.subject.SubjectManager.runAs(SubjectManager.java:262)
    at weblogic.security.Security.runAs(Security.java:48)
    at Thor.API.Security.LoginHandler.weblogicLoginSession.runAs(weblogicLoginSession.java:52)
    at Thor.API.Base.SecurityInvocationHandler.invoke(SecurityInvocationHandler.java:79)
    at $Proxy3.create(Unknown Source)
    at com.idm.role.CreateRole.createRole(CreateRole.java:113)
    at com.idm.role.CreateRole.main(CreateRole.java:167)
    Thanks In Advance

    Hi , I have used OIM 11g  R2.
    Please find below the code we have used,
    package com.idm.role;
    import java.util.HashMap;
    import java.util.HashSet;
    import java.util.Hashtable;
    import java.util.Iterator;
    import java.util.Set;
    import java.util.logging.Logger;
    import javax.security.auth.login.LoginException;
    import oracle.iam.identity.exception.NoSuchRoleException;
    import oracle.iam.identity.exception.RoleAlreadyExistsException;
    import oracle.iam.identity.exception.RoleCreateException;
    import oracle.iam.identity.exception.RoleLookupException;
    import oracle.iam.identity.exception.RoleModifyException;
    import oracle.iam.identity.exception.SearchKeyNotUniqueException;
    import oracle.iam.identity.exception.ValidationFailedException;
    import oracle.iam.identity.rolemgmt.api.RoleManager;
    import oracle.iam.identity.rolemgmt.api.RoleManagerConstants;
    import oracle.iam.identity.rolemgmt.vo.Role;
    import oracle.iam.platform.OIMClient;
    import oracle.iam.platform.authz.exception.AccessDeniedException;
    public class CreateRole {
    private final static Logger LOGGER = Logger.getLogger(CreateRole.class .getName());
    OIMClient oimClient = null;
    public OIMClient connectToOIM() {
      LOGGER.info("In connectToOIM ");
      Hashtable env = new Hashtable();
      env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL,
        "weblogic.jndi.WLInitialContextFactory");
      env.put(OIMClient.JAVA_NAMING_PROVIDER_URL,
        "t3://V-hydidm1.itig.co.in:14000");
      System.setProperty("java.security.auth.login.config",
        "F:\\Projects\\IDM\\Team\\Env_setup\\OIM_Setup\\designconsole\\config\\authwl.conf");
      System.setProperty("java.security.policy",
        "F:\\Projects\\IDM\\Team\\Env_setup\\OIM_Setup\\designconsole\\config\\xl.policy");
      System.setProperty("OIM.AppServerType", "wls");
      System.setProperty("APPSERVER_TYPE", "wls");
      System.setProperty("weblogic.Name", "oim_server1");
      oimClient = new OIMClient(env);
      try {
       oimClient.login("xelsysadm", "Passw0rd".toCharArray());
      } catch (LoginException e) {
       e.printStackTrace();
      System.out.println("Connected");
      return oimClient;
    public void readRoleMetadata() {
      LOGGER.info("in readRoleMetadata ");
      RoleManager roleManagerService = oimClient
        .getService(RoleManager.class);
      try {
       Role roleVo = roleManagerService.getDetails(
         RoleManagerConstants.ROLE_DISPLAY_NAME, "API Role1", null);
       Set attributeNameSet = roleVo.getAttributeNames();
       Iterator it = attributeNameSet.iterator();
       while (it.hasNext()) {
        System.out.println("Attribute Name :: " + it.next());
       // roleVo.setAttribute("ADentitlements", "Security Admin access");
       String adEntitlements = "" + roleVo.getAttribute("ADentitlements");
       System.out.println("AD Entitlements :: " + adEntitlements);
       System.out.println("DB Entitlements :: " + ""
         + roleVo.getAttribute("DBEntitlements"));
       System.out.println("Unix Entitlements :: " + ""
         + roleVo.getAttribute("UnixWindows"));
       System.out.println("VPN :: " + "" + roleVo.getAttribute("VPN"));
      } catch (SearchKeyNotUniqueException e) {
       e.printStackTrace();
      } catch (NoSuchRoleException e) {
       e.printStackTrace();
      } catch (RoleLookupException e) {
       e.printStackTrace();
      } catch (AccessDeniedException e) {
       e.printStackTrace();
    public void createRole() {
      LOGGER.info(" in Create role ");
      RoleManager roleManagerService = oimClient
        .getService(RoleManager.class);
      HashMap<String, Object> roleCreationAttrMap = new HashMap<String, Object>();
      roleCreationAttrMap.put(RoleManagerConstants.ROLE_NAME, "API Role1");
      roleCreationAttrMap.put(RoleManagerConstants.ROLE_DESCRIPTION,
        "This Role is created using API Role1");
      roleCreationAttrMap.put(RoleManagerConstants.ROLE_DISPLAY_NAME,
        "API Role1");
      roleCreationAttrMap.put("ADentitlements", "API Role1 AD Entitlements");
      roleCreationAttrMap.put("DBEntitlements", "API Role1 DB Entitlements");
      roleCreationAttrMap.put("VPN", "No");
      roleCreationAttrMap.put("UnixWindows", "API Role1 Unix Entitlements");
      Role roleVo = new Role(roleCreationAttrMap);
      try {
       System.out.println(" Before Create role *********************************************");
       roleManagerService.create(roleVo);
       System.out.println("Role Created .. ");
      } catch (ValidationFailedException e) {
       e.printStackTrace();
      } catch (RoleAlreadyExistsException e) {
       e.printStackTrace();
      } catch (RoleCreateException e) {
       e.printStackTrace();
      } catch (AccessDeniedException e) {
       e.printStackTrace();
    public void modifyRole() {
      LOGGER.info(" in modifyRole ");
      RoleManager roleManagerService = oimClient
        .getService(RoleManager.class);
      Role roleVo;
      try {
       roleVo = roleManagerService.getDetails(
         RoleManagerConstants.ROLE_DISPLAY_NAME, "API Role1", null);
       String roleKey = roleVo.getEntityId();
       HashMap<String, Object> roleCreationAttrMap = new HashMap<String, Object>();
       roleCreationAttrMap.put("ADentitlements",
         "Updated API Role1 AD Entitlements");
       Set roleKeySet = new HashSet<String>();
       roleKeySet.add(roleKey);
       Role roleVoNew = new Role(roleCreationAttrMap);
       roleManagerService.modify(roleKeySet, roleVoNew);
       System.out.println("Role Modified ..");
      } catch (SearchKeyNotUniqueException e) {
       e.printStackTrace();
      } catch (NoSuchRoleException e) {
       e.printStackTrace();
      } catch (RoleLookupException e) {
       e.printStackTrace();
      } catch (AccessDeniedException e) {
       e.printStackTrace();
      } catch (ValidationFailedException e) {
       e.printStackTrace();
      } catch (RoleModifyException e) {
       e.printStackTrace();
    public static void main(String args[]) {
      CreateRole miscObj = new CreateRole();
      miscObj.connectToOIM();
      miscObj.createRole();
      //miscObj.readRoleMetadata();
    Thanks In Advance .

  • How to represent XML inline tags in a Java class

    Dear all,
    I am currently dealing with the issue of how to transform an XML document into a Java representation. As far as the strucural elements are concerned, I'd represent them each one of them as a Java class. However, the XML structure also allows for inline tags, i.e. elements which specify formatting information for the text. I am looking for good ideas for how to best represent these in my Java class(es).
    Let's use an example. Suppose I have something like this:
    <root>
       <structure>A piece of text</structure>
       <moreStructure>A piece of <b>bold</b> text</moreStructure>
       <finalStructure>A piece of <inlineTag att="value"> more text!</inlineTag>   </finalStructure>
    </root>I this case I would build four classes for the strucural elements. But how do I represent <b> and <inlineTag>? In my XML documents I have several such inline tags, each of which may also have a bunch of attributes. I am sure this has been solved cleverly before. Any help greatly appreciated.
    Best regards,
    N.

    The XML term for "containing tags and text" is "mixed content". And XML designers generally don't care much for mixed content. You're finding out one of the reasons for that right now. They aren't elegant or clever, just inconvenient.
    However sometimes you have to deal with ugly structures. This is one of them. I would represent mixed content as a list, just as you already thought of. The elements in this list would be either text or elements. So in this example:<moreStructure>A piece of <b>bold</b> text</moreStructure>you would have three entries:
    1. Text "A piece of "
    2. A <b> element
    3. Text " text"
    And when retrieving from that list you would have to use "instanceof" to see if you had a String or an element of some kind.
    And if "standalone tags" versus "paired tags" is a complication, then you're looking at it wrong. XML doesn't care much about tags. Tags only exist to delimit an element, and you should be looking at elements.
    I'm guessing at your non-standard terminology here: a "standalone tag" is an empty element like
    , right? And "paired tags" means a non-empty element like <this>that</this>? They're all elements. The first is a "br" element and the second is a "this" element.

  • Java Mapping Error - Unable to instantiate the Java class

    Hi,
    I am trying out a Java Mapping scenario.
    The code worked fine in eclipse.i could get the desired output.
    but when i tried it out in XI ....i got the following error in moni:
    *Unable to instantiate the Java class*
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    - <!--  Request Message Mapping
      -->
    - <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
      <SAP:Category>Application</SAP:Category>
      <SAP:Code area="MAPPING">CANNOT_INSTANCIATE_CLASS</SAP:Code>
      <SAP:P1>JavaMapping</SAP:P1>
      <SAP:P2>http://www.sdsdsd.com/XI/Sales/T~</SAP:P2>
      <SAP:P3>3bd13b30-6300-11dc-b9f1-f0050aa5c91a</SAP:P3>
      <SAP:P4>-1</SAP:P4>
      <SAP:AdditionalText />
      <SAP:ApplicationFaultMessage namespace="" />
      <SAP:Stack>Unable to instantiate the Java class JavaMapping (http://www.sdsdsd.com/XI/Sales/T~, 3bd13b30-6300-11dc-b9f1-f0050aa5c91a, -1)</SAP:Stack>
      <SAP:Retry>M</SAP:Retry>
      </SAP:Error>
    Please help me out with this error.

    Hi Anu,
    Currently I am also facing the same Unable to instantiate the Java class  same java class is working fine in eclipse .
    Could you please confirm Is this because of version mismatch that in Eclipse JAVA and SAP JAVA ?
    Thanks in Advance.
    Best,
    Srinivas

  • Cannot Import Java Classes

    I am trying to do the sample contact walkthrough in FLEX
    builder. For the Java Adapter.
    http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=00000138 .html
    I cannot get any import statements to work for the java class
    files. I have tried this using the FDS as a J2EE application
    running in tomcat, I have tried with the standalone JRUN version of
    the FDS app.
    I have put the contact files everywhere I can think of, in
    the server classes folder, in the project, in the default web
    folder and nothing I try works. I have even setup the project to
    compile on the server and I get nothing. Everytime, I get errors.
    I did the tutorial from the JDJ magazine:
    http://java.sys-con.com/read/210991.htm
    I cant get that java connection to work either. Please
    someone help me.
    The flex code is below.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute">
    <mx:Script>
    <![CDATA[
    import mx.data.DataService;
    import mx.collections.ArrayCollection;
    import samples.contact.Contact;
    public var ds:DataService;
    [Bindable]
    public var contacts:ArrayCollection;
    //public var contact:Contact;
    ]]>
    </mx:Script>
    <mx:DataGrid id="dg" editable="true">
    <mx:columns>
    <mx:DataGridColumn dataField="contactId" headerText="Id"
    editable="false"/>
    <mx:DataGridColumn dataField="firstName"
    headerText="First Name"/>
    <mx:DataGridColumn dataField="lastName" headerText="Last
    Name"/>
    </mx:columns>
    </mx:DataGrid>
    </mx:Application>

    Ken, thank you for replying, I have had absolutly nothing but
    problems trying to get this 'simple' thing to work.
    Here is my code.
    In the remote-config.xml file, I have this code:
    <?xml version="1.0" encoding="UTF-8"?>
    <service id="remoting-service"
    class="flex.messaging.services.RemotingService"
    messageTypes="flex.messaging.messages.RemotingMessage">
    <adapters>
    <adapter-definition id="java-object"
    class="flex.messaging.services.remoting.adapters.JavaAdapter"
    default="true"/>
    </adapters>
    <default-channels>
    <channel ref="my-amf"/>
    </default-channels>
    <destination id="SimpleJava">
    <properties>
    <source>javaSamples.SimpleMath</source>
    </properties>
    </destination>
    </service>
    Here is my MXML file: (Called new.MXML)
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute">
    <mx:RemoteObject id="math" destination="SimpleJava">
    <mx:method name="doMath" concurrency="last"
    result="fillTxt(event.result as int)"/>
    </mx:RemoteObject>
    <mx:Script>
    <![CDATA[
    import mx.rpc.events.ResultEvent
    private function fillTxt(b: int):void{
    txtResult.text = (String)
    //comment
    ]]>
    </mx:Script>
    <mx:Panel x="10" y="24" width="250" height="200"
    layout="absolute" title="Simple Math with Java">
    <mx:Label x="10" y="10" text="Input Number to
    Multiply:"/>
    <mx:TextInput x="10" y="36" id="txtNumber"
    maxChars="1"/>
    <mx:Label x="10" y="126" id="txtResult"/>
    <mx:Label x="10" y="100" text="Your Number will appear
    below:"/>
    <mx:Button x="10" y="66" label="Multiply by 2"
    click="math.doMath(txtNumber.text)"/>
    </mx:Panel>
    </mx:Application>
    Here is my SimpleJava.java file:
    package javaSamples;
    //import java.util.*;
    * @author jsanders
    public class SimpleMath {
    public int doMath(String a){
    int new_a = Integer.parseInt(a.trim());
    int b = new_a * 2;
    return b;
    //changesd
    Like I said I have had absolutly nothing but problems with
    this. Yesterday, I was getting send failures, So I did some
    reasearch found some folks who said that they had the same problem,
    and they had to hard code the app name into the services-config.xml
    file. The file used to have {context.root} in it, and that variable
    was set to /flex, now I hardcoded this line into the my-amf channel
    definition to get rid of the send failure error.
    <channel-definition id="my-amf"
    class="mx.messaging.channels.AMFChannel">
    <endpoint uri="
    http://{server.name}:{server.port}/flex/messagebroker/amf"
    class="flex.messaging.endpoints.AMFEndpoint"/>
    <properties>
    <polling-enabled>false</polling-enabled>
    </properties>
    </channel-definition>
    As you can see what should say:
    http://{server.name}:{server.port}/{context.root}
    Now says:
    http://{server.name}:{server.port}/flex.
    This was the only way I could get the send error to go away.
    Now I worry that I might have broken something else. Since I
    removed all references to {context.root} in that file.
    {context.root} is defined in the flex-config.xml file, like
    this:
    <context-root>/flex</context-root>
    I have tried it with or without the '/' in the value of the
    context.root variable.
    I have played with the remoting-config file, and I know that
    I am accessing the destination.
    I have played with the <source> option of the
    destination, and I know that I am finding the class and making a
    good connection.
    I am using the JRUN install of FDS on my box, and yesterday
    at the end of the day after getting the context.root situation
    sorted out, I got a different error something like major.minor
    versioning errors.
    So the Java guys here at work told me that the JRUN version
    packaged with FDS was 1.4, and I used 1.5 to compile my java class.
    So I recompiled this morning with the 1.4 sdk. Now I dont get that
    error about the major minor versioning anymore.
    Now I get nothing. I use firefox, and all the browser tells
    me is 'transferring data from localhost' Nothing else. It just sits
    there and does nothing.
    When I did the debug on it, I got into a loop on the
    UIComponent.as file in the callLaterDispatcher(event:Event)
    function.
    Any clues what might be causing this new hang up. Basically
    the machine just hangs. Is there a problem with the result from the
    Method I am calling in the MXML? Did I do something wrong with the
    Event as Int thing?
    Again any help would be appreciated.

Maybe you are looking for