Throws Throwable

Hi,
I have come across the classes where for handling the exceptions, they have used as
'throws Throwable'.
It gives me confusion since from my understanding we need to throw only the exception and not this Throwable class itself.
Could anyone help me understanding the idea behind this.
Thanks in adv.
-Bh.

Throwable is the superclass of Exception & Error.
have a look :
http://java.sun.com/docs/books/jls/secondedition/html/exceptions.doc.html#44278_
in general you can throw any subclass of Throwable or Throwable itself.
have a look for Throw statement:
http://java.sun.com/docs/books/jls/secondedition/html/statements.doc.html#79311_
Hope this will clear your doubt.
Thanx

Similar Messages

  • Question about throws exception in interface and realized class

    Hi,all
    If I define a method In the interface like that-
    public void Execute() throws NumberFormatException; In the realized class, I can define this method like that-
    public void Execute() throws RuntimeException{
            System.out.println("test");       
    }This is a right realization. But if I manage it to throws Exception or to throws Throwable in the class it leads a error. Why add this restrict only to Exception? What is the purpose of this way?
    Greetings and thanks,
    Jason

    When you say "throws NumberFormatException" you are really saying:
    When using classes implementing this interface, you have to be prepared to deal with them throwing a NumberFormatException. Other exceptions won't happen.
    When you come to implement it, it might not be possible for it to throw a NumberFormatException, so there's no reason why you should have to lie about that. Code handling it directly will be fine (it doesn't throw a NFE) and code handling it via the interface will be fine (it will handle NFEs, they just don't happen).
    If your concrete implementation throws other sorts of exception, such as Exception or IOException, and so on, it's incompatible with code that's manipulating the interface. The interface says "NFEs might get thrown, nothing else will." while your implementation says "IOExceptions might get thrown".
    So that explains why you can't use arbitrary exceptions. The special case is RuntimeException. RuntimeExceptions don't have to be caught, and it's expected that they can happen at any time - so there's no point trying to catch and handle them as a general case.
    The classic example of a RuntimeException is a NullPointerException. You don't need to declare your method as throwing a NullPointerException even though it might get thrown. And you don't have to add NullPointerException to the throws part of the interface definition, because you already know that the concrete implementation could throw a NPE at any time.
    Hope that helps (a little).
    I'd recommend reading the API documentation on RuntimeException and Exception to get a clearer insight into this.
    Dave.

  • Does Throw in a JCD rollback whole JCD??

    Hi All,
    I have a Try Catch in a JCD.
    When an error is raised i want to send a JMS to a queue(error log) then Throw so the Redelivery Handling kicks in.
    The send a JMS to a queue doesn't ever happen though, unless i remove the Throw.
    Seems like everything is rolled back by the throw?
    Is there any way i can send this JMS to the queue and throw.
    Cheers,
    Ken

    This is cut down, but shows whats happening.
    Basically placing a file in a directory.
    Redelivery Handling setup in connectivity map in link between queue & this JCD to try a certain no. of times.
    If a delivery fails i want to write to a queue (notificationSend in catch) as well as using Redelivery Handling.
    The problem is...
    1) Throw is needed to make the Redelivery Handling work, but then otdJMS_NOTIFICATIONSUMMARY.send( jmsMsg ) never sends massage.
    2) if throw is disabled then message will send, but Redelivery Handling won't work, presumably because it thinks JCD didn't fail.
    How can i use Redelivery Handling and send a message to a queue?
    Am i approaching this the wrong way?
    public void receive( com.stc.connectors.jms.Message input, com.stc.eways.batchext.BatchLocal BatchLocalFile_eWay_Out, , com.stc.connectors.jms.JMS otdJMS_NOTIFICATIONSUMMARY)
    throws Throwable
    try {
    // Setup Batch eWay
    BatchLocalFile_eWay_Out.getClient().setPayload( input.retrieveBytesFromMessage() );
    BatchLocalFile_eWay_Out.getClient().put();
    } catch ( Throwable t ) {
    notificationSend( input);
    // throw to use "Redelivery Handling"
    throw t;
    // Assign User Properties & send to Notifictaions project
    private void notificationSend( com.stc.connectors.jms.Message input )
    throws Exception
    // Create new message
    com.stc.connectors.jms.Message jmsMsg = otdJMS_NOTIFICATIONSUMMARY.createMessage();
    jmsMsg.setTextMessage( input.getTextMessage() );
    // send massage on it merry way...
    otdJMS_NOTIFICATIONSUMMARY.send( jmsMsg );
    }

  • Can i call a JMenuBar in a number of JFrame(s) ?

    Hi ,
    I've a program with a number of JFrames.
    I wanted to add a JMenuBar for each frame of my program, this menu bar has the same design code and the same events code in all the program frames, so is there a way to create this JMenuBar once only & call it some how in every JFrame to load it directly instead of writing its same code a lot of times for every JFrame ?
    Thanks ,
    Hesham

    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    class Test{
         public static void main( String[] argv ) throws Throwable {
              for(int i=0; i<10; i++){
                   SuperFrame f = new SuperFrame();
                   f.setLocation(i*10,i*10);
                   f.setSize(400,300);
                   f.setVisible(true);
    class SuperFrame extends JFrame{
         private static final long serialVersionUID = 1L;
          * All the menu item goes here
         JMenuBar mbar = new JMenuBar();
         JMenu menu = new JMenu("Menu");
         JMenuItem menuItem1  = new JMenuItem("Close");
         JMenuItem menuItem2  = new JMenuItem("Exit");
         public SuperFrame(){
              super("Testing");
              this.menu.add(menuItem1);
              this.menu.add(menuItem2);
              this.mbar.add(menu);
              this.setJMenuBar(mbar);
              menuItem1.addActionListener(new ActionListener(){
                   @Override
                   public void actionPerformed(ActionEvent arg0) {
                        dispose();
              menuItem2.addActionListener(new ActionListener(){
                   @Override
                   public void actionPerformed(ActionEvent arg0) {
                        System.exit(0);
    }

  • Custom button UI Problem

    Hi all,
    I have written CustomButtonUI for JButton.
    But, it results into error.please suggest me.
    Here is the code:
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Rectangle;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.accessibility.Accessible;
    import javax.swing.AbstractButton;
    import javax.swing.JButton;
    import javax.swing.JComponent;
    import javax.swing.UIManager;
    import javax.swing.plaf.ComponentUI;
    import javax.swing.plaf.basic.BasicButtonListener;
    import javax.swing.plaf.metal.MetalButtonUI;
    * CustomButtonUI.java
    * Created on March 4, 2010, 5:13 PM
    * @author  mourya
    public class CustomButtonUI extends javax.swing.JDialog {
        /** Creates new form CustomButtonUI */
        public CustomButtonUI(java.awt.Frame parent, boolean modal) {
            super(parent, modal);
            String DEFAULTCLASSID="Mybutton";
            UIManager.put(DEFAULTCLASSID, "Mybutton");
            UIManager.put("ButtonUI",DEFAULTCLASSID);
            initComponents();
            JButton jbutton = new JButton("Custom");
            jbutton.setBounds(10,10,100,20);
            add(jbutton);
            this.addWindowListener(new WindowAdapter()
                public void windowClosing(WindowEvent event)
                    System.exit(0);
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                         
        private void initComponents() {
            setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
            org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(0, 400, Short.MAX_VALUE)
            layout.setVerticalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(0, 300, Short.MAX_VALUE)
            pack();
        }// </editor-fold>                       
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new CustomButtonUI(new javax.swing.JFrame(), true).setVisible(true);
        // Variables declaration - do not modify                    
        // End of variables declaration                  
    class Mybutton extends MetalButtonUI
         private final static Mybutton
          mMybutton = new Mybutton();
        public static ComponentUI createUI(JComponent c)
          return mMybutton;
        protected void clearTextShiftOffset()
            super.clearTextShiftOffset();
        protected void finalize() throws Throwable
            super.finalize();
        protected BasicButtonListener createButtonListener(AbstractButton b)
            return super.createButtonListener(b);
        protected Color getDisabledTextColor()
            return super.getDisabledTextColor();
        protected Color getFocusColor()
            return super.getFocusColor();
        protected String getPropertyPrefix()
            return super.getPropertyPrefix();
        protected Color getSelectColor()
            return super.getSelectColor();
        protected int getTextShiftOffset() {
            return super.getTextShiftOffset();
        protected void installKeyboardActions(AbstractButton b)
            super.installKeyboardActions(b);
        protected void installListeners(AbstractButton b) {
            super.installListeners(b);
        protected Object clone() throws CloneNotSupportedException {
            return super.clone();
        protected void paintButtonPressed(Graphics g, AbstractButton b)
            super.paintButtonPressed(g,b);
        protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect) {
            super.paintFocus(g,b,viewRect,textRect,iconRect);
        protected void paintIcon(Graphics g, JComponent c, Rectangle iconRect) {
            super.paintIcon(g,c,iconRect);
        protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text)
            g.setColor(Color.GRAY);
            super.paintText(g,b,textRect,text);
        protected void paintText(Graphics g, JComponent c, Rectangle textRect, String text) {
            g.setColor(Color.GRAY);
            super.paintText(g,c,textRect,text);
        protected void setTextShiftOffset() {
            super.setTextShiftOffset();
        protected void uninstallKeyboardActions(AbstractButton b) {
            super.uninstallKeyboardActions(b);
        protected void uninstallListeners(AbstractButton b) {
            super.uninstallListeners(b);
        public boolean contains(JComponent c, int x, int y)
            return super.contains(c,x,y);
        public boolean equals(Object obj)
            return super.equals(obj);
        public Accessible getAccessibleChild(JComponent c, int i) {
            return super.getAccessibleChild(c,i);
        public int getAccessibleChildrenCount(JComponent c) {
            return super.getAccessibleChildrenCount(c);
        public int getDefaultTextIconGap(AbstractButton b) {
            return super.getDefaultTextIconGap(b);
        public Dimension getMaximumSize(JComponent c) {
            return super.getMaximumSize(c);
        public Dimension getMinimumSize(JComponent c) {
            return super.getMinimumSize(c);
        public Dimension getPreferredSize(JComponent c) {
            return super.getPreferredSize(c);
        public void installDefaults(AbstractButton b) {
            super.installDefaults(b);
        public void installUI(JComponent c) {
            super.installUI(c);
        public int hashCode() {
            return super.hashCode();
        public void paint(Graphics g, JComponent c) {
            super.paint(g,c);
        public String toString() {
            return super.toString();
        public void uninstallDefaults(AbstractButton b)
            super.uninstallDefaults(b);
        public void uninstallUI(JComponent c)
            super.uninstallUI(c);
        public void update(Graphics g, JComponent c)
            super.update(g,c);
    }Thank You

    Hi DarrylBurke,
    Sure i will.
    But i have posted that code after trying all the possibilities.
    I thought that getUI() failed exception may have the resulkt for not implementing any method or any registration problem with UIManager.
    So, that is my test code not exactly i have posted that in hurry.
    Here is the code :
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Rectangle;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.accessibility.Accessible;
    import javax.swing.AbstractButton;
    import javax.swing.JButton;
    import javax.swing.JComponent;
    import javax.swing.UIManager;
    import javax.swing.plaf.ComponentUI;
    import javax.swing.plaf.basic.BasicButtonListener;
    import javax.swing.plaf.metal.MetalButtonUI;
    * CustomButtonUI.java
    * Created on March 4, 2010, 5:13 PM
    * @author  mourya
    public class CustomButtonUI extends javax.swing.JDialog {
        /** Creates new form CustomButtonUI */
        public CustomButtonUI(java.awt.Frame parent, boolean modal) {
           super(parent, modal);
            String DEFAULTCLASSID="Mybutton";
            UIManager.put(DEFAULTCLASSID, "Mybutton");
            UIManager.put("ButtonUI",DEFAULTCLASSID);
            initComponents();
            JButton jbutton = new JButton("Custom");
            jbutton.setBounds(10,10,100,20);
            add(jbutton);
            this.addWindowListener(new WindowAdapter()
                public void windowClosing(WindowEvent event)
                    System.exit(0);
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                         
        private void initComponents() {
            setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
            org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(0, 400, Short.MAX_VALUE)
            layout.setVerticalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(0, 300, Short.MAX_VALUE)
            pack();
        }// </editor-fold>                       
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new CustomButtonUI(new javax.swing.JFrame(), true).setVisible(true);
        // Variables declaration - do not modify                    
        // End of variables declaration                  
    class Mybutton extends MetalButtonUI
         private final static Mybutton
          mMybutton = new Mybutton();
        public static ComponentUI createUI(JComponent c)
          return mMybutton;
        protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text)
            g.setColor(Color.RED);
            super.paintText(g,b,textRect,text);
    }Can you please suggest me the possible solution for this problem.
    Thank You DarrylBurke

  • Problem with JNDI and JSP in Tomcat

    Hi,
    Basically, what I've done is to use the Tomcat administration web
    application to create the DataSource, which looks like it populated the
    server.xml (see below). I then try to access the testconn.jsp, and am
    getting that "Name java:comp is not bound in this Context" error.
    I was wondering if anyone could tell me what I'm doing wrong?
    Thanks,
    Feri
    My Configuration:
    - Tomcat 5.0.19
    - MySQL 4.0.18-nt
    - mysql-connector-java-3.0.15-ga-bin.jar
    server.xml:
    <GlobalNamingResources>
    <!-- Test entry for demonstration purposes -->
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
    <!-- Editable user database that can also be used by
    UserDatabaseRealm to authenticate users -->
    <Resource name="UserDatabase" auth="Container"
    type="org.apache.catalina.UserDatabase"
    description="User database that can be updated and saved">
    </Resource>
    <ResourceParams name="UserDatabase">
    <parameter>
    <name>factory</name>
    <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
    </parameter>
    <parameter>
    <name>pathname</name>
    <value>conf/tomcat-users.xml</value>
    </parameter>
    </ResourceParams>
    <!--Feri test JNDI-->
         <Context crossContext="true" debug="5" docBase="injury" path="/injury" reloadable="true">
         <Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_injury_log." suffix=".txt" timestamp="true"/>
              <Resource name="jdbc/injury" auth="Container"
    type="javax.sql.DataSource">
    </Resource>
    <ResourceParams name="jdbc/injury">
         <parameter>
              <name>factory</name>
              <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
         </parameter>
    <parameter>
    <name>username</name>
    <value>root</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>root</value>
    </parameter>
         <parameter>
    <name>driverClassName</name>
    <value>com.mysql.jdbc.Driver</value>
    </parameter>
         <parameter>
    <name>url</name>
    <value>jdbc:mysql://localhost:3306/injury</value>
    </parameter>
         <parameter>
              <name>maxIdle</name>
              <value>30</value>
         </parameter>
         <parameter>
              <name>maxActive</name>
              <value>10</value>
         </parameter>
         <parameter>
              <name>maxWait</name>
              <value>10000</value>
         </parameter>
    </ResourceParams>
         </Context>
    <!--Feri test JNDI end-->
    </GlobalNamingResources>
    \webapps\injury\WEB-INF\web.xml:
    <resource-ref>
    <description>Resource reference to a factory for java.sql.Connection instances that may be used for talking to a particular database that is configured in the server.xml file.</description>
    <res-ref-name>jdbc/injury</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    \webapps\injury\testconn.jsp
    <%@ page import="java.sql.*" %>
    <%@ page import="javax.sql.*" %>
    <%@ taglib prefix="ct" uri="/injury" %>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
    <h1>Connection test</h1>
    <ct:connection name="jdbc/injury">
    <%
    Statement stmt= conn.createStatement();
    ResultSet rs;
    rs = stmt.executeQuery("select * from user");
    while (rs.next()){
    %><%=rs.getString(1)%><%=rs.getInt(2) %><br><%
    rs.close();
    stmt.close();
    %>
    </ct:connection>
    ConnectionTag.java
    import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    import javax.naming.*;
    import javax.sql.*;
    import javax.sql.DataSource;
    public class ConnectionTag extends TagSupport implements TryCatchFinally {
    private Connection conn;
    // JNDI name of the connection
    private String name;
    public void setName(String name)
         this.name = name;
    public int doStartTag()
         throws JspException
         try {
         Context env = (Context) new InitialContext().lookup("java:comp/env");
         DataSource ds = (DataSource) env.lookup(name);
         if (ds != null)
              conn = ds.getConnection();
         } catch (Exception e) {
         throw new JspException(e);
         if (conn == null)
         throw new JspException("can't open connection " + name);
         pageContext.setAttribute("conn", conn);
         return EVAL_BODY_INCLUDE;
    public void doCatch(Throwable t)
         throws Throwable
         throw t;
    public void doFinally()
         try {
         Connection conn = this.conn;
         this.conn = null;
         pageContext.removeAttribute("conn");
         conn.close();
         } catch (Exception e) {
    Tomcat 5.0\conf\Catalina\localhost\injury.xml
    <?xml version='1.0' encoding='utf-8'?>
    <Context displayName="Injury" docBase="E:\Tomcat 5.0\webapps\injury" path="/injury" className="org.apache.catalina.core.StandardContext"
    cachingAllowed="true" charsetMapperClass="org.apache.catalina .util.CharsetMapper" cookies="true" crossContext="false" debug="0"
    mapperClass="org.apache.catalina.core.StandardContextMapper" useNaming="true" wrapperClass="org.apache.catalina.core.StandardWrapper" >
    <Resource auth="Container" description="Resource reference to a factory for java.sql.Connection instances that may be used for talking to a particular database that is configured in the server.xml file." name="jdbc/injury" type="javax.sql.DataSource"/>
    <ResourceLink global="jdbc/injury" name="injury" type="javax.sql.DataSource"/>
    </Context>

    Hi,
    First of all, you can find alot of information about this in the forum about jsp's.
    I think a good thing to do is not to put your context tag directly into the server.xml file.
    What you should do is create a context.xml file with the context-tag in it, and put it in the META-INF directory of your .war file. Upon deployment to tomcat5 this file will be extracted from the war, copied to the conf\enginename\hostname directory, and it will be renamed to contextName.xml.
    I think you are developing directly into the webapps directory, and I believe you should avoid that and use the deployment feature of the manager web-app or you should use the deployertool from you ide or standalone ant.
    anyway, for starters try to remove the context tag from the server.xml file as described above, and check out the jsp / jdbc forums for simular problems and answers.
    good luck

  • Event Dispatch Thread Hangs, what is wrong?

    The Event Dispatch Thread Hangs when showing a modal dialog while running a
    SwingWorker Thread.
    I have included my code at the bottom of the page. There are three classes. I have posted a bug report to red hat. But I want to make sure my code is correct.
    My test case just puts the SwingWorker to sleep
    but the problem occurs if I do something real, like connect to a database, etc.
    Also I have tried little different variations of the logic calling
    setVisible(true)/(false) in different places and the same problem occurs.
    It seems to work with Sun JDK, note I am using IcedTea with Fedora Core 8.
    Version-Release number of selected component (if applicable):
    [szakrews@tuxtel ~]$ java -version
    java version "1.7.0"
    IcedTea Runtime Environment (build 1.7.0-b21)
    IcedTea Client VM (build 1.7.0-b21, mixed mode)How reproducible:
    Every couple times.
    javac TestClass2
    java TestClass2eventually it will hang. If it doesn't try again.
    You don't have to wait for the program to finish either.
    The program runs the Dialog 10 times but it never works or fails in the middle, it will either work or fail from the first dialog displayed.
    I have included a thread dump. That is about the most informative information I can get. Neither tracing nor writing a custom ThreadQueue or Drawing Manager to trace events produces any helpful information.
    Actual results:
    The JProccessBar won't move, and the SwingWorker finishes but the done() method is never run. The PROGRAM is not hung however because if I close the dialog then it will continue.
    Expected results:
    The JProccessBar should always move and the SwingWorker should always run the done() method.
    Additional info:
    java thread dump after freeze, taken with kill -s SIGQUIT <pid>
    2008-06-25 12:25:50
    Full thread dump IcedTea Client VM (1.7.0-b21 mixed mode):
    "DestroyJavaVM" prio=10 tid=0x938afc00 nid=0x1419 waiting on condition
    [0x00000000..0x0018a074]
       java.lang.Thread.State: RUNNABLE
    "AWT-EventQueue-0" prio=10 tid=0x938ae400 nid=0x1429 in Object.wait()
    [0x07f96000..0x07f96f04]
       java.lang.Thread.State: WAITING (on object monitor)
            at java.lang.Object.wait(Native Method)
            - waiting on <0x96748f80> (a java.awt.EventQueue)
            at java.lang.Object.wait(Object.java:503)
            at java.awt.EventQueue.getNextEvent(EventQueue.java:485)
            - locked <0x96748f80> (a java.awt.EventQueue)
            at
    java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:248)
            at
    java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:201)
            at
    java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:195)
            at java.awt.Dialog$1.run(Dialog.java:1073)
            at java.awt.Dialog$3.run(Dialog.java:1127)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.awt.Dialog.show(Dialog.java:1125)
            at java.awt.Component.show(Component.java:1456)
            at java.awt.Component.setVisible(Component.java:1408)
            at java.awt.Window.setVisible(Window.java:871)
            at java.awt.Dialog.setVisible(Dialog.java:1012)
            at net.xtel.production.WaitDialog.showWaitDialog(WaitDialog.java:72)
            at net.xtel.production.WaitDialog.showWaitDialog(WaitDialog.java:102)
            at TestClass2.showWait(TestClass2.java:79)
            at TestClass2.createAndShowGUI(TestClass2.java:126)
            at TestClass2.access$0(TestClass2.java:114)
            at TestClass2$3.run(TestClass2.java:138)
            at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:227)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:603)
            at
    java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:276)
            at
    java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:201)
            at
    java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:191)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:186)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:178)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:139)
    "AWT-Shutdown" prio=10 tid=0x938ad000 nid=0x1428 in Object.wait()
    [0x03ea7000..0x03ea7f84]
       java.lang.Thread.State: WAITING (on object monitor)
            at java.lang.Object.wait(Native Method)
            - waiting on <0x96749268> (a java.lang.Object)
            at java.lang.Object.wait(Object.java:503)
            at sun.awt.AWTAutoShutdown.run(AWTAutoShutdown.java:281)
            - locked <0x96749268> (a java.lang.Object)
            at java.lang.Thread.run(Thread.java:675)
    "AWT-XAWT" daemon prio=10 tid=0x938a8400 nid=0x1423 runnable
    [0x02ccc000..0x02ccd104]
       java.lang.Thread.State: RUNNABLE
            at sun.awt.X11.XToolkit.waitForEvents(Native Method)
            at sun.awt.X11.XToolkit.run(XToolkit.java:550)
            at sun.awt.X11.XToolkit.run(XToolkit.java:525)
            at java.lang.Thread.run(Thread.java:675)
    "Java2D Disposer" daemon prio=10 tid=0x93854000 nid=0x1421 in Object.wait()
    [0x07aea000..0x07aead84]
       java.lang.Thread.State: WAITING (on object monitor)
            at java.lang.Object.wait(Native Method)
            - waiting on <0x966e7010> (a java.lang.ref.ReferenceQueue$Lock)
            at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
            - locked <0x966e7010> (a java.lang.ref.ReferenceQueue$Lock)
            at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:150)
            at sun.java2d.Disposer.run(Disposer.java:143)
            at java.lang.Thread.run(Thread.java:675)
    "Low Memory Detector" daemon prio=10 tid=0x93c15000 nid=0x141f runnable
    [0x00000000..0x00000000]
       java.lang.Thread.State: RUNNABLE
    "CompilerThread0" daemon prio=10 tid=0x93c13400 nid=0x141e waiting on condition
    [0x00000000..0x03a8a954]
       java.lang.Thread.State: RUNNABLE
    "Signal Dispatcher" daemon prio=10 tid=0x93c11c00 nid=0x141d waiting on
    condition [0x00000000..0x00000000]
       java.lang.Thread.State: RUNNABLE
    "Finalizer" daemon prio=10 tid=0x095e7000 nid=0x141c in Object.wait()
    [0x005d2000..0x005d3004]
       java.lang.Thread.State: WAITING (on object monitor)
            at java.lang.Object.wait(Native Method)
            - waiting on <0x966e71d8> (a java.lang.ref.ReferenceQueue$Lock)
            at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
            - locked <0x966e71d8> (a java.lang.ref.ReferenceQueue$Lock)
            at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:150)
            at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:177)
    "Reference Handler" daemon prio=10 tid=0x095e2400 nid=0x141b in Object.wait()
    [0x00581000..0x00582084]
       java.lang.Thread.State: WAITING (on object monitor)
            at java.lang.Object.wait(Native Method)
            - waiting on <0x966e7260> (a java.lang.ref.Reference$Lock)
            at java.lang.Object.wait(Object.java:503)
            at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:134)
            - locked <0x966e7260> (a java.lang.ref.Reference$Lock)
    "VM Thread" prio=10 tid=0x095dec00 nid=0x141a runnable
    "VM Periodic Task Thread" prio=10 tid=0x93c17400 nid=0x1420 waiting on condition
    JNI global references: 836
    Heap
    def new generation   total 960K, used 152K [0x93f40000, 0x94040000, 0x966a0000)
      eden space 896K,   9% used [0x93f40000, 0x93f56148, 0x94020000)
      from space 64K, 100% used [0x94020000, 0x94030000, 0x94030000)
      to   space 64K,   0% used [0x94030000, 0x94030000, 0x94040000)
    tenured generation   total 4096K, used 1088K [0x966a0000, 0x96aa0000, 0xb3f40000)
       the space 4096K,  26% used [0x966a0000, 0x967b01b0, 0x967b0200, 0x96aa0000)
    compacting perm gen  total 12288K, used 9169K [0xb3f40000, 0xb4b40000, 0xb7f40000)
       the space 12288K,  74% used [0xb3f40000, 0xb4834740, 0xb4834800, 0xb4b40000)
    No shared spaces configured.CLASS1:
    import java.awt.Dimension;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.sql.SQLException;
    import java.util.concurrent.ExecutionException;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.RepaintManager;
    import javax.swing.SwingUtilities;
    import javax.swing.UIManager;
    import javax.swing.UnsupportedLookAndFeelException;
    public class TestClass2 extends JFrame implements ActionListener {
            /** Action Command for <code>searchbtn</code> */
            public static final String SEARCH_BTN_ACTION = "search_btn_action";
             * Constructor.
            public TestClass2() {
                    setSize(650, 350);
                    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
                    setLocation(screenSize.width / 2 - getSize().width / 2,
                                    screenSize.height / 2 - getSize().height / 2);
                    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
                    addWindowListener(new WindowAdapter() {
                            @Override
                            public void windowClosing(WindowEvent e) {
                                    exit();
                    JPanel panel = new JPanel();
                    add(panel);
                    setVisible(true);
            @Override
            public void actionPerformed(ActionEvent e) {
                    if (e.getActionCommand().equals(SEARCH_BTN_ACTION)) {
                            JOptionPane.showMessageDialog(this, "Button Pressed");
            public void showWait() {
                    try {
                            WaitDialog.showWaitDialog(this, "Testing...", new SwingWorkerInterface(){
                                    @Override
                                    public Object workToDo() throws Throwable {
                                            Thread.currentThread().sleep(3000);
                                            return null;
                    } catch (InterruptedException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                    } catch (ExecutionException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
             * Exits the program.
            public void exit(){
                    System.exit(0);
             * Create the GUI and show it. For thread safety, this method should be
             * invoked from the event-dispatching thread.
             * @throws UnsupportedLookAndFeelException
             * @throws IllegalAccessException
             * @throws InstantiationException
             * @throws ClassNotFoundException
             * @throws NullInstanceVariableException
             * @throws SQLException
            private static void createAndShowGUI() {
                    // set look and feel
                    try{
                            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                            // Create instance of the ProductCatalog
                            TestClass2 root = new TestClass2();
                            for(int i = 0; i < 10; i++){
                                    root.showWait();
                    }catch(Exception e){
                            e.printStackTrace();
             * @param args
             *            this program does not use arguments
            public static void main(String[] args) {
                    SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                                    createAndShowGUI();
    }CLASS 2:
    import java.awt.Component;
    import java.awt.Frame;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.util.concurrent.ExecutionException;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JProgressBar;
    import javax.swing.SwingWorker;
    public class WaitDialog extends JDialog {
            private boolean disposed = false;
            private boolean displayed = false;
            private WorkerThread worker = null;
            WaitDialog(Frame parent, String text, SwingWorkerInterface in){
                    super(parent, true);
                    worker = new WorkerThread(in);
                    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
                    addWindowListener(new WindowAdapter() {
                            @Override
                            public void windowOpened(WindowEvent e) {
                                    worker.execute();
                            @Override
                            public void windowClosing(WindowEvent e) {
                                    disposeWaitDialog();
                    this.setResizable(false);
                    JLabel message = new JLabel();
                    message.setText(text);
                    JProgressBar pb = new JProgressBar();
                    pb.setIndeterminate(true);
                    // set size and location
                    setSize(200, 100);
                    setLocationRelativeTo(parent);
                    JPanel panel = new JPanel();
                    panel.add(message);
                    panel.add(pb);
                    add(panel);
            public void showWaitDialog(){
                    if(displayed == true){
                            return;
                    if(disposed == true){
                            disposed = false;
                            return;
                    disposed = false;
                    displayed = true;
                    setVisible(true);
            public void disposeWaitDialog(){
                    if(disposed == true){
                            return;
                    if(displayed == true){
                            displayed = false;
                            setVisible(false);
                            return;
                    disposed = true;
                    displayed = false;
            public static Object showWaitDialog(Component parent, String text, SwingWorkerInterface in) throws InterruptedException, ExecutionException {
                    WaitDialog waitDialog = null;
                    if (parent == null) {
                            waitDialog = new WaitDialog(JOptionPane.getRootFrame(), text, in);
                    } else {
                            waitDialog = new WaitDialog(JOptionPane.getFrameForComponent(parent), text, in);
                    while(!waitDialog.worker.isDone()){
                            System.out.println("about to show");
                            waitDialog.showWaitDialog();
                            System.out.println("done showing");
                    waitDialog.dispose();
                    return waitDialog.worker.get();
            class WorkerThread extends SwingWorker<Throwable, Void> {
                    private SwingWorkerInterface in = null;
                    WorkerThread(SwingWorkerInterface in){
                            this.in = in;
                    public Throwable doInBackground(){
                                    try {
                                            System.out.println("about to do work");
                                            in.workToDo();
                                            System.out.println("done work no exception");
                                    } catch (Throwable e) {
                                            System.out.println("done work with exception");
                                            return e;
                                    return null;
                    public void done(){
                                    System.out.println("about to dispose");
                                    disposeWaitDialog();
                                    System.out.println("disposed");
    }CLASS 3:
    public interface SwingWorkerInterface {
            public Object workToDo() throws Throwable;
    }

    There's nothing directly wrong with it, but it will
    prevent other threads acquiring the class lock - but
    that may be what you want.True. Although the typical case for code that looks like this would be to use wait--usually the various threads in question require the same lock, so you have to use wait in order for the waiting thread to give it up and allow the other thread to do its work. Hard to say for sure though what he's doing.
    Also, if loading is all that the other thread does, and you're waiting for that thread to die, use join. But then, if that's the case, and you're only waiting for a single other thread, then you might as well just put it all in one thread, as already indicated.

  • Right way to dispose frame/components/containers?

    Hi,
    My application creates a lot of frames with lots of containers and components (heavyweights as well as light weights) inside them. I have obeserved that none of the frames/containers/components get finalized unless I do a remove/removeAll() over the respective container. Currently I just make a call to frame.dispose() to dispose it off and assume that all components would be reclaimed by the garbage collector at some point of time. Is that the right way to dispose off the frames and mark all its child components for garbage collection? Or is an explicit call to removeAll() required to release the memory. I am aware that garbage collection doesn't happen immediately and may take a while before the GC collects objects. I have run the application continuously for couple of hours and created/disposed a lot of frames during that period. GC recollected none of them (none of the components either) except for those that were removed by an explicit call to remove or removeAll during the lifetime of the session. I even hit OOM errors but none of the components were recollected.
    What could be the problem?
    Some additional information:
    I overridden removeNotify() and finalize() methods to see what's going on. For all components removeNotify() was called (even if I don't do explicit remove/removeAll and just dispose off the frame) but finalize never gets called. My methods:
         public void removeNotify()
              super.removeNotify();
              System.out.println("Remove notify called "+compId);
         protected void finalize() throws Throwable
              super.finalize();
              System.out.println("Finalized component "+compId);
         }Thanks in advance.
    Edited by: crack_it on Jul 31, 2009 8:52 AM

    Sorry to bother guys. The problem was not with AWT but with one evil component that was displayed inside most of my Frame classes and was also registered as an Observer with an Observable class. The event at which the component was supposed to unregister itself with Observable never got fired and this one reference prevented garbage collection of entire gui brigade. Damn! Tiny monster.
    Anyway the issue stands resolved. Thanks for your time.

  • Custom Login using the Pluggable Identity Management Framework

    Hi all,
    We are trying to establish 2 ways into our application:
    1. via a login form
    2. seamless login from an external application
    To achieve this we are trying to build our own custom authentication using the pluggable IDM framework.
    Basically if a secure page is requested, we want to check the header/cookie/request (don't mind which) for a key which is provided by the external application. If present, the key is validated against a web service provided by the external app, the identity is asserted and the user is entered seamlessly into the application. If the header/cookie/request does not contain a key the user is to be redirected to a login page, where they can input username and password which will be validated against our database.
    We've created a Token Collector and Token Asserter class, we've modified our custom Login Module to retrieve the identity created by the Token Asserter but we haven't worked out how to get the alternate login page working for users which don't come through the external application.
    Has anybody built anything similar? From the documentation it appears we should be able to achieve our goal using the pluggable IDM, but we're going around in circles a bit at the moment.
    Any help/sample code would be greatly appreciated.
    thanks.

    Can you tell why the page is not working? I mean, any errors ? What happens when you try to open the protected resource?
    Here is an example of the code, I removed some part of the code specific to the bussines so if you have doubts just let me know
    token collector
    import java.io.IOException;
    import java.io.UnsupportedEncodingException;
    import java.net.URLEncoder;
    import java.util.Hashtable;
    import java.util.List;
    import java.util.Map;
    import java.util.Properties;
    import javax.servlet.http.Cookie;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import oracle.security.jazn.collector.CollectorException;
    import oracle.security.jazn.collector.TokenCollector;
    import oracle.security.jazn.sso.SSOTokenFormatException;
    import oracle.security.jazn.token.IdentityToken;
    import oracle.security.jazn.token.TokenNotFoundException;
    public class MyTokenCollector implements TokenCollector
    private Properties _properties;
    public void fail(HttpServletRequest request,
    HttpServletResponse response, int reason)
    throws CollectorException
    String loginURL = _properties.getProperty("custom.sso.url.login");
    String urlParam = _properties.getProperty("custom.sso.url.param");
    String idParam = _properties.getProperty("custom.sso.id.param");               
    Log.Info("Token collection failed (" + reason + ")");
    StringBuffer requestURL = request.getRequestURL();
    String queryString = request.getQueryString();
    requestURL = requestURL.append("?").append(queryString);
    StringBuffer sb = new StringBuffer();
    try
    sb = sb.append(urlParam).append("=");
    String encodedStr =
    URLEncoder.encode(requestURL.toString(), "UTF-8");
    sb = sb.append(encodedStr);
    sb = sb.append("#").append(request.getServerName()).append("#").append(request.getServerPort());
    String redirectQueryString = sb.toString();
    String rurl = loginURL + "?" + redirectQueryString;
    response.sendRedirect(response.encodeRedirectURL(rurl));
    catch (UnsupportedEncodingException uee)
    SSOTokenFormatException stfe =
    new SSOTokenFormatException(uee, 4);
    Log.Error(stfe.getMessage());
    throw new CollectorException(stfe);
    catch (IOException ioe)
    Log.Error("IOException occured: " + ioe);
    throw new CollectorException(ioe);
    public IdentityToken getToken(String tokenType,
    HttpServletRequest request,
    List tokenNames, Properties properties)
    throws TokenNotFoundException, CollectorException
    _properties = properties;
    String valor = null;
    Log.Info("URL: "+request.getRequestURI());
    if ( tokenType. equalsIgnoreCase("HTTP_COOKIE"))
    valor = procesarCookie(request, tokenNames);
    }else if (tokenType.equalsIgnoreCase("HTTP_HEADER"))
    valor = procesarHeader(request, tokenNames);
    }else
    throw new CollectorException("token type not supported");
    MyIdentityToken token = new MyIdentityToken(valor);
    token.setTokenType(tokenType);
    token.setPropiedades(properties);
    return token;
    private String procesarCookie(HttpServletRequest request, List tokenNames)
    throws TokenNotFoundException
    if (1 != tokenNames.size())
    //Only one cookie can be handled
    String error = "Invalid number of cookies check jazn.xml";
    throw new TokenNotFoundException(error);
    Map cookies = new Hashtable();
    Cookie allCookies[] = request.getCookies();
    if (allCookies != null)
    String cookieName = (String) tokenNames.get(0);
    Log.Info( "Searching for cookie: " + cookieName);
    Cookie cookie;
    for(int i = 0; i < allCookies.length; i++)
    cookie = allCookies;
    if (cookie.getName().equals(cookieName))
    return cookie.getValue();
    String error = "Rquired cookie not found";
    Log.Error(error);
    throw new TokenNotFoundException(error);
    }else
    String error = "No cookie on request";
    throw new TokenNotFoundException(error);
    private String procesarHeader(HttpServletRequest request, List tokenNames)
    throws TokenNotFoundException
    String nombreHeader = (String) tokenNames.get(0);
    String header = request.getHeader(nombreHeader);
    if (header != null)
    return header;
    }else
    String error = "Request doesn't have the requierd header";
    throw new TokenNotFoundException(error);
    Token Asserter Example
    import java.util.Properties;
    import javax.security.auth.Subject;
    import oracle.security.jazn.asserter.AsserterException;
    import oracle.security.jazn.asserter.TokenAsserter;
    import oracle.security.jazn.callback.IdentityCallbackHandler;
    import oracle.security.jazn.callback.IdentityCallbackHandlerImpl;
    import oracle.security.jazn.token.IdentityToken;
    public class MyTokenAsserter
    implements TokenAsserter
    public void finalize()
    throws Throwable
    public IdentityCallbackHandler assertIdentity(String tokenType,
    IdentityToken token,
    Properties properties)
    throws AsserterException
    InversuraIdentityToken idToken = (InversuraIdentityToken) token;
    String valorToken = idToken.getValorToken();
    InversuraToken invToken;
    try {
    invToken = new InversuraToken(valorToken);
    if (verificarVigencia(invToken))
    IdentityCallbackHandlerImpl idcb = new IdentityCallbackHandlerImpl(invToken.getLogin());
    idcb.setAuthenticationType("InversuraSSO");
    idcb.setIdentityAsserted(true);
    MyPrincipal ppal = new MyPrincipal(invToken.getLogin());
    Subject subj = new Subject();
    subj.getPrincipals().add(ppal);
    idcb.setSubject(subj);
    return idcb;
    throw new AsserterException("Token expired");
    }catch (Exception e)
    String error = e.getMessage();
    throw new AsserterException(error, e);
    public boolean verificarVigencia(InversuraToken token)
    return token.estaVigente();

  • Help : How to import .pfx file to keystore

    Hi,
    I need to generate digital signature for some data string. I got the pfx file with password blank.
    it shows the following detailsusing keytool.
    keytool -list -keystore rating/ebs/scripts/MPay_certificate_11072003.p12 -storetype pkcs12
    unknown attr1.3.6.1.4.1.311.17.1
    Enter keystore password:
    unknown attr1.3.6.1.4.1.311.17.1
    ***************** WARNING WARNING WARNING *****************
    * The integrity of the information stored in your keystore *
    * has NOT been verified! In order to verify its integrity, *
    * you must provide your keystore password. *
    ***************** WARNING WARNING WARNING *****************
    Keystore type: pkcs12
    Keystore provider: SunJSSE
    Your keystore contains 1 entry
    c1e673ff559b00e86a399a1b21e4aed2_6ee3fa08-8ba8-4ff1-a8fd-01031842a3a3, Aug 18, 2003, keyEntry,
    How can I generate the keystore file and know the private key alias so that i can generate the sign using sign().
    thanks in advance.
    Ranjan

    It is possible to import a .p12 file into a keystore with a small Java program...
    I found a sample to do this about a year ago, the source page is no longer valid. I have made some slight modifications to the original program, but left credit to the original author in the top (to the best of my knowledge).
    Sample execution being:
    $ java KeyStoreMove PKCS12 ~/igo.p12 p12-pas JKS ~/.keystore key-pas
    Source alias: lester igo id #2
    Rename alias to [<return> to keep original alias]: my-cert
    New alias: my-cert
    importing key lester igo id #2
    keystore copy successful
    * This code has been downloaded from the internet and contained no license.
    * The Source for this was: http://home.istar.ca/~neutron/Thawte/KeystoreMove.txt
    * The Page referencing it was: http://home.istar.ca/~neutron/Thawte/index.html
    * The author appears to be:
    * Michel I. Gallant
    * [email protected]
    import java.io.*;
    import java.security.*;
    import java.util.*;
    public class KeyStoreMove {
    public static void main(String args[]) throws Throwable {
    java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
    if (args.length<6) {
    System.out.println(
    "\nKeyStoreMove Usage: \njava KeyStoreMove <source> <destination> where\n" +
    " <source> and <destination> are " +
    "<storetype> <keystore> <password>\n");
    System.out.println(" - Requires jsse for PKCS12 keystore support \n" +
    " - source storetype can be JKS or PKCS12\n" +
    " - destination storetype must be JKS type (PKCS12 write not supported)\n") ;
    System.exit(0);
    FileInputStream in;
    // -------- Load source keystore to memory ---------
    in = new FileInputStream(args[1]);
    KeyStore ksin = KeyStore.getInstance(args[0]);
    char[] pwin = args[2].toCharArray();
    if (pwin.length==0) { pwin = null; }
    ksin.load(in,pwin);
    in.close();
    // -------- Load destination keystore initial contents to memory ---------
    in = new FileInputStream(args[4]);
    KeyStore ksout = KeyStore.getInstance(args[3]);
    char[] pwout = args[5].toCharArray();
    if (pwout.length==0) { pwout = null; }
    ksout.load(in,pwout);
    in.close();
    //--------- Main Loop to get keys/certs from source keystore ------------
    BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
    Enumeration en = ksin.aliases();
    while (en.hasMoreElements()) {
    String alias = (String) en.nextElement();
    if (ksout.containsAlias(alias)) {
    System.out.println(args[4] + " already contains " + alias + " Key will not be copied.");
    continue;
    // ------- Ask user if alias of source key/cert should be renamed -----------
    System.out.println("Source alias: " + alias);
    System.out.print("Rename alias to [<return> to keep original alias]: ") ;
    String newuseralias = stdin.readLine().trim() ;
    if (newuseralias.equals("")){
    newuseralias=alias;
    System.out.println("Original alias used") ;
    else {
    System.out.println("New alias: " + newuseralias) ;
    if (ksin.isCertificateEntry(alias)) {
    System.out.println("importing certificate " + alias);
    ksout.setCertificateEntry(newuseralias, ksin.getCertificate(alias));
    if (ksin.isKeyEntry(alias)) {
    System.out.println("importing key " + alias);
    ksout.setKeyEntry(newuseralias, ksin.getKey(alias,pwin), pwout,ksin.getCertificateChain(alias));
    //--------- End main loop ----------------------
    //--------- Overwrite the destination keystore with new keys/certs --------------
    FileOutputStream out = new FileOutputStream(args[4]);
    ksout.store(out,pwout);
    out.close();
    System.out.println("keystore copy successful\n") ;
    System.exit(0);

  • Problem printing the JTable

    Hi all,
    I have a problem with printing JTable.
    My application has a submit button,JTable and Print Button.
    As I click on the Submit button, the data is retrieved from the Database(MS Access) and displayed on the JTable.
    Now when I click on the Print button, the printer properties dialog box is displayed. But when I click on the print button in the dialog box, nothing is printed on the paper.
    I checked the printers and faxes in the control panel, It showed Java printing under the Document name and Printing under the Status. It is displayed for sometime and then disappeared after some time. But nothing is printed on the paper(not even the blank paper).
    I tried a lot but couldn't understand the problem.
    I have used the following files:
    PrintJTable.java
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.print.*;
    import java.awt.geom.*;
    import java.awt.Dimension;
    import java.applet.*;
    import java.sql.*;
    import java.util.*;
    import java.net.*;
    import java.lang.*;
    import javax.swing.table.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    class PrintJTable implements ActionListener,Printable
    Connection connect;
    ResultSet rs;
    JTable table;
    JScrollPane tableAggregate;
    DisplayTable displayTable;
    JButton print,submitButton;
    public PrintJTable()
    JFrame frame = new JFrame("Table");
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {System.exit(0);}});
    connect();
    displayTable= new DisplayTable();
    JButton submitButton= new JButton("SUBMIT");
    submitButton.addActionListener(this);
    JButton printButton= new JButton("PRINT!");
    // for faster printing turn double buffering off
    RepaintManager.currentManager( frame).setDoubleBufferingEnabled(false);
    printButton.addActionListener( new ActionListener(){
    public void actionPerformed(ActionEvent evt) {
    PrinterJob pj=PrinterJob.getPrinterJob();
    pj.setPrintable(PrintJTable.this);
    pj.printDialog();
    try{
    pj.print();
    }catch (Exception PrintException) {}
    tableAggregate = createTable();
    tableAggregate.setBorder(new BevelBorder(BevelBorder.LOWERED));
    frame.getContentPane().setLayout(new BorderLayout());
    frame.getContentPane().add(submitButton,BorderLayout.NORTH);
    frame.getContentPane().add(tableAggregate,BorderLayout.CENTER);
    frame.getContentPane().add(printButton,BorderLayout.SOUTH);
    frame.pack();
    frame.setVisible(true);
    } // end of constructor
    public void connect()
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    System.out.println("Opening db connection");
    connect = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=C:/db1.mdb","","");
    catch (ClassNotFoundException ex) {
    System.err.println("Cannot find the database driver classes.");
    System.err.println(ex);
    catch (SQLException ex) {
    System.err.println("Cannot connect to this database.");
    System.err.println(ex);
    public JScrollPane createTable() {
    displayTable= new DisplayTable();
    JTable table = new JTable(displayTable);
         table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
         table.getTableHeader().setReorderingAllowed(false);
    JScrollPane scrollpane = new JScrollPane(table,
    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
    JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    return scrollpane;
    } // end of createTable()
    public void actionPerformed(ActionEvent ie)
    try
    Statement statement6=connect.createStatement();
    ResultSet rs6=statement6.executeQuery("select * from benf_details");
    displayTable.executeQuery(rs6);
    statement6.close();
    catch(SQLException sqle)
    JOptionPane.showMessageDialog(null,"error2"+sqle);
    }// end of actionPerformed
    public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException {
    Graphics2D g2 = (Graphics2D)g;
    g2.setColor(Color.black);
    int fontHeight=g2.getFontMetrics().getHeight();
    int fontDesent=g2.getFontMetrics().getDescent();
    double pageHeight = pageFormat.getImageableHeight()-fontHeight; //leave room for page number
    double pageWidth = pageFormat.getImageableWidth();
    System.out.println("page width = " + pageWidth );
    double tableWidth = (double) table.getColumnModel().getTotalColumnWidth();
    System.out.println("table width = " + tableWidth );
    double scale = 1;
    if (tableWidth >= pageWidth) {
    scale = pageWidth / tableWidth;
    System.out.println("scale = " + scale );
    double headerHeightOnPage = table.getTableHeader().getHeight() * scale;
    double tableWidthOnPage = tableWidth * scale;
    double oneRowHeight = (table.getRowHeight() + table.getRowMargin()) * scale;
    int numRowsOnAPage = (int)((pageHeight - headerHeightOnPage) / oneRowHeight);
    double pageHeightForTable = oneRowHeight * numRowsOnAPage;
    int totalNumPages = (int)Math.ceil(((double)table.getRowCount())/numRowsOnAPage);
    if(pageIndex >= totalNumPages) {
    return NO_SUCH_PAGE;
    g2.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
    g2.drawString("Page: "+ (pageIndex + 1),(int)pageWidth / 2 - 35,
    (int)( pageHeight + fontHeight - fontDesent ));//bottom center
    g2.translate( 0f, headerHeightOnPage );
    g2.translate( 0f, -pageIndex * pageHeightForTable );
    //If this piece of the table is smaller than the size available,
    //clip to the appropriate bounds.
    if (pageIndex + 1 == totalNumPages) {
    int lastRowPrinted = numRowsOnAPage * pageIndex;
    int numRowsLeft = table.getRowCount() - lastRowPrinted;
    g2.setClip(0, (int)(pageHeightForTable * pageIndex),
    (int) Math.ceil(tableWidthOnPage),
    (int) Math.ceil(oneRowHeight * numRowsLeft));
    //else clip to the entire area available.
    else{
    g2.setClip(0, (int)(pageHeightForTable * pageIndex),
    (int) Math.ceil(tableWidthOnPage),
    (int) Math.ceil(pageHeightForTable));
    g2.scale(scale,scale);
    table.paint(g2);
    g2.scale(1/scale,1/scale);
    g2.translate( 0f, pageIndex * pageHeightForTable);
    g2.translate( 0f, -headerHeightOnPage);
    g2.setClip(0, 0,(int) Math.ceil(tableWidthOnPage), (int)Math.ceil(headerHeightOnPage));
    g2.scale(scale,scale);
    table.getTableHeader().paint(g2);//paint header at top
    return Printable.PAGE_EXISTS;
    } // end of print()
    public static void main(String[] args) {
    new PrintJTable();
    }// end of PrintJTable
    DisplayTable.java
    import java.util.Vector;
    import java.sql.*;
    import javax.swing.*;
    import javax.swing.table.AbstractTableModel;
    import javax.swing.event.TableModelEvent;
    public class DisplayTable extends AbstractTableModel {
    Connection connection;
    Statement statement;
    ResultSet resultSet;
    String[] columnNames = {};
    Vector          rows = new Vector();
    ResultSetMetaData metaData;
    String db_uname,db_passwd;
    public DisplayTable() {
    public void executeQuery(ResultSet resultSet) {
    try {
    metaData = resultSet.getMetaData();
    int numberOfColumns = metaData.getColumnCount();
    columnNames = new String[numberOfColumns];
    // Get the column names and cache them.
    // Then we can close the connection.
    for(int column = 0; column < numberOfColumns; column++) {
    columnNames[column] = metaData.getColumnLabel(column+1);
    // Get all rows.
    rows = new Vector();
    while (resultSet.next()) {
    Vector newRow = new Vector();
    for (int i = 1; i <= getColumnCount(); i++) {
         newRow.addElement(resultSet.getObject(i));
    rows.addElement(newRow);
    // close(); Need to copy the metaData, bug in jdbc:odbc driver.
    fireTableChanged(null); // Tell the listeners a new table has arrived.
    catch (SQLException ex) {
    System.err.println(ex);
    public void close() throws SQLException {
    System.out.println("Closing db connection");
    resultSet.close();
    statement.close();
    connection.close();
    protected void finalize() throws Throwable {
    close();
    super.finalize();
    // Implementation of the TableModel Interface
    // MetaData
    public String getColumnName(int column) {
    if (columnNames[column] != null) {
    return columnNames[column];
    } else {
    return "";
    public Class getColumnClass(int column) {
    int type;
    try {
    type = metaData.getColumnType(column+1);
    catch (SQLException e) {
    return super.getColumnClass(column);
    switch(type) {
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
    return String.class;
    case Types.BIT:
    return Boolean.class;
    case Types.TINYINT:
    case Types.SMALLINT:
    case Types.INTEGER:
    return Integer.class;
    case Types.BIGINT:
    return Long.class;
    case Types.FLOAT:
    case Types.DOUBLE:
    return Double.class;
    case Types.DATE:
    return java.sql.Date.class;
    default:
    return Object.class;
    // to make the cells editable
    public boolean isCellEditable(int row, int column) {
    try {
    return metaData.isWritable(column+1);
    catch (SQLException e) {
    return false;
    public int getColumnCount() {
    return columnNames.length;
    // Data methods
    public int getRowCount() {
    return rows.size();
    public Object getValueAt(int aRow, int aColumn) {
    Vector row = (Vector)rows.elementAt(aRow);
    return row.elementAt(aColumn);
    public String dbRepresentation(int column, Object value) {
    int type;
    if (value == null) {
    return "null";
    try {
    type = metaData.getColumnType(column+1);
    catch (SQLException e) {
    return value.toString();
    switch(type) {
    case Types.INTEGER:
    case Types.DOUBLE:
    case Types.FLOAT:
    return value.toString();
    case Types.BIT:
    return ((Boolean)value).booleanValue() ? "1" : "0";
    case Types.DATE:
    return value.toString(); // This will need some conversion.
    default:
    return "\""+value.toString()+"\"";
    public void setValueAt(Object value, int row, int column) {
    try {
    String tableName = metaData.getTableName(column+1);
    // Some of the drivers seem buggy, tableName should not be null.
    if (tableName == null) {
    System.out.println("Table name returned null.");
    String columnName = getColumnName(column);
    String query =
    "update "+tableName+
    " set "+columnName+" = "+dbRepresentation(column, value)+
    " where ";
    // We don't have a model of the schema so we don't know the
    // primary keys or which columns to lock on. To demonstrate
    // that editing is possible, we'll just lock on everything.
    for(int col = 0; col<getColumnCount(); col++) {
    String colName = getColumnName(col);
    if (colName.equals("")) {
    continue;
    if (col != 0) {
    query = query + " and ";
    query = query + colName +" = "+
    dbRepresentation(col, getValueAt(row, col));
    System.out.println(query);
    System.out.println("Not sending update to database");
    // statement.executeQuery(query);
    catch (SQLException e) {
    // e.printStackTrace();
    System.err.println("Update failed");
    Vector dataRow = (Vector)rows.elementAt(row);
    dataRow.setElementAt(value, column);
    }

    Java 1.5 incorporates a very simple way to print from a JTable. I am using a mysql DB but it is the same concept. Review my code and let me know if you have any questions.
    package emsmain;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.*;
    import java.sql.*;
    import java.text.MessageFormat;
    import java.util.*;
    import javax.print.*;
    import javax.print.attribute.HashPrintRequestAttributeSet;
    import javax.print.attribute.PrintRequestAttributeSet;
    import javax.swing.*;
    import javax.swing.JTable;
    import javax.swing.table.*;
    import java.awt.print.*;
    public class TableFromDatabase extends JFrame implements ActionListener{
        JButton jbtprint = new JButton("Print Report");
        JTable Reporttable;
        Connection conn = Connect_Database.getConnection();
         public TableFromDatabase()
    Vector columnNames = new Vector();
    Vector data = new Vector();     
              try{  
                String query = null;
                Statement ps = null;
                ResultSet rs = null;
                  //Class Master List
                  if (Report_Menu.jrbMaster_list.isSelected()){
                      query =("Select * from students") ;
                  //Classes taken by student
                  if (Report_Menu.jrbClass_taken.isSelected()){
                      String taken = Report_Menu.jtfStudent.getText();
                      query = ("select program.course_num, course_name, course_start_date, course_stat_desc from registration, program where student_id = '"+taken+"' and program.course_num = registration.course_num");
                  //Birthday report
                  if (Report_Menu.jrbBirthday.isSelected()){
                      String birthday = (String) Report_Menu.jcb_birthday.getSelectedItem();
                      query = ("SELECT student_id, fname, lname, address, city, state_name, zipcode, dob FROM students where substring(dob, 6,2) = '"+birthday+"'"); 
                  //Course Catologue
                  if (Report_Menu.jrbCourseCatologue.isSelected()){
                      String course = (String) Report_Menu.jcbChooseCourse.getSelectedItem();
                      query = ("select  course_name, course_length, course_cost, course_credits from course where course_name = '"+course+"'");
                  //Certification expiration report
                  if (Report_Menu.jrbExpiration.isSelected()){
                      String month = (String) Report_Menu.jcbMonth.getSelectedItem();
                      String year = (String) Report_Menu.jcbYear.getSelectedItem();
                      query = ("SELECT FNAME, LNAME FROM STUDENTS, REGISTRATION WHERE substring(expiration_date, 6,2) = '"+month+"' and substring(expiration_date, 1,4) = '"+year+"' and registration.student_id = students.student_id") ;
                  //Class Roster
                  if (Report_Menu.jrbRoster.isSelected()){
                      String c_number = Report_Menu.jtfClassNumber.getText();
                      query = ("Select course_name, course_start_date, fname, lname from program, registration, students where program.course_num = '"+c_number+"' and registration.student_id = students.student_id;");
                  //Squad list and counts
                  if (Report_Menu.jrbSquadCount.isSelected()){
                      query = ("SELECT Squad_Name, count(student_id) from students group by Squad_Name");
                  //Student List
                  if (Report_Menu.jrbStudent_list.isSelected()){
                      String Choose_month = (String) Report_Menu.jcbcourse_month.getSelectedItem();
                      String Choose_Course = (String) Report_Menu.jcbcourse_name.getSelectedItem();
                      query = ("select count(student_id) from (registration, program) where program .course_name = '"+Choose_Course+"' and substring(course_start_date, 6,2) = '"+Choose_month+"'and registration.course_num = program.course_num;");
                ps = conn.createStatement();
                //Run Selected Report
                ps.execute(query);
                rs = ps.executeQuery(query);
                ResultSetMetaData md = rs.getMetaData();
                int columns = md.getColumnCount();
                //  Get column names
                for (int i = 1; i <= columns; i++)
                    columnNames.addElement( md.getColumnName(i) );
                //  Get row data
                while (rs.next())
                    Vector row = new Vector(columns);
                    for (int i = 1; i <= columns; i++)
                        row.addElement( rs.getObject(i) );
                    //add row data to JTable
                    data.addElement( row );
                rs.close();
                ps.close();
            catch(Exception e)
                JOptionPane.showMessageDialog(null,e.getMessage());
            //  Create Jtable with database data 
            Container c = getContentPane();
            c.setLayout(new BorderLayout());
            Reporttable = new JTable(data, columnNames);
            JScrollPane scrollPane = new JScrollPane( Reporttable );
            c.add( scrollPane );
            JPanel buttonPanel = new JPanel();
            buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
            buttonPanel.add(jbtprint);
            c.add(buttonPanel,BorderLayout.SOUTH);
            jbtprint.addActionListener(this);
        public void actionPerformed(ActionEvent e){
             if(e.getActionCommand().equals("Print Report")){
               PrintForm();
    public void PrintForm(){ 
         try {
             String name = null;
             // Will display correct heading for print job
             if (Report_Menu.jrbMaster_list.isSelected()){
             name = "Master List";
             if (Report_Menu.jrbBirthday.isSelected()){
             name = "Birthday List";
             if (Report_Menu.jrbClass_taken.isSelected()){
             name = "Classes taken by Student";
             if (Report_Menu.jrbCourseCatologue.isSelected()){
             name = "Course Catalogue";
             if (Report_Menu.jrbExpiration.isSelected()){
             name = "Certification Expiration Report";
             if (Report_Menu.jrbRoster.isSelected()){
             name = "Class Roster";
             if (Report_Menu.jrbSquadCount.isSelected()){
             name = "Squad list with Student Counts";
             if (Report_Menu.jrbStudent_list.isSelected()){
             name = "Student count by Course";
             // fetch the printable
             Printable printable = Reporttable.getPrintable(JTable.PrintMode.FIT_WIDTH,
                                                      new MessageFormat(name),
                                                      new MessageFormat("Page - {0}"));
             // fetch a PrinterJob
             PrinterJob job = PrinterJob.getPrinterJob();
             // set the Printable on the PrinterJob
             job.setPrintable(printable);
             // create an attribute set to store attributes from the print dialog
             PrintRequestAttributeSet attr = new HashPrintRequestAttributeSet();
             // display a print dialog and record whether or not the user cancels it
             boolean printAccepted = job.printDialog(attr);
             // if the user didn't cancel the dialog
             if (printAccepted) {
                    try {
                          // do the printing (may need to handle PrinterException)
                        job.print(attr);
                    } catch (PrinterException ex) {
                        ex.printStackTrace();
         } finally {
             // restore the original table state here (for example, restore selection)
    }

  • Sample JAVA Mobile Server Publish code, and technical questions

    Dear Oracle technical representative, or user:
    I need to programmatically create, and remove publications using the pure JAVA classes of Consolidator, ConsolidatorManager, and ResourceManager for the Mobile Server in OracleLite 9i Release 5.0.1. On the creation side I have managed to get the example found in the directory OraLite501\Mobile\Server\Sample\Sample11 functioning using my installation parameters. I had a very difficult time of it because (1) the sample11 code fails to open an jdbc connection to the Mobile Server Repository Schema with the function Consolidator.OpenConnection, and (2) the ResourceManager function openConnection will not work unless the Webtogo.ora file is in the current working directory. The ConsolidatorManager function OpenConnection may also not work unless the Webtogo.ora file is in the current working directory, but I did test the hypothesis. Both of these problems need to be addressed in the sample11 code, and documentation to save other software developers from wasting hours of their valuable time. See line 223, 386, and 448 in the Publish.Java code that follows this problem description.
    With the above two problems resolved, I can now programmatically create publications, but no hints on how to programmatically remove a publication exist in the documentation. The application I am developing will require the dynamic creation, and removal of publications. Also, when developing applications the complete removal of a publication is absolutely necessary when you have botched a publication. Thus my first question is What sequence of ResourceManager, and ConsolidatorManager function calls will completely remove a Publication?.
    I also have two issues remaining with the code that I have so far developed. These issues will most likely be resolved, when I obtain instructions on how to completely remove a publication, and associated users. But, perhaps not. Referencing the Publish.java file that follows this problem description,
         1. The ResourceManager function dropUser does not drop a user. See my comments, and code beginning at line 277 in Publish.java. Do I need to de-instantiate all subscriptions, and unsubscribe all subscription users before calling this function.? I think, I tried the de-instantiate, unsubscribe sequence without success, but in the confusion I may not have made the try.
         2. How do I get rid of an index created with the ConsolidatorManager function DropPublicationItemIndex?. My comments on this problem begin at line 522 in Publish.java. For some reason the DropPublicationItemIndex function call made below line 448 does not work. What function calls are required prior to calling the DropPublicationItemIndex function?
    Throughout the Publish.java code, I have made comments about some of the problems that I have had in getting the sample11 code working for my installation parameters. I think these comments should help the programmers maintaining the ResourceManager, and ConsolidatorManager code improve the stability of the programs. Please pass these comments, and attached files to the appropriate individuals,
    if you are in a position to do so.
    The other files that follow the Publish.java code are
         1. Compile.bat - Compiles Publish.java using j2sdk1.4.0.
         2. Run.bat - Executes Publish using \ j2sdk1.4.0\jre\server\jvm.dll.
         3. Webtogo.ora
         4. tnsnames.ora for the Mobile Server.
         5. tnsnames.ora for the Database.
    Feel free to access my server if you need to do so in resolving my problems. The parameters you will need to gain access can be found at the top of Publish.java, and in the included *.ora files.
    Thanks,
    Thomas G. Matney
    [email protected]
    (662)325-2791
    //Start of Publish.java code
    // Oracle HTTP Server URL = http://yggdrasill.cfr.msstate.edu:7778
    // = http://130.18.168.225:7778
    // Mobile Server URL = http://yggdrasill.cfr.msstate.edu/webtogo/startup
    // = http://130.18.168.225/webtogo/startup
    // Mobile Server Control Center URL = http://yggdrasill.cfr.msstate.edu/webtogo
    // = http://130.18.168.225/webtogo
    // Mobile Server Control Center URL = http://yggdrasill.cfr.msstate.edu/webtogo
    // = http://130.18.168.225/webtogo
    // Mobile Server Control Center username = administrator
    // Mobile Server Control Center password = admin
    // Mobile Server URL = http://yggdrasill.cfr.msstate.edu/webtogo/startup
    // = http://130.18.168.225/webtogo/startup
    // Mobile administrator username = fiafield // Schema FIAFIELD on FIA.CFR.MSSTATE.EDU
    // Mobile administrator password = fiafield // Username and password are the same
    import java.sql.SQLException;
    import java.sql.*;
    import oracle.lite.sync.Consolidator;
    import oracle.lite.sync.ConsolidatorManager;
    import oracle.mobile.admin.ResourceManager;
    import oracle.mobile.admin.ResException;
    import oracle.sql.*;
    import oracle.jdbc.*;
    import oracle.mobile.admin.*;
    public class Publish
    // Schema names and usernames are not case sensitive.
    // UN fiafield = FIAFIELD
    // SCHEMA fiafield = FIAFIELD
    // Schema name/Username, and password used on creation of Mobile Repository
    static String CONS_SCHEMA = "fiafield";
    static String DEFAULT_PASSWORD = "fiafield";
    static String admin_jdbc_url = "jdbc:oracle:oci8:@WEBTOGO.WORLD";
    static String thin_jdbc_url =
    "jdbc:oracle:thin:@YGGDRASILL:1521:FIA.YGGDRASILL.CFR.MSSTATE.EDU";
    static String Publication;
    static String CreateTreeTableShortNames =
    "CREATE TABLE FIAFIELD.ZMTR1TBL("
    + "id FLOAT,"
    + "subp FLOAT,"
    + "rnum FLOAT,"
    + "st FLOAT,"
    + "unit FLOAT,"
    + "cnty FLOAT,"
    + "plot FLOAT,"
    + "cyc FLOAT,"
    + "scyc FLOAT,"
    + "tree FLOAT,"
    + "ncpt FLOAT NULL,"
    + "dist FLOAT NULL,"
    + "diam FLOAT NULL,"
    + "dmht FLOAT NULL,"
    + "dmck FLOAT NULL,"
    + "spec FLOAT NULL,"
    + "lang FLOAT NULL,"
    + "nctc FLOAT NULL,"
    + "stat FLOAT NULL,"
    + "util FLOAT NULL,"
    + "deca FLOAT NULL,"
    + "crat FLOAT NULL,"
    + "ccls FLOAT NULL,"
    + "az FLOAT NULL,"
    + "cond FLOAT NULL,"
    + "tlen FLOAT NULL,"
    + "alen FLOAT NULL,"
    + "lmet FLOAT NULL,"
    + "nctg FLOAT NULL,"
    + "rcul FLOAT NULL,"
    + "ncpd FLOAT NULL,"
    + "dead FLOAT NULL,"
    + "mor FLOAT NULL,"
    + "modm FLOAT NULL,"
    + "dml1 FLOAT NULL,"
    + "dmt1 FLOAT NULL,"
    + "dms1 FLOAT NULL,"
    + "dma1 FLOAT NULL,"
    + "dml2 FLOAT NULL,"
    + "dmt2 FLOAT NULL,"
    + "dms2 FLOAT NULL,"
    + "dma2 FLOAT NULL,"
    + "dml3 FLOAT NULL,"
    + "dmt3 FLOAT NULL,"
    + "dms3 FLOAT NULL,"
    + "dma3 FLOAT NULL,"
    + "dbtr FLOAT NULL,"
    + "dbsp FLOAT NULL,"
    + "nxtn FLOAT NULL,"
    + "dbds FLOAT NULL,"
    + "dbaz FLOAT NULL,"
    + "psta FLOAT NULL,"
    + "fiat FLOAT NULL,"
    + "fhmt FLOAT NULL"
    + ")";
    static String CreateTreeTableLongNames =
    "CREATE TABLE FIAFIELD.ZMTR1TBL("
    + "ID FLOAT,"
    + "SUBPLOT FLOAT,"
    + "RECORD_NUMBER FLOAT,"
    + "STATE FLOAT,"
    + "UNIT FLOAT,"
    + "COUNTY FLOAT,"
    + "PLOT FLOAT,"
    + "CYCLE FLOAT,"
    + "SUBCYCLE FLOAT,"
    + "TREE FLOAT,"
    + "NC_PLOT_TYPE FLOAT,"
    + "DISTANCE FLOAT NULL,"
    + "DIAMETER FLOAT NULL,"
    + "DIAMETER_HEIGHT FLOAT NULL,"
    + "DIAMETER_CHECK FLOAT NULL,"
    + "SPECIES FLOAT NULL,"
    + "LEAN_ANGLE FLOAT NULL,"
    + "NC_TREE_CLASS FLOAT NULL,"
    + "STATUS FLOAT NULL,"
    + "UTILIZATION FLOAT NULL,"
    + "DECAY FLOAT NULL,"
    + "CROWN_RATIO FLOAT NULL,"
    + "CROWN_CLASS FLOAT NULL,"
    + "AZIMUTH FLOAT NULL,"
    + "CONDITION FLOAT NULL,"
    + "TOTAL_LENGTH FLOAT NULL,"
    + "ACTUAL_LENGTH FLOAT NULL,"
    + "LENGTH_METHOD FLOAT NULL,"
    + "NC_TREE_GRADE FLOAT NULL,"
    + "ROTTEN_CULL FLOAT NULL,"
    + "NC_PREVIOUS_DBH FLOAT NULL,"
    + "CAUSE_OF_DEATH FLOAT NULL,"
    + "MORTALITY_YEAR FLOAT NULL,"
    + "MO_DAMAGE FLOAT NULL,"
    + "DAMAGE_LOCATION1 FLOAT NULL,"
    + "DAMAGE_TYPE1 FLOAT NULL,"
    + "DAMAGE_SEVERITY1 FLOAT NULL,"
    + "NC_DAMAGE_AGENT1 FLOAT NULL,"
    + "DAMAGE_LOCATION2 FLOAT NULL,"
    + "DAMAGE_TYPE2 FLOAT NULL,"
    + "DAMAGE_SEVERITY2 FLOAT NULL,"
    + "NC_DAMAGE_AGENT2 FLOAT NULL,"
    + "DAMAGE_LOCATION3 FLOAT NULL,"
    + "DAMAGE_TYPE3 FLOAT NULL,"
    + "DAMAGE_SEVERITY3 FLOAT NULL,"
    + "NC_DAMAGE_AGENT3 FLOAT NULL,"
    + "DB_TREE FLOAT NULL,"
    + "DB_SPECIES FLOAT NULL,"
    + "NEXT_NUMBER FLOAT NULL,"
    + "DB_DISTANCE FLOAT NULL,"
    + "DB_AZIMUTH FLOAT NULL,"
    + "PREVIOUS_STATUS FLOAT NULL,"
    + "FIA_TREE_NUMBER FLOAT NULL,"
    + "FHM_TREE FLOAT NULL"
    + ")";
    public static void main(String argv[]) throws Throwable
    // Publish - an OKAPI sample
    if(argv.length == 2)
    CONS_SCHEMA = argv[0] ;
    DEFAULT_PASSWORD = argv[1] ;
    //create required tables using standard jdbc
    //DriverManager.registerDriver ((Driver)Class.forName ("oracle.jdbc.driver.OracleDriver").newInstance ());
    DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
    Connection c = null;
    Statement s = null;
    try
    // Open connection to Mobile Repositoty/FIAFIELD schema as SYSTEM.
    // Need the ability to grant resources, and connection to Mobile Repository user
    //c = DriverManager.getConnection ("jdbc:oracle:oci8:@WEBTOGO.WORLD", "SYSTEM", "phwphw" );
    // Remote connection. See attached webtogo.ora.
    c = DriverManager.getConnection ("jdbc:oracle:oci8:@WEBTOGO.WORLD.YGG",
    "SYSTEM", "phwphw");
    s = c.createStatement ();
    try
    s.executeUpdate("DROP table FIAFIELD.ZMTR1TBL");
    catch (SQLException ee)
    ee.printStackTrace ();
    try
    s.executeUpdate(CreateTreeTableShortNames);
    catch (SQLException ee)
    ee.printStackTrace ();
    try
    s.executeUpdate("alter table FIAFIELD.ZMTR1TBL add constraint"
    +" zmtr1tbl_pk primary key(subp, tree)");
    catch (SQLException ee)
    ee.printStackTrace ();
    // Line 223 // create consolidator publications.
    try
    // *****!!!!! Unless the Webtogo.ora file is in the current working
    // directory the connection is not made. This version of the resource
    // manager must be looking for the file in the old 8i Mobile default
    // directory. This is a definite problem. If the code was working, the
    // addition of the webtogo.ora should have affect on the functionality
    // of the code.
    // The connection is made to the Mobile Server. At least no exceptions
    // are thrown, provided the webtogo.ora is in the current working
    // directory.
    //oracle.mobile.admin.ResourceManager.openConnection(CONS_SCHEMA, DEFAULT_PASSWORD);
    // I tried making a direct connect to possibly avoid needing to have the
    // webtogo.ora file in the current directory. The direct coonect did not work.
    // You can quickly convince yourself that the webtogo.ora file must
    // be in the current working directory, by running the code with and
    // without the webtogo.ora in the current working directory.
    // The directory OraLiteHome\Mobile\Server\bin is in the PATH after
    // after installation but the extension .ora is not in PATHEXT. The
    // OraLite installer should put .ora in PATHEXT. I tried adding .ora
    // to the PATHEXT, but it still could not find thw webtogo.ora file,
    // and it should have. What is going on? I am a bit rusty on DOS so
    // I may not have thing right.
    // OraLiteHome\Mobile\Server\bin is the residing directory for
    // the functional copy of the webtogo.ora file.
    oracle.mobile.admin.ResourceManager.openConnection(
    CONS_SCHEMA,
    DEFAULT_PASSWORD,
    "jdbc:oracle:oci8:@WEBTOGO.WORLD");
    catch(ResException ee)
    ee.printStackTrace (); // NULL Pointer Exception?
    // The Mobile user is created, and then the function throws a resource exception.
    // This is a serious problem with the code. One would assume that the user
    // is not created if and exception is thrown.
    // This appears to be a bug in the createUser code. The function should return
    // false if the user is not created, and handle, or not throw the exception.
    // The function always returns false. It does return true when a user is created
    // because it throws an exception.
    boolean bIsCreated;
    System.out.println("Begin of why is ResourceManager not dropping users?");
    // Line 277
    try
    // The dropUser function will not drop a user. I have tested the function
    // by creating the user ZMPT1UA in the Mobile Server Control Center
    // http://Yggdrasill.cfr.msstate.edu/webtogo
    // so I know that the user exist.
    // This function throws a ResException but it is not declared correctly
    // since you cannot trap the exception as a ResException. It always tells
    // me the view does not exist. What steps are required to get the function
    // to work? What function calls need to be made prior to calling the dropUser
    // function.
    oracle.mobile.admin.ResourceManager.dropUser("ZMPT1UA");
    catch (Throwable ee)
    ee.printStackTrace (); // NULL Pointer Exception?
    System.out.println("End of why is ResourceManager not dropping users?");
    try
    bIsCreated = oracle.mobile.admin.ResourceManager.createUser(
    "ZMPT1UA",
    DEFAULT_PASSWORD,
    "ZMPT1UA", "S");
    catch (Throwable ee)
    ee.printStackTrace (); // Ignore exception
    // Obsolete or depreciated function, according to documentation?
    oracle.mobile.admin.ResourceManager.commitTransaction();
    // Create CONS_SCHEMA user on the database with the same username, and
    // password as the user on the Mobile Server side. This is why the
    // DriverManager connection was made as SYSTEM/phwphw.
    // Grant ALL to repository, and user on replicated database
    // On the database side there is a user with un = fiafield,
    // and pw = fiafield, which is the same as the Mobile Repository
    // schema name/password pair fiafield/fiafield. Can this duality
    // create a problem? Probably not.
    // Need SYSTEM ADMIN privilages for the next two steps, and that is
    // why the coonection was established as SYSTEM/phwphw.
    // Make user, and grants for Publish to user CONS_SCHEMA, and ZMPT1UA
    System.out.println("Pargress point D");
    try
    s.execute("Create user " + "ZMPT1UA" + " identified by " + DEFAULT_PASSWORD);
    catch (SQLException ee)
    ee.printStackTrace (); // ignore
    try
    s.execute("GRANT ALL ON FIAFIELD.ZMTR1TBL to " + CONS_SCHEMA + " WITH GRANT OPTION");
    catch (SQLException ee)
    ee.printStackTrace (); // ignore
    try
    s.execute("GRANT ALL ON FIAFIELD.ZMTR1TBL to " + "ZMPT1UA" + " WITH GRANT OPTION");
    catch (SQLException ee)
    ee.printStackTrace (); // ignore
    /* This code is not needed to test the code
    // Insert items into table FIAFIELD.ZMTR1TBL from FIAFIELD.HUSKY_TREE
    String Statement =
    "INSERT INTO FIAFIELD.ZMTR1TBL SELECT * from FIAFIELD.HUSKY_TREE WHERE PLOT = 1";
    try
    s.execute(Statement);
    catch (SQLException ee)
    System.out.println("FIAFIELD.HUSKY_TREE was not inserted into FIAFIELD.ZMTR1TBL");
    ee.printStackTrace (); // ignore
    c.commit ();
    catch (SQLException ee)
    ee.printStackTrace ();
    finally
    if (s!= null) try {s.close ();}catch (SQLException e1){}
    if (c!= null) try {c.close ();}catch (SQLException e2){}
    // The Consolidator class is not thread safe, and I will eventually
    // need thread safety. The ConsolidatorManage class is thread safe.
    //Consolidator ConsolidatorXX = new Consolidator();
    ConsolidatorManager ConsolidatorXX = new ConsolidatorManager();
    // Line 386
    // Try opening a connection. Sample11 does not open a connection, but it seems
    // like a logical first thing to do.
    // At least with this connection the DropPublication, and AddPublication functions
    // appear to work, or at least they do not throw exceptions. The DropPublication
    // throws an exception if a publication does not exist? I tested this and indeed
    // if I call the DropPublication function, and do not create the Publication again
    // when I reenter the program the DropPublication function throws an exception, and
    // produces the correct error message(The publication does not exist). There is hope.
    // It is very disturbing that the program fails unless the webtogo.ora file is not
    // in the current working directory. Because the OpenConnection functions of both
    // the ResourceManager, and ConsolidatorManager both appear to need access to the
    // webtogo.ora file, and they are finding them in the current directory, the
    // logical conclusion is that both of the classes are attempting to open the
    // webtogo.ora with the relative path webtogo.ora, and not the absolute path
    // OraHomeLite/Mobile/Server/Bin/webtogo.ora. As this has to be the case, why
    // is this very important fact not in the documentation? Or, am I wrong?
    Connection conn = null;
    try
    //ConsolidatorXX.OpenConnection(CONS_SCHEMA,
    //DEFAULT_PASSWORD);
    //ConsolidatorXX.OpenConnection(CONS_SCHEMA,
    //DEFAULT_PASSWORD,
    //"jdbc:oracle:oci8:@WEBTOGO.WORLD");
    conn = DriverManager.getConnection
    ("jdbc:oracle:oci8:@WEBTOGO.WORLD",
    CONS_SCHEMA,DEFAULT_PASSWORD);
    //conn = DriverManager.getConnection
    //("jdbc:oracle:oci8:@WEBTOGO.WORLD",
    //"SYSTEM","phwphw");
    ConsolidatorXX.OpenConnection(conn);
    catch (Throwable e)
    e.printStackTrace(); //ignore error
    // Publication name
    Publication = "ZMTR1PUB";
    try
    ConsolidatorXX.DeinstantiateSubscription(Publication, "ZMPT1UA");
    catch (Throwable e)
    System.out.println("Could not Deinstantiate Subscription ZMPT1UA");
    e.printStackTrace(); //ignore error
    // Line 448
    // There is no Consolidator.OpenConnection in the orginal sample11.java code.
    // Why?. It appears to be neccessary. The only way I can make the sample11 code
    // or this program work is to open a jdbc connection with the Consolidator.OpenConnection
    // function. I assume that somehow the Consolidator.OpenConnection function was
    // deleted from sample11.java.
    // This try to drop a publication index does not work, because when I try
    // to recreate the index in the following code it warns me that I have a
    // bad column name for the index. So it thinks the index still exist.
    // Why?. How do I get rid of the index?
    try
    ConsolidatorXX.DropPublicationItemIndex("ZMTR1IX1");
    catch (Throwable e)
    e.printStackTrace(); //ignore error
    try
    ConsolidatorXX.DropPublicationItem("ZMTR1ITM");
    catch (Throwable e)
    e.printStackTrace(); //ignore error
    try
    ConsolidatorXX.DropPublication(Publication);
    catch (Throwable e)
    e.printStackTrace(); //ignore error
    try
    //ConsolidatorXX.CreatePublication(Publication, Consolidator.OKPI_CREATOR_ID,
    //"zMTR1.%s", null);
    ConsolidatorXX.CreatePublication(Publication, Consolidator.OKAPI_WINCE,
    "zMTR1.%s", null);
    catch (Throwable e)
    e.printStackTrace(); //ignore error
    try
    ConsolidatorXX.DropPublicationItemIndex("ZMTR1IX1");
    catch (Throwable e)
    e.printStackTrace(); //ignore error
    try
    ConsolidatorXX.CreatePublicationItem("ZMTR1ITM","FIAFIELD","ZMTR1TBL", "F",
    "SELECT * FROM FIAFIELD.ZMTR1TBL", null, null);
    catch (Throwable e)
    e.printStackTrace();
    System.out.println("Begin of how can drop this index and get rid of the warning?");
    // Line 522
    // I defined the index ZMTR1IX1 originally on the variable subp, and did not get
    // any warning. I then changed the index variable for the index to id, and started
    // receiving the warning to check the index column for typographical errors. Even
    // if I change the index variable back to subp, I continue to receive the warning.
    // How do I get rid of the index and the warning, so I can recreate the index for
    // another variable? I quess the real question is "How to I completely remove a
    // publication, and all of its parts so I can start over?
    try
    ConsolidatorXX.CreatePublicationItemIndex(
    "ZMTR1IX1", "ZMTR1ITM", "I", "id");
    catch (Throwable e)
    e.printStackTrace ();
    System.out.println("End of how can drop this index and get rid of the warning?");
    try
    ConsolidatorXX.AddPublicationItem(
    Publication, "ZMTR1ITM", null, null, "S", null, null);
    catch (Throwable e)
    e.printStackTrace ();
    try
    ConsolidatorXX.CreateSubscription(Publication, "ZMPT1UA");
    catch (Throwable e)
    e.printStackTrace ();
    try
    ConsolidatorXX.InstantiateSubscription(Publication, "ZMPT1UA");
    catch (Throwable e)
    e.printStackTrace ();
    try
    ConsolidatorXX.CloseConnection();
    if(conn != null)
    conn.close();
    catch (Throwable e)
    e.printStackTrace(); //ignore error
    // Obsolete or depreciated function, according to documentation?
    oracle.mobile.admin.ResourceManager.commitTransaction();
    oracle.mobile.admin.ResourceManager.closeConnection();
    End of Publish.java code     
    Begin Compile.bat
    set CLASSPATH = .;D:\jdk1.4.0\lib\tools.jar;D:\OraLite501\MOBILE\classes\CONSOLIDATOR.JAR;D:\OraLite501\MOBILE\SERVER\BIN\WEBTOGO.JAR;D:\OraLite501\jdbc\lib\classes12.zip;D:\OraLite501\MOBILE\classes\classgen.jar;D:\OraLite501\MOBILE\classes\servlet.jar;D:\OraLite501\MOBILE\CLASSES\OLITE40.JAR
    set PATH= d:\jdk1.4.0\jre\bin\server;d:\jdk1.4.0\bin;D:\OraLite501\bin;D:\OraLite501\Mobile\Server\bin;D:\oracle\ora92\bin;D:\OraLite501\MOBILE\sdk\bin
    d:\jdk1.4.0\bin\javac Publish.java
    End Compile.bat          
    Begin Run.bat
    set CLASSPATH= .;D:\jdk1.4.0\lib\tools.jar;D:\OraLite501\MOBILE\classes\CONSOLIDATOR.JAR;D:\OraLite501\MOBILE\SERVER\BIN\WEBTOGO.JAR;D:\OraLite501\jdbc\lib\classes12.zip;D:\OraLite501\MOBILE\classes\classgen.jar;D:\OraLite501\MOBILE\classes\servlet.jar;D:\OraLite501\MOBILE\CLASSES\OLITE40.JAR
    set PATH= d:\jdk1.4.0\jre\bin\server;d:\jdk1.4.0\bin;D:\OraLite501\bin;D:\OraLite501\Mobile\Server\bin;D:\oracle\ora92\bin;D:\OraLite501\MOBILE\sdk\bin
    d:\jdk1.4.0\bin\java Publish
    End Run.bat
    Begin webtogo.ora
    USE_SYSTEM_CLASSPATH = NO
    MODE = SERVER
    PORT = 80
    BASE_URL=/webtogo
    ADMIN_TNS_NAME=WEBTOGO.WORLD
    ADMIN_JDBC_URL=jdbc:oracle:oci8:@WEBTOGO.WORLD
    APPLET_USE_THIN_JDBC = YES
    THIN_JDBC_URL=jdbc:oracle:thin:@YGGDRASILL:1521:FIA.YGGDRASILL.CFR.MSSTATE.EDU
    SITE_OFFLINE_PERIOD=0
    CUSTOM_WORKSPACE=no
    CUSTOM_DIRECTORY=myworkspace
    DEFAULT_PAGE=myfirstpage.html
    ADMIN_USER=8B37E78535B55525292A3A2929292999
    ADMIN_PASSWORD=873515A838B85828292A3A2929292999
    [EXTERNAL_AUTHENTICATION]
    #CLASS=com.acme.SampleAuthenticator
    # Web-to-go workspace's font
    FONT_NAME=Arial
    [FILESYSTEM]
    #ROOT_DIR=%WEBTOGO_HOME%\server
    #TYPE=O8
    #TYPE=OL
    #TYPE=OS
    # Cache size in MBs
    #CACHE_SIZE=10
    MAX_CONNECTIONS=4
    [DEBUG]
    #ENABLE=YES
    # The log file name.
    #LOG_FILE=test.log
    # Machine name and port where wsh.exe -m is running. Web-to-go
    # will send debug output to that machine.
    #MACHINE=
    #PORT=100
    [APPLICATIONS]
    XMLFILE = ws1.xml
    PACK_HELP=D:\OraLite501\mobile\doc\wtg\html\wtgdep.htm
    [PUBLIC]
    oracle.lite.sync.ConsolidatorServlet=/Consolidator
    [CONSOLIDATOR]
    # Installer will change these values
    SERVER_VERSION=8.1.5
    # 8.0.5 or 8.1.5
    # Installer won't change these values
    MAX_THREADS=3
    JDBC_DRIVER=oracle.jdbc.driver.OracleDriver
    CREATE_USER_OPTIONS_O8I=PROFILE CONSOLIDATOR_CLIENT_P DEFAULT TABLESPACE USERS QUOTA UNLIMITED ON USERS TEMPORARY TABLESPACE INDX QUOTA UNLIMITED ON INDX
    CREATE_USER_OPTIONS_O8=PROFILE CONSOLIDATOR_CLIENT_P DEFAULT TABLESPACE USR QUOTA UNLIMITED ON USR
    TEMPORARY TABLESPACE TEMPORARY QUOTA UNLIMITED ON TEMPORARY
    TEMP=c:\\temp
    WTG_PROXY_PORT=80
    TRACE=NO
    TRACE_ALL=NO
    End webtogo.ora
    Begin Mobile Server tnsnames.ora file
    # TNSNAMES.ORA Network Configuration File: D:\OraLite501\network\admin\tnsnames.ora
    # Generated by Oracle configuration tools.
    WEBTOGO.WORLD =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = YGGDRASILL.CFR.MSSTATE.EDU)(PORT = 1521))
    (CONNECT_DATA =
    (SERVICE_NAME = FIA.YGGDRASILL.CFR.MSSTATE.EDU)
    WEBTOGO.WORLD.YGG =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = YGGDRASILL.CFR.MSSTATE.EDU)(PORT = 1521))
    (CONNECT_DATA =
    (SERVICE_NAME = FIA.YGGDRASILL.CFR.MSSTATE.EDU)
    End Mobile Server tnsnames.ora file
    Begin Database tnsnames.ora file
    # TNSNAMES.ORA Network Configuration File: D:\oracle\ora92\network\admin\tnsnames.ora
    # Generated by Oracle configuration tools.
    INST1_HTTP.CFR.MSSTATE.EDU =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = yggdrasill)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = SHARED)
    (SERVICE_NAME = MODOSE)
    (PRESENTATION = http://HRService)
    FIA.CFR.MSSTATE.EDU =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = yggdrasill)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = FIA.YGGDRASILL.CFR.MSSTATE.EDU)
    FIA.YGGDRASILL.CFR.MSSTATE.EDU =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = yggdrasill.cfr.msstate.edu)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = FIA.YGGDRASILL.CFR.MSSTATE.EDU)
    FIA =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = yggdrasill)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = FIA.YGGDRASILL.CFR.MSSTATE.EDU)
    FIA.YGG =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = yggdrasill.cfr.msstate.edu)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = FIA.YGGDRASILL.CFR.MSSTATE.EDU)
    EXTPROC_CONNECTION_DATA.CFR.MSSTATE.EDU =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    (CONNECT_DATA =
    (SID = PLSExtProc)
    (PRESENTATION = RO)
    End Database tnsnames.ora file

    Dear Oracle technical representative, or user:
    I need to programmatically create, and remove publications using the pure JAVA classes of Consolidator, ConsolidatorManager, and ResourceManager for the Mobile Server in OracleLite 9i Release 5.0.1. On the creation side I have managed to get the example found in the directory OraLite501\Mobile\Server\Sample\Sample11 functioning using my installation parameters. I had a very difficult time of it because (1) the sample11 code fails to open an jdbc connection to the Mobile Server Repository Schema with the function Consolidator.OpenConnection, and (2) the ResourceManager function openConnection will not work unless the Webtogo.ora file is in the current working directory. The ConsolidatorManager function OpenConnection may also not work unless the Webtogo.ora file is in the current working directory, but I did test the hypothesis. Both of these problems need to be addressed in the sample11 code, and documentation to save other software developers from wasting hours of their valuable time. See line 223, 386, and 448 in the Publish.Java code that follows this problem description.
    With the above two problems resolved, I can now programmatically create publications, but no hints on how to programmatically remove a publication exist in the documentation. The application I am developing will require the dynamic creation, and removal of publications. Also, when developing applications the complete removal of a publication is absolutely necessary when you have botched a publication. Thus my first question is What sequence of ResourceManager, and ConsolidatorManager function calls will completely remove a Publication?.
    I also have two issues remaining with the code that I have so far developed. These issues will most likely be resolved, when I obtain instructions on how to completely remove a publication, and associated users. But, perhaps not. Referencing the Publish.java file that follows this problem description,
         1. The ResourceManager function dropUser does not drop a user. See my comments, and code beginning at line 277 in Publish.java. Do I need to de-instantiate all subscriptions, and unsubscribe all subscription users before calling this function.? I think, I tried the de-instantiate, unsubscribe sequence without success, but in the confusion I may not have made the try.
         2. How do I get rid of an index created with the ConsolidatorManager function DropPublicationItemIndex?. My comments on this problem begin at line 522 in Publish.java. For some reason the DropPublicationItemIndex function call made below line 448 does not work. What function calls are required prior to calling the DropPublicationItemIndex function?
    Throughout the Publish.java code, I have made comments about some of the problems that I have had in getting the sample11 code working for my installation parameters. I think these comments should help the programmers maintaining the ResourceManager, and ConsolidatorManager code improve the stability of the programs. Please pass these comments, and attached files to the appropriate individuals,
    if you are in a position to do so.
    The other files that follow the Publish.java code are
         1. Compile.bat - Compiles Publish.java using j2sdk1.4.0.
         2. Run.bat - Executes Publish using \ j2sdk1.4.0\jre\server\jvm.dll.
         3. Webtogo.ora
         4. tnsnames.ora for the Mobile Server.
         5. tnsnames.ora for the Database.
    Feel free to access my server if you need to do so in resolving my problems. The parameters you will need to gain access can be found at the top of Publish.java, and in the included *.ora files.
    Thanks,
    Thomas G. Matney
    [email protected]
    (662)325-2791
    //Start of Publish.java code
    // Oracle HTTP Server URL = http://yggdrasill.cfr.msstate.edu:7778
    // = http://130.18.168.225:7778
    // Mobile Server URL = http://yggdrasill.cfr.msstate.edu/webtogo/startup
    // = http://130.18.168.225/webtogo/startup
    // Mobile Server Control Center URL = http://yggdrasill.cfr.msstate.edu/webtogo
    // = http://130.18.168.225/webtogo
    // Mobile Server Control Center URL = http://yggdrasill.cfr.msstate.edu/webtogo
    // = http://130.18.168.225/webtogo
    // Mobile Server Control Center username = administrator
    // Mobile Server Control Center password = admin
    // Mobile Server URL = http://yggdrasill.cfr.msstate.edu/webtogo/startup
    // = http://130.18.168.225/webtogo/startup
    // Mobile administrator username = fiafield // Schema FIAFIELD on FIA.CFR.MSSTATE.EDU
    // Mobile administrator password = fiafield // Username and password are the same
    import java.sql.SQLException;
    import java.sql.*;
    import oracle.lite.sync.Consolidator;
    import oracle.lite.sync.ConsolidatorManager;
    import oracle.mobile.admin.ResourceManager;
    import oracle.mobile.admin.ResException;
    import oracle.sql.*;
    import oracle.jdbc.*;
    import oracle.mobile.admin.*;
    public class Publish
    // Schema names and usernames are not case sensitive.
    // UN fiafield = FIAFIELD
    // SCHEMA fiafield = FIAFIELD
    // Schema name/Username, and password used on creation of Mobile Repository
    static String CONS_SCHEMA = "fiafield";
    static String DEFAULT_PASSWORD = "fiafield";
    static String admin_jdbc_url = "jdbc:oracle:oci8:@WEBTOGO.WORLD";
    static String thin_jdbc_url =
    "jdbc:oracle:thin:@YGGDRASILL:1521:FIA.YGGDRASILL.CFR.MSSTATE.EDU";
    static String Publication;
    static String CreateTreeTableShortNames =
    "CREATE TABLE FIAFIELD.ZMTR1TBL("
    + "id FLOAT,"
    + "subp FLOAT,"
    + "rnum FLOAT,"
    + "st FLOAT,"
    + "unit FLOAT,"
    + "cnty FLOAT,"
    + "plot FLOAT,"
    + "cyc FLOAT,"
    + "scyc FLOAT,"
    + "tree FLOAT,"
    + "ncpt FLOAT NULL,"
    + "dist FLOAT NULL,"
    + "diam FLOAT NULL,"
    + "dmht FLOAT NULL,"
    + "dmck FLOAT NULL,"
    + "spec FLOAT NULL,"
    + "lang FLOAT NULL,"
    + "nctc FLOAT NULL,"
    + "stat FLOAT NULL,"
    + "util FLOAT NULL,"
    + "deca FLOAT NULL,"
    + "crat FLOAT NULL,"
    + "ccls FLOAT NULL,"
    + "az FLOAT NULL,"
    + "cond FLOAT NULL,"
    + "tlen FLOAT NULL,"
    + "alen FLOAT NULL,"
    + "lmet FLOAT NULL,"
    + "nctg FLOAT NULL,"
    + "rcul FLOAT NULL,"
    + "ncpd FLOAT NULL,"
    + "dead FLOAT NULL,"
    + "mor FLOAT NULL,"
    + "modm FLOAT NULL,"
    + "dml1 FLOAT NULL,"
    + "dmt1 FLOAT NULL,"
    + "dms1 FLOAT NULL,"
    + "dma1 FLOAT NULL,"
    + "dml2 FLOAT NULL,"
    + "dmt2 FLOAT NULL,"
    + "dms2 FLOAT NULL,"
    + "dma2 FLOAT NULL,"
    + "dml3 FLOAT NULL,"
    + "dmt3 FLOAT NULL,"
    + "dms3 FLOAT NULL,"
    + "dma3 FLOAT NULL,"
    + "dbtr FLOAT NULL,"
    + "dbsp FLOAT NULL,"
    + "nxtn FLOAT NULL,"
    + "dbds FLOAT NULL,"
    + "dbaz FLOAT NULL,"
    + "psta FLOAT NULL,"
    + "fiat FLOAT NULL,"
    + "fhmt FLOAT NULL"
    + ")";
    static String CreateTreeTableLongNames =
    "CREATE TABLE FIAFIELD.ZMTR1TBL("
    + "ID FLOAT,"
    + "SUBPLOT FLOAT,"
    + "RECORD_NUMBER FLOAT,"
    + "STATE FLOAT,"
    + "UNIT FLOAT,"
    + "COUNTY FLOAT,"
    + "PLOT FLOAT,"
    + "CYCLE FLOAT,"
    + "SUBCYCLE FLOAT,"
    + "TREE FLOAT,"
    + "NC_PLOT_TYPE FLOAT,"
    + "DISTANCE FLOAT NULL,"
    + "DIAMETER FLOAT NULL,"
    + "DIAMETER_HEIGHT FLOAT NULL,"
    + "DIAMETER_CHECK FLOAT NULL,"
    + "SPECIES FLOAT NULL,"
    + "LEAN_ANGLE FLOAT NULL,"
    + "NC_TREE_CLASS FLOAT NULL,"
    + "STATUS FLOAT NULL,"
    + "UTILIZATION FLOAT NULL,"
    + "DECAY FLOAT NULL,"
    + "CROWN_RATIO FLOAT NULL,"
    + "CROWN_CLASS FLOAT NULL,"
    + "AZIMUTH FLOAT NULL,"
    + "CONDITION FLOAT NULL,"
    + "TOTAL_LENGTH FLOAT NULL,"
    + "ACTUAL_LENGTH FLOAT NULL,"
    + "LENGTH_METHOD FLOAT NULL,"
    + "NC_TREE_GRADE FLOAT NULL,"
    + "ROTTEN_CULL FLOAT NULL,"
    + "NC_PREVIOUS_DBH FLOAT NULL,"
    + "CAUSE_OF_DEATH FLOAT NULL,"
    + "MORTALITY_YEAR FLOAT NULL,"
    + "MO_DAMAGE FLOAT NULL,"
    + "DAMAGE_LOCATION1 FLOAT NULL,"
    + "DAMAGE_TYPE1 FLOAT NULL,"
    + "DAMAGE_SEVERITY1 FLOAT NULL,"
    + "NC_DAMAGE_AGENT1 FLOAT NULL,"
    + "DAMAGE_LOCATION2 FLOAT NULL,"
    + "DAMAGE_TYPE2 FLOAT NULL,"
    + "DAMAGE_SEVERITY2 FLOAT NULL,"
    + "NC_DAMAGE_AGENT2 FLOAT NULL,"
    + "DAMAGE_LOCATION3 FLOAT NULL,"
    + "DAMAGE_TYPE3 FLOAT NULL,"
    + "DAMAGE_SEVERITY3 FLOAT NULL,"
    + "NC_DAMAGE_AGENT3 FLOAT NULL,"
    + "DB_TREE FLOAT NULL,"
    + "DB_SPECIES FLOAT NULL,"
    + "NEXT_NUMBER FLOAT NULL,"
    + "DB_DISTANCE FLOAT NULL,"
    + "DB_AZIMUTH FLOAT NULL,"
    + "PREVIOUS_STATUS FLOAT NULL,"
    + "FIA_TREE_NUMBER FLOAT NULL,"
    + "FHM_TREE FLOAT NULL"
    + ")";
    public static void main(String argv[]) throws Throwable
    // Publish - an OKAPI sample
    if(argv.length == 2)
    CONS_SCHEMA = argv[0] ;
    DEFAULT_PASSWORD = argv[1] ;
    //create required tables using standard jdbc
    //DriverManager.registerDriver ((Driver)Class.forName ("oracle.jdbc.driver.OracleDriver").newInstance ());
    DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
    Connection c = null;
    Statement s = null;
    try
    // Open connection to Mobile Repositoty/FIAFIELD schema as SYSTEM.
    // Need the ability to grant resources, and connection to Mobile Repository user
    //c = DriverManager.getConnection ("jdbc:oracle:oci8:@WEBTOGO.WORLD", "SYSTEM", "phwphw" );
    // Remote connection. See attached webtogo.ora.
    c = DriverManager.getConnection ("jdbc:oracle:oci8:@WEBTOGO.WORLD.YGG",
    "SYSTEM", "phwphw");
    s = c.createStatement ();
    try
    s.executeUpdate("DROP table FIAFIELD.ZMTR1TBL");
    catch (SQLException ee)
    ee.printStackTrace ();
    try
    s.executeUpdate(CreateTreeTableShortNames);
    catch (SQLException ee)
    ee.printStackTrace ();
    try
    s.executeUpdate("alter table FIAFIELD.ZMTR1TBL add constraint"
    +" zmtr1tbl_pk primary key(subp, tree)");
    catch (SQLException ee)
    ee.printStackTrace ();
    // Line 223 // create consolidator publications.
    try
    // *****!!!!! Unless the Webtogo.ora file is in the current working
    // directory the connection is not made. This version of the resource
    // manager must be looking for the file in the old 8i Mobile default
    // directory. This is a definite problem. If the code was working, the
    // addition of the webtogo.ora should have affect on the functionality
    // of the code.
    // The connection is made to the Mobile Server. At least no exceptions
    // are thrown, provided the webtogo.ora is in the current working
    // directory.
    //oracle.mobile.admin.ResourceManager.openConnection(CONS_SCHEMA, DEFAULT_PASSWORD);
    // I tried making a direct connect to possibly avoid needing to have the
    // webtogo.ora file in the current directory. The direct coonect did not work.
    // You can quickly convince yourself that the webtogo.ora file must
    // be in the current working directory, by running the code with and
    // without the webtogo.ora in the current working directory.
    // The directory OraLiteHome\Mobile\Server\bin is in the PATH after
    // after installation but the extension .ora is not in PATHEXT. The
    // OraLite installer should put .ora in PATHEXT. I tried adding .ora
    // to the PATHEXT, but it still could not find thw webtogo.ora file,
    // and it should have. What is going on? I am a bit rusty on DOS so
    // I may not have thing right.
    // OraLiteHome\Mobile\Server\bin is the residing directory for
    // the functional copy of the webtogo.ora file.
    oracle.mobile.admin.ResourceManager.openConnection(
    CONS_SCHEMA,
    DEFAULT_PASSWORD,
    "jdbc:oracle:oci8:@WEBTOGO.WORLD");
    catch(ResException ee)
    ee.printStackTrace (); // NULL Pointer Exception?
    // The Mobile user is created, and then the function throws a resource exception.
    // This is a serious problem with the code. One would assume that the user
    // is not created if and exception is thrown.
    // This appears to be a bug in the createUser code. The function should return
    // false if the user is not created, and handle, or not throw the exception.
    // The function always returns false. It does return true when a user is created
    // because it throws an exception.
    boolean bIsCreated;
    System.out.println("Begin of why is ResourceManager not dropping users?");
    // Line 277
    try
    // The dropUser function will not drop a user. I have tested the function
    // by creating the user ZMPT1UA in the Mobile Server Control Center
    // http://Yggdrasill.cfr.msstate.edu/webtogo
    // so I know that the user exist.
    // This function throws a ResException but it is not declared correctly
    // since you cannot trap the exception as a ResException. It always tells
    // me the view does not exist. What steps are required to get the function
    // to work? What function calls need to be made prior to calling the dropUser
    // function.
    oracle.mobile.admin.ResourceManager.dropUser("ZMPT1UA");
    catch (Throwable ee)
    ee.printStackTrace (); // NULL Pointer Exception?
    System.out.println("End of why is ResourceManager not dropping users?");
    try
    bIsCreated = oracle.mobile.admin.ResourceManager.createUser(
    "ZMPT1UA",
    DEFAULT_PASSWORD,
    "ZMPT1UA", "S");
    catch (Throwable ee)
    ee.printStackTrace (); // Ignore exception
    // Obsolete or depreciated function, according to documentation?
    oracle.mobile.admin.ResourceManager.commitTransaction();
    // Create CONS_SCHEMA user on the database with the same username, and
    // password as the user on the Mobile Server side. This is why the
    // DriverManager connection was made as SYSTEM/phwphw.
    // Grant ALL to repository, and user on replicated database
    // On the database side there is a user with un = fiafield,
    // and pw = fiafield, which is the same as the Mobile Repository
    // schema name/password pair fiafield/fiafield. Can this duality
    // create a problem? Probably not.
    // Need SYSTEM ADMIN privilages for the next two steps, and that is
    // why the coonection was established as SYSTEM/phwphw.
    // Make user, and grants for Publish to user CONS_SCHEMA, and ZMPT1UA
    System.out.println("Pargress point D");
    try
    s.execute("Create user " + "ZMPT1UA" + " identified by " + DEFAULT_PASSWORD);
    catch (SQLException ee)
    ee.printStackTrace (); // ignore
    try
    s.execute("GRANT ALL ON FIAFIELD.ZMTR1TBL to " + CONS_SCHEMA + " WITH GRANT OPTION");
    catch (SQLException ee)
    ee.printStackTrace (); // ignore
    try
    s.execute("GRANT ALL ON FIAFIELD.ZMTR1TBL to " + "ZMPT1UA" + " WITH GRANT OPTION");
    catch (SQLException ee)
    ee.printStackTrace (); // ignore
    /* This code is not needed to test the code
    // Insert items into table FIAFIELD.ZMTR1TBL from FIAFIELD.HUSKY_TREE
    String Statement =
    "INSERT INTO FIAFIELD.ZMTR1TBL SELECT * from FIAFIELD.HUSKY_TREE WHERE PLOT = 1";
    try
    s.execute(Statement);
    catch (SQLException ee)
    System.out.println("FIAFIELD.HUSKY_TREE was not inserted into FIAFIELD.ZMTR1TBL");
    ee.printStackTrace (); // ignore
    c.commit ();
    catch (SQLException ee)
    ee.printStackTrace ();
    finally
    if (s!= null) try {s.close ();}catch (SQLException e1){}
    if (c!= null) try {c.close ();}catch (SQLException e2){}
    // The Consolidator class is not thread safe, and I will eventually
    // need thread safety. The ConsolidatorManage class is thread safe.
    //Consolidator ConsolidatorXX = new Consolidator();
    ConsolidatorManager ConsolidatorXX = new ConsolidatorManager();
    // Line 386
    // Try opening a connection. Sample11 does not open a connection, but it seems
    // like a logical first thing to do.
    // At least with this connection the DropPublication, and AddPublication functions
    // appear to work, or at least they do not throw exceptions. The DropPublication
    // throws an exception if a publication does not exist? I tested this and indeed
    // if I call the DropPublication function, and do not create the Publication again
    // when I reenter the program the DropPublication function throws an exception, and
    // produces the correct error message(The publication does not exist). There is hope.
    // It is very disturbing that the program fails unless the webtogo.ora file is not
    // in the current working directory. Because the OpenConnection functions of both
    // the ResourceManager, and ConsolidatorManager both appear to need access to the
    // webtogo.ora file, and they are finding them in the current directory, the
    // logical conclusion is that both of the classes are attempting to open the
    // webtogo.ora with the relative path webtogo.ora, and not the absolute path
    // OraHomeLite/Mobile/Server/Bin/webtogo.ora. As this has to be the case, why
    // is this very important fact not in the documentation? Or, am I wrong?
    Connection conn = null;
    try
    //ConsolidatorXX.OpenConnection(CONS_SCHEMA,
    //DEFAULT_PASSWORD);
    //ConsolidatorXX.OpenConnection(CONS_SCHEMA,
    //DEFAULT_PASSWORD,
    //"jdbc:oracle:oci8:@WEBTOGO.WORLD");
    conn = DriverManager.getConnection
    ("jdbc:oracle:oci8:@WEBTOGO.WORLD",
    CONS_SCHEMA,DEFAULT_PASSWORD);
    //conn = DriverManager.getConnection
    //("jdbc:oracle:oci8:@WEBTOGO.WORLD",
    //"SYSTEM","phwphw");
    ConsolidatorXX.OpenConnection(conn);
    catch (Throwable e)
    e.printStackTrace(); //ignore error
    // Publication name
    Publication = "ZMTR1PUB";
    try
    ConsolidatorXX.DeinstantiateSubscription(Publication, "ZMPT1UA");
    catch (Throwable e)
    System.out.println("Could not Deinstantiate Subscription ZMPT1UA");
    e.printStackTrace(); //ignore error
    // Line 448
    // There is no Consolidator.OpenConnection in the orginal sample11.java code.
    // Why?. It appears to be neccessary. The only way I can make the sample11 code
    // or this program work is to open a jdbc connection with the Consolidator.OpenConnection
    // function. I assume that somehow the Consolidator.OpenConnection function was
    // deleted from sample11.java.
    // This try to drop a publication index does not work, because when I try
    // to recreate the index in the following code it warns me that I have a
    // bad column name for the index. So it thinks the index still exist.
    // Why?. How do I get rid of the index?
    try
    ConsolidatorXX.DropPublicationItemIndex("ZMTR1IX1");
    catch (Throwable e)
    e.printStackTrace(); //ignore error
    try
    ConsolidatorXX.DropPublicationItem("ZMTR1ITM");
    catch (Throwable e)
    e.printStackTrace(); //ignore error
    try
    ConsolidatorXX.DropPublication(Publication);
    catch (Throwable e)
    e.printStackTrace(); //ignore error
    try
    //ConsolidatorXX.CreatePublication(Publication, Consolidator.OKPI_CREATOR_ID,
    //"zMTR1.%s", null);
    ConsolidatorXX.CreatePublication(Publication, Consolidator.OKAPI_WINCE,
    "zMTR1.%s", null);
    catch (Throwable e)
    e.printStackTrace(); //ignore error
    try
    ConsolidatorXX.DropPublicationItemIndex("ZMTR1IX1");
    catch (Throwable e)
    e.printStackTrace(); //ignore error
    try
    ConsolidatorXX.CreatePublicationItem("ZMTR1ITM","FIAFIELD","ZMTR1TBL", "F",
    "SELECT * FROM FIAFIELD.ZMTR1TBL", null, null);
    catch (Throwable e)
    e.printStackTrace();
    System.out.println("Begin of how can drop this index and get rid of the warning?");
    // Line 522
    // I defined the index ZMTR1IX1 originally on the variable subp, and did not get
    // any warning. I then changed the index variable for the index to id, and started
    // receiving the warning to check the index column for typographical errors. Even
    // if I change the index variable back to subp, I continue to receive the warning.
    // How do I get rid of the index and the warning, so I can recreate the index for
    // another variable? I quess the real question is "How to I completely remove a
    // publication, and all of its parts so I can start over?
    try
    ConsolidatorXX.CreatePublicationItemIndex(
    "ZMTR1IX1", "ZMTR1ITM", "I", "id");
    catch (Throwable e)
    e.printStackTrace ();
    System.out.println("End of how can drop this index and get rid of the warning?");
    try
    ConsolidatorXX.AddPublicationItem(
    Publication, "ZMTR1ITM", null, null, "S", null, null);
    catch (Throwable e)
    e.printStackTrace ();
    try
    ConsolidatorXX.CreateSubscription(Publication, "ZMPT1UA");
    catch (Throwable e)
    e.printStackTrace ();
    try
    ConsolidatorXX.InstantiateSubscription(Publication, "ZMPT1UA");
    catch (Throwable e)
    e.printStackTrace ();
    try
    ConsolidatorXX.CloseConnection();
    if(conn != null)
    conn.close();
    catch (Throwable e)
    e.printStackTrace(); //ignore error
    // Obsolete or depreciated function, according to documentation?
    oracle.mobile.admin.ResourceManager.commitTransaction();
    oracle.mobile.admin.ResourceManager.closeConnection();
    End of Publish.java code     
    Begin Compile.bat
    set CLASSPATH = .;D:\jdk1.4.0\lib\tools.jar;D:\OraLite501\MOBILE\classes\CONSOLIDATOR.JAR;D:\OraLite501\MOBILE\SERVER\BIN\WEBTOGO.JAR;D:\OraLite501\jdbc\lib\classes12.zip;D:\OraLite501\MOBILE\classes\classgen.jar;D:\OraLite501\MOBILE\classes\servlet.jar;D:\OraLite501\MOBILE\CLASSES\OLITE40.JAR
    set PATH= d:\jdk1.4.0\jre\bin\server;d:\jdk1.4.0\bin;D:\OraLite501\bin;D:\OraLite501\Mobile\Server\bin;D:\oracle\ora92\bin;D:\OraLite501\MOBILE\sdk\bin
    d:\jdk1.4.0\bin\javac Publish.java
    End Compile.bat          
    Begin Run.bat
    set CLASSPATH= .;D:\jdk1.4.0\lib\tools.jar;D:\OraLite501\MOBILE\classes\CONSOLIDATOR.JAR;D:\OraLite501\MOBILE\SERVER\BIN\WEBTOGO.JAR;D:\OraLite501\jdbc\lib\classes12.zip;D:\OraLite501\MOBILE\classes\classgen.jar;D:\OraLite501\MOBILE\classes\servlet.jar;D:\OraLite501\MOBILE\CLASSES\OLITE40.JAR
    set PATH= d:\jdk1.4.0\jre\bin\server;d:\jdk1.4.0\bin;D:\OraLite501\bin;D:\OraLite501\Mobile\Server\bin;D:\oracle\ora92\bin;D:\OraLite501\MOBILE\sdk\bin
    d:\jdk1.4.0\bin\java Publish
    End Run.bat
    Begin webtogo.ora
    USE_SYSTEM_CLASSPATH = NO
    MODE = SERVER
    PORT = 80
    BASE_URL=/webtogo
    ADMIN_TNS_NAME=WEBTOGO.WORLD
    ADMIN_JDBC_URL=jdbc:oracle:oci8:@WEBTOGO.WORLD
    APPLET_USE_THIN_JDBC = YES
    THIN_JDBC_URL=jdbc:oracle:thin:@YGGDRASILL:1521:FIA.YGGDRASILL.CFR.MSSTATE.EDU
    SITE_OFFLINE_PERIOD=0
    CUSTOM_WORKSPACE=no
    CUSTOM_DIRECTORY=myworkspace
    DEFAULT_PAGE=myfirstpage.html
    ADMIN_USER=8B37E78535B55525292A3A2929292999
    ADMIN_PASSWORD=873515A838B85828292A3A2929292999
    [EXTERNAL_AUTHENTICATION]
    #CLASS=com.acme.SampleAuthenticator
    # Web-to-go workspace's font
    FONT_NAME=Arial
    [FILESYSTEM]
    #ROOT_DIR=%WEBTOGO_HOME%\server
    #TYPE=O8
    #TYPE=OL
    #TYPE=OS
    # Cache size in MBs
    #CACHE_SIZE=10
    MAX_CONNECTIONS=4
    [DEBUG]
    #ENABLE=YES
    # The log file name.
    #LOG_FILE=test.log
    # Machine name and port where wsh.exe -m is running. Web-to-go
    # will send debug output to that machine.
    #MACHINE=
    #PORT=100
    [APPLICATIONS]
    XMLFILE = ws1.xml
    PACK_HELP=D:\OraLite501\mobile\doc\wtg\html\wtgdep.htm
    [PUBLIC]
    oracle.lite.sync.ConsolidatorServlet=/Consolidator
    [CONSOLIDATOR]
    # Installer will change these values
    SERVER_VERSION=8.1.5
    # 8.0.5 or 8.1.5
    # Installer won't change these values
    MAX_THREADS=3
    JDBC_DRIVER=oracle.jdbc.driver.OracleDriver
    CREATE_USER_OPTIONS_O8I=PROFILE CONSOLIDATOR_CLIENT_P DEFAULT TABLESPACE USERS QUOTA UNLIMITED ON USERS TEMPORARY TABLESPACE INDX QUOTA UNLIMITED ON INDX
    CREATE_USER_OPTIONS_O8=PROFILE CONSOLIDATOR_CLIENT_P DEFAULT TABLESPACE USR QUOTA UNLIMITED ON USR
    TEMPORARY TABLESPACE TEMPORARY QUOTA UNLIMITED ON TEMPORARY
    TEMP=c:\\temp
    WTG_PROXY_PORT=80
    TRACE=NO
    TRACE_ALL=NO
    End webtogo.ora
    Begin Mobile Server tnsnames.ora file
    # TNSNAMES.ORA Network Configuration File: D:\OraLite501\network\admin\tnsnames.ora
    # Generated by Oracle configuration tools.
    WEBTOGO.WORLD =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = YGGDRASILL.CFR.MSSTATE.EDU)(PORT = 1521))
    (CONNECT_DATA =
    (SERVICE_NAME = FIA.YGGDRASILL.CFR.MSSTATE.EDU)
    WEBTOGO.WORLD.YGG =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = YGGDRASILL.CFR.MSSTATE.EDU)(PORT = 1521))
    (CONNECT_DATA =
    (SERVICE_NAME = FIA.YGGDRASILL.CFR.MSSTATE.EDU)
    End Mobile Server tnsnames.ora file
    Begin Database tnsnames.ora file
    # TNSNAMES.ORA Network Configuration File: D:\oracle\ora92\network\admin\tnsnames.ora
    # Generated by Oracle configuration tools.
    INST1_HTTP.CFR.MSSTATE.EDU =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = yggdrasill)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = SHARED)
    (SERVICE_NAME = MODOSE)
    (PRESENTATION = http://HRService)
    FIA.CFR.MSSTATE.EDU =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = yggdrasill)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = FIA.YGGDRASILL.CFR.MSSTATE.EDU)
    FIA.YGGDRASILL.CFR.MSSTATE.EDU =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = yggdrasill.cfr.msstate.edu)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = FIA.YGGDRASILL.CFR.MSSTATE.EDU)
    FIA =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = yggdrasill)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = FIA.YGGDRASILL.CFR.MSSTATE.EDU)
    FIA.YGG =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = yggdrasill.cfr.msstate.edu)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = FIA.YGGDRASILL.CFR.MSSTATE.EDU)
    EXTPROC_CONNECTION_DATA.CFR.MSSTATE.EDU =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    (CONNECT_DATA =
    (SID = PLSExtProc)
    (PRESENTATION = RO)
    End Database tnsnames.ora file

  • Very subtle DB corruption ?

    Hello all,
        I'm experiencing what I call a very subtle bug. Subtle because there are no exceptions, no memory leak, not even an error message.
        My application uses BDB XML and it inserts, updates, removes and searches documents - pretty basic functionality. But after some time of use, my users are calling me saying the searches never return any results. I mean, they send a request, then it's sent to BDB, but it doesnt return.
        First I thought it was another memory leak, but memory cosumption is high as always, but it is stable at some point. Just for checking, I restarted the server and tried searching again - dog slow, no return, even with 600MB free RAM.
        The only solution was to run recovery, which I chose to do manually at this time (and I dont do it automatically yet). Started the server, and then it returns to its normal state.
         So, I can just wonder what can possibility cause this? The containers are getting corrupted (although no corruption messages appear)? My Environment is managed by this class:
    package br.gov.al.delegaciainterativa.controles;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.util.ArrayList;
    import javax.naming.LimitExceededException;
    import br.gov.al.delegaciainterativa.utils.Dir;
    import com.sleepycat.db.DatabaseException;
    import com.sleepycat.db.Environment;
    import com.sleepycat.db.EnvironmentConfig;
    import com.sleepycat.dbxml.XmlContainer;
    import com.sleepycat.dbxml.XmlContainerConfig;
    import com.sleepycat.dbxml.XmlException;
    import com.sleepycat.dbxml.XmlManager;
    import com.sleepycat.dbxml.XmlManagerConfig;
    public class EnvironmentInit {
        private Environment myEnv; // objeto ambiente
        private XmlManager myManager;
        private XmlManagerConfig managerConfig;
        private File envPath;
        private boolean ismyEnvOpen = false;
        private String nomeAmbiente;
        private String separador;
        private String envHome;
        private ArrayList containersAbertos;
        public EnvironmentInit(String envHome, String nomeAmbiente)
                throws Throwable {
            this.nomeAmbiente = nomeAmbiente;
            containersAbertos = new ArrayList();
            separador = System.getProperty("file.separator"); // pega o separador
            this.envHome = envHome + separador + nomeAmbiente;
             System.out.println(".EnvironmentInit:iniciar");       
            iniciar();
        public EnvironmentInit(String envHome, String nomeAmbiente, XmlManager mgr)
        throws Throwable {
            this.nomeAmbiente = nomeAmbiente;
            this.myManager = mgr;
            containersAbertos = new ArrayList();
            separador = System.getProperty("file.separator"); // pega o separador
            this.envHome = envHome + separador + nomeAmbiente;
            iniciar();
        private void iniciar() throws Exception {
            Dir.criarDiretorio(this.envHome); // cria o diretorio
            envPath = new File(this.envHome); // converte o caminho de String p/ File, requerido pelo construtor do Environment
            //System.out.println(envPath);
            if (!envPath.isDirectory()) {
    //            System.out.println("Criando dir.. " + envHome);
    //            Dir.criarDiretorio(this.envHome);
                throw new Exception(envPath.getPath()
                        + " does not exist or is not a directory.");
            try {
                EnvironmentConfig envConf = new EnvironmentConfig();
                //envConf.setCacheSize(50 * 1024 * 1024); //let default cache size.
                envConf.setAllowCreate(true); // If the environment does not
                                              // exits,create it.
                envConf.setInitializeCache(true); // Turn on the shared memory
                                                  // region.
                envConf.setInitializeLocking(true); // Turn on the locking
                                                     // subsystem
                envConf.setInitializeLogging(true); // Turn on the logging subsystem
                envConf.setTransactional(true); // Turn on the transactional
                                                // subsystem - Passo 1 para setar transa??????es.
                //envConf.setLogInMemory(true);
                //envConf.setLogBufferSize(10 * 1024 * 1024); //100 Mbs de log. Logs são usados para recuperação do banco em caso de corrupção.
                envConf.setErrorStream(System.err);
                //envConf.setRunRecovery(true); // Roda o recovery automaticamente
                myEnv = new Environment(envPath, envConf);
                managerConfig = new XmlManagerConfig();
                managerConfig.setAdoptEnvironment(true); // autoriza ao XmlManager, quando for fechado, fechar tamb???m o ambiente
                //  managerConfig.setAllowAutoOpen(true); // autoriza a abrir um
                                                      // container automaticamente
                //managerConfig.setAllowExternalAccess(true); // acesso externo
                myManager = new XmlManager(myEnv, managerConfig);
                myManager.setDefaultContainerType(XmlContainer.WholedocContainer);
                ismyEnvOpen = true;
            } catch (DatabaseException de) {
                // Exception handling goes here
                System.err.println("[erro] EnvironmentInit:iniciar - erro no banco");
            } catch (FileNotFoundException fnfe) {
                // Exception handling goes here
                System.err.println("[erro] EnvironmentInit:iniciar - Config faltando");
            } catch (Exception e) {
                // Exception handling goes here
                System.err.println("[erro] EnvironmentInit:iniciar  \n" + e.toString());
        //Returns the path to the database environment
        public File getDbEnvPath() {
            return envPath;
        //Returns the database environment encapsulated by this class.
        public Environment getEnvironment() {
            return myEnv;
        //Returns the XmlManager encapsulated by this class.
        public XmlManager getManager() {
            return myManager;
         * Reabre o container com as configura??????es j??? preparadas. ??? necess???rio
         * re-abrir posteriormente os containers
        public void reabrir() {
            if (ismyEnvOpen == false) {
                try {
                    iniciar();
                    //System.out.println(".EnvironmentInit: reabrir()");
                } catch (Exception e) {
                    System.err.println("[erro] EnvironmentInit:iniciar - Erro ao tentar reabrir ambiente!");
                    //e.printStackTrace();
        public String getName() {
            return nomeAmbiente;
        public void cleanup() throws DatabaseException {
            ismyEnvOpen = false;
            fechaContainersAbertos();
            try {
                if (myManager != null) {
                    // myEnv.close(); // fechado automaticamente pelo myManager
                    //myManager.close();
                    myManager.delete(); //trocado pelo close() pois é mais seguro.
                    ismyEnvOpen = false;
            } catch (Exception de) {
                // Exception handling goes here
                System.err.println("[erro] EnvironmentInit:iniciar - N�o conseguiu fechar o banco");
            System.out.println(".EnvironmentInit:cleanup");
        private void registraContainerAberto(XmlContainer container) {
            containersAbertos.add(container);
        private void fechaContainersAbertos() {
            for (int i = 0; i < containersAbertos.size(); i++) {
                try {
                    System.out.println(".EnvironmentInit:fechaContainer:" + ((XmlContainer) containersAbertos.get(i)).getName());
                    ((XmlContainer) containersAbertos.get(i)).closeContainer();
                    ((XmlContainer) containersAbertos.get(i)).delete(); //realmente garante o fechamento, destruindo o objeto associado.
                } catch (XmlException e) {
                    System.err
                            .println("[erro] EnvironmentInit:iniciar - Erro ao tentar fechar container");
                    e.printStackTrace();
            containersAbertos.clear();
        public XmlManagerConfig getXmlManagerConfig() {
            return managerConfig;
        public XmlContainer abrirContainer(String nome) {
            int ind = indiceContainerRegistrado(nome);
            XmlContainer container = null;
            if (ind >= 0) {
                //System.out.println(".EnvironmentInit:abrirContainer (j??? aberto) : " + nome + " - ambiente aberto!");
                return (XmlContainer) containersAbertos.get(ind);
            boolean existe = Dir
                    .existeArquivo(envPath.toString() + separador, nome);
            try {
                if (!existe) {
                    container = myManager.createContainer(nome);               
                    System.out.println(".EnvironmentInit:abrirContainer (create) : " + nome + " - criando container");
                    return null;
                } else {
                     System.out.println(".EnvironmentInit:abrirContainer - nome = '" nome "'");
                    XmlContainerConfig conf = new XmlContainerConfig();
                    conf.setAllowCreate(true);
                    conf.setTransactional(true);
                     container = myManager.openContainer(nome, conf);
                    //System.out.println(".EnvironmentInit:abrirContainer (open) : " + nome + " - ambiente aberto!");
                registraContainerAberto(container); // registra que o container foi
                // aberto
                return container;
            } catch (XmlException e) {
                e.printStackTrace();
            return null;
        public boolean removeContainer(XmlContainer c) {
            String path = null;
            try {
                path = envPath.toString() + separador + c.getName();
                //.closeContainer();
                c.delete(); //trocado pelo close acima por ser mais seguro.
                myManager.removeContainer(path);
                System.out.println(".EnvironmentInit:removeContainer : " + path);
                return true;
            } catch (XmlException e) {
                System.err.println("[erro] EnvironmentInit:iniciar - Erro ao tentar remover container ");
                //e.printStackTrace();
            return false;
        public int indiceContainerRegistrado(String nome) {
            try {
                for (int i = 0; i < containersAbertos.size(); i++) {
                    XmlContainer cont = (XmlContainer)containersAbertos.get(i);
                    if (cont.getName().compareTo(nome) == 0)
                        return i;
            } catch (Exception e) {
            return -1;
        Is there anything wrong with it, that could be causing this? Any help would be much appreciated.
    thanks,
    -- Breno Costa

    Hello all,
        I'm experiencing what I call a very subtle bug. Subtle because there are no exceptions, no memory leak, not even an error message.
        My application uses BDB XML and it inserts, updates, removes and searches documents - pretty basic functionality. But after some time of use, my users are calling me saying the searches never return any results. I mean, they send a request, then it's sent to BDB, but it doesnt return.
        First I thought it was another memory leak, but memory cosumption is high as always, but it is stable at some point. Just for checking, I restarted the server and tried searching again - dog slow, no return, even with 600MB free RAM.
        The only solution was to run recovery, which I chose to do manually at this time (and I dont do it automatically yet). Started the server, and then it returns to its normal state.
         So, I can just wonder what can possibility cause this? The containers are getting corrupted (although no corruption messages appear)? My Environment is managed by this class:
    package br.gov.al.delegaciainterativa.controles;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.util.ArrayList;
    import javax.naming.LimitExceededException;
    import br.gov.al.delegaciainterativa.utils.Dir;
    import com.sleepycat.db.DatabaseException;
    import com.sleepycat.db.Environment;
    import com.sleepycat.db.EnvironmentConfig;
    import com.sleepycat.dbxml.XmlContainer;
    import com.sleepycat.dbxml.XmlContainerConfig;
    import com.sleepycat.dbxml.XmlException;
    import com.sleepycat.dbxml.XmlManager;
    import com.sleepycat.dbxml.XmlManagerConfig;
    public class EnvironmentInit {
        private Environment myEnv; // objeto ambiente
        private XmlManager myManager;
        private XmlManagerConfig managerConfig;
        private File envPath;
        private boolean ismyEnvOpen = false;
        private String nomeAmbiente;
        private String separador;
        private String envHome;
        private ArrayList containersAbertos;
        public EnvironmentInit(String envHome, String nomeAmbiente)
                throws Throwable {
            this.nomeAmbiente = nomeAmbiente;
            containersAbertos = new ArrayList();
            separador = System.getProperty("file.separator"); // pega o separador
            this.envHome = envHome + separador + nomeAmbiente;
             System.out.println(".EnvironmentInit:iniciar");       
            iniciar();
        public EnvironmentInit(String envHome, String nomeAmbiente, XmlManager mgr)
        throws Throwable {
            this.nomeAmbiente = nomeAmbiente;
            this.myManager = mgr;
            containersAbertos = new ArrayList();
            separador = System.getProperty("file.separator"); // pega o separador
            this.envHome = envHome + separador + nomeAmbiente;
            iniciar();
        private void iniciar() throws Exception {
            Dir.criarDiretorio(this.envHome); // cria o diretorio
            envPath = new File(this.envHome); // converte o caminho de String p/ File, requerido pelo construtor do Environment
            //System.out.println(envPath);
            if (!envPath.isDirectory()) {
    //            System.out.println("Criando dir.. " + envHome);
    //            Dir.criarDiretorio(this.envHome);
                throw new Exception(envPath.getPath()
                        + " does not exist or is not a directory.");
            try {
                EnvironmentConfig envConf = new EnvironmentConfig();
                //envConf.setCacheSize(50 * 1024 * 1024); //let default cache size.
                envConf.setAllowCreate(true); // If the environment does not
                                              // exits,create it.
                envConf.setInitializeCache(true); // Turn on the shared memory
                                                  // region.
                envConf.setInitializeLocking(true); // Turn on the locking
                                                     // subsystem
                envConf.setInitializeLogging(true); // Turn on the logging subsystem
                envConf.setTransactional(true); // Turn on the transactional
                                                // subsystem - Passo 1 para setar transa??????es.
                //envConf.setLogInMemory(true);
                //envConf.setLogBufferSize(10 * 1024 * 1024); //100 Mbs de log. Logs são usados para recuperação do banco em caso de corrupção.
                envConf.setErrorStream(System.err);
                //envConf.setRunRecovery(true); // Roda o recovery automaticamente
                myEnv = new Environment(envPath, envConf);
                managerConfig = new XmlManagerConfig();
                managerConfig.setAdoptEnvironment(true); // autoriza ao XmlManager, quando for fechado, fechar tamb???m o ambiente
                //  managerConfig.setAllowAutoOpen(true); // autoriza a abrir um
                                                      // container automaticamente
                //managerConfig.setAllowExternalAccess(true); // acesso externo
                myManager = new XmlManager(myEnv, managerConfig);
                myManager.setDefaultContainerType(XmlContainer.WholedocContainer);
                ismyEnvOpen = true;
            } catch (DatabaseException de) {
                // Exception handling goes here
                System.err.println("[erro] EnvironmentInit:iniciar - erro no banco");
            } catch (FileNotFoundException fnfe) {
                // Exception handling goes here
                System.err.println("[erro] EnvironmentInit:iniciar - Config faltando");
            } catch (Exception e) {
                // Exception handling goes here
                System.err.println("[erro] EnvironmentInit:iniciar  \n" + e.toString());
        //Returns the path to the database environment
        public File getDbEnvPath() {
            return envPath;
        //Returns the database environment encapsulated by this class.
        public Environment getEnvironment() {
            return myEnv;
        //Returns the XmlManager encapsulated by this class.
        public XmlManager getManager() {
            return myManager;
         * Reabre o container com as configura??????es j??? preparadas. ??? necess???rio
         * re-abrir posteriormente os containers
        public void reabrir() {
            if (ismyEnvOpen == false) {
                try {
                    iniciar();
                    //System.out.println(".EnvironmentInit: reabrir()");
                } catch (Exception e) {
                    System.err.println("[erro] EnvironmentInit:iniciar - Erro ao tentar reabrir ambiente!");
                    //e.printStackTrace();
        public String getName() {
            return nomeAmbiente;
        public void cleanup() throws DatabaseException {
            ismyEnvOpen = false;
            fechaContainersAbertos();
            try {
                if (myManager != null) {
                    // myEnv.close(); // fechado automaticamente pelo myManager
                    //myManager.close();
                    myManager.delete(); //trocado pelo close() pois é mais seguro.
                    ismyEnvOpen = false;
            } catch (Exception de) {
                // Exception handling goes here
                System.err.println("[erro] EnvironmentInit:iniciar - N�o conseguiu fechar o banco");
            System.out.println(".EnvironmentInit:cleanup");
        private void registraContainerAberto(XmlContainer container) {
            containersAbertos.add(container);
        private void fechaContainersAbertos() {
            for (int i = 0; i < containersAbertos.size(); i++) {
                try {
                    System.out.println(".EnvironmentInit:fechaContainer:" + ((XmlContainer) containersAbertos.get(i)).getName());
                    ((XmlContainer) containersAbertos.get(i)).closeContainer();
                    ((XmlContainer) containersAbertos.get(i)).delete(); //realmente garante o fechamento, destruindo o objeto associado.
                } catch (XmlException e) {
                    System.err
                            .println("[erro] EnvironmentInit:iniciar - Erro ao tentar fechar container");
                    e.printStackTrace();
            containersAbertos.clear();
        public XmlManagerConfig getXmlManagerConfig() {
            return managerConfig;
        public XmlContainer abrirContainer(String nome) {
            int ind = indiceContainerRegistrado(nome);
            XmlContainer container = null;
            if (ind >= 0) {
                //System.out.println(".EnvironmentInit:abrirContainer (j??? aberto) : " + nome + " - ambiente aberto!");
                return (XmlContainer) containersAbertos.get(ind);
            boolean existe = Dir
                    .existeArquivo(envPath.toString() + separador, nome);
            try {
                if (!existe) {
                    container = myManager.createContainer(nome);               
                    System.out.println(".EnvironmentInit:abrirContainer (create) : " + nome + " - criando container");
                    return null;
                } else {
                     System.out.println(".EnvironmentInit:abrirContainer - nome = '" nome "'");
                    XmlContainerConfig conf = new XmlContainerConfig();
                    conf.setAllowCreate(true);
                    conf.setTransactional(true);
                     container = myManager.openContainer(nome, conf);
                    //System.out.println(".EnvironmentInit:abrirContainer (open) : " + nome + " - ambiente aberto!");
                registraContainerAberto(container); // registra que o container foi
                // aberto
                return container;
            } catch (XmlException e) {
                e.printStackTrace();
            return null;
        public boolean removeContainer(XmlContainer c) {
            String path = null;
            try {
                path = envPath.toString() + separador + c.getName();
                //.closeContainer();
                c.delete(); //trocado pelo close acima por ser mais seguro.
                myManager.removeContainer(path);
                System.out.println(".EnvironmentInit:removeContainer : " + path);
                return true;
            } catch (XmlException e) {
                System.err.println("[erro] EnvironmentInit:iniciar - Erro ao tentar remover container ");
                //e.printStackTrace();
            return false;
        public int indiceContainerRegistrado(String nome) {
            try {
                for (int i = 0; i < containersAbertos.size(); i++) {
                    XmlContainer cont = (XmlContainer)containersAbertos.get(i);
                    if (cont.getName().compareTo(nome) == 0)
                        return i;
            } catch (Exception e) {
            return -1;
        Is there anything wrong with it, that could be causing this? Any help would be much appreciated.
    thanks,
    -- Breno Costa

  • How to handle multiple database tables in a single UIX page?

    Hi,
    I am new to UIX & BC4J. I have to handle data from four different tables in the database. The scenario is as follows:
    The tables are
    1. user
    fields are: userid number, name varchar2
    2. business
    fields are: businessId number, name varchar2
    3. service
    fields are: serviceId number, serviceName varchar2
    4. userBusiness
    userid,businessid (both are foreign keys) & form complex primary keys.
    and userid,businessid, serviceId are primary keys.
    Now my problem is: to create a webpage where
    1. The userid is available in the httpSession Variable as string.
    2. according to the userId stored in the session variable I have to retrieve the business names and show them in a choice i.e., pull down box.
    3. I have to show the services provided by the business for the business name selected in the combo box.
    Could anyone Please help me solve this problem? Could you please give me hints? I have truncated the other fields in the tables.
    Thanking you,
    Velpandian .S

    At the moment, you can't do it declaratively. You have to do it in an event handler. Assuming you have the userid setup as a query parameter in the view object, something like this should get you started:
    public EventResult handleEvent(
    BajaContext context, Page page, PageEvent event) throws Throwable
    HttpSession session = context.getServletRequest().getSession(true);
    ViewObject view = ServletBindingUtils.getViewObject(context);
    String userid = session.getAttribute("userid");
    view.setWhereClauseParam(0, userid);
    view.executeQuery();

  • Can I use multiple coherence instances on one JVM?

    Or can I explicitly designate a tangosol-coherence-override.xml to coherence? If I can, how to?
    Thanks.
    Edited by: user8028833 on May 31, 2010 1:35 AM

    OK apologies as I was going to just post the bits of code but I didn't get much time last night.
    This code was originally written by a couple of us who wrote some security and single sign on code for Coherence. The project is on Google Code here: http://code.google.com/p/coherence-security/
    The source is a Maven project so it follows the Maven directory structure. If you look in the coherence-security-core test sources there is a package called com.oracle.coherence.patterns.security.test.starter which contains all the ClassLoader code and classes to start a Coherence "cluster" in a single JVM.
    The com.oracle.coherence.patterns.security.ApacheDirectoryTest test class uses this code to start a cluster to run its unit tests. To start the cluster you call CoherenceClusterStarter.getInstance() for example the com.oracle.coherence.patterns.security.ApacheDirectoryTest testSecureClientWithUnauthorisedCredentials() method.
        @Test
        public void testSecureClientWithUnauthorisedCredentials() throws Throwable {
            // Set the main class that runs to be the Secure servers
            System.setProperty("coherence.incubator.mainclass", SecureSandboxStarter.class.getName());
            // Make sure the cluster members run with the [email protected] Principal
            System.setProperty("sun.security.krb5.principal", "[email protected]");
            CoherenceClusterStarter.getInstance();
            // Run the client as the Thomas the Tank identity ([email protected]) which is
            // not authorised to connect as an Extend client in the extend-permissions.xml file
            System.setProperty("sun.security.krb5.principal", "[email protected]");
            LoginContext lc = new LoginContext("Coherence");
            lc.login();
            Subject subject = lc.getSubject();
            try {
                Subject.doAs(subject, new PrivilegedExceptionAction<Object>(){
                    public Object run() throws Exception {
                        SystemPropertyLoader.loadEnvironment("client");
                        System.setProperty("tangosol.coherence.security", "true");
                        CacheFactory.getCache("test");
                        return null;
                fail("Expected to have a PortableException wrapping a java.lang.SecurityException thrown");
            } catch (PortableException e) {
                assertEquals("Portable(java.lang.SecurityException)", e.getName());
        }In the code above the first line sets the coherence.incubator.mainclass System property to the name of the class that will be run (in this case our secured DefaultCacheServer wrapper). Then the next line starts the psuedo-Cluster which the rest of the code uses.
    Note
    The Google Code above was originally done due to a requierment to secure Coherence using Active Directory (Kerberos). The code was started on 3.4 and eventually on 3.5.3 and then used to help Oracle change the Security API for 3.6. There are a few things not quite right and a few "gotchas" that are not in the code online.
    Anyone is welcome to take it and use it but I and the others who worked on it offer no warranty or guarantee it will work for you.
    As of Coherence 3.6 there are much simpler ways to do security - although if you want to use Active Directory or Kerberos some of the code on Google will still be useful.
    Any problems or questions give me a shout either here or mail [email protected].
    Regards
    JK

Maybe you are looking for

  • In Answers am seeing "Folder is Empty" for Logical Fact and Dimension Table

    Hi All, Am working on OBIEE Answers, on of sudden when i clicked on Logical Fact table it showed me as "folder is empty". I restarted all the services and then tried still showing same for Logical Fact and Dimension tables but am able to see all my r

  • EssDisplayAlias C API problem with ASO outlines

    HI,<BR><BR>I am having an ASO outline which has few Year dimension aliases applied. Now I want to extract those aliases using C API. I am using API "EssDisplayAlias" to get the aliases from the default alias table but somehow this APi return me an er

  • SQL Server 2000 on Windows 7

     I need to install SQL Server 2000 on a Windows 7 machine.  When I start the install I get a message "SQL Server 2000 is incompatible with this versions.  For more information contact Microsoft."  I searched the forums but did not find anything about

  • Print sample draw instruction

    Hi I am facing problem with printing sample drawing proceducre for inspection type 04 Print is checked for MIC and inspection type when I do GR, the session is terminate with message program RQDSES10 not found same error - when i try to do QA02 But t

  • Why do I get this error (The request timed out.(102)) when i try and download an app from the mac app store?

    I have been trying to download the new updates for Aperture , Safari, and Iphoto. I click update and it gets the download bar but it doesnt get passed 0 KB when downloading the apps. Previously I had gotten the NSURLErrorDomain error -3001.)(102) but