Java.io.PrintStream deprecation

Hello,
When I compile my program, which is written with JDK 1.4.2, I get as output from the compilation
the message warning: The class `java.io.PrintStream' has been deprecated. But when I look
in javadoc there isn't anything about deprecation for java.io.PrintStream. Anyone who knows why
this output is written?

The row the compiler is complaining on is row #2
BLOB blob=((oracle.jdbc.driver.OracleResultSet)rs).getBLOB(1);
PrintStream pw = new PrintStream(blob.getBinaryOutputStream());
where blob is an instance of oracle.sql.BLOB

Similar Messages

  • 1.4.2 - What is the correct way to format output in the java.io.PrintStream

    With Java 1.4.2:
    What is the correct way to format output in the java.io.PrintStream?
    The following is incorrect, even though it is still used in the The JavaTM Tutorial at: http://java.sun.com/docs/books/tutorial/essential/
    System.out.formatThis returns "cannot resolve the method 'format'"
    Any detailed suggestions or information is greatly appreciated.

    The following is incorrect, even though it is still
    used in the The JavaTM Tutorial at:
    http://java.sun.com/docs/books/tutorial/essential/
    The whole format thing has been introduced in 1.5. The tutorial also states it's been "updated to 1.5.".
    That's all I've got to say for I don't know how you can format a PrintWriter, let alone a PrintStream, prior to 1.5. I'm not really sure there is any way. Any "legacy way", that is. There almost certainly are third-party API which achieve similar results.

  • Blocked trying to get lock: java.io.PrintStream

    hello,everybody
    i have a problem with ejb deployed in weblogic 9.2
    sometimes it throws exceptions as follows:
    Blocked trying to get lock: java.io.PrintStream
    is this io deadlock?
    which is more than the configured time (StuckThreadMaxTime) of "600" seconds. Stack trace:
    Thread-169 "[STUCK] ExecuteThread: '84' for queue: 'weblogic.kernel.Default (self-tuning)'" <alive, in native, suspended, blocked, priority=1, DAEMON> {
        -- Blocked trying to get lock: java.io.PrintStream@23f1a60[fat lock]
        org.hibernate.exception.NestableDelegate.printStackTrace(NestableDelegate.java:303)
        org.hibernate.exception.NestableDelegate.printStackTrace(NestableDelegate.java:292)
        org.hibernate.exception.NestableRuntimeException.printStackTrace(NestableRuntimeException.java:187)
        com.test.bean.testBusinessBean.getInforByid(testBusinessBean.java:1628)
        com.test.bean.testBusinessBean_cdq3cw_EOImpl.getInforByid(testBusinessBean_cdq3cw_EOImpl.java:2422)
        com.test.bean.testBusinessBean_cdq3cw_EOImpl_WLSkel.invoke(Unknown Source)
        weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:526)
        weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:210)
        weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:438)
        weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:350)
        weblogic.security.service.SecurityManager.runAs(SecurityManager.java:143)
        weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:386)
        weblogic.rmi.internal.BasicServerRef.access$300(BasicServerRef.java:57)
        weblogic.rmi.internal.BasicServerRef$BasicExecuteRequest.run(BasicServerRef.java:964)
        weblogic.work.ExecuteThread.execute(ExecuteThread.java:206)
        weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    }thanks

    I'm getting the same problem. What happens on my server is that sometimes when a thread tries to print a stack trace, it gets stuck at "FileOutputStream.writeBytes". All other threads will then stop at "printStackTrace" when they try to synchronize on the System.err, like yours. I have no idea why this is happening. However, I don't use weblogic or ejb, so it seems to be a more basic issue. As a workaround, I'm considering to set a custom System.err that writes all its output to a queue which then in turn gets written to the real System.err by a separate thread. That way, the worst that can happen is that that separate thread gets stuck.
    This is quite annoying but I'm not sure if we have enough information yet to file a bug. I can't reproduce it yet. My server sometimes runs for weeks without this problem happening...
    If anyone has updates on this, that would be much appreciated.
    My system:
    Java: Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_02-b05, mixed mode)
    OS: Debian 4.0
    Processor: AMD Athlon 64 X2 5600+ Dual Core

  • Java.util.Date deprecated methods, looking for new ones

    Hi,
    I can't find anywhere.
    I'm looking for Date methods, exactly like
    getYear();
    getDay();
    but i don't want them being deprecated.
    I want to get an INT out of a Date (Year, Day, ...)
    please give me a link, name of a fucntion or something.
    Thanks

    Look at the API docs. It says that you have to use the methods in java.util.Calendar instead.

  • Writing to file using PrintStream and PrintWriter...

    I tried to write a string to a file, it actually ADD the string to the bottom of the text file without deleting what was already in there. at first I use PrintStream, it worked fine when run it from my MS-J++6.0, but it says "PrintStream has been deprecated by the author of java.io.printstream", and when I try to run it from IE it doesn't even work. then I look into the MSDN, it says jdk 1.1 prefer to use PrintWritier, so I change it to PrintWriter, no more error message but now the file only records the last string I entered and deleted all the text I had in there before. and it still doesn't work when I try to run it from IE. And for some reason, the program will creat the text file on my desktop(winXP) instead in the same folder where the java files are....
    Please help me understand what's wrong and how to solve it.. thank you. here is my code...
    public void storing(String msg)
              PrintWriter ps = null;
              try
                   ps = new PrintWriter(new FileOutputStream("collect.txt"), true);
                   ps.println(msg);
              catch (IOException e)
                   feedback.append("Cannot write to file.");
              finally
                   if(ps != null)
                        ps.close();

    cuz what I am doing is to have the user input 30 lines of messages, each time a message is written, they press a "next" button then that line of message will be saved to file, then the user can write the next line. I do this becuz I am affraid that the user will close the applet before he finishes all 30 line, if he does that, I still want to get as much line that the user has wrote that's why I have it write to file each time a line is written. So if I open a file at the beginning of the program, will it encounter any problem if the user close the applet without close the file??
    thanx.

  • Needed help with updating java code

    Hello all,
    Let me begin by let you know I am not a programmer and I have tried to solve this by reading on the net. I am a network admin so I tech knowledge but no programming.
    I have a webcam sending a Jpg to an FTP site and there I have used an applet called view.class to refresh once a second.
    site:http://70.154.170.253/webcamold.html
    My problems is now that it refreshes the same image over and over. It refreshes the cached image not the new image.
    From reading I suspect that it has to do with the newer version of java (it used to work fine).
    I have tried using JavaCam but same issue it just refreshes cached image. Also image flickers, the applet I am trying to fix was really smooth.
    I have also tried to compile code that I found on this forum but I got error dealing with deprecated code.
    Any help would be greatly appreciated!!!
    Code:
    import java.applet.Applet;
    import java.awt.*;
    import java.io.PrintStream;
    public class View extends Applet
    implements Runnable
    public void init()
    setBackground(Color.white);
    String s = getParameter("refresh");
    if(s == null)
    update = 30;
    else
    try
    update = Integer.parseInt(s);
    catch(Exception _ex)
    update = 30;
    filename = getParameter("picture");
    if(filename == null)
    System.out.println("No filename given as parameter.");
    md = new MediaTracker(this);
    off = createImage(size().width, size().height);
    refreshImage();
    public void paint(Graphics g)
    g.drawImage(off, 0, 0, this);
    public void update(Graphics g)
    paint(g);
    public void refreshImage()
    img = getImage(getDocumentBase(), filename);
    md.addImage(img, 0);
    try
    md.waitForID(0);
    catch(Exception exception)
    exception.printStackTrace();
    Graphics g = off.getGraphics();
    g.drawImage(img, 0, 0, this);
    img.flush();
    public void run()
    while(th != null)
    try
    refreshImage();
    repaint();
    Thread.sleep(update * 1000);
    catch(Exception exception)
    System.out.println("Error when thread was supposed to sleep: " + exception.getMessage());
    public void start()
    if(th == null)
    th = new Thread(this);
    try
    th.start();
    return;
    catch(Exception exception)
    System.out.println("Couldn't start thread: " + exception.getMessage());
    return;
    } else
    return;
    public void stop()
    if(th != null)
    th.stop();
    th = null;
    public void destroy()
    stop();
    public View()
    update = 30;
    Thread th;
    String filename;
    int update;
    Image img;
    Image off;
    MediaTracker md;

    This is compile error free code and regarding your issues i don't think am good at this stuff
    import java.applet.Applet;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.MediaTracker;
    public class View extends Applet implements Runnable {
         Thread th;
         String filename;
         int update;
         Image img;
         Image off;
         MediaTracker md;
         public void init() {
              setBackground(Color.white);
              String s = getParameter("refresh");
              if (s == null) {
                   update = 30;
              } else {
                   try {
                        update = Integer.parseInt(s);
                   } catch (Exception _ex) {
                        update = 30;
              filename = getParameter("picture");
              if (filename == null) {
                   System.out.println("No filename given as parameter.");
              md = new MediaTracker(this);
              off = createImage(size().width, size().height);
              refreshImage();
         public void paint(Graphics g) {
              g.drawImage(off, 0, 0, this);
         public void update(Graphics g) {
              paint(g);
         public void refreshImage() {
              img = getImage(getDocumentBase(), filename);
              md.addImage(img, 0);
              try {
                   md.waitForID(0);
              } catch (Exception exception) {
                   exception.printStackTrace();
              Graphics g = off.getGraphics();
              g.drawImage(img, 0, 0, this);
              img.flush();
         public void run() {
              while (th != null) {
                   try {
                        refreshImage();
                        repaint();
                        Thread.sleep(update * 1000);
                   } catch (Exception exception) {
                        System.out.println("Error when thread was supposed to sleep: "
                                  + exception.getMessage());
         public void start() {
              if (th == null) {
                   th = new Thread(this);
                   try {
                        th.start();
                        return;
                   } catch (Exception exception) {
                        System.out.println("Couldn't start thread: "
                                  + exception.getMessage());
                   return;
              } else {
                   return;
         public void stop() {
              if (th != null) {
                   th.stop();
                   th = null;
         public void destroy() {
              stop();
         public View() {
              update = 30;
    }

  • Unable to capture messages from java.util.logging

    I have a class called (Caller.java) which invokes a method called foo from another java class(Util.java) using reflection API.Now this method foo logs messages using Java's logger.My requirement is to call foo for 3 times from Caller and capture/redirect the log messages into 3 log files.
    But only the first log file is capturing the log messages(from logger) and other two are not ?
    Plz suggest if I am doing somethin wrong here ?
    Caller.java
    package project2;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.PrintStream;
    import java.lang.reflect.Method;
    public class Caller {
        public Caller() {
        public static void main(String[] args) throws Exception {
            Caller caller = new Caller();
            for (int i = 0 ;i<3 ;i++ )  {
                caller.createLogStream(i);
                System.setOut(caller.getPs());
                System.setErr(caller.getPs());
                /*****************Invoking Util.java*****************************/
                Class clas = Class.forName("project2.Util");
                Method m = clas.getMethod("foo",null);
                Object obj =clas.newInstance();
                m.invoke(obj,null);
        public void createLogStream(int i) throws FileNotFoundException {
            ps = new PrintStream(new File(System.getenv("HOME")+File.separator+"MyLog"+i+".log"));
        public void closeLogStream(){
            ps.close();
            ps = null;
        private PrintStream ps = null;
        public PrintStream getPs() {
            return ps;
    } Util.java
    package project2;
    import java.util.logging.Logger;
    public class Util {
        Logger logger = null;
        public Util() {
            logger = Logger.getLogger(this.getClass().getName());
        public void foo(){
            System.out.println("Hello out stream");
            System.err.println("Hello error stream");
            logger.info("This is an information");
            logger.warning("This is a warning message");
            logger.severe("This is fatal!! ");
    }First Log file MyLog0.log:
    Hello out stream
    Hello error stream
    Feb 16, 2009 7:55:55 PM project2.Util foo
    INFO: This is an information
    Feb 16, 2009 7:55:55 PM project2.Util foo
    WARNING: This is a warning message
    Feb 16, 2009 7:55:55 PM project2.Util foo
    SEVERE: This is fatal!!
    Feb 16, 2009 7:55:55 PM project2.Util foo
    INFO: This is an information
    Feb 16, 2009 7:55:55 PM project2.Util foo
    WARNING: This is a warning message
    Feb 16, 2009 7:55:55 PM project2.Util foo
    SEVERE: This is fatal!!
    Feb 16, 2009 7:55:55 PM project2.Util foo
    INFO: This is an information
    Feb 16, 2009 7:55:55 PM project2.Util foo
    WARNING: This is a warning message
    Feb 16, 2009 7:55:55 PM project2.Util foo
    SEVERE: This is fatal!! Other 2 log files have only this much
    Hello out stream
    Hello error stream

    A stale Connection Factory or Connection Handle may be used in SOA 11g
    Regards,
    Anuj

  • Question concerning java Serialization of a complex internal field variable.

    Not everything in the J2SE implements serializable by default.  Say BufferedImage.
    I have learned from an online artical that absolutely all fields to be serialized must
    implement Serializable, including internal ("global") class fields,
    a la
    http://javarevisited.blogspot.com.au/2011/04/top-10-java-serialization-interview.html
    (point 5).
    However, for my purposes, I cannot re-implement (extend) and recompile every and any
    java class I would want to serialize, eg. anything which is a "complex" sub field of
    a conceptual class I do want to serialize, which doesn't occur on the java 1.6 list
    of default serializable classes:
    a la
    http://docs.oracle.com/javase/6/docs/api/java/io/Serializable.html
    and
    "If member variables of a serializable object reference to a non-serializable object, the code will compile but a RumtimeException will be thrown."
    Understanding there are implications for the java security model, is there anything to be done for these non-serializable-implementing class fields?
    Is there a Serialization add on kit for Java or something?

    Indeed, however, with a distinct lack of success with the instrumentation api, my request is dualfold now.
    I do understand the restrictions explained here concerning more complex classes and the Serializable API.
    I have found that there is an input line that needs to be submitted when running an Inustrumentation, premain Agent class.
    However, I would have to avoid that by doing System.setProperty(a,b); appropriately.
    Why won't the following just work, without any further supplied input parameters?
       import static java.lang.System.out;
       import java.io.PrintStream;
       import java.lang.instrument.Instrumentation;
       public class InstrumentationAgent
          private static volatile Instrumentation globalInstrumentation;
          public static void premain(String paramString, Instrumentation paramInstrumentation)
             System.out.println("premain...");
             globalInstrumentation = paramInstrumentation;
          public static void agentmain(String paramString, Instrumentation paramInstrumentation)
             System.out.println("agentmain...");
             globalInstrumentation = paramInstrumentation;
          public static void main(String ... args)
             out.println("!");
             String data = new String("data");
             long size = getObjectSize(data);
             out.println(size);
          public static long getObjectSize(Object paramObject)
             if (globalInstrumentation == null)
                throw new IllegalStateException("Agent not initialized.");
             return globalInstrumentation.getObjectSize(paramObject);
    I am still curious as to how the DataFlavor approach I have outlined above.  Does it accomplish a shallow or deep conversion?  Are
    there other limitations which restrict what's put to the underlying ByteOutputStream?
    Why won't my agent class execute though, regardless?

  • Problem Using Java Store Procedure (java class) to connect to sybase

    Hi, I'm trying to use a java class to obtain some data from another databse (SYBASE) in another server.. here are the code
    package pkg;
    import com.sybase.jdbcx.SybDriver;
    import java.sql.Connection;
    import java.sql.Driver;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    public class clsTest
    public clsTest()
    public static void main(String[] args)
    testConn("");
    private static void testConn()
    Connection _con= null;
    String host = "XXX";
    String port= "XXX";
    String url = host + ":" + port;
    Statement _stmt= null;
    int timeout = 10;
    boolean needsReconnect = true;
    SybDriver sybDriver = null;
    try
    Class c = Class.forName("com.sybase.jdbc3.jdbc.SybDriver");
    sybDriver = (SybDriver) c.newInstance();
    DriverManager.registerDriver((Driver) sybDriver);
    catch (Exception e)
    System.err.print("Unable to load the Sybase JDBC driver. "
    + e.toString());
    e.printStackTrace(System.out);
    if (needsReconnect)
    try
    if (_con != null)
    _con.close();
    url="jdbc:sybase:Tds:BDSERVER:PORT/BD";
    System.err.println("Trying to connect to: " + url);
    DriverManager.setLoginTimeout(timeout);
    con = DriverManager.getConnection(url,"usrquery","mundial");
    _stmt = _con.createStatement();
    boolean results = _stmt.execute("select count(*) from TABLA");
    if (results)
    ResultSet rs= _stmt.getResultSet();
    rs.next();
    System.err.println(rs.getString(1));
    _con.close();
    catch (SQLException sqle)
    System.err.println(sqle.toString() + " Restart connection.");
    return;
    catch (Exception e)
    e.printStackTrace();
    System.err.println("Unexpected Exception: " + e.toString());
    return;
    When I run the proyect using the IDE JDeveloper I have no problem, but when I make de use loadjava I receive these error message
    creating : resource META-INF/MANIFEST.MF
    loading : resource META-INF/MANIFEST.MF
    Error while creating resource META-INF/MANIFEST.MF
    ORA-29547: Java system class not available: oracle/aurora/rdbms/Compiler
    creating : class pkg/clsTest
    loading : class pkg/clsTest
    creating : resource jconn3.jar
    loading : resource jconn3.jar
    Error while creating resource jconn3.jar
    ORA-29547: Java system class not available: oracle/aurora/rdbms/Compiler
    granting : execute on class pkg/clsTest to public
    Error while computing shortname of pkg/clsSybaseLAE
    ORA-06550: line 1, column 13:
    PLS-00201: identifier 'DBMS_JAVA.SHORTNAME' must be declared
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    resolving: class pkg/clsTest
    errors : class pkg/clsTest
    ORA-29521: referenced name java/lang/StringBuffer could not be found
    ORA-29521: referenced name java/lang/Class could not be found
    ORA-29521: referenced name com/sybase/jdbcx/SybDriver could not be found
    ORA-29521: referenced name java/sql/Driver could not be found
    ORA-29521: referenced name java/sql/DriverManager could not be found
    ORA-29521: referenced name java/lang/System could not be found
    ORA-29521: referenced name java/lang/Exception could not be found
    ORA-29521: referenced name java/io/PrintStream could not be found
    ORA-29521: referenced name java/sql/Connection could not be found
    ORA-29521: referenced name java/sql/Statement could not be found
    ORA-29521: referenced name java/sql/ResultSet could not be found
    ORA-29521: referenced name java/sql/SQLException could not be found
    ORA-29521: referenced name java/lang/Object could not be found
    ORA-29521: referenced name java/lang/String could not be found
    synonym : pkg/clsTest
    The following operations failed
    resource META-INF/MANIFEST.MF: creation
    class pkg/clsTest: resolution
    resource jconn3.jar: creation
    exiting : Failures occurred during processing
    Please some one help me!.. Thank's a lot

    Thanks, you was right, but I have another problem
    The following operations failed
    class cl/bcch/clsSyBase: resolution
    source cl/bcch/clsSyBase: creation (createFailed)
    oracle.aurora.server.tools.loadjava.ToolsException: Failures occurred during processing
         at oracle.aurora.server.tools.loadjava.LoadJava.process(LoadJava.java:1057)
         at oracle.jdeveloper.deploy.tools.OracleLoadjava.deploy(OracleLoadjava.java:124)
         at oracle.jdeveloper.deploy.tools.OracleLoadjava.deploy(OracleLoadjava.java:53)
         at oracle.jdevimpl.deploy.OracleDeployer.deploy(OracleDeployer.java:98)
         at oracle.jdevimpl.deploy.StoredProcHandler.doDeploy(StoredProcHandler.java:503)
         at oracle.jdevimpl.deploy.StoredProcHandler.doDeploy(StoredProcHandler.java:381)
         at oracle.jdevimpl.deploy.StoredProcHandler.doDeploy(StoredProcHandler.java:300)
         at oracle.jdevimpl.deploy.StoredProcProfileDt$Action$1.run(StoredProcProfileDt.java:598)
    #### Export incomplete. #### 09-01-2008 02:28:39 PM
    *** Note ***
    One possibility for the database export failure is that the target Database may not support JDK version 1.4. Updating your Project Properties compiler Source & Target to an earlier release could fix this problem.
    ************

  • Provisioning on third party apps with java handlers

    Hello,
    I am trying to configure OID to enable provisioning against third party applications like an J2EE app who use MySQL )
    I want to develop a Java plugin for handling events on OID and propagate on other DBMS.
    I saw on the following page (http://download-uk.oracle.com/docs/cd/B14099_14/idmanage.1012/b14087/prov_plug.htm#BCGJFHEB
    ) a sample of Java code who could help me. The, I tried to apply the Grocery demo with a JAVA plugin but unsuccessfully.
    Thats my configuration issues:
    1 ) In oidadmin
    I have created the following entries:
    cn=ApplicationsCCIP,cn=Products,cn=OracleContext
    cn=Plugins,cn=Training,cn=Applications,cn=Provisioning,cn=Directory Integration Platform,cn=Products,cn=OracleContext
    2) With ldapmodify
    dn: cn=Plugins, cn=Training, cn=Applications, cn=Provisioning,cn=Directory Integration Platform,cn=Products,cn=OracleContext
    changetype: add
    add: orclODIPPluginExecData
    orclODIPPluginExecData: path to jar addressbook-oidplugin-2.1.1.jar
    objectclass:orclODIPPluginContainer
    dn: cn=PRE_DATA_ENTRY_CREATE, cn=Plugins, cn=Training, cn=Applications,cn=Provisioning, cn=Directory Integration Platform, cn=Products, cn=OracleContext cn=Provisioning
    changetype: add
    objectClass: orclODIPPlugin
    orclStatus: ENABLE
    orclODIPPluginExecName: fr.ccip.training.addressbook.oid.PreDataPlugin
    orclODIPPluginAddInfo: Pre Data Entry Plugin for CREATE operation
    dn: cn=PRE_DATA_ENTRY_MODIFY, cn=Plugins, cn=Training, cn=Applications,cn=Provisioning, cn=Directory Integration Platform, cn=Products, cn=OracleContext
    changetype: add
    objectClass: orclODIPPlugin
    orclStatus: ENABLE
    orclODIPPluginExecName: fr.ccip.training.addressbook.oid.PreDataPlugin
    orclODIPPluginAddInfo: Pre Data Entry Plugin for MODIFY operation
    dn: cn=POST_DATA_ENTRY_CREATE, cn=Plugins, cn=Training, cn=Applications, cn=Provisioning, cn=Directory Integration Platform, cn=Products, cn=OracleContext
    changetype: add
    objectClass: orclODIPPlugin
    orclStatus: ENABLE
    orclODIPPluginExecName: fr.ccip.training.addressbook.oid.PostDataPlugin
    orclODIPPluginAddInfo: Post Data Entry Plugin for CREATE and modify operations
    dn: cn=POST_DATA_ENTRY_MODIFY, cn=Plugins, cn=Training, cn=Applications, cn=Provisioning, cn=Directory Integration Platform, cn=Products, cn=OracleContext
    changetype: add
    objectClass: orclODIPPlugin
    orclStatus: ENABLE
    orclODIPPluginExecName: fr.ccip.training.addressbook.oid.PostDataPlugin
    orclODIPPluginAddInfo: Post Data Entry Plugin for MODIFY and CREATE operation
    dn: cn=DATA_ACCESS, cn=Plugins, cn=Training, cn=Applications, cn=Provisioning, cn=Directory Integration Platform, cn=Products, cn=OracleContext
    changetype: add
    objectClass: orclODIPPlugin
    orclStatus: ENABLE
    orclODIPPluginExecName: fr.ccip.training.addressbook.oid.DataAccessPlugin
    orclODIPPluginAddInfo: Data Access Plugin
    dn: cn=EVENT_DELIVERY_OUT, cn=Plugins, cn=Training, cn=Applications, cn=Provisioning, cn=Directory Integration Platform, cn=Products, cn=OracleContext
    changetype: add
    objectClass: orclODIPPlugin
    orclStatus: ENABLE
    orclODIPPluginExecName: fr.ccip.training.addressbook.oid.DeliveryOutEvent
    orclODIPPluginAddInfo: Event Delivery Plugin for Outbound
    dn: cn=EVENT_DELIVERY_IN, cn=Plugins, cn=Training, cn=Applications, cn=Provisioning, cn=Directory Integration Platform, cn=Products, cn=OracleContext
    changetype: add
    objectClass: orclODIPPlugin
    orclStatus: ENABLE
    orclODIPPluginExecName: fr.ccip.training.addressbook.oid.DeliveryInEvent
    orclODIPPluginAddInfo: Event Delivery Plugin for Inbound
    3) I have uploaded the jar in /oas/infra/ldap/jlib
    4 ) With oidprovisioning tool
    oidprovtool operation=create ldap_host=dev-orainfra.ccip.fr ldap_port=389 ldap_user_dn="cn=orcladmin" ldap_user_password=password1 organisation_dn=ccip application_dn="orclapplicationcommonname=Training,cn=ApplicationsCCIP,cn=Products,cn=OracleContext" organization_dn="dc=ccip,dc=fr" event_subscription="USER:ccip:ADD(uname)" event_subscription="USER:ccip:DELETE" event_subscription="GROUP:ccip:MODIFY(cn,uniquemember)" interface_type=JAVA interface_name=PORTAL.WWSEC_OID_SYNC interface_version=3.0 application_type=Addressbook profile_debug=debug
    5) Restart OID
    I have previously uploaded a jar with some plugins
    Thas my code
    import java.io.FileOutputStream;
    import java.io.PrintStream;
    import oracle.idm.provisioning.event.Event;
    import oracle.idm.provisioning.event.EventStatus;
    import oracle.idm.provisioning.plugin.EventDeliveryException;
    import oracle.idm.provisioning.plugin.EventPluginInitException;
    import oracle.idm.provisioning.plugin.IEventsFromOID;
    import oracle.idm.provisioning.plugin.PluginException;
    import oracle.ldap.util.UtilDebug;
    public class OIDToAddressbookEvent implements IEventsFromOID {
    static {
    try {
    UtilDebug.setPrintStream(new PrintStream(new FileOutputStream("/tmp/oidtoaddressbookevent.log")));
    UtilDebug.setDebugMode(UtilDebug.MODE_ALL);
    } catch (Exception e) {
    e.printStackTrace();
    * (non-Javadoc)
    * @see oracle.idm.provisioning.plugin.IEventsFromOID#initialize(java.lang.Object)
    public void initialize(Object _arg0) throws EventPluginInitException {
    // TODO Auto-generated method stub
    * (non-Javadoc)
    * @see oracle.idm.provisioning.plugin.IEventsFromOID#sendEventsToApp(oracle.idm.provisioning.event.Event[])
    public EventStatus[] sendEventsToApp(Event[] _arg0) throws EventDeliveryException {
    UtilDebug.log(UtilDebug.MODE_ALL, "sendEvents", _arg0);
    EventStatus[] events = new EventStatus[1];
    events[0] = new EventStatus(EventStatus.SUCCESS, null, null, null);
    return events;
    * (non-Javadoc)
    * @see oracle.idm.provisioning.plugin.IEventPlugin#terminate(java.lang.Object)
    public void terminate(Object _arg0) throws PluginException {
    // TODO Auto-generated method stub
    public OIDToAddressbookEvent() {
    super();
    // TODO Auto-generated constructor stub
    public class DataAccessPlugin implements IDataAccessPlugin{
    static {
    try {
    UtilDebug.setPrintStream(new PrintStream(new FileOutputStream("/tmp/dataaccessplugin.log")));
    UtilDebug.setDebugMode(UtilDebug.MODE_ALL);
    } catch (Exception e) {
    e.printStackTrace();
    /* (non-Javadoc)
    * @see oracle.idm.provisioning.plugin.IDataAccessPlugin#getAppUserData(oracle.idm.provisioning.plugin.ApplicationContext, oracle.idm.user.IdmUser, java.lang.String[])
    public PropertySet getAppUserData(ApplicationContext arg0, IdmUser arg1, String[] _arg2) throws PluginException {
    return null;
    /* (non-Javadoc)
    * @see oracle.idm.provisioning.plugin.IDataAccessPlugin#process(oracle.idm.provisioning.plugin.ApplicationContext, oracle.idm.user.IdmUser, oracle.ldap.util.ModPropertySet, oracle.ldap.util.ModPropertySet)
    public PluginStatus process(ApplicationContext arg0, IdmUser arg1, ModPropertySet arg2, ModPropertySet arg3) throws PluginException {
    UtilDebug.log(UtilDebug.MODE_ALL,"Processing DAP...",_arg0);
    return new PluginStatus(PluginStatus.SUCCESS,null,null);
    I have already develop event wich implements IEventsPlugin.
    I dont see what s wrong in my configuration
    Thanks in advance for your help
    Alexandre Touret
    Message was edited by:
    [email protected]
    Message was edited by:
    [email protected]

    Ahhh...OK...that makes more sense now. From your first post, it seemed like you wanted to sync the actual app (as in, for instance, backup the actual app and then restore it after an OS reload...as opposed to reinstalling the app after an OS reload). But, now I see that it is the App data that you wish to sync.
    To be 100% clear -- is this a sync function, similar to how the desktop software synchs with your PIM (e.g., Outlook) for organizer data? Or is this a backup function, where the data is backed up for use in a subsequent restore?
    Thanks!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Warning: [deprecation] getRealPath in ServletRequest has been deprecated

    I have extended class HttpServletRequestWrapper for custom implementation I have neither overriden the method getRealPath(java.lang.String) nor has this method been used/accessed anywhere. I still get following warning
    [javac] /home/pangav1/dev/upgrade/webapps/common/src/minimed/ddms/webapp/common/filter/LocaleFilter.java:222: warning: [deprecation] getRealPath(java.lang.String) in javax.servlet.ServletRequest has been deprecated
    [javac] public static class HttpRequest extends HttpServletRequestWrapper {
    [javac] ^
    Can anyone tell me the reason why compiler shows the warning message?

    It should certainly not be ignored, especially if you don't understand the reason of deprecation and don't know the alternatives, which is the case of the topicstarter. In any case of deprecated classes/methods, the reasoning of deprecation and any alternatives should already be described in the API docs.
    [Here is the API doc of ServletRequest#getRealPath()|http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html#getRealPath(java.lang.String)]

  • Java - InputStream - Weird Characters in the Output!

    Hi,
    I have a software which outputs lines of numbers one by one. In another java program, I use BufferedReader as follows:
    BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream(),"US-ASCII"));
    where pr is the process which runs the software. For each line in the output stream, I try to check whether the first number in the line is greater than a certain value and if it is, I write to another file.
    The problem is, when I run the software repeatedly (in a linux cluster) like 10 simulations simultaneously, one of them have got @^@^.... characters followed by some huge numbers. So, I tried eliminating that line alone by using String.matches command but now, it seems even after that I get the error - so, I think it might mean that it is actually during the writing process that the problem occurs. I use BufferedWriter like the following to write it: (I do flush it after writing.)
    BufferedWriter out=new BufferedWriter(new FileWriter(tmp_file));
    I would greatly appreciate if someone can help. This thing really seems to be a huge bottleneck!
    Thanks,
    Senthil

    Hi ejp! Thanks - here is the code!
    import java.io.BufferedReader;
    import java.io.FileOutputStream;
    import java.io.InputStreamReader;
    import java.io.PrintStream;
    import java.io.*;
    import java.util.*;
    //call the class file with the input xml file to simulate
    public class RunSim {
    public static void main(String[] args) {
    String[] xmlFiles = new String[] { "/home/senthil/Simulator/Dessa1.4/" args[0]};
    Scanner input=null;
    FileWriter ofw=null;
    PrintWriter out=null;
    for(String file:xmlFiles) {
    try {
    String[] command = {"java","Test",file, "10000"};
    Process pr = Runtime.getRuntime().exec(command); // run the command
    input = new Scanner(new InputStreamReader(pr.getInputStream()));
    String line=null;
    ofw=new FileWriter(file"_out.txt");
    out=new PrintWriter(ofw);
    while(input.hasNextLine()) {
    line=input.nextLine();
    System.out.println(line);
    if(line.matches("[0-9.\\s]*")) { // I included this as I didn't want the '@^' character - but still, it is being produced.
    out.println(line);
    out.flush();
    String[] str = line.split(" ");
    if(!line.equals("Badly formatted XML file")){
    if((Float.parseFloat(str[0]) >= 196)) //this is the limit upto which the process has to be run
    pr.destroy();
    else
    continue;
    out.close();
    int exitVal = pr.waitFor();
    System.out.println("Exited with error code "+exitVal);
    } catch(Exception e) {
    System.out.println(e.toString());
    e.printStackTrace();
    }

  • Urgent : 11g Fault Policy Java Handler

    Im trying to use fault policies in 11g and in fault policies want to catch the remote faults and pass it to a custom java handler.
    in Custom Handler use IFaultRecoveryJavaClass and also BPELFaultRecoveryContextImpl , i want to pick fault information
    and pass store it in DB...
    i placed the client jar file in <Oracle_HOME>\user_projects\domains\base_domain\lib
    Duuring runtime the server is able to Pick the IFaultRecoveryJavaClass but not BPELFaultRecoveryContextImpl
    is there anything im missing ?
    As per oracle documentation in Fault Handling in BPEL form SOA developer guide ..
    public class TestJavaAction implements IFaultRecoveryJavaClass {
    public void handleRetrySuccess(IFaultRecoveryContext ctx) {
    System.out.println("This is for retry success");
    handleFault(ctx);
    public String handleFault(IFaultRecoveryContext ctx) {          
    System.out.println("-----Inside handleFault-----\n" + ctx.toString());
    dumpProperties(ctx.getProperties());
    /* Get BPEL specific context here */
    BPELFaultRecoveryContextImpl bpelCtx = (BPELFaultRecoveryContextImpl) ctx;
    bpelCtx.addAuditTrailEntry("hi there");
    System.out.println("Policy Id" + ctx.getPolicyId());
    please find the Fault Policy and Custom Java Class
    please see may fault policy below..
    =====================================================================================================================
    <?xml version="1.0" encoding="UTF-8"?>
    <faultPolicies xmlns="http://schemas.oracle.com/bpel/faultpolicy" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <faultPolicy version="2.1.3" id="ConnectionFaults">
    <Conditions>
    <!-- Remote Fault Handler -->
    <faultName xmlns:bpelx="http://schemas.oracle.com/bpel/extension" name="bpelx:remoteFault">
    <condition>
    <action ref="technical-fault-handler"/>
    </condition>
    </faultName>
    </Conditions>
    <Actions>
    <!-- Human Intervention -->
    <Action id="ora-human-intervention">
    <humanIntervention/>
    </Action>
    <!-- Technical Fault Action -->
    <Action id="technical-fault-handler">
    <javaAction className="com.FaultHandler"
    defaultAction="ora-human-intervention" propertySet="TechnicalProps">
    <returnValue value="OK" ref="ora-human-intervention"/>
    </javaAction>
    </Action>
    </Actions>
    <Properties>
    <!-- Properties for Technical Errors -->
    <propertySet name="TechnicalProps">
    <property name="logFileName">techinical-faults.log</property>
    <property name="logFileDir">c:\tmp\log</property>
    <property name="ErrorType">Technical</property>
    </propertySet>
    </Properties>
    </faultPolicy>
    </faultPolicies>
    Custom Java Handler ..
    =====================================================================================================================
    import java.io.File;
    import java.io.PrintStream;
    import java.util.ArrayList;
    import java.util.Map;
    ==============================================================
    // SOA Runtime fabric-runtime.jar Available with SOA Runtime Libraries
    ==============================================================
    import oracle.integration.platform.faultpolicy.IFaultRecoveryContext;
    import oracle.integration.platform.faultpolicy.IFaultRecoveryJavaClass;
    ==============================================================
    // BPEL Runtime orabpel.jar Available with BPEL Runtime Libraries
    ==============================================================
    import com.collaxa.cube.engine.fp.BPELFaultRecoveryContextImpl;
    public class FaultHandler implements IFaultRecoveryJavaClass {
    public FaultHandler() {
    super();
    public void handleRetrySuccess(IFaultRecoveryContext ifc) {
    print("RertySuccess");
    public String handleFault(IFaultRecoveryContext ifc) {
    print("Handle Fault");
    Map<String,ArrayList> props = ifc.getProperties();
    for (Map.Entry<String,ArrayList> entry: props.entrySet()){
    print (entry.getKey() + " = " + entry.getValue().get(0));
    String logFileName = (String) props.get("logFileName").get(0);
    String logFileDir = (String) props.get("logFileDir").get(0);
    String ErrorType = (String) props.get("ErrorType").get(0);
    PrintStream ps = null;
    try
    ps = new PrintStream(logFileDir + File.separator + logFileName);
    catch (Exception e) {
    print(e.getMessage());
    System.out.println( "Fault Details");
    System.out.println("===============================================================");
    System.out.println("Fault Type ................ " + ifc.getType());
    System.out.println("Poilcy ID ................. " + ifc.getPolicyId());
    System.out.println("Faulted Partner Link ...... " + ifc.getReferenceName());
    System.out.println("Error Type ...... " + ErrorType);
    System.out.println("Port Type ................. " + ifc.getPortType());
    try {
    BPELFaultRecoveryContextImpl bpelCtx = (BPELFaultRecoveryContextImpl) ifc;
    System.out.println("BPEL Context + getActivityName" + bpelCtx.getActivityName());
    System.out.println("BPEL Context + getActivityType" + bpelCtx.getActivityType());
    System.out.println("BPEL Context + getComponentInstanceId" + bpelCtx.getComponentInstanceId());
    System.out.println("BPEL Context + getComponentInstanceId" + bpelCtx.getComponentInstanceId());
    System.out.println("BPEL Context + getCompositeName" + bpelCtx.getCompositeName());
    System.out.println("BPEL Context + getECID" + bpelCtx.getECID());
    System.out.println("BPEL Context + getFault" + bpelCtx.getFault());
    System.out.println("BPEL Context + getFault" + bpelCtx.getProcessDN());
    catch (Exception ee){
    System.out.println("BPEL Context + Exception" + ee.getMessage());
    return "OK";
    Error Log ..
    =====================================================================================================================
    Caused by: com.oracle.bpel.client.BPELFault: faultName: {{http://schemas.oracle.com/bpel/extension}runtimeFault}
    parts: {{
    summary=<summary>com/collaxa/cube/engine/fp/BPELFaultRecoveryContextImpl</summary>
    ,detail=<detail>java.lang.NoClassDefFoundError: com/collaxa/cube/engine/fp/BPELFaultRecoveryContextImpl
         at com.FaultHandler.handleFault(FaultHandler.java:56)
         at com.collaxa.cube.engine.fp.RecoveryActionJava.execute(RecoveryActionJava.java:67)
         at com.collaxa.cube.engine.fp.BPELRecoverFault.recover(BPELRecoverFault.java:87)
         at oracle.fabric.CubeServiceEngine.recoverFault(CubeServiceEngine.java:1589)
         at oracle.integration.platform.faultpolicy.RecoverFault.recoverAndChain(RecoverFault.java:149)
         at oracle.integration.platform.faultpolicy.RecoverFault.resolveAndRecover(RecoverFault.java:112)
         at oracle.integration.platform.faultpolicy.FaultRecoveryManagerImpl.resolveAndRecover(FaultRecoveryManagerImpl.java:121)
         at com.collaxa.cube.engine.ext.bpel.common.wmp.BPELInvokeWMP.resolveAndRecover(BPELInvokeWMP.java:1170)
         at com.collaxa.cube.engine.ext.bpel.common.wmp.BPELInvokeWMP.__handleException(BPELInvokeWMP.java:1111)
         at com.collaxa.cube.engine.ext.bpel.common.wmp.BPELInvokeWMP.__callback(BPELInvokeWMP.java:626)
         at com.collaxa.cube.engine.ext.bpel.common.wmp.BPELInvokeWMP.handleNormalInvoke(BPELInvokeWMP.java:465)
         at com.collaxa.cube.engine.ext.bpel.common.wmp.BPELInvokeWMP.__executeStatements(BPELInvokeWMP.java:182)
         at com.collaxa.cube.engine.ext.bpel.common.wmp.BaseBPELActivityWMP.perform(BaseBPELActivityWMP.java:140)
         at com.collaxa.cube.engine.CubeEngine._performActivity(CubeEngine.java:2675)
         at com.collaxa.cube.engine.CubeEngine.performActivity(CubeEngine.java:2558)
         at com.collaxa.cube.engine.CubeEngine.handleWorkItem(CubeEngine.java:1256)
         at com.collaxa.cube.engine.dispatch.message.instance.PerformMessageHandler.handleLocal(PerformMessageHandler.java:73)
         at com.collaxa.cube.engine.dispatch.DispatchHelper.handleLocalMessage(DispatchHelper.java:188)
         at com.collaxa.cube.engine.dispatch.DispatchHelper.sendMemory(DispatchHelper.java:285)
         at com.collaxa.cube.engine.CubeEngine.endRequest(CubeEngine.java:4607)
         at com.collaxa.cube.engine.CubeEngine.createAndInvoke(CubeEngine.java:828)
         at com.collaxa.cube.engine.delivery.DeliveryService.handleInvoke(DeliveryService.java:610)
         at com.collaxa.cube.engine.ejb.impl.CubeDeliveryBean.handleInvoke(CubeDeliveryBean.java:354)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:37)
         at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
         at com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:50)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
         at $Proxy184.handleInvoke(Unknown Source)
         at com.collaxa.cube.engine.ejb.impl.bpel.BPELDeliveryBean_5k948i_ICubeDeliveryLocalBeanImpl.handleInvoke(BPELDeliveryBean_5k948i_ICubeDeliveryLocalBeanImpl.java:241)
         at com.collaxa.cube.engine.dispatch.message.invoke.InvokeInstanceMessageHandler.handle(InvokeInstanceMessageHandler.java:34)
         at com.collaxa.cube.engine.dispatch.DispatchHelper.handleMessage(DispatchHelper.java:139)
         at com.collaxa.cube.engine.dispatch.BaseDispatchTask.run(BaseDispatchTask.java:58)
         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
         at java.lang.Thread.run(Thread.java:619)
    </detail>

    I tried bundling the jar file but still it is not able to pick up the class and throws the same exception. please find the following code which i tried to use to pick up the remote fault.
    System.out.println( "Fault Details");
    System.out.println( "===============================================================");
    System.out.println( "Fault Type ................ " + ifc.getType());
    System.out.println( "Poilcy ID ................. " + ifc.getPolicyId());
    System.out.println( "Faulted Partner Link ...... " + ifc.getReferenceName());
    System.out.println( "Error Type ...... " + ErrorType);
    System.out.println( "Port Type ................. " + ifc.getPortType());
    BPELFaultRecoveryContextImpl bpelCtx = (BPELFaultRecoveryContextImpl) ifc;
    System.out.println("BPEL Context + getActionId" + bpelCtx.getActionId());
    System.out.println("BPEL Context + getActivityName" + bpelCtx.getActivityName());
    System.out.println("BPEL Context + getActivityType" + bpelCtx.getActivityType());
    System.out.println("BPEL Context + getComponentInstanceId" + bpelCtx.getComponentInstanceId());
    System.out.println("BPEL Context + getCompositeName" + bpelCtx.getCompositeName());
    System.out.println("BPEL Context + getECID" + bpelCtx.getECID());
    System.out.println("BPEL Context + getFault" + bpelCtx.getFault());
    System.out.println("BPEL Context + getFault" + bpelCtx.getProcessDN());
    If you have any working example can you please pass the code. my emailid is [email protected]
    Edited by: lakshmi nadh on Jul 27, 2009 3:39 AM

  • Problems with WLST embedded in java app.

    Hi,
    I have a problem with the WLST embedded in a java app.
    I want to programatically create or reconfigure a domain from a java application. Following is a simple example of what I want to do.
    import weblogic.management.scripting.utils.WLSTInterpreter;
    public class DomainTester {
      static WLSTInterpreter interpreter = new WLSTInterpreter();
      private void processDomain() {
        if(domainExists()) {
          System.out.println("Should now UPDATE the domain");
        } else {
          System.out.println("Should now CREATE the domain");
      private boolean domainExists() {
        try {
          interpreter.exec("readDomain('d:/myDomains/newDomain')");
          return true;
        }catch(Exception e) {
          return false;
    }The output of this should be one of two possibles.
    1. If the domain exists already it should output
    "Should now UPDATE the domain"
    2. If the domain does not exist it should output
    "Should now CREATE the domain"
    However, if the domain does not exist the output is always :
    Error: readDomain() failed. Do dumpStack() to see details.
    Should now UPDATE the domain
    It never returns false from the domainExists() method therefor always states that the exec() worked.
    It seams that the exec() method does not throw ANY exceptions from the WLST commands. The catch clause is never executed and the return value from domainExists() is always true.
    None of the VERY limited number of examples using embedded WLST in java has exception or error handling in so I need to know what is the policy to detect failures in a WLST command executed in java??? i.e. How does my java application know when a command succeeds or not??
    Regards
    Steve

    Hi,
    I did some creative wrapping for the WLSTInterpreter and I now have very good programatic access to the WLST python commands.
    I will put this on dev2dev somewhere and release it into the open source community.
    Don't know the best place to put it yet, so if anybody sees this and has any good ideas please feel free to pass them on.
    Here is the wrapper class. It can be used as a direct replacement for the weblogic WLSTInterpreter. As I can't overload the actual exec() calls because I want to return a String from this call I created an exec1(String command) that will return a String and throw my WLSTException which is a RuntimeException which you can handle if you like.
    It sets up stderr and stdout streams to interpret the results both from the Python interpreter level and at the JVM level where dumpStack() just seem to do a printStackTrace(). It also calls the dumpStack() command should the result contain this in its text. If either an exception is thrown from the lower level interpreter or dumpStack() is in the response I throw my WLSTException containing this information.
    package eu.medsea.WLST;
    import java.io.ByteArrayOutputStream;
    import java.io.PrintStream;
    import weblogic.management.scripting.utils.WLSTInterpreter;
    public class WLSTInterpreterWrapper extends WLSTInterpreter {
         // For interpreter stdErr and stdOut
         private ByteArrayOutputStream baosErr = new ByteArrayOutputStream();
         private ByteArrayOutputStream baosOut = new ByteArrayOutputStream();
         private PrintStream stdErr = new PrintStream(baosErr);
         private PrintStream stdOut = new PrintStream(baosOut);
         // For redirecting JVM stderr/stdout when calling dumpStack()
         static PrintStream errSaveStream = System.err;
         static PrintStream outSaveStream = System.out;
         public WLSTInterpreterWrapper() {
              setErr(stdErr);
              setOut(stdOut);
         // Wrapper function for the WLSTInterpreter.exec()
         // This will throw an Exception if a failure or exception occures in
         // The WLST command or if the response containes the dumpStack() command
         public String exec1(String command) {
              String output = null;
              try {
                   output = exec2(command);
              }catch(Exception e) {
                   try {
                        synchronized(this) {
                             stdErr.flush();
                             baosErr.reset();
                             e.printStackTrace(stdErr);
                             output = baosErr.toString();
                             baosErr.reset();
                   }catch(Exception ex) {
                        output = null;
                   if(output == null) {
                        throw new WLSTException(e);
                   if(!output.contains(" dumpStack() ")) {
                        // A real exception any way
                        throw new WLSTException(output);
              if (output.length() != 0) {
                   if(output.contains(" dumpStack() ")) {
                        // redirect the JVM stderr for the durration of this next call
                        synchronized(this) {
                             System.setErr(stdErr);
                             System.setOut(stdOut);
                             String _return = exec2("dumpStack()");
                             System.setErr(errSaveStream);
                             System.setOut(outSaveStream);
                             throw new WLSTException(_return);
              return stripCRLF(output);
         private String exec2(String command) {
              // Call down to the interpreter exec method
              exec(command);
              String err = baosErr.toString();
              String out = baosOut.toString();
              if(err.length() == 0 && out.length() == 0) {
                   return "";
              baosErr.reset();
              baosOut.reset();
              StringBuffer buf = new StringBuffer("");
              if (err.length() != 0) {
                   buf.append(err);
              if (out.length() != 0) {
                   buf.append(out);
              return buf.toString();
         // Utility to remove the end of line sequences from the result if any.
         // Many of the response are terminated with either \r or \n or both and
         // some responses can contain more than one of them i.e. \n\r\n
         private String stripCRLF(String line) {
              if(line == null || line.length() == 0) {
                   return line;
              int offset = line.length();          
              while(true && offset > 0) {
                   char c = line.charAt(offset-1);
                   // Check other EOL terminators here
                   if(c == '\r' || c == '\n') {
                        offset--;
                   } else {
                        break;
              return line.substring(0, offset);
    }Next here is the WLSTException class
    package eu.medsea.WLST;
    public class WLSTException extends RuntimeException {
         private static final long serialVersionUID = 1102103857178387601L;
         public WLSTException() {
              super();
         public WLSTException(String message) {
              super(message);
         public WLSTException(Throwable t) {
              super(t);
         public WLSTException(String s, Throwable t) {
              super(s, t);
    }And here is the start of a wrapper class for so that you can use the WLST commands directly. I will flesh this out later with proper var arg capabilities as well as create a whole Exception hierarchy that better suites the calls.
    package eu.medsea.WLST;
    // Provides methods for the WLSTInterpreter
    // just to make life a little easier.
    // Also provides access to the more generic exec(...) call
    public class WLSTCommands {
         public void cd(String path) {
              exec("cd('" + path + "')");
         public void edit() {
              exec("edit()");
         public void startEdit() {
              exec("startEdit()");
         public void save() {
              exec("save()");
         public void activate() {
              exec("activate(block='true')");
         public void updateDomain() {
              exec("updateDomain()");
         public String state(String serverName) {
              return exec("state('" + serverName + "')");
         public String ls(String dir) {
              return exec("ls('" + dir + "')");
         // The generic wrapper for the interpreter exec() call
         public String exec(String command) {
              return interpreter.exec1(command);
         private WLSTInterpreterWrapper interpreter = new WLSTInterpreterWrapper();
    }Lastly here is some example code using these classes:
    its using both the exec(...) and cd(...) wrapper commands from the WLSTCommand.class shown above.
        String machineName = ...; // get name from somewhere
        try {
         exec("machine=create('" + machineName + "','Machine')");
         cd("/Machines/" + machineName + "/NodeManager/" + machineName);
         exec("set('ListenAddress','10.42.60.232')");
         exec("set('ListenPort', 5557)");
        }catch(WLSTException e) {
            // Possibly the machine object already exists so
            // lets just try to look it up.
         exec("machine=lookup('" + machineName + "','Machine')");
    ...After this call a machine object is setup that can be allocated later like so:
         exec("set('Machine',machine)");Regards
    Steve

  • Problem with running sample code from XML Schema Processor for Java

    Hi there,
    I downloaded the XML Schema Processor for Java and tried it out. Unfortunately, it failed at the first step. FYI, I included all xmlparserv2.jar and xmlschema.jar in my classpath.
    I compiled XSDSample.java with a warning: XSDSample.java uses a deprecated API. Recompile with "-deprecation" for details. There was no problem with compiling XSDSetSchema.java.
    When I tried to run report.xml by typing java XSDSample report.xml, I got Parsing report.xml
    NonParserException: null.
    I guess that report.xml from the sample is not valid.
    Could any one give me a hint? Any suggestion would be greatly appreciated.
    ---Denali
    null

    Please post this message at:
    Forums Home » Oracle Technology Network (OTN) » Products » Database » XML DB

Maybe you are looking for