x:out / - throws exception -

xml file
<?xml version="1.0" encoding="UTF-8"?>
<trains>
     <train id="100">
          <name>train0</name>
          <speed>70</speed>
          <fast>false</fast>
     </train>
</trains>JSP code
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %>
<html>
     <body>
          <c:import url="/train.xml" var="trains" />
          <x:parse doc="${trains}" var="parsedTrains" />
          <x:out var="theTrain" select="$parsedTrains/trains/train[@id=100]"/>
          Train name: <x:out value="$theTrain/name" />
     </body>
</html>Exception
SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: /index2.jsp(9,14) According to the TLD or the tag file, attribute select is mandatory for tag out
     at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
     at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)Although, the similar code works fine:
<html>
     <body>
          <c:import url="/train.xml" var="trains" />
          <x:parse doc="${trains}" var="parsedTrains" />
          Train name: <x:out  select="$parsedTrains/trains/train[@id=100]/name"/>
     </body>
</html>

it is some errors in JSP code
the correct code
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %>
<html>
     <body>
          <c:import url="/train.xml" var="trains" />
          <x:parse doc="${trains}" var="parsedTrains" />
          <x:set  var="theTrain"  select="$parsedTrains/trains/train[@id=100]" />
          Train name: <x:out select="$theTrain/name" />
     </body>
</html>

Similar Messages

  • Throwing Exception having multiple arguments in constructor

    hi,
    I am trying to implement exception handling for a JAVA + C++ module.
    In which C++ exception is caught by a Java module.
    The c++ code is as follows,
    try
    ///////////===========
    } catch (Exception1 &e) {
    jclass clazz = jenv->FindClass("test/Exception1Java");
    if(clazz)
    jenv->ThrowNew(clazz,e.getErrMsg().c_str());
    return 0;
    } catch (Exception2 &e) {
    jclass clazz = jenv->FindClass("test/Exception2");
    if(clazz)
    jenv->ThrowNew(clazz,e.getErrMsg().c_str());
    return 0;
    This works perfectly fine.
    But I want to pass one more argument as int while throwing the java exception.
    jenv->ThrowNew(clazz,e.getErrId(),e.getErrMsg().c_str());
    As the jenv->ThrowNew function only take two arguments I am unable to send the error id( int ) to the message.
    Is there any alternate to this function or some other approach to throw the java exceptions.

    hi,
    I am trying to implement exception handling for a
    JAVA + C++ module.
    In which C++ exception is caught by a Java module.
    The c++ code is as follows,<snip>
    >
    But I want to pass one more argument as int while
    throwing the java exception.
    env->ThrowNew(clazz,e.getErrId(),e.getErrMsg().c_str());>
    As the jenv->ThrowNew function only take two
    arguments I am unable to send the error id( int ) to
    the message.
    Is there any alternate to this function or some other
    approach to throw the java exceptions.Build the exception using the normal FindClass, GetMethodID approach,. and then throw it.
    #include "NativeExceptionTest.h"
    JNIEXPORT void JNICALL Java_NativeExceptionTest_test
    (JNIEnv *env, jobject obj, jint data) {
         if (data == 42) {
              jclass excClass = env->FindClass("MyException");
              if (!excClass) {
                   return;
              jmethodID ctorID = env->GetMethodID(excClass, "<init>", "(ILjava/lang/String;)V");
              if (!ctorID) {
                   return;
              jstring excMessage = env->NewStringUTF("ILLEGAL VALUE");
              jobject excObject = env->NewObject(excClass, ctorID,-1,excMessage);
              if (!excObject) {
                   return;
              env->Throw((jthrowable)excObject);
         return;
    }============================================
    public class NativeExceptionTest {
         static {
              System.loadLibrary("nativeException");
         NativeExceptionTest() {
               try {
                    test(42);
               } catch (MyException e) {
                   System.out.println("Exception: " + e.getCode() + "(" + e.getMessage() +")");
         private native void test(int i) throws MyException;
         public static void main(String[] args) {
              new NativeExceptionTest();
    class MyException extends Exception {
         private int code;
         MyException(int code, String message) {
              super(message);
              this.code = code;
         int getCode() {
              return this.code;
    }

  • Programmatically adding chart to a report throws exception

    programmatically adding chart to a report throws exception "chart condition fields are not valid".
    Configuration:
    I am using CR4E to create web application, I've added RAS jars (rasapp.jar, rascore.jar, reporttemplate.jar, serialization.jar) to this web application. For designing reports i am using Crystal Reports 2008.
    Code:
    <%
    // Get the previously opened report from the session.
    ReportClientDocument reportClientDocument =
         (ReportClientDocument)session.getAttribute("ReportClientDocument");
    System.out.println(reportClientDocument.getReportDocument().getName());
    // Try to get the report's DataDefinition object.
    IDataDefinition dataDefinition;
    try
         dataDefinition = reportClientDocument.getDataDefController().getDataDefinition();
    // If the DataDefinition object can not be retrieved, redirect the user to an error page.
    catch (Exception e)
         System.out.println("With error1");
        return;
    // Create a new ChartDefinition object and set its type to ChartType.group.
    ChartDefinition chartDefinition = new ChartDefinition();
    chartDefinition.setChartType(ChartType.group);
    Get the conditional field of the report's first group. Set this conditional
    field for the ChartDefinition object using the setConditonalFields method. Notice
    that the conditional field is first placed in a Fields collection because the
    setConditionalFields method takes a Fields object as an argument.
    Fields conditionFields = new Fields();
    if (!dataDefinition.getGroups().isEmpty())
         IField field = dataDefinition.getGroups().getGroup(0).getConditionField();
         System.out.println("Condition field name ->" + field.getLongName(Locale.ENGLISH));
         conditionFields.addElement(field);
    chartDefinition.setConditionFields(conditionFields);
    //Get the summary field name from the form on the previous page.
    String summaryFieldName = URLDecoder.decode(request.getParameter("summaryField"));
    System.out.println("Summary field name ->" + summaryFieldName);
    Loop through all of the report's summary fields until the one matching the name
    above is found. Set this summary field for the ChartDefinition object using the
    setDataFields method. Notice that the summary field is first placed in a Fields
    collection because the setDataFields method takes a Fields object as an argument.
    Fields dataFields = new Fields();
    for (int i = 0; i < dataDefinition.getSummaryFields().size(); i++)
        IField summaryField = dataDefinition.getSummaryFields().getField(i);
         if (summaryField.getLongName(Locale.ENGLISH).equals(summaryFieldName))
              System.out.println("Adding data field ->" + summaryFieldName);
              dataFields.addElement(summaryField);
    chartDefinition.setDataFields(dataFields);
    Create a new ChartObject to represent the chart that will be added.  Set the
    ChartDefinition property of the ChartObject using the ChartDefinition object created
    above.
    ChartObject chartObject = new ChartObject();
    chartObject.setChartDefinition(chartDefinition);
    Get the chart type, chart placement, and chart title strings from the form on the
    previous page. If no chart title was chosen, create a generic title.
    String chartTypeString = request.getParameter("type");
    String chartPlacementString = request.getParameter("placement");
    String chartTitle = request.getParameter("title");
    System.out.println("chartTypeString ->"+ chartTypeString + "<-chartPlacementString->" + chartPlacementString + "<-chartTitle->"+chartTitle);
    if (chartTitle.equals(""))
         chartTitle = "untitled";
    Create a ChartStyleType object and a AreaSectionKind object based on the
    the chartTypeString and chartPlacementString retrieved above. In this example
    possible chart types are bar chart and pie chart. Possible chart placements
    are header and footer.
    ChartStyleType chartStyleType = ChartStyleType.from_string(chartTypeString);
    AreaSectionKind chartPlacement = AreaSectionKind.from_string(chartPlacementString);
    // Set the chart type, chart placement, and chart title for the chart.
    chartObject.getChartStyle().setType(chartStyleType);
    chartObject.setChartReportArea(chartPlacement);
    chartObject.getChartStyle().getTextOptions().setTitle(chartTitle);
    // Set the width, height, and top for the chart.
    chartObject.setHeight(5000);
    chartObject.setWidth(5000);
    chartObject.setTop(1000);
    Get a ReportDefController object that can be used to modify the report's definition.
    ReportDefController reportDefController;
    try
         reportDefController = reportClientDocument.getReportDefController();
    catch (Exception e)
         System.out.println("With Error2");
         return;
    *Create a Section object that represents the section that will hold the chart.
    If the chart placement was set header, get the header section, otherwise, if the
    chart placement was set to footer, get the footer section.
    Section chartSection = null;
    if (chartPlacement.equals(AreaSectionKind.reportHeader))
         IArea reportHeaderArea =
              reportDefController.getReportDefinition().getReportHeaderArea();
         chartSection = (Section)reportHeaderArea.getSections().getSection(0);
    else if (chartPlacement.equals(AreaSectionKind.reportFooter))
         IArea reportFooterArea =
              reportDefController.getReportDefinition().getReportFooterArea();
         chartSection = (Section)reportFooterArea.getSections().getSection(0);
    Add the chart to the section using the ReportDefController object.
    reportDefController.getReportObjectController().add(chartObject, chartSection, 1);
    // Save the changes and close the report.
    reportClientDocument.save();
    reportClientDocument.close();
    session.removeAttribute("ReportClientDocument");
    %>     
    Trace:
    com.crystaldecisions.sdk.occa.report.lib.ReportDefControllerException: The chart condition fields are not valid.---- Error code:-2147213287 Error code name:invalidChartObject
         at com.crystaldecisions.sdk.occa.report.lib.ReportDefControllerException.throwReportDefControllerException(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ReportObjectController.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ReportObjectController.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ReportObjectController.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ReportObjectController.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ReportObjectController.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ReportObjectController.add(Unknown Source)
         at org.apache.jsp.AddChart_jsp._jspService(AddChart_jsp.java:230)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:387)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:244)
         at java.security.AccessController.doPrivileged(Native Method)
         at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
         at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:276)
         at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:162)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:283)
         at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:56)
         at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:189)
         at java.security.AccessController.doPrivileged(Native Method)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:185)
         at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:244)
         at java.security.AccessController.doPrivileged(Native Method)
         at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
         at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:276)
         at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:218)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
         at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:56)
         at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:189)
         at java.security.AccessController.doPrivileged(Native Method)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:185)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
         at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
         at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
         at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
         at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:393)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
         at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
         at java.lang.Thread.run(Thread.java:595)

    Please try this code snippet
    var cs:ColumnSeries = new ColumnSeries();
    cs.dataProvider = dp;
    cs.displayName = "Series 2";
    cs.yField = "values";
    chart.series.push(cs);
    OR
    var temp:Array = [];
    var cs:ColumnSeries = new ColumnSeries();
    cs.dataProvider = dp;
    cs.displayName = "Series 2";
    cs.yField = "values";
    temp = chart.series;
    temp.add(cs);
    chart.series = temp;

  • ** Throw Exception in BPM - Webservice to JDBC

    Hi friends,
    I am doing Webservice to JDBC scenario using BPM. I am doing insert data in backend system oracle table by passing inputs from WebService. After insert data in table, JBDC returns the response to web service thru response variable 'insert_count = 1' like this. When I try to insert the same record, that is, employee no as primary key in my table,  XI throws an error 'ORA-00001 - unique constraint' in Addtional . We have to pass this information to Web Service. How will we achive this ?
    Presently in our BPM design,
    1) Exception property of the block as 'Error'.
    2) Inside Block, in Sync Send Step (BPM -> JDBC) specified 'Exception/System Error'  as 'Error'.
    3) Inserted one Exception Handler Brach. In this Brach, inserted one control step. In this step, itself we put a Control Step, the action property of this step is 'Throw Exception'. Here , what we need to set for the 'Exception Property' ..?
    Kindly help me friends.

    Hi Mahesh,
    I refered those scenarios. But, our requirment is we want to take 'Additional Text' option from SXMB_MONI and map to WS source structure one element.
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?><!-- Call Adapter --> <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="1"><SAP:Category>XIServer</SAP:Category><SAP:Code area="INTERNAL">PL_TIMEOUT</SAP:Code><SAP:P1/><SAP:P2/><SAP:P3/><SAP:P4/><SAP:AdditionalText>TIME OUT REACHED</SAP:AdditionalText><SAP:ApplicationFaultMessage namespace=""/><SAP:Stack>Timeout condition of pipeline reached
    </SAP:Stack><SAP:Retry>N</SAP:Retry></SAP:Error>
    Could you kindly help me ?

  • 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.

  • Throws Exception when jdbc connect to Oracle

    Hi! I'm waiting for your answers.
    When i use jdbc to connect Oracle,system throws exceptions as follows:
    java.lang.ClassCastException: oracle.sql.converter.CharacterConverter12Byte
    oracle.sql.CharacterSet1Byte oracle.sql.CharacterSet1Byte.getInstance (int,racle.sql.converter.CharacterConverter)
              CharacterSet1Byte.java:82
         oracle.sql.CharacterSet oracle.sql.CharacterSetWithConverter.getInstance(int)     CharacterSetWithConverter.java:85
    I code in Oracle9i Jdeveloper 9.0.2. The Oracle version is 9.0.2.
    My code example is as follows:
    package mypackage2;
    import java.sql.*;
    import oracle.jdbc.driver.*;
    public class Class1
    public Class1()
    public static void main(String[] args)
    Class1 class1 = new Class1();
    Connection conn = null;
    try
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    //exception throws in getConnection()
    conn = DriverManager.getConnection
    ("jdbc:oracle:thin:@localhost:1521:CR","system","CR2001");
    catch (Exception e)
    e.printStackTrace();

    import java.io.*;
    import java.sql.*;
    import java.text.*;
    import oracle.jdbc.driver.*;
    public class viewtable
         Connection con;
         Statement st;
         public viewtable (String args[]) throws ClassNotFoundException,FileNotFoundException,IOException,SQLException
         url="jdbc:oracle:thin:system/manager@IP:1521:SID";
         Class.forName ("oracle.jdbc.driver.OracleDriver");
         try
         con=DriverManager.getConnection(url);
              st = con.createStatement ();
              doexample ();
              st.close ();
              con.close ();
         }catch(SQLException e)
              System.err.println(e.getMessage());
         public void doexample () throws SQLException
         ResultSet rs = st.executeQuery("select * from sales");
              if(rs!=null) {
              while(rs.next())
                   int a = rs.getInt("no");                    System.out.println("NO = "+a);
              rs.close();
         public static void main (String args[])
              System.out.println ("Oracle Exercise 1 \n");
              try
                   viewtable test = new viewtable(args);
              } catch (Exception ex)
                   System.err.println ("Exception caught.\n"+ex);
                   ex.printStackTrace ();
    the above is the full code, please check the problem....many thanks

  • Throws Exception - a newcomer...

    I have written a small amount of code that takes information from a text file and displays it in a GUI (swing) - this is called my RasterDisplay class. However, I am now creating another part of the GUI which will have a button that makes a new RasterDisplay. However, when I try and call my RasterDisplay constructor from within my actionPerformed method (see below) It tells me I have an "unhandled Exception type Exception". I can't throw Exception in the actionPerformed method so how do I get this method to work? Any help would be greatly appreciated - I am a total newcomer to Java and can't make head nor tail of related topics in all the forums...
    Cheers!
    import javax.swing.*;
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.event.*;
    public class RasterToolbar extends JFrame implements ActionListener{
         JButton open;
         public static void main(String[] args) throws Exception{
              new RasterToolbar();
         //method to make display panel with buttons
         public RasterToolbar()throws Exception{
                   super("Raster Viewer 1.0 beta");
                   setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
                   Container contentPane = getContentPane();
                   JPanel p1 = new JPanel();
                   p1.setLayout(new FlowLayout());
                   p1.setBorder(BorderFactory.createEmptyBorder(4,4,4,4));
                   open = new JButton("Open Viewer");
                   p1.add(open);
                   contentPane.add(p1,BorderLayout.WEST);
                   open.addActionListener(this);
                   pack();
                   setVisible(true);
         public void actionPerformed(ActionEvent ev){
         if(ev.getSource()== open){
              System.out.println("Open pressed");
              RasterDisplay viewer = new RasterDisplay(); // HERE IS THE PROBLEM LINE!
    }

    public void actionPerformed(ActionEvent ev){
         if(ev.getSource()== open){
              System.out.println("Open pressed");
              try {
                   RasterDisplay viewer = new RasterDisplay(); // HERE IS THE PROBLEM LINE!
              } catch(Exception e) {
                   // do what ever you want here!
                   e.printStackTrace();
    }

  • Java.utils.prefs.Preferences API throws exception on Mac, not Windows

    This is a Mac-specific problem. Is it a bug, or am I misusing the java.utils.prefs.Preferences API?
    The Preferences flush() API call always throws a BackingStoreException if a system tree preferences root has been read. The system tree has not been modified or written to, but the flush() call is nevertheless throwing an exception. This occurs when running as a normal user without the ability to write to /Library/Preferences.
    See sample code below. Note that I only want to read the system prefs tree. The user tree write flush fails. If the system tree node is not created, the user flush() succeeds.
    Steps to Reproduce
    Delete any existing Java prefs files:
    ~/Library/Preferences/com.apple.java.util.prefs.plist
    ~/Library/Preferences/com.mycompany.prefstest
    /Library/Preferences/com.apple.java.util.prefs.plist
    /Library/Preferences/com.mycompany.prefstest
    Run the following Java code:
    package com.mycompany.prefstest;
    import java.util.prefs.BackingStoreException;
    import java.util.prefs.Preferences;
    public class PrefsTest {
          * @param args
         public static void main(String[] args) {
              String strKey1 = "com/mycompany/prefstest/one/two/three/four/key1";
              Preferences systemRoot = Preferences.systemRoot();
              Preferences userRoot = Preferences.userRoot();
              // Get a value for user prefs.
              String value1 = userRoot.get(strKey1, "missing");
              // Fall back to system prefs if it is not defined.
              if (value1.equals("missing"))
                   value1 = systemRoot.get(strKey1, "missing");
              System.out.println("key1 --> " + value1);
              // If still not defined, set a user-specific value
              if (value1.equals("missing"))
                   userRoot.put(strKey1, "value1");
                   try {
                        userRoot.flush();
                        System.out.println("flushed prefs successfully");
                   catch (BackingStoreException e)
                        System.out.println("Exception: " + e.toString());
    Expected Results
    Should produce the output:
    key --> missing
    flushed prefs successfully
    Actual Results
    Console output is
    key --> missing
    Exception: java.util.prefs.BackingStoreException: Synchronization failed for node '/'
    Notes
    $ java -version
    java version "1.6.0_29"
    Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11D50b)
    Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)
    also tested with:
    java version "1.7.0_04-ea"
    Java(TM) SE Runtime Environment (build 1.7.0_04-ea-b16)
    Java HotSpot(TM) 64-Bit Server VM (build 23.0-b17, mixed mode)
    Mac OS X 10.7.3.
    The "Expected Results" are correctly obtained running the same code on MS-Windows.
    Running the jar as sudo works (with write access to /Library/Preferences), as expected.

    Just for fun, try a key without slashes in it (but for example dots if you must use such a long key).
    I say that because a quick Google search points out that Apple stores the preferences in a file hierarchy in the user home folder. I can already see how using keys which look like a file path are going to cause nuclear reactors to meltdown...

  • Java Does Not Throw Exception When Writing To Read-Only Files

    I have noticed that when I try to write to a read-only file in a window environment, Java does not throw an IOExcpetion, it just dosn't write to the file.
    I am writing an FTP server and here is the code:
         public static long copyStream(InputStream in, OutputStream out)throws IOException
              IOException exception = null;
              long copied = 0;
              try
                   byte buffer[] = new byte[1024];
                   int read;
                   while((read = in.read(buffer)) != -1)
                        out.write(buffer, 0, read);
                        copied += read;
              catch(IOException e)
                   //ensures that the streams are closed.
                   exception = e;
              try
                   in.close();//ensures output stream gets closed, even if there is an
                   //excption here.
              catch(IOException e){exception = e;}
              out.close();//try to close output.
              if(exception != null)
                   //exception is not null, an exception has occured.
                   //rethrow exception.
                   throw exception;
              return copied;//all ok, return bytes copied.
         }Is this a bug in JAVA VM? Is so, how should I report it?

    I have noticed that when I try to write to a read-only file in a window environment,
    Java does not throw an IOExcpetion, it just dosn't write to the file.C:\source\java\Markov>attrib readonly.out
    A R C:\source\java\Markov\readonly.out
    �C:\source\java\Markov>java b
    java.io.FileNotFoundException: readonly.out (Access is denied)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(Unknown Source)
    at java.io.FileOutputStream.<init>(Unknown Source)
    at b.main(b.java:5)
    import java.io.*;
    public class b {
        public static void main(String[] args) {
         try     {
              OutputStream os = new FileOutputStream ( "readonly.out");
         catch (Exception e) {
              e.printStackTrace();
    }

  • Core dump on throwing exception

    Hi,
    I am using an exception class derived from C++ standard exception class (MyException). In this, I am having a member variable of type std::string. I am using this in a DLL that is being used by Java application using JNI.
    In my C++ code, I am catching exception following way:
    catch(XException& exp)
    catch(MyException& exp)
    catch(exception& exp)
    If I am using std::string as member in MyException class, it results in a coredump whatever exception is thrown (MyException or any other unknown exception supposed to be caught in the standard exception class.). Note that this happens in release build of my dll and never repeatable in debug build.
    This problem occurs only in Solaris (tested both in Solaris 7 and Solaris 8). It does not occur in Windows.
    Now, if I use char array instead of std::string the problem does not occur!!!! Exceptions are caught properly.
    If anyone can throw more light on why usage of std::string causes issues in exception handling in Solaris using CC 5.0 compiler, it shall be of help. I feel problem might be due to not updating the patches related to CC 5.0 exception handling. Also, is it a good practise to use std::string in exception handling classes?

    C++ 5.0 is very old and is no longer supported. Patches are still available for it, however. You should get the latest patches from
    http://access1.sun.com/sundev
    and see if that solves your problem. If not, you should upgrade to a supported compiler release.
    The standard string class can perfrom dynamic memory allocation and can throw exceptions. It's not ideal for use in exception handling for those reasons. But for ordinary situations when you are not out of memory it' s probably OK.

  • Advanced Datagrid GroupingCollection of flat data (XMLLISTCollection) while sorting throws exception

    HI,
         Iam using AdvancedDatagrid inorder to group the flat data populated from the backend through BlazeDS. Result data will be in xml format and i have converted it to xmllistcollection and assigned to the grouping collection source. Flat data is grouped by one of the attribute called 'Name' and refreshed after data has been populated.
    Data structre used as input is: WIth this structure, iam grouping by the field 'Name'.
      <Report> <att_report>
      <id>FDR1</id>
      <Name>Feeder 1</Name>
      <frequency>Monthly</frequency>
      <Field>Finance 1</Field>
      <Aug_10>100</Aug_10>
      <Jul_10>200</Jul_10>
    </att_report>
    <att_report>
      <id>FDR1</id>
      <Name>Feeder 1</Name>
      <frequency>Yearly</frequency>
      <Field>Finance 2</Field>
      <Jul_10>200</Jul_10>
    </att_report>
    <att_report>
      <id>FDR2</id>
      <Name>Feeder 2</Name>
      <frequency>Quarterly</frequency>
      <Field>Finance 3</Field>
      <Jul_10>2000</Jul_10>
    </att_report>
    <att_report>
      <id>FDR2</id>
      <Name>Feeder 2</Name>
      <frequency>MOnthly</frequency>
      <Field>Finance 2</Field>
      <Jul_10>2000</Jul_10>
    </att_report>
    <att_report>
      <id>FDR4</id>
      <Name>Feeder 4</Name>
      <frequency>yearly</frequency>
      <Field>Finance 5</Field>
      <Jul_10>2000</Jul_10>
    </att_report>
    </Report>
    Grouping is done as expected. We have additional functionalities like soring / seraching of the result set. Either one is working fine. Other functionality throws excpetion mentioned below.
    When any of the advanced datagrid grid column header is clicked for sorting, it throws exception. I have pasted the exception below for reference.
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at mx.collections::HierarchicalCollectionView/internalRefresh()[C:\work\flex\dmv_automation\ projects\datavisualisation\src\mx\collections\HierarchicalCollectionView.as:709]
    at mx.collections::HierarchicalCollectionView/refresh()[C:\work\flex\dmv_automation\projects \datavisualisation\src\mx\collections\HierarchicalCollectionView.as:686]
    at mx.controls::AdvancedDataGridBaseEx/sortHandler()[C:\work\flex\dmv_automation\projects\da tavisualisation\src\mx\controls\AdvancedDataGridBaseEx.as:6869]
    at mx.controls::AdvancedDataGrid/sortHandler()[C:\work\flex\dmv_automation\projects\datavisu alisation\src\mx\controls\AdvancedDataGrid.as:6899]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.core::UIComponent/dispatchEvent()
    at mx.controls::AdvancedDataGrid/headerReleaseHandler()[C:\work\flex\dmv_automation\projects \datavisualisation\src\mx\controls\AdvancedDataGrid.as:7120]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.core::UIComponent/dispatchEvent()
    at mx.controls::AdvancedDataGridBaseEx/mouseUpHandler()[C:\work\flex\dmv_automation\projects \datavisualisation\src\mx\controls\AdvancedDataGridBaseEx.as:5738]
    at mx.controls::AdvancedDataGrid/mouseUpHandler()[C:\work\flex\dmv_automation\projects\datav isualisation\src\mx\controls\AdvancedDataGrid.as:8457]
    I tried with couple of options but still not able to get rid of the excpetion. I browsed through couple of links also, still not able to find an solution. Can i know whether it is a bug or it can be fixed.
    Any help / suggestions on this will be great.
    Thanks in Advance,
    Srinivasan

    Read the error messages and pay attention to the line number of the error:
    1)1 import java.io.*;
    2
    3 public class Test
    4 {
    5   public static void openFile()
    6   {
    7     FileOutputStream f = new FileOutputStream("data.txt");
    8   }
    9
    10   public static void main (String[] args)
    11   {
    12     openFile();
    13   }
    14 }
    $ javac -cp "" Test.java
    Test.java:7: unreported exception java.io.FileNotFoundException; must be caught or declared to be thrown
        FileOutputStream f = new FileOutputStream("data.txt");
                             ^
    1 error2)1 import java.io.*;
    2
    3 public class Test
    4 {
    5   public static void openFile() throws FileNotFoundException
    6   {
    7     FileOutputStream f = new FileOutputStream("data.txt");
    8   }
    9
    10   public static void main (String[] args)
    11   {
    12     openFile();
    13   }
    14 }
    $ javac -cp "" Test.java
    Test.java:12: unreported exception java.io.FileNotFoundException; must be caught or declared to be thrown
        openFile();
                ^
    1 error3)
    1 import java.io.*;
    2
    3 public class Test
    4 {
    5   public static void openFile() throws FileNotFoundException
    6   {
    7     FileOutputStream f = new FileOutputStream("data.txt");
    8   }
    9
    10   public static void main (String[] args)
    11   {
    12     try
    13     {
    14       openFile();
    15     }
    16     catch(FileNotFoundException e)
    17     {
    18       System.out.println("Error file doesn't exist.");
    19     }
    20   }
    21 }
    $ javac -cp "" Test.java
    $
    1 import java.io.*;
    2
    3 public class Test
    4 {
    5   public static void openFile() throws FileNotFoundException
    6   {
    7     FileOutputStream f = new FileOutputStream("data.txt");
    8   }
    9
    10   public static void main (String[] args) throws FileNotFoundException
    11   {
    12     openFile();
    13   }
    14 }
    $ javac -cp "" Test.java
    $

  • Print out meaningful exception messages

    Hi There,
    I have sucessfully imported java classes to forms. Java talks to webservices.
    the CLient java that talks to forms throws Exception
    public class ANB {
    public static String ANB(java.lang.String b) throws Exception{
    ............code..................
    return a;
    private static String a = "";
    In the forms I have
    call ANB
    WHEN Ora_java.Java_error THEN
    Message ('Unable to call out to Java, ' || Ora_java.Last_error);
    WHEN Ora_java.Exception_thrown THEN
    Raisedexception := Ora_java.Last_exception;
    Message (Exception_.Getmessage_347 (Raisedexception));
    Ora_java.Clear_exception;******************************
    With the code written above, if an error occurs then error message displayed is as follows:
    java.sql.SQLException: ORA-21111:
    ORA-06512: at "ABCD.TestTable_BIUR", line 6
    ORA-04088: error during execution of trigger 'ABCD.TestTable_BIUR'
    ORA-06512: at line 1............
    I want the error message displayed, to be meaningful to the user. Say for example,
    if an user defined Exception ORA-21111 was raised , i want only the error message associated with the error code to be shown.
    Thanks

    Yes this seems a good idea. I recommend you do that.
    Please next time ask an actual question. I suspect the answer to your unasked question is to look at using methods like getVendorCode or getSQLState of java.sql.SQLException.

  • Can't throw exception inside try block!

    Hi,
    I'm having a problem trying to throw an error inside a try block.
    To illustrate:
    public class TestException {
    public TestException() {
    try {
    int ret = foo();
    System.out.println("ret is " + ret);
    } catch (Exception ex) {
    System.out.println("exception caught");
    public int foo() throws Exception {
    int ret = 0;
    try {
    throw new Exception("test exception");
    } finally {
    return ret;
    public static void main(String[] args) {
    new TestException();
    If I run this the only output is "ret is 0" - I do not catch the thrown exception! What am I doing wrong?
    Any and all help will be very gratefully received.
    Thanks.

    I need to correct myself: I've re-read the spec, and actually the behaviour is conformant with the JLS: JLS says that the return statement completes abruptly, and an abrupt return in a finally block that didn't have a (applicable or any) catch block will result in the original exception being 'forgotten'.
    Very unintuitive, but as-spec'ed

  • Task.cancel() throw exception

    Hi,
    I'm new to JavaFx and recently try out example on javafx.concurrent.Task:
    Example is from a book:
    The following is the model class
    private static class Model {
            public Worker<String> worker;
            public AtomicBoolean shouldThrow = new AtomicBoolean(false);
            private Model() {
                worker = new Task<String>() {
                    @Override
                    protected String call() throws Exception {                   
                        updateTitle("Example Task");
                        updateMessage("Starting...");
                        final int total = 250;
                        updateProgress(0, total);
                        for (int i = 1; i <= total; i++) {
                            try {
                                Thread.sleep(20);
                            } catch (InterruptedException e) {
                                if (isCancelled()) //I modified this part to check for isCancelled()
                                    return "Cancelled at " + System.currentTimeMillis();
                            if (shouldThrow.get()) {
                                throw new RuntimeException("Exception thrown at " + System.currentTimeMillis());
                            updateTitle("Example Task (" + i + ")");
                            updateMessage("Processed " + i + " of " + total + " items.");
                            updateProgress(i, total);
                        return "Completed at " + System.currentTimeMillis();
        }On JavaFx, it has 2 Label that are bind to Worker.value and Worker.exception as shown below:
    value.textProperty().bind(
                    model.worker.valueProperty());
                exception.textProperty().bind(new StringBinding() {
                        super.bind(model.worker.exceptionProperty());
                    @Override
                    protected String computeValue() {
                        final Throwable exception = model.worker.getException();
                        if (exception == null) return "";
                        return exception.getMessage();
                });Next: There are 3 buttons "Start", "Cancel" and "Exception". Following is the method to hook up events to all three buttons:
    private void hookupEvents() {
            view.startButton.setOnAction(new EventHandler<ActionEvent>() {
                @Override
                public void handle(ActionEvent actionEvent) {
                    new Thread((Runnable) model.worker).start();
            view.cancelButton.setOnAction(new EventHandler<ActionEvent>() {
                @Override
                public void handle(ActionEvent actionEvent) {
                    model.worker.cancel();
            view.exceptionButton.setOnAction(new EventHandler<ActionEvent>() {
                @Override
                public void handle(ActionEvent actionEvent) {
                    model.shouldThrow.getAndSet(true);
        }Now, first test is when Task is successfully executed. Value label will be filled with the return value i.e: Completed at ......................
    Second is throw exception and the result is as what in the book, the exception label is filled with the exception property. i.e. Exception thrown at ..................
    But when I test the Cancel button, it throws and exception instead of return a String value.
    The exception label is filled with:
    "Task must only be used from the FX Application Thread"
    Instead of having Value label filled with: "Cancelled at .................."
    Can anybody help me please?
    Regards,
    Henri

    i got the same problem and I'm interested in an answer too.
    My Workaround was to have a secon AtomicBoolean-Var
    public AtomicBoolean cancel = new AtomicBoolean(false);
    if (cancel.get()) {
        return "Cancelled at " + System.currentTimeMillis();
    }this code works but it cannot be the answer.

  • WebAuthenticationBroker.AuthenticateAsync throws exception on the desktop

    My code (C# - windows store) uses WebAuthenticationBroker.AuthenticateAsync().
    This method used to work on the desktop until last week, but now it throws exception
    "The process terminated unexpectedly. (Exception from HRESULT: 0x8007042B)"
    The code was not changed and the same code that does not work on the PC, does work on the tablet (Surface).
    The same code can be found in https://github.com/facebook-csharp-sdk/facebook-windows8-sample
    and also at this sample it throws the same exception.
    How can I solve this issue?
    Ronit

    I know it's been a while since the original question was asked, but I've not seen any solutions published for this issue yet. I
    recently faced the same issue. It turned out to be misconfigured permissions on the Internet Explorer's Temporary Internet Files folder. If you have changed that location from default to some custom, please make sure that your account has Full Access permission
    to this folder. I had Administrators group having full access, and my account was a part of administrators group. It worked in normal browsing scenarios, but Windows apps run in a sandbox with stripped permissions, i.e. they don't get permissions granted to
    Admins. Wininet running in the app process was not able to clean up state before starting authentication.

Maybe you are looking for

  • Where is the movie template in GB 10.0.3?

    Need to add music to a preexisting, pre shot movie. The video tutorials show an older version of GB, where the movie template appears in create a new project. Can not find that template on 10.0.3 version. All I found was movie under tracks. Is that t

  • How to get another page item value in page process.

    Hi all i have an after submit process on page 32 to insert into a table. and a page 34 where there is a region containing from page 32. when page 32 get submitted (process as well as) it contain no value for :P34_USER_ID although i am in page 34 and

  • Best option for file storage

    I want to archive some of my CAD files and other files on a 'by year' basis. Is a flash drive a good option? They seem neat but then again they are a bit small & could get lost. Any ideas on the best option these days?

  • Tnsping Test in BI 7.0

    Hi,   I recently established a DB Connect with a Oracle Database to BW. Now i want to check the Database connection from BW How can i do a TNSPING test in BW to check the connection Thanks

  • Cannot find the tab option on Safari

    I want to have the option to just click on a new tab anytime, however the option is not there for me to do so, how do i get to it? I went to edit>preferences>tabs but the option is not there. Whenever i want a new tab i have to click on an existing l