Java SDO API import bug

There is a bug in the Oracle Java SDO API. It cannot import compound geometries which consist of either 3 or 4 sub-elements. e.g., the following geometry cannot be imported:
SDO_GEOMETRY(2002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 4, 4, 1, 2, 1, 9, 2, 2, 13
, 2, 2, 17, 2, 1), SDO_ORDINATE_ARRAY(278222.37, 179102.519, 278222.37, 179111.223,
278222.37, 179176.31, 278223.164, 179194.567, 278224.751, 179206.473, 278238.913,
179237.143, 278262.587, 179261.242, 278288.15, 179273.083, 278316.033, 179277.117,
278336.935, 179274.471, 278357.997, 179271.272))
Apparently the API does not validate the SDO_ETYPE when checking the SDO_INTERPRETATION value in the geometry.
SDO_INTERPRETATION values of 3 and 4 are assumed to be a rectangle and circle, respectively, independent of the SDO_ETYPE value. In fact, these SDO_INTERPRETATION should be handled such only for SDO_ETYPE value of 3.
For an SDO_ETYPE value of 4 (as in the example above), the SDO_INTERPRETATION value indicates the number of sub-elements in the compound geometry element.
Any ideas for a workaround or fix for this bug?

Hi Sunil,
This is a bug. There doesn't seem to be a workaround.
Can you contact me via email or post your email?
Thanks.

Similar Messages

  • [End of TNS data channel] with Java SDO API (JDBC thin 9.0.1.2.1)

    Hello folks,
    Environment:
    Win2K, 1.2GHz Intel, 500MB RAM, Oracle 9i, Oracle JDBC Thin (9.0.1.2.1), JDK1.3
    Our data in the DB is 2-D. It consists of SDO LineString geometries. We use SRID = 8307.
    I run into this problem with Java SDO API. I got this exception: "Io exception: End of TNS data channel"
    when I try to execute query that uses the SDO_RELATE function:
    SELECT e.shape
    FROM edge e
    WHERE SDO_RELATE(e.shape,
    mdsys.sdo_geometry( 2003, 8307, NULL,
    mdsys.sdo_elem_info_array(1,1003,1),
    mdsys.sdo_ordinate_array(-125.8,49.9,-125.6,49.9,-125.6,50.0,-125.8,50.0,-125.8,49.9) ),
    'mask=ANYINTERACT querytype=WINDOW') = 'TRUE'
    If I use SDO_FILTER instead of SDO_RELATE it works!
    Here is how I execute the query in Java:
    public int executeSpatialQuery(OracleConnection conn, String spatialQuery) throws Exception
    int numberOfGeometries = 0;
    conn.setDefaultRowPrefetch(1000);
    Statement ps = conn.createStatement();
    ResultSet rs = ps.executeQuery(spatialQuery);
    while (rs.next()) {
    numberOfGeometries++;
    rs.close();
    ps.close();
    return numberOfGeometries;
    Note: I was playing with the "conn.setDefaultRowPrefetch(n)" method hoping that there might be something to do with that but with no success.
    Any help will be much appreciated. Thank you.
    GKK

    Hello folks,
    Here is what I've done:
    1. Created a "mini" Realtional model (modelB) which mimics exactly our existing "big" Realtional model (modelA). The tables, sequences, indices, etc. in modelB have been created in exactly the same fashion we'd created the corresponding entities in modelA. The only difference is that I preceeded the entities in our test modelB with "TEST_".
    2. Populated the modelB with 1298 Lakes (3993 edges in total) in exatly the same fashion we use to populate our modelA - using a Data Loader based on Java SDO API.
    3. Indexed the test modelB in exactly the same fashion as modelA.
    4. Ran the query:
    SELECT e.shape FROM test_edge e WHERE SDO_RELATE(e.shape,
    mdsys.sdo_geometry(
    2003,
    8307,
    NULL,
    mdsys.sdo_elem_info_array(1,1003,1),
    mdsys.sdo_ordinate_array(
    -123.80833332065798,48.58352678668598,
    -123.80833332065798,48.675352618459506,
    -123.65050767229724,48.675352618459506,
    -123.65050767229724,48.58352678668598,
    -123.80833332065798,48.58352678668598
    ), 'mask=ANYINTERACT querytype=WINDOW'
    ) = 'TRUE'
    in SQL*PLUS and it worked fine (retrieved a bunch of geometries)!
    Ran the same query in the Daniel Geringer's OraTest utility and it worked this time and returned:
    TIME : 1.222 seconds, TOTAL FETCH TIME 267 ROWS
    Ran the query with our JCS Query Plug-In and it worked fine!
    ANALYSIS
    ========
    ModelA
    ======
    - 59652 Lakes and 178764 edges
    - it's properly indexed
    - its SDO layers and geometries are valid
    - when we count the number of related SDO geometries for this query we get:
    SQL> SELECT count(e.shape) FROM edge e WHERE SDO_RELATE(e.shape,
    2 mdsys.sdo_geometry(
    3 2003,
    4 8307,
    5 NULL,
    6 mdsys.sdo_elem_info_array(1,1003,1),
    7 mdsys.sdo_ordinate_array(
    8 -123.80833332065798,48.58352678668598,
    9 -123.80833332065798,48.675352618459506,
    10 -123.65050767229724,48.675352618459506,
    11 -123.65050767229724,48.58352678668598,
    12 -123.80833332065798,48.58352678668598
    13 )
    14 ), 'mask=ANYINTERACT querytype=WINDOW'
    15 ) = 'TRUE';
    COUNT(E.SHAPE)
    267
    - when we run the following query via the Java SDO API:
    SELECT e.shape FROM edge e WHERE SDO_RELATE(e.shape,
    mdsys.sdo_geometry(
    2003,
    8307,
    NULL,
    mdsys.sdo_elem_info_array(1,1003,1),
    mdsys.sdo_ordinate_array(
    -123.80833332065798,48.58352678668598,
    -123.80833332065798,48.675352618459506,
    -123.65050767229724,48.675352618459506,
    -123.65050767229724,48.58352678668598,
    -123.80833332065798,48.58352678668598
    ), 'mask=ANYINTERACT querytype=WINDOW'
    ) = 'TRUE'
    it FAILS with: "TNS end of communaction channel"!
    ModelB
    ======
    - 1298 Lakes and 3993 edges
    - it's properly indexed
    - its SDO layers and geometries are valid
    - when we count the number of related SDO geometries for this query we get:
    SQL> SELECT count(e.shape) FROM test_edge e WHERE SDO_RELATE(e.shape,
    2 mdsys.sdo_geometry(
    3 2003,
    4 8307,
    5 NULL,
    6 mdsys.sdo_elem_info_array(1,1003,1),
    7 mdsys.sdo_ordinate_array(
    8 -123.80833332065798,48.58352678668598,
    9 -123.80833332065798,48.675352618459506,
    10 -123.65050767229724,48.675352618459506,
    11 -123.65050767229724,48.58352678668598,
    12 -123.80833332065798,48.58352678668598
    13 )
    14 ), 'mask=ANYINTERACT querytype=WINDOW'
    15 ) = 'TRUE';
    COUNT(E.SHAPE)
    267
    - when we run the following query via the Java SDO API:
    SELECT e.shape FROM test_edge e WHERE SDO_RELATE(e.shape,
    mdsys.sdo_geometry(
    2003,
    8307,
    NULL,
    mdsys.sdo_elem_info_array(1,1003,1),
    mdsys.sdo_ordinate_array(
    -123.80833332065798,48.58352678668598,
    -123.80833332065798,48.675352618459506,
    -123.65050767229724,48.675352618459506,
    -123.65050767229724,48.58352678668598,
    -123.80833332065798,48.58352678668598
    ), 'mask=ANYINTERACT querytype=WINDOW'
    ) = 'TRUE'
    it SUCCESSFULLY returns the related geometries!
    So, what can we make of all this? We know that there exists a model for which the SDO_RELATE works via the Java SDO API. This model is a subset (w.r.t. the data set) of our original model in which we detected the "TNS end of communication channel problem". The environment we used for these tests is exactly the same: JDBC Thin driver (version 9.0.1.0.0), Oracle9i Enterprise Edition (Release 9.0.1.2.1 - Production).
    One can think that the problem lies in the Oracle Object-Realational or Oracle Spatial but the fact that we can successfully execute the same SDO_RELATE queries in SQL*PLUS rejects this possibility. Perhaps it depends on the amount of data passed to the JDBC driver and the fashion in which it handles it! In our test above we had RELATED 267 geometries. We know that there exist SDO_RELATE queries that run successfully with modelA, but those are queries which ONLY retrieve an EMPTY set of RELATED geometries. In other words we don't get the "TNS end of communication channel" because NO data gets fetched from the server to the client! As soon as we find a SDO_RELATE query which retrieves (RELATES) at least 1 geometry that runs successfully in SQL*PLUS and run it via the Java SDO API - it FAILS! This means that no matter what volume of data is fetched from the server-JDBCThin-SDOAPI-client as long as there is ANY data, the query FAILS in modelA.
    Perhaps something internally in the Oracle 9i Server happens that prevent the data being fetch to the JDBCThin for that particular modelA. But what that might be?
    Very peculiar problem!
    Regards,
    Georgi

  • Java Speech API

    Hi
    When i compile the following program it give me error some of the Java speech API.
    import javax.speech.AudioException;
    import javax.speech.Central;
    import javax.speech.EngineException;
    import javax.speech.synthesis.Synthesizer;
    import javax.speech.synthesis.SynthesizerModeDesc;
    Can any one help.
    Thanks
    import java.awt.BorderLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.io.File;
    import java.io.FileReader;
    import java.io.IOException;
    import java.util.Collections;
    import java.util.Comparator;
    import java.util.Locale;
    import java.util.Hashtable;
    import java.util.prefs.Preferences;
    import javax.speech.AudioException;
    import javax.speech.Central;
    import javax.speech.EngineException;
    import javax.speech.synthesis.Synthesizer;
    import javax.speech.synthesis.SynthesizerModeDesc;
    import javax.swing.DefaultComboBoxModel;
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JFileChooser;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextField;
    import javax.swing.JTextArea;
    import javax.swing.JToolBar;
    public class JavaVoice extends JFrame implements Comparator {
         private Synthesizer synth;
         private File readFile = null;
         Preferences preferences = Preferences.userRoot().node("dlb/JavaVoice");
         JComboBox voices;
         Hashtable list;
         public JavaVoice() {
              super("Java Voice Synthesizer");
              addWindowListener(new AppCloser());
              DefaultComboBoxModel model = new DefaultComboBoxModel();
              try {
                   javax.speech.EngineList elist = Central.availableSynthesizers(null);
                   list = new Hashtable(elist.size());
                   Collections.sort(elist,this);
                   for (int i=0;i<elist.size();i++) {
                        SynthesizerModeDesc desc = (SynthesizerModeDesc)elist.elementAt(i);
                        model.addElement(desc.getModeName());
                        list.put(desc.getModeName(),desc);
                   synth = Central.createSynthesizer((SynthesizerModeDesc) list.get(preferences.get("voice.selected","")));
                   synth.allocate();
                   synth.resume();
              catch(EngineException ex) {
                   ex.printStackTrace();
              catch(AudioException ex) {
                   ex.printStackTrace();
              final JTextArea textArea = new JTextArea();
              textArea.setLineWrap(true);
              textArea.setWrapStyleWord(true);
              JScrollPane scrollPane = new JScrollPane(textArea);
              getContentPane().add(scrollPane,BorderLayout.CENTER);
              JToolBar toolBar = new JToolBar();
              JButton button = new JButton("Open");
              button.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent ev) {
                        JFileChooser fileChooser = new JFileChooser(preferences.get("voice.openDirectory",System.getProperty("user.dir")));
                        if(fileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
                             readFile = fileChooser.getSelectedFile();
                             preferences.put("voice.openDirectory",readFile.getParent());
                             try {
                                  FileReader reader = new FileReader(readFile);
                                  textArea.read(reader,readFile.getName());
                                  reader.close();
                             catch(IOException ex) {
                                  ex.printStackTrace();
              toolBar.add(button);
              button = new JButton("Clear");
              button.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent ev) {
                        textArea.setText("");
              toolBar.add(button);
              toolBar.add(button);
              button = new JButton("Start");
              button.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent ev) {
                        String str = textArea.getSelectedText();
                        if(str != null && str.length() > 0) {
                             synth.speakPlainText(str.toLowerCase(),null);
                             textArea.setSelectionStart(0);
                             textArea.setSelectionEnd(0);
                        else {
                             str = textArea.getText();
                             synth.speakPlainText(str.toLowerCase(),null);
              toolBar.add(button);
              button = new JButton("Stop");
              button.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent ev) {
                        try {
                             synth.cancel();
                        catch(ArrayIndexOutOfBoundsException ex) {}
              toolBar.add(button);
              toolBar.addSeparator();
              toolBar.add(new JLabel("Voice:"));
              voices = new JComboBox(model);
              voices.setSelectedItem(preferences.get("voice.selected",""));
              voices.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent ev) {
                        try {
                             synth.deallocate();
                             String str = (String) voices.getSelectedItem();
                             preferences.put("voice.selected",str);
                             synth = Central.createSynthesizer((SynthesizerModeDesc) list.get(str));
                             synth.allocate();
                             synth.resume();
                        catch(EngineException ex) {
                             ex.printStackTrace();
                        catch(AudioException ex) {
                             ex.printStackTrace();
              toolBar.add(voices);
              toolBar.addSeparator();
              button = new JButton("Exit");
              button.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent ev) {
                        try {
                             synth.deallocate();
                        catch(EngineException ex) {
                             ex.printStackTrace();
                        preferences.putInt("voice.mainWindow.x",getLocation().x);
                        preferences.putInt("voice.mainWindow.y",getLocation().y);
                        preferences.putInt("voice.mainWindow.width",getSize().width);
                        preferences.putInt("voice.mainWindow.height",getSize().height);
                        System.exit(1);
              toolBar.add(button);
              getContentPane().add(toolBar,BorderLayout.NORTH);
              final JTextField textField = new JTextField();
              textField.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent ev) {
                        String txt = textField.getText();
                        if(txt.length() > 0) {
                             textArea.append(txt+'\n');
                             synth.speakPlainText(txt, null);
                             textField.setText("");
              getContentPane().add(textField,BorderLayout.SOUTH);
              int x = preferences.getInt("voice.mainWindow.x",1);
              int y = preferences.getInt("voice.mainWindow.y",1);
              int width = preferences.getInt("voice.mainWindow.width",640);
              int height = preferences.getInt("voice.mainWindow.height",480);
              setLocation(x,y);
              setSize(width,height);
              setVisible(true);
         public int compare(Object obj1, Object obj2) {
              SynthesizerModeDesc desc1 = (SynthesizerModeDesc) obj1;
              SynthesizerModeDesc desc2 = (SynthesizerModeDesc) obj2;
              return desc1.getModeName().compareToIgnoreCase(desc2.getModeName());
         public static void main(String args[]) {
              new JavaVoice();
         class AppCloser extends WindowAdapter {
              public void windowClosing(WindowEvent ev) {
                   try {
                        synth.deallocate();
                   catch(EngineException ex) {
                        ex.printStackTrace();
                   System.exit(1);
    ---------------------------------------------------------------------------------------------------------

    use code tags, post the error message.
    http://forum.java.sun.com/help.jspa?sec=formatting

  • Import metadata by java public api

    Hi,
    There is anyone who can point to me the direction on how I can import database objects (like tables, view, etc.) from a location into an Oracle module with owb java public api?
    Thanks and best regards,
    Cipi

    See discussion: Import metadata using owb java api

  • Java Sound API - Threads

    Hi, I have a bit of a problem with my program. I have a class that runs my GUI for the application that I am developing. One of the features of the GUI is that when you hit the "Speak" button a recording is made of the speech input from a mic connected to the PC. The class I have for doing the speech recording (in Java) is a seperate class and an instance of this is created when the "Speak" button is clicked in the GUI. Once the "Speak" button is clicked, it changes into a "Stop" button, and when this is clicked, the recording should stop. The problem is that the recording will not stop unitl the GUI is exited, and this is a big problem. I know that there is a bug in the Thread class in Java for this type of thing and this is where the problem comes from, what I am looking for is a workaround, so that I can stop the recording without exiting the GUI. The following is the code:
    audio recorder class:
    import java.io.IOException;
    import java.io.File;
    import javax.sound.sampled.DataLine;
    import javax.sound.sampled.TargetDataLine;
    import javax.sound.sampled.AudioFormat;
    import javax.sound.sampled.AudioSystem;
    import javax.sound.sampled.AudioInputStream;
    import javax.sound.sampled.LineUnavailableException;
    import javax.sound.sampled.AudioFileFormat;
    public class myAudioRecorder extends Thread
         private TargetDataLine m_line;
         private AudioFileFormat.Type     m_targetType;
         private AudioInputStream m_audioInputStream;
         private File     outputFile;
         boolean finished = false;
         public myAudioRecorder(TargetDataLine line,
                        AudioFileFormat.Type targetType,
                        File file)
              m_line = line;
              m_audioInputStream = new AudioInputStream(line);
              m_targetType = targetType;
              outputFile = file;
         /** Starts the recording.
         To accomplish this, (i) the line is started and (ii) the
         thread is started.
         public void start()
              /* Starting the TargetDataLine. It tells the line that
              we now want to read data from it. If this method
              isn't called, we won't
              be able to read data from the line at all.
              m_line.start();
              /* Starting the thread. This call results in the
              method 'run()' (see below) being called. There, the
              data is actually read from the line.
              super.start();
         // Stops the recording.
         public void stopRecording()
              m_line.stop();
              m_line.close();
         /** Main working method.
         public void run()
                   try
                        AudioSystem.write(
                             m_audioInputStream,
                             m_targetType,
                             outputFile);
                   catch (IOException e)
                        e.printStackTrace();
         } // END public void run()
         public void closeProgram()
              System.exit(1);
    } // END myAudioRecorder class
    This is the code in the GUI class that creates an instance of the recorder and calls the start and stopRecording methods.
    // Handle events that arise from the "Speak" button being clicked
         public void speakButtonMouseClicked(java.awt.event.MouseEvent evt) {
    // Start the recording of the Speech
              File     outputFile = new File("C:/Donn/Java/simpleAudioRecording.wav");
              AudioFormat     audioFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 11025.0F, 16, 1, 2, 11025.0F, false);
              /* Now, we are trying to get a TargetDataLine. The
              TargetDataLine is used later to read audio data from it.
              If requesting the line was successful, we are opening
              it (important!).
              DataLine.Info     info = new DataLine.Info(TargetDataLine.class, audioFormat);
              TargetDataLine     targetDataLine = null;
              try
                   targetDataLine = (TargetDataLine) AudioSystem.getLine(info);
                   targetDataLine.open(audioFormat);
              catch (LineUnavailableException e)
                   e.printStackTrace();
                   System.exit(1);
              /* Again for simplicity, we've hardcoded the audio file
              type, too.
              AudioFileFormat.Type     targetType = AudioFileFormat.Type.WAVE;
              myAudioRecorder myRecorder = new myAudioRecorder(targetDataLine, targetType, outputFile);
              if (speakButton.getText().equals("Speak"))
                   myRecorder.start();
                   speakButton.setText("Stop");
                   speakButton.setMnemonic('t');
                   speakButton.setToolTipText("Click here to stop recording your word");
              else if (speakButton.getText().equals("Stop"))
                   myRecorder.stopRecording();
                   speakButton.setText("Speak");
                   speakButton.setMnemonic('p');
                   speakButton.setToolTipText("Click to start speaking");
    } // END private void speakButtonMouseClicked - Speak
    Any help majorly appreciated, thanks!

    I spent a few hours trying to solve this but kept getting the same problem as you whatever I did. On investigation I found this page:
    http://www.developer.com/java/other/article.php/1572251
    The code listing seems to be doing pretty much what you want, plus playing it also. He's gone down the ByteArray stream route.
    hth

  • How do i use java printing api 1.4

    How can i print documents using jdk1.4 api.
    I have used the following program for printing.
    import java.io.*;
    import java.awt.*;
    import java.awt.print.*;
    import javax.print.*;
    import javax.print.attribute.*;
    import javax.print.attribute.standard.*;
    public class Print2DtoStream implements Printable{
    public Print2DtoStream() {
    /* Use the pre-defined flavor for a Printable from an InputStream */
    DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
    /* Specify the type of the output stream */
    String psMimeType = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType();
    /* Locate factory which can export a GIF image stream as Postscript */
    StreamPrintServiceFactory[] factories =
    StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, psMimeType);
    if (factories.length == 0) {
    System.err.println("No suitable factories");
    System.exit(0);
    try {
    /* Create a file for the exported postscript */
    FileOutputStream fos = new FileOutputStream("out.ps");
    /* Create a Stream printer for Postscript */
    StreamPrintService sps = factories[0].getPrintService(fos);
    /* Create and call a Print Job */
    DocPrintJob pj = sps.createPrintJob();
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    Doc doc = new SimpleDoc(this, flavor, null);
    pj.print(doc, aset);
    fos.close();
    } catch (PrintException pe) {
    System.err.println(pe);
    } catch (IOException ie) {
    System.err.println(ie);
    public int print(Graphics g,PageFormat pf,int pageIndex) {
    if (pageIndex == 0) {
    Graphics2D g2d= (Graphics2D)g;
    g2d.translate(pf.getImageableX(), pf.getImageableY());
    g2d.setColor(Color.black);
    g2d.drawString("example string", 250, 250);
    g2d.fillRect(0, 0, 200, 200);
    return Printable.PAGE_EXISTS;
    } else {
    return Printable.NO_SUCH_PAGE;
    public static void main(String args[]) {
    Print2DtoStream sp = new Print2DtoStream();
    However when i run this program,it prints "example string" as used in g2d.drawString("example string",250,250) method above.
    What if i want to print content from any file.
    So anybody konwing this plz reply

    This is covered pretty well in the Java Print Service API Guide.
    You could start here http://java.sun.com/j2se/1.4.1/docs/guide/jps/spec/printing.fm1.html
    Basically, you have two choices - either you're going to throw a document at the print service, or you're going to print using Graphics2D commands. You also have the choice between printing to a printer, or to a stream. Mix and match for four combinations.
    Whether you can just take a raw document and send it to a printer via the document printing stuff depends on what print services you have installed. For the standard J2SE, it's pretty limited.
    If you're doing it via the Graphics2D approach, however, you can print anything you can draw. That's nice - it means you can use the same code to display stuff on the screen and print it.

  • Retrieving suitcase jar back from BPEL PM using 'java client api' ?

    Hi All,
    I have ANT based TeamFoundationServer auto builds working for BPEL workflow. I also have custom ANT tasks that call oracle bpel java API to be able to clearWSDL cache in various non-production environments.
    I would now like to attempt retrieving suitcase jar that was deployed previously. Before describing any further, I guess, my first question would be whether this is a possible thing to do.
    While browsing the JAVA API , I came across a method in class --> IBPELDomainHandle ( getSuitcase ) that seem to be returning back byte[] if the suitcaseId was provided to it.
    If below approach is in right direction, what else could I be missing ? Once , below class begins to retrieve the suitcase jar, the goal is to package it in an already existing jar and make it part of regular auto builds ( using ANT 1.6.5's custom task) hosted on windows 2003 server.
    The line in bold below, when uncommented, gives error that is posted after the java code.
    ********START : LocallyConnect2BPELPM.java ************************************************
    package com.collaxa.cube.ant.taskdefs.deploy;
    import com.oracle.bpel.client.BPELProcessMetaData;
    import com.oracle.bpel.client.IBPELDomainHandle;
    import com.oracle.bpel.client.IBPELProcessHandle;
    import com.oracle.bpel.client.Locator;
    import java.util.Properties;
    import java.io.*;
    import org.apache.tools.ant.BuildException;
    public class LocallyConnect2BPELPM {
    public LocallyConnect2BPELPM() {
    public static void main(String[] args) {
    LocallyConnect2BPELPM locallyConnect2BPELPM = new LocallyConnect2BPELPM();
    args[0]="SOME_BPEL_DOMAIN";
    String BPELdomain;
    BPELdomain = args[0];
    try {
    Properties props = new Properties();
    String hostName = "hostAtMyWork";
    String port = "10000";
    String user = "SomeServiceAccount";
    String pwd = "SomePassword";
    String domain = BPELdomain ; //getProject().getProperty("domain");
    System.err.println("host name - " + hostName + " port - " + port + " passwd - " + pwd);
    props.put("java.naming.factory.initial", "weblogic.jndi.WLInitialContextFactory");
    props.put("java.naming.provider.url", "t3://" + hostName + ":" +port);
    props.put("java.naming.security.principal", user);
    props.put("java.naming.security.credentials", pwd);
    System.out.println("test connection to host = " + hostName + " port " + port);
    Locator locator = new Locator(domain,"bpel",props);
    IBPELDomainHandle d = locator.lookupDomain();
    //get Handle to list of processes deployed in the domain
    IBPELProcessHandle[] processes = locator.listProcesses();
    for(int j = 0 ; j < processes.length ; j++) {
    IBPELProcessHandle process = processes[j];
    String processName = process.getProcessId().getProcessId() ;
    if ( process.isDefaultRevision())
    System.out.println(" processName = " + processName + "_" + process.getProcessId().getRevisionTag() + " in domain " + domain);
    /* I am intending to use class BPELProcessMetaData's java.lang.String getSuitcaseId() method to retrieve suitcaseId
    http://www.oracle.com/technology/products/ias/bpel/htdocs/apidocs/101340MLR4/com/oracle/bpel/client/BPELProcessMetaData.html
    attempting to use Interface IBPELDomainHandle's method --> byte[] getSuitcase(java.lang.String suitcaseId)
    since it needs suitcaseId, I am trying to get it from class BPELProcessMetaData's method --> java.lang.String getSuitcaseId() to retrieve suitcaseId .
    however, i always get suitcaseId as null for all processes resulting in error posted.
    // to get suitcaseId, BPELProcessMetaData has getSuitcaseId. pass this to d.getSuitcase
    String strFilePath = "D://bpel_"+processName +"_" + process.getProcessId().getRevisionTag() + ".jar";
    FileOutputStream fos = new FileOutputStream(strFilePath);
              // upon uncommenting the line below , I get error that is posted after the java code.
    // byte[] jarfile = d.getSuitcase(process.getMetaData().getSuitcaseId() );
    BPELProcessMetaData bpelMeta = process.getMetaData();
    String suitcaseId = bpelMeta.getSuitcaseId() ;
    System.out.println( processName + " suitcaseId = " + suitcaseId );
    // fos.write(d.getSuitcase(process.getMetaData().getSuitcaseId() ));
    System.out.println(strFilePath);
    fos.close();
    // uncomment below
    // d.getSuitcase(process.getMetaData().getSuitcaseId());
    }catch(Exception ex) {
    ex.printStackTrace();
    throw new BuildException(ex);
    String BPELdomain;
    public void setBPELdomain(String BPELdom) {
    BPELdomain = BPELdom;
    *************END : LocallyConnect2BPELPM.java **********************************************
    java.lang.IllegalStateException: [EJB:010158]Illegal attempt to call EJBContext.setRollbackOnly() from an EJB that was not participating in a transaction.
         at weblogic.ejb.container.internal.BaseEJBContext.setRollbackOnly(BaseEJBContext.java:361)
         at com.collaxa.cube.ejb.impl.BaseCubeSessionBean.setTransactionRollback(BaseCubeSessionBean.java:180)
         at com.collaxa.cube.ejb.impl.BPELDomainManagerBean.getSuitcase(BPELDomainManagerBean.java:1544)
         at com.collaxa.cube.ejb.impl.DomainManagerBean_tho2et_EOImpl.getSuitcase(DomainManagerBean_tho2et_EOImpl.java:615)
         at com.collaxa.cube.ejb.impl.DomainManagerBean_tho2et_EOImpl_WLSkel.invoke(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:553)
         at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:224)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:443)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:439)
         at weblogic.rmi.internal.BasicServerRef.access$300(BasicServerRef.java:61)
         at weblogic.rmi.internal.BasicServerRef$BasicExecuteRequest.run(BasicServerRef.java:983)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
    Exception in thread "main" java.lang.IllegalStateException: [EJB:010158]Illegal attempt to call EJBContext.setRollbackOnly() from an EJB that was not participating in a transaction.
         at com.collaxa.cube.ant.taskdefs.deploy.LocallyConnect2BPELPM.main(LocallyConnect2BPELPM.java:76)
    Caused by: java.lang.IllegalStateException: [EJB:010158]Illegal attempt to call EJBContext.setRollbackOnly() from an EJB that was not participating in a transaction.
         at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:215)
         at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:338)
         at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:252)
         at com.collaxa.cube.ejb.impl.DomainManagerBean_tho2et_EOImpl_923_WLStub.getSuitcase(Unknown Source)
         at com.oracle.bpel.client.BPELDomainHandle.getSuitcase(BPELDomainHandle.java:234)
         at com.collaxa.cube.ant.taskdefs.deploy.LocallyConnect2BPELPM.main(LocallyConnect2BPELPM.java:60)
    Caused by: java.lang.IllegalStateException: [EJB:010158]Illegal attempt to call EJBContext.setRollbackOnly() from an EJB that was not participating in a transaction.
         at com.collaxa.cube.ejb.impl.BaseCubeSessionBean.setTransactionRollback(BaseCubeSessionBean.java:184)
         at com.collaxa.cube.ejb.impl.BPELDomainManagerBean.getSuitcase(BPELDomainManagerBean.java:1544)
         at com.collaxa.cube.ejb.impl.DomainManagerBean_tho2et_EOImpl.getSuitcase(DomainManagerBean_tho2et_EOImpl.java:615)
         at com.collaxa.cube.ejb.impl.DomainManagerBean_tho2et_EOImpl_WLSkel.invoke(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:553)
         at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:224)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:443)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:439)
         at weblogic.rmi.internal.BasicServerRef.access$300(BasicServerRef.java:61)
         at weblogic.rmi.internal.BasicServerRef$BasicExecuteRequest.run(BasicServerRef.java:983)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
    Caused by: java.lang.IllegalStateException: [EJB:010158]Illegal attempt to call EJBContext.setRollbackOnly() from an EJB that was not participating in a transaction.
         at weblogic.ejb.container.internal.BaseEJBContext.setRollbackOnly(BaseEJBContext.java:361)
         at com.collaxa.cube.ejb.impl.BaseCubeSessionBean.setTransactionRollback(BaseCubeSessionBean.java:180)
         ... 13 more
    --- Nested Exception ---
    java.lang.IllegalStateException: [EJB:010158]Illegal attempt to call EJBContext.setRollbackOnly() from an EJB that was not participating in a transaction.
         at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:215)
         at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:338)
         at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:252)
         at com.collaxa.cube.ejb.impl.DomainManagerBean_tho2et_EOImpl_923_WLStub.getSuitcase(Unknown Source)
         at com.oracle.bpel.client.BPELDomainHandle.getSuitcase(BPELDomainHandle.java:234)
         at com.collaxa.cube.ant.taskdefs.deploy.LocallyConnect2BPELPM.main(LocallyConnect2BPELPM.java:60)
    Caused by: java.lang.IllegalStateException: [EJB:010158]Illegal attempt to call EJBContext.setRollbackOnly() from an EJB that was not participating in a transaction.
         at com.collaxa.cube.ejb.impl.BaseCubeSessionBean.setTransactionRollback(BaseCubeSessionBean.java:184)
         at com.collaxa.cube.ejb.impl.BPELDomainManagerBean.getSuitcase(BPELDomainManagerBean.java:1544)
         at com.collaxa.cube.ejb.impl.DomainManagerBean_tho2et_EOImpl.getSuitcase(DomainManagerBean_tho2et_EOImpl.java:615)
         at com.collaxa.cube.ejb.impl.DomainManagerBean_tho2et_EOImpl_WLSkel.invoke(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:553)
         at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:224)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:443)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:439)
         at weblogic.rmi.internal.BasicServerRef.access$300(BasicServerRef.java:61)
         at weblogic.rmi.internal.BasicServerRef$BasicExecuteRequest.run(BasicServerRef.java:983)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
    Caused by: java.lang.IllegalStateException: [EJB:010158]Illegal attempt to call EJBContext.setRollbackOnly() from an EJB that was not participating in a transaction.
         at weblogic.ejb.container.internal.BaseEJBContext.setRollbackOnly(BaseEJBContext.java:361)
         at com.collaxa.cube.ejb.impl.BaseCubeSessionBean.setTransactionRollback(BaseCubeSessionBean.java:180)
         ... 13 more
    Process exited with exit code 1.
    Thanks in advance for your time !!
    Sameer
    Server side:
    Oracle BPEL v10.1.3.4.0
    MLR 8 patched.
    Windows 2003
    underlying server : weblogic 9.2
    client side: (while running the above java code)
    windows vista
    ANT: version 1.6.5
    Java: Jrockit 1.5.2

    Hi
    I have been trying what you want to achieve. I was getting some other error.
    Then I tried to print the suitcase Id as returned by process.getMetaData().getSuitcaseId() and this is returning null.
    Is that the case with you too?

  • Save Attachment from exchange server 2010 from oracle using java mail API

    Hello,
    I want to read email from microsoft exchangeserver 2010 and save attachement into a folder.I created an Java program to import attachments from a exchange server mailbox using "POP3S".It works fine when run as a java application.But when i put this inside Oracle11g R2 using load java and while executing from a procedure it gives an error at parsing message into Multipart
    Error at line : Multipart mp = (Multipart)m.getContent();
    Error:
    Content-Type: multipart/mixed;
    boundary="_002_A0C2E09A..................................."
    java.lang.ClassCastException
    at mailPop3.checkmail(mailPop3:71)
    My Java Class is as follows,
    import java.io.*;
    import java.util.Properties;
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.Date;
    The function i used to check for attachments is given below.
    public static boolean hasAttachments(Message m) throws java.io.IOException, MessagingException
    Boolean hasAttachments = false;
    try
    // if it is a plain/html text - no attachements
    if (m.isMimeType("text/*"))
    return hasAttachments;
    else if (m.isMimeType("multipart/alternative"))
    return hasAttachments;
    else if (m.isMimeType("multipart/*"))
    Multipart mp = (Multipart)m.getContent();
    if (mp.getCount() > 1)
    hasAttachments = true;
    return hasAttachments;
    catch (Exception e) {
    e.printStackTrace();
    } finally {
    return hasAttachments;
    My Java Details as follows
    java Version :1.5.0_10
    java.vm.specification.version:1.0
    java.vm.version :1.5.0_01
    java.specification.version:1.5
    java.class.version:48.0
    Java mail API:javamail-1.4.4
    Used Jars:mail.jar
    Could someone explain why I am getting this error? What can I do to resolve this error?
    Is any other Jar need other than mail.jar?
    Any help would be much appreciated.
    Regards,
    Nisanth

    Hai EJP,
    Thanks for your reply,
    My full java class as follows,
    import java.util.Properties;
    import javax.mail.Authenticator;
    import javax.mail.Folder;
    import javax.mail.Message;
    import javax.mail.PasswordAuthentication;
    import javax.mail.Session;
    import javax.mail.Store;
    import javax.mail.Part;
    import javax.mail.Multipart;
    import javax.mail.internet.MimeMultipart;
    import javax.mail.internet.MimeMessage;
    public class Newmail
    public Newmail()
    super();
    public static int mailPOP3(String phost,
    String pusername,
    String ppassword)
    Folder inbox =null;
    Store store =null;
    int result = 1;
    try
    String host=phost;
    final String username=pusername;
    final String password=ppassword;
    System.out.println("Authenticator");
    Authenticator auth=new Authenticator()
    protected PasswordAuthentication getPasswordAuthentication()
    return new PasswordAuthentication(username, password);
    System.out.println("Certificate");
    String filename="D:\\Certi\\jssecacerts";
    String password2 = "changeit";
    System.setProperty("javax.net.ssl.trustStore",filename);
    System.setProperty("javax.net.ssl.trustStorePassword",password2);
    Properties props = System.getProperties();
    System.out.println("host-----"+props);
    props.setProperty("mail.pop3s.port", "993");
    props.setProperty("mail.pop3s.starttls.enable","true");
    props.setProperty("mail.pop3s.ssl.trust", "*");
    Session session = Session.getInstance(props,auth);
    session.setDebug(true);
    store = session.getStore("pop3s");
    System.out.println("store------"+store);
    store.connect(host,username,password);
    System.out.println("Connected...");
    inbox = store.getDefaultFolder().getFolder("INBOX");
    inbox.open(Folder.READ_ONLY);
    Message[] msgs = inbox.getMessages();
    System.out.println("msgs.length-----"+msgs.length);
    result = 0;
    int no_of_messages = msgs.length;
    for ( int i=0; i < no_of_messages; i++)
    System.out.println("msgs.count-----"+i);
    System.out.println("Attachment....>"+msgs.getContentType());
    Multipart mp = (Multipart)msgs[i].getContent();
    System.out.println("Casting Success" + mp.getContentType());
    catch(Exception e)
    e.printStackTrace();
    finally
    try
    if(inbox!=null)
    inbox.close(false);
    if(store!=null)
    store.close();
    return result;
    catch(Exception e)
    e.printStackTrace();
    return result;
    Please check it
    Regards,
    Nisanth

  • Suppressing Applet alerts when using java mail api

    Hi,
    Im using the following code to send email from my application. Im using JSF (tomahawk), Spring and hibernate in my application. I'm using spring email API classes to send email. This code works perfectly fine in the sense its parsing template and sending emails to the configured email id.
    I have defined this class as a managed bean and i have a commanButton is UI which is bound to this sendEmail() method
    <t:commandButton value="Send email" action= #{email.sendEmail}/>
    import java.io.StringWriter;
    import java.util.ArrayList;
    import java.util.Date;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    import java.util.Properties;
    import javax.mail.MessagingException;
    import javax.mail.internet.MimeMessage;
    import org.apache.velocity.Template;
    import org.apache.velocity.VelocityContext;
    import org.apache.velocity.app.VelocityEngine;
    import org.apache.velocity.exception.ParseErrorException;
    import org.apache.velocity.runtime.resource.loader.StringResourceLoader;
    import org.apache.velocity.runtime.resource.util.StringResourceRepository;
    import org.springframework.mail.MailException;
    import org.springframework.mail.SimpleMailMessage;
    import org.springframework.mail.javamail.JavaMailSenderImpl;
    import org.springframework.mail.javamail.MimeMessageHelper;
    import au.gov.nsw.railcorp.onlineticketing.external.model.request.ServiceFees;
    public class EmailService {
         JavaMailSenderImpl sender;
         VelocityEngine engine;
         public EmailService(){
         sender = new JavaMailSenderImpl();
             sender.setHost("<smtp ip>");
             sender.setPort(25);
             sender.setUsername("<user id>");
             sender.setPassword("<password>");
             engine = new VelocityEngine();
             Properties p = new Properties();
             p.setProperty("resource.loader", "string");
             p.setProperty("string.resource.loader.class",
                  "org.apache.velocity.runtime.resource.loader.StringResourceLoader");
             try {
                   engine.init(p);
              } catch (Exception e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         public VelocityEngine getEngine() {
              return engine;
         public void setEngine(VelocityEngine engine) {
              this.engine = engine;
         public JavaMailSenderImpl getSender() {
              return sender;
         public void setSender(JavaMailSenderImpl sender) {
              this.sender = sender;
         public static void main(String args[]){
              EmailService emailService=new EmailService();
              emailService.sendEmail();
         public boolean sendEmail(){
         try{
                 MimeMessage message = sender.createMimeMessage();
                 MimeMessageHelper helper = new MimeMessageHelper(message);
                 helper.setTo("<to email id>");
                 helper.setFrom("<from email id>");
                 helper.setSubject("Teting velocity");
                 VelocityContext context = new VelocityContext();
                 StringWriter writer =  new StringWriter();
                 Template template =new Template();
                    StringResourceRepository repository =StringResourceLoader.getRepository();
                    String tempText="<html><body>Hi, ${username}...<p> this is a some template!</p></body></html>";
                 repository.putStringResource("myTemplate",tempText );
                 context.put("username", "Marc");
                 template = engine.getTemplate("myTemplate");
                  template.merge(context, writer);
                  System.out.println("VM Template:\n" + tempText);
                  System.out.println("Output:\n" + writer);
                  String body=writer.toString();
                  helper.setText(body,true);
                  sender.send(message);
            catch (MessagingException ex) {
                // simply log it and go on...
                System.err.println(ex.getMessage());           
            catch (MailException ex) {
                // simply log it and go on...
                System.err.println(ex.getMessage());           
            } catch (ParseErrorException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
         return true;
    }The problem i have is when i try to invoke the function sendEmail() from my UI it is throwing a series of applet alerts (some 10 of them) . The following are the alerts that i get
    1. The applet is attempting to invoke the java/lang/System.getProperty() operation on java.home
    2. The applet is attempting to perform a read operation on the file C:\Program Files\java\jre1.5.0_14\javamail.providers
    3. The applet is attempting to perform a read operation on the file C:\Program Files\java\jre1.5.0_14\javamail.address.map etc....
    For ever applet alert i had to click on 'allow' for it to proceed. But there is no problem in sending mail after that. One more interesting this is i DONT get this alert when i try to execute this java class directly instead of calling the method from another class or from UI.
    Can someone please let me know the reason for this applet alert and the way to suppress it?
    Its really urgent .. please help
    Thank you..

    Hi Subhadip,
    Thanks for the quick response :)
    Please help me understand this.. Im not explicitly using applet anywhere .I guess it should be used internally by one or many of the API classes i have used . In this scenario how can self sign the applet and which one?
    I have included some jars like activation.jar,mail-1.4.2.jar,velocity-1.6.2.jar in my webapp lib . Is there a means to sign these jars and use? Is this what you are suggesting me to do?
    One more doubt i have is how come the same method runs without any problem when executed as a standalone java class (with main() method)
    Will be really helpful if you could help me understand this...
    Thanks,
    Swami

  • Problem in using java print API

    I am facing a problem in using printAll and printComponents API.
    The application was developed in java1.1
    Now the same application is migrated to java 1.4
    But the reports are not being printed in desired format.
    The application make use of printAll() API of Component.
    Using java1.1 the print output is without the borders for components like textField or TextArea,
    whereas for java 1.4 we get border and scrollbar on print which is not the desired output.
    Can anybody suggest a solution for the same?
    here is the sample code, you can see the difference by executing this code in java1.1 and java 1.4.
    import java.awt.*;
    import java.util.*;
    public class TestPrint extends Frame implements java.awt.event.ActionListener {
    PrintJob job = null;
    //Frame aFrame = new Frame("Test Frame");
    private TextArea txaChangeNotes = null;
    private Label lb = null;
    private Panel ivjContentsPane = null;
    private Button ivjButton1 = null;
    TestPrint () {
         super("Test Frame");
         init();
    private void init() {
         ivjContentsPane = new java.awt.Panel();
         ivjContentsPane.setName("ContentsPane");
         txaChangeNotes = new java.awt.TextArea("",0,0,java.awt.TextArea.SCROLLBARS_BOTH);
         txaChangeNotes.setText("****\n&&&");
         ivjButton1 = new java.awt.Button();
         ivjButton1.setName("Button1");
         ivjButton1.addActionListener(this);
         ivjContentsPane.add(txaChangeNotes);
         ivjContentsPane.add(lb);
         ivjContentsPane.add(ivjButton1);
         this.add(ivjContentsPane);
         setSize(595, 735);
         show();
    public void actionPerformed(java.awt.event.ActionEvent e) {
         Object obj = e.getSource() ;
         if( obj instanceof java.awt.Button ){
              //Button but = e.getSource();
              print();
    private void print() {
         System.out.println("In Print");
         job = getPrintJob(this , "Print All Parts");
         //job.setPrintable(this);
         if(job!=null){
              System.out.println("Job not null");     
              /*if (job.printDialog()) {
         try {
                   System.out.println("printing");     
         job.print();
         } catch (Exception ex) {
         ex.printStackTrace();
              Graphics pg=job.getGraphics();
              if(pg!=null){
              System.out.println("graphics not null");     
                   this.requestFocus();
                   //this.printComponents(pg);
                   this.printAll(pg);
              }else{
              System.out.println("graphics null");     
                   //this.dispose();
                   return;
              pg.dispose();
         }else{
              System.out.println("job null");
              //this.dispose();
              return;
         job.end();     
    private PrintJob getPrintJob (Frame aFrame,String aString) {
         Properties printprefs = null;
         Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit();
         PrintJob job = toolkit.getPrintJob(aFrame, aString, printprefs);
         /*JobAttributes jab = null;
         jab = new JobAttributes();
         PageAttributes pab = null;
         pab = new PageAttributes();
         pab.setPrinterResolution(70);
         jab.setDialog(JobAttributes.DialogType.COMMON);
    PrintJob job = Toolkit.getDefaultToolkit().getPrintJob(aFrame, aString, jab, pab);*/
         return job;
    public static void main(String arg[]){
         TestPrint objTestPrintFrame = new TestPrint();
    }

    You must not have the complete IFS_BASE_CLASSPATH defined in your CLASSPATH environment variable. The easiest way to do this is to type ". ifsenv.sh" on Solaris (or run ifsenv.bat on NT). Then you can invoke java like this:
    java -classpath $CLASSPATH:$IFS_BASE_CLASSPATH ...
    (your standard JDK classes should already be in the CLASSPATH; append our classpath to it)

  • Issue with JAVA Mail API

    Hi
    We have a requirement to create a custom e mail. For the same I am trying to use Java Mail API.I am facing an issue with the following code:
    session session1 = session.getInstance(properties, null);
    System gives an error Sourced file: inline evaluation of: ``Properties props = new Properties(); session session1 = session.getInstance(prop . . . '' : Typed variable declaration : Class: session not found in namespace
    Is there some specific API i need to import for session class. Kindly suggest.
    Regards
    Shobha

    Hi Shobha,
    I was also facing the same issue from last couple of weeks and just now i have achieved the working functionality.
    Please find below working code and replace values as per your serveru2019s configuration.
    import com.sap.odp.api.util.*;
    import java.util.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    import java.io.File;
    import java.net.*;
    // SUBSTITUTE YOUR EMAIL ADDRESSES HERE!!!
    String to =<email address>;
    String from =<email address>;
    // SUBSTITUTE YOUR ISP'S MAIL SERVER HERE!!!
    String host = <smtp host name>;
    String user = <smtp user name>;
    // Create properties, get Session
    // Properties props = new Properties();
    Properties props = System.getProperties();
    props.put("mail.transport.protocol", "smtp");
    props.put("mail.smtp.host", host);
    props.put("mail.debug", "false");
    props.put("mail.smtp.auth", "false");
    props.put("mail.user",user);
    props.put("mail.from",from);
    Session d_session = Session.getInstance(props,null);//Authenticator object need to be set
    Message msg = new MimeMessage(d_session);
    msg.setFrom(new InternetAddress(from));
    InternetAddress[] address = {new InternetAddress(to)};
    msg.setRecipients(Message.RecipientType.TO, address);
    msg.setSubject("Test E-Mail through Java");
    msg.setSentDate(new Date());
    msg.setText("This is a test of sending a " +
    "plain text e-mail through Java.\n" +
    "Here is line 2.");
    Transport.send(msg);
    Deepak!!!

  • Using Java Mail API from Tomcat

    Hello,
    Purely as an academic exercise I have written a JSP page which, upon being requested from the client's browser, should send me a default email using Java Mail Api.
    here is the code :
    import java.util.*;
    import java.io.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    public class TestMail {
        static String msgText1 = "success this time 12";
        static String msgText2 = "This is the text in the message attachment.";
        public String sendIt() {
            String to = "<my email";
            String from = "<anything>";
            String host = "<my ip address of smtp server>";
            boolean debug = false;
            Properties props = new Properties();
            props.put("mail.smtp.host", host);
            Session session = Session.getInstance(props, null);
    .....The code works fine as a stand alone app but when called from JSP page it hangs on the Session.getInstance line. I can only guess that this might be a security issue with the container not allowing access to the smtp server ?
    Can anyone give me a clue ???

    Your Tomcat log files should spell out the problem for you.
    My Tomcat installation does not come with the Java Mail API. I had to add the mail and activation jar files to the server/common.lib directory (or the server's shared/lib or the WEB-INF/lib of your application.)
    HTH.

  • Problem in retrieving email using java mail api

    hi,
    In my project,i am retrieving mails from a particular email id.
    I am able to retrieve the latest mails and save it in a folder in my system.
    The problem is whenever i run the program eventhough the most recently received mail in inbox is retrieved and saved,again it is retrieving the same one and saving it in the same folder(not repeating).
    I tried to check the newmessages in the inbox using the folder.hasNewMessage() method in java mail api,but the method is returning false only regardless new mail is there in inbox or not.
    I want to read the unread messages only.Dont want to retrieve the already read mails.
    I got the mail retrieving code from the below site.(sorry not posting the code because it is so long and having 4 classes)
    http://www.builderau.com.au/program/java/soa/Getting_the_mail_in_receiving_in_JavaMail/0,39024620,39228060,00.htm
    Can anyone tell me how to read unread mails in the inbox?
    Thanks a lot

    hi parvathi
    i think your mail program is receving mails using imap
    the imap is only receve the mail from server but the pop is deleting the mails after receving
    use the following sample code
    package com.sfrc.mail.pop;
    import javax.mail.*;
    import javax.mail.internet.*;
    import com.sun.mail.handlers.message_rfc822;
    import java.util.*;
    import java.io.*;
    * Owner: SFRC IT Solutions Pvt Ltd
    * Author:Arunkumar Subramaniam
    * Date :12-06-2006
    * File Name: AttachRecive.java
    public class AttachRecive
    public static void main(String args[])
    try
    String popServer="192.168.1.1";
    String popUser="pl";
    String popPassword="password";
    // Create empty properties
    Properties props = new Properties();
    // Get session
    Session session = Session.getDefaultInstance(props, null);
    // Get the store
    Store store = session.getStore("pop3");
    store.connect(popServer, popUser, popPassword);
    // Get folder
    Folder folder = store.getFolder("INBOX");
    folder.open(Folder.READ_ONLY);
    // Get directory
    Message message =folder.getMessages();
    Multipart mp = (Multipart)message.getContent();
    for (int i=0, n=mp.getCount(); i<n; i++) {
    Part part = mp.getBodyPart(i);
    String disposition = part.getDisposition();
    // Close connection
    folder.close(false);
    store.close();
    catch (Exception ex)
    System.out.println("Usage: "
    +" popServer popUser popPassword");
    System.exit(0);
    Regards
    Arunkumar Subramaniam
    SFRC IT Solutions Pvt Ltd
    Chennai

  • Possible Classpath Error, Java POI API

    Hiya,
    I'm not new to Java, well not that new, but the class path, packages and such have always been a bit of a blind spot for me. Once I finally get that part working the applications write themselves.
    I've written an application that writes large grids as csv files, but I'd like to go a step further and add forumlae and formatting, therefore I've been looking at the Java POI HSSF API (http://jakarta.apache.org/).
    I've downloaded the files from here: http://apache.mirror.positive-internet.com/jakarta/poi/release/bin/ and added them to my classpath (I think..), which I have pasted below [and have spaced out for ease of reading];
    My Classpath
    C:.; C:\Dev\JavaServer\bin;
    C:\Dev\JavaLive\io\MySQL\mysql-connector-java-3.1.12-bin.jar;
    C:\Dev\JavaLive\io\Excel\poi-2.5.1-final-20040804.jar;
    C:\Dev\JavaLive\io\Excel\poi-contrib-2.5.1-final-20040804.jar;
    C:\Dev\JavaLive\io\Excel\poi-scratchpad-2.5.1-final-20040804.jar;
    %CLASSPATH%
    My Test Code
    import java.io.*;
    import org.apache.poi.hssf.usermodel.HSSFCell;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    import org.apache.poi.hssf.usermodel.HSSFSheet;
    import org.apache.poi.hssf.usermodel.HSSFWorkbook;
    public class exceltest
         public exceltest()
              HSSFWorkbook wb = new HSSFWorkbook();
              FileOutputStream fileOut = new FileOutputStream("workbook.xls");
              wb.write(fileOut);
              fileOut.close();
         public static void main(String args[])
              new exceltest();
    }I've checked the integrity of the the jar files, and the structure seems intact. Shouldn't adding the three jars to the classpath, as above, allow me to import them as above?
    The following errors result at compile:
    C:\Dev\JavaLive\exceltest.java:2: package org.apache.poi.hssf.usermodel does not exist
    import org.apache.poi.hssf.usermodel.HSSFCell;
                                         ^
    C:\Dev\JavaLive\exceltest.java:3: package org.apache.poi.hssf.usermodel does not exist
    import org.apache.poi.hssf.usermodel.HSSFRow;
                                         ^
    C:\Dev\JavaLive\exceltest.java:4: package org.apache.poi.hssf.usermodel does not exist
    import org.apache.poi.hssf.usermodel.HSSFSheet;
                                         ^
    C:\Dev\JavaLive\exceltest.java:5: package org.apache.poi.hssf.usermodel does not exist
    import org.apache.poi.hssf.usermodel.HSSFWorkbook;
                                         ^
    C:\Dev\JavaLive\exceltest.java:17: cannot resolve symbol
    symbol  : class HSSFWorkbook
    location: class exceltest
              HSSFWorkbook wb = new HSSFWorkbook();
                    ^
    C:\Dev\JavaLive\exceltest.java:17: cannot resolve symbol
    symbol  : class HSSFWorkbook
    location: class exceltest
              HSSFWorkbook wb = new HSSFWorkbook();
                                          ^
    6 errors
    Tool completed with exit code 1I've googled, searched the forums and such and have yet to turn up an answer. I assume it's something to do with the classpath as it's not seeing the package? Any help would be very appreciated.
    Thanks
    David
    Message was edited by:
    davidrhowells

    Well, it works ok for me. The only thing I can think of is that you haven't re-sourced your classpath? Did you run(start) whatever you're compiling from before or after you set the classpath? Try opening a command prompt and cd to your source file.
    Type
    echo %classpath%to make sure the classpath is set correctly and then type
    javac exceltest.javaThat should work if the classpath is correct...

  • Newbie question on the Java communications API

    Hi All,
    I found the javax.comm extension package that lets me listen to the serial port of the PC, but am unsure as to how to use it. Well, I've tried running the SimpleRead.java program and I get an error message that says the package is missing in the import (which I assume means that I havent downloaded it and added it to one of the folders in my Java directory). Where can I find the package from? And am I missing anything else?
    In case you're all wondering, I've got a microcontroller attached to the serial port that sends data periodically. I would like to use the Java comm API to read the incoming data (and if possible store it in the form of a text file or something). Any suggestions would be great as I'm still new to Java. More of a C/C++ person (^_^) Thanks in advance.....

    Did you try using that little search field in the upper right hand corner of your browser?

Maybe you are looking for

  • Using only selected playlists

    I use the auto-sync feature of iTunes and I recently tried going from 'Sync all songs and playlists' to 'selected playlists.' To my dismay, this erased everything that was not on the playlists. Is there a way to sync only the music in my library and

  • Load balancing v/s Clustering with  BOXI enterprise premium

    We are planning to install Businessobjects enterprise premium on windows2008 server (64 bit) and we are going to use oracle database. my question is "Can we set up Crystal reports and businessobjects (web intelligence) both either on clustered enviro

  • SAP 4.6 work processes too often goes to completed status

    Hello, SAP 4.6 C  (Oracle 9i / windows NT) system, always work process goes to completed status. This a quality system. As of now we are only restaring the work processes (SM50->process->restart after error-> yes) manually as a temporary fix. Could y

  • Cross company sales and GTS

    Esteemed Gurus: We have a scenario where a sale is made to a 3rd party customer in country A,  The materials are supplied by another company code, in another country (country B) - a typical cross company sale with direct shipment. ECC will have a sal

  • How to add multiple desktop on mac os x?

    On my previous version of Mac OS X I was able to add as much desktops I want by just going into upper right corner with my pointer and clickin on the sign +. Now, after replacing my SSD and installing new OS I don't have that option. Does anyone know