XmlEncoder & transient

Hi All, a question regarding the use of transient when serialising to xml using the XMLEncoder class. I'm serialising a graph of java objects contained in a vector to xml, in some of the classes I have member variables I don't want serialised so I mark them transient. However, these are still being serialised, the only way I can seem to prevent this is to remove their getters & setters. Is there some bug regarding the use of transient with the Encoder or is it not intended to be used by it in the first place?
At the moment, if I have member variable's that need their getters & setters but I don't want serialised, I have to reset them when I deserialise the xml, otherwise I just remove the getters & setters in the first place. Not a very elegant solution though, precisely the reason transient is there in the first place I think. Any suggestions as to why the serialisation seems to ignore transient are welcome.
Thanks in advance
Damien

Transient only works for the "normal" serialisation. If you want the XMLSerializer to ignore some variables, use a static block in the class declaring them so.
public class TestBean {
     private int eins;
     private int zwei;
     private transient int drei;     
     public TestBean(){
     public TestBean(int eins, int zwei, int drei){
          this.eins=eins;
          this.zwei=zwei;
     this.drei=drei;
     /* ... getters and setters ... */
     static{
          try{
     BeanInfo info = Introspector.getBeanInfo(TestBean.class);
     PropertyDescriptor[] propertyDescriptors = info.getPropertyDescriptors();
     for (int i = 0; i < propertyDescriptors.length; ++i) {
          PropertyDescriptor pd = propertyDescriptors;
          if (pd.getName().equals("drei")) {
               pd.setValue("transient", Boolean.TRUE);
} catch (IntrospectionException e) {

Similar Messages

  • Java 5 Enums serialization with XMLEncoder...

    Hello,
    I'd like to know why a bean attribute whose type is a Java 5 enum is
    not saved when using XMLEncoder. This field is in fact ignored...
    Anybody knows how to persist such fields using standard JDK (I mean
    no third party library) ?
    public enum TestBeanEnum {
        R160x100,
        R320x200,
        R640x480,
        R800x600,
        R1024x768,
        R1280x1024,
        R1600x1200;
    public class Setup {
        private TestBeanEnum a0;
        private boolean a1;
        public Setup() {
        public boolean isA1() {
            return a1;
        public void setA1(boolean a1) {
            this.a1 = a1;
        public TestBeanEnum getA0() {
            return a0;
        public void setA0(TestBeanEnum a0) {
            this.a0 = a0;
        private static void save(Setup setup, File file) throws IOException {
            FileOutputStream out = new FileOutputStream(file);
            XMLEncoder encoder = new XMLEncoder(out);
            encoder.writeObject(setup);
            encoder.close();
            out.close();           
    ...Only the attribute a0 is not saved all over, even relatively complex data
    types are automatically persisted.
    I also find a strange behavior, the keyword "transient" seems to be ignored
    by the XMLEncoder and a transient field is made persistent !!!
    Did I miss something ? Is this strange behavior a bug ?
    Thanks for all,
    David Crosson.

    looks like a bug to me
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5015403

  • XMLEncoder runtime problem

    I'm trying to use XMLEncode for the first time.
    I have a simple class TextPanel which extends JTextPane. It overrides the paint() method and adds a setRotation() and getRotation() method. The few member variables all have get/set methods.
    When I apply encoder.writeObject() to an instance of TextPanel I get this message:
    java.lang.IllegalAccessException: Class sun.reflect.misc.Trampoline
    can not access a member of class TextPanel with modifiers ""
    Continuing ...
    java.lang.Exception: XMLEncoder: discarding statement XMLEncoder.writeObject(TextPanel);
    Continuing ...Can anyone give me any clues regarding what this message means? It seems to be telling me I don't have the necessary get/set methods, but I do.
    Thanks for any help.
    --gary                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    That's what it seems to be saying, but all the methods are public, and all correctly named.
    Just to see what would happen, I marked every single variable (there are only three of them) as "transient". It still tells me the same thing even though there are no variables left that need to be serialized.

  • Previewing Transients in Loops?

    Hi there,
    I've got two questions regarding transients in Apple Loops.
    If I create an Apple Loop from an audio sample I have, the transients differ in the Logic Sample Editor to how they are when I open the loop in Apple Loops Util.
    For example, let's say I've 'rhythmically' sliced a drum loop with a transient at each hit, when I open it in Apple Loops Util, the transients just show at regular intervals as selected in the toolbar (1/4s, 8ths, 16ths, etc etc). Is there a way to keep the transients from the Sample Editor?
    Also, when working with transients in the Apple Loops Utility, is there a way to preview the audio between transients. Like when you double click a section between transients in the Sample Editor, you can play back just that slice.
    Thanks

    exo wrote:
    Okay, let me try again. I need three loops. Two loops start at the same time one runs fast one runs slow. The slow one is probably independent to the problem. When the second loop is done, it needs to restart and start a third loop that takes less than the second.
    This is all still very vague. You are omitting crucial information.
    Which one is the "second loop". Slow or fast?
    What is the meaning or "probably" in this context?
    Should the first loop continue forever?
    What determines if the second loop is done?
    What does the third loop do during that one second? Is it actually looping many times or is it just executing some code once?
    What should happen after the third loop is done?
    It might be much easier if you could describe your problem from a real-world perspective instead of programming terms.
    What is it suppused to do? What is is controlling? What behavior should the user see?
    Message Edited by altenbach on 04-28-2008 08:32 AM
    LabVIEW Champion . Do more with less code and in less time .

  • How to retrieve the values from a Transient View Object

    Hi Experts,
    I am using Jdevelpoer11.1.1.5.0. I created one Transient view object with attributes EmpId,Salary.
    In Backing Bean i will create rows for that view object and display it in the form of <af:Table> like Empid, Salary and an Update Link.
    Now my problem is i want to update the salary of the particular EmpId. For Example if the EmpId is 100 and salary is 10000 now i want to increase the salary to 20000 and if i click on the update button; i want to retrieve the particular employee details in my backing bean. How can i acheive this?
    Thanks in advance.

    A better approach would be to programmatically populate rows in the <VO>Impl.java by overriding the executeQueryForCollection(0 as specified here -
    http://adfpractice-fedor.blogspot.in/2011/01/adf-bc-programmatically-populated-vo.html
    You can write the logic to update the salary in an AM method then on click of Update or in the getter of Salry field if logic is valid for all fields...

  • Transient persestant memory-begin abort transaction-arraycopynonatomic

    If array defined as transient, then abort doesnt make any sense, chages are not rolled back.(Both for arrayCopy and arraycopyNonAtomic functions)
         public void AtomicNonatomic()
    byte hello[] = {'H','E','L','L','O'};
              byte[] key_buffer = JCSystem.makeTransientByteArray((byte)16, JCSystem.CLEAR_ON_RESET);
              //byte[] key_buffer = new byte[16];
              JCSystem.beginTransaction();
              //Util.arrayCopy(hello, (short)0, key_buffer, (short)0, (short)5);
              Util.arrayCopyNonAtomic(hello,(short)0, key_buffer, (short)0, (short)5);
              for(byte i =0; i<2; i++)
              key_buffer=0; //This types of assigning values are atomic operations, so can be thougth as arrayCopy
              JCSystem.abortTransaction();          
    If array not defined as transient and if arrayCopy is used then abort works
    If array not defined as transient and if arrayCopyNonatomic is used then abort not works
         public void AtomicNonatomic()
              //byte[] key_buffer = JCSystem.makeTransientByteArray((byte)16, JCSystem.CLEAR_ON_RESET);
              byte[] key_buffer = new byte[16];
              JCSystem.beginTransaction();
              //Util.arrayCopy(hello, (short)0, key_buffer, (short)0, (short)5);
              Util.arrayCopyNonAtomic(hello,(short)0, key_buffer, (short)0, (short)5);
              for(byte i =0; i<2; i++)
              key_buffer[i]=0;
              JCSystem.abortTransaction();          
    As a result begin-abort-commit should be used with non-transient arrays and without arrayCopyNonatomic function.
    Edited by: simeranya_00 on Aug 7, 2010 6:51 AM
    Edited by: simeranya_00 on Aug 7, 2010 6:56 AM

    Check out JCRE specification. Therein you will find what is (not) part of a transaction.
    1. All global arrays are not part of a transaction
    2. All transient fields/arrays/keys are not part of a transaction
    3. OwnerPIN object is not part of a transaction
    4. All Java Card API methods are transactional, except arrayCopyNonAtomic and arrayFillNonAtomic
    Lifetime of a transaction
    begin <--> commit
    begin <--> abort < -- rollback
    begin <--> JCRE context (process method exit) < -- abort transaction (done by JCRE) < -- rollback
    begin <--> uncaught exception < -- abort < -- rollback
    begin <--> tear/reset < -- rollback

  • Problem with XMLEncoder for complex java object i

    Hi All.
    My problem with XMLEncoder is it doesnt transfrom java objects without default no arguement constructor. I was able to resolve this in my main java object class, by setting a new persistence delegate, but for other classes that are contained in the main class, they are not being encoded.
    Thanks in advance for your answers

    Better to put this in java forum :-)
    Just check, if this helps.
    http://forum.java.sun.com/thread.jspa?threadID=379614&messageID=1623434

  • Doubt in transient and volatile

    Hi,
    I have doubt in using transient n volatile modifiers
      class Test
          public static final  transient  int i=1;
          public static final  volatile int i=1;  //line 1
    }If i use final n volatile ,having a comp err like
    illegal combination of final and volatile.. line 1..while i dont have any problem with
    final transient
    I didnt understand the reason..Can anyone pls explain?
    Thnx.
    Mysha.

    this is just off the top of my head, so it might not be strictly accurate, but:
    transient has to do with serialization, it means that field won't be serialzed. Of course, for a static final variable, it's I'm not sure, but that could be a redundent modifier, as I'd think the reconstituted class still has whatever it's static final contents are anyway.
    volatile has to do with synchronization and access across threads, and since you can't change a final variable's value once initialized, volatile is contrary to what final is saying. So it's either one or the other.

  • Send E-mail from Oracle (9.2.0.1) : SMTP transient error: 421 Service not a

    I have used Oracle 9i server (9.2.0.1 version) on Windows XP machine(with SP2).I want to send Email from PL/SQL procedure.
    My Question is what sort of configuration needed to perform this activity?
    I have installed IIS (Internet Information Service)
    in my machine, then configure my SMTP mail server
    with a valid email id and password given TCP port 465.
    Later I came to know that to send Email from PL/SQL I have to install Oracle JServer Code. Follow three steps. the steps are
    1. Execute the script as sys "$ORACLE_HOME\javavm\install\initjvm.sql"
    2. Execute the loadjava classfile as
    $ORACLE_HOME\plsql\jlib>loadjava -f -v -r -u sys/**** plsql.jar
    3. Execute the script as sys "$ORACLE_HOME\rdbms\admin\initplsj.sql"
    I sucessfully executed the first step, but for the second step iam not able to locate the plsql.jar file in the specified path.
    So Please tell me if there is any other method to perform this task
    My code is as follows.
    CREATE OR REPLACE PROCEDURE SEND_MAIL (
                                  msg_to varchar2,
                                  msg_subject varchar2,
                                  msg_text varchar2
                                  IS
                                  c utl_smtp.connection;
                                  rc integer;
                                  msg_from varchar2(50) := '[email protected]';
                                  mailhost VARCHAR2(30) := 'mail.google.com';
                             BEGIN
                                  c := utl_smtp.open_connection(mailhost, 465);
                                  utl_smtp.helo(c, mailhost);
                                  utl_smtp.mail(c, msg_from);
                                  utl_smtp.rcpt(c, msg_to);
                                  dbms_output.put_line(' Start Sending data');
                                  utl_smtp.data(c,'From: Oracle Database' || utl_tcp.crlf ||
                                  'To: ' || msg_to || utl_tcp.crlf ||
                                  'Subject: ' || msg_subject ||
                                  utl_tcp.crlf || msg_text);
                                  dbms_output.put_line(' Finish Sending data');
                                  utl_smtp.quit(c);
              EXCEPTION
                   WHEN UTL_SMTP.INVALID_OPERATION THEN
    dbms_output.put_line(' Invalid Operation in Mail attempt using UTL_SMTP.');
                   WHEN UTL_SMTP.TRANSIENT_ERROR THEN
    dbms_output.put_line(' Temporary e-mail issue - try again');
    WHEN UTL_SMTP.PERMANENT_ERROR THEN
    dbms_output.put_line(' Permanent Error Encountered.');
    END;
    Procedure Created.
    SQL> execute prc_send_mail('[email protected]','[email protected]','Good Morning.');
    BEGIN prc_send_mail('[email protected]','[email protected]','Good Morning.'); END;
    ERROR at line 1:
    ORA-29278: SMTP transient error: 421 Service not available
    ORA-06512: at "SYS.UTL_SMTP", line 17
    ORA-06512: at "SYS.UTL_SMTP", line 96
    ORA-06512: at "SYS.UTL_SMTP", line 374
    ORA-06512: at "SCOTT.PRC_SEND_MAIL", line 19
    ORA-29278: SMTP transient error: 421 Service not available
    ORA-06512: at line 1.
    Please tell me how to solve this problem.
    Thank You.

    1) Why did you install an SMTP server locally and then tell your code to try to use the server mail.google.com?
    2) The error you're getting is from mail.google.com indicating that Google isn't running an open SMTP server there. I would be very surprised if Google were running a publicly available SMTP server anywhere since that would be an invitation for spammers.
    Justin

  • How to Use Transient View Objects to Store Session-level Global Variables

    hi
    Please consider section "40.8.5 How to Use Transient View Objects to Store Session-level Global Variables"
    at http://download.oracle.com/docs/cd/E14571_01/web.1111/b31974/bcstatemgmt.htm#ADFFD19610
    Based on this documentation I created the example application
    at http://www.consideringred.com/files/oracle/2010/ProgrammaticalViewObjectAndRollbackApp-v0.01.zip
    It behaves as show in the screencast at http://screencast.com/t/qDvSQCgpvYdd
    Its Application Module has a Transient View Object instance "MyEmployeesContextVOVI", as master for the child View Object instance "EmpInCtxJobVI".
    On rollback the Transient View Object instance keeps its row and attribute values.
    Also when passivation and activation is forced (using jbo.ampool.doampooling=false ) the Transient View Object instance seems to keep its row and attribute values.
    questions:
    - (q1) Why does the expression #{bindings.MyEmployeesContextVOVIIterator.dataControl.transactionDirty} evaluate as true when a Transient View Object instance attribute value is changed (as shown in screencast at http://screencast.com/t/qDvSQCgpvYdd )?
    - (q2) What would be a robust approach to make a Transient View Object instance more self-contained, and manage itself to have only one single row (per instance) at all times (and as such removing the dependency on the Application Module prepareSession() as documented in "5. Create an empty row in the view object when a new user begins using the application module.")?
    many thanks
    Jan Vervecken

    Thanks for your reply Frank.
    q1) Does sample 90 help ? http://blogs.oracle.com/smuenchadf/examples/
    Yes, the sample from Steve Muench does help, "90. Avoiding Dirtying the ADF Model Transaction When Transient Attributes are Set [10.1.3] "
    at http://blogs.oracle.com/smuenchadf/examples/#90
    It does point out a difference in marking transactions dirty by different layers of the framework, "... When any attribute's value is changed through an ADFM binding, the ADFM-layer transaction is marked as dirty. ...".
    This can be illustrate with a small change in the example application
    at http://www.consideringred.com/files/oracle/2010/ProgrammaticalViewObjectAndRollbackApp-v0.02.zip
    It now shows the result of both these expressions on the page ...
    #{bindings.MyEmployeesContextVOVIIterator.dataControl.transactionDirty}
    #{bindings.MyEmployeesContextVOVIIterator.dataControl.dataProvider.transaction.dirty}... where one can be true and the other false respectively.
    See also the screencast at http://screencast.com/t/k8vgNqdKgD
    Similar to the sample from Steve Muench, another modification to the example application introduces MyCustomADFBCDataControl
    at http://www.consideringred.com/files/oracle/2010/ProgrammaticalViewObjectAndRollbackApp-v0.03.zip
    public class MyCustomADFBCDataControl
      extends JUApplication
      @Override
      public void setTransactionModified()
        ApplicationModule vApplicationModule = (ApplicationModule)getDataProvider();
        Transaction vTransaction = vApplicationModule.getTransaction();
        if (vTransaction.isDirty())
          super.setTransactionModified();
    }Resulting in what seems to be more consistent/expected transaction (dirty) information,
    see also the screencast at http://screencast.com/t/756yCs1L1
    Any feedback on why the ADF Model layer is so eager to mark a transaction dirty is always welcome.
    Currently, question (q2) remains.
    regards
    Jan

  • How can i remove services from the transient name service?

    hello all..
    i am using the transient name service and i would like to remove a service if a server goes down...how can i do that?

    hmm the thing is were to put the statement... after the code that makes the server waits for invocations?
             synchronized(sync){
                sync.wait();
             ncRef.unbind(pathEnglishToGreek);
           what happens if the server failed/hw failure/ shutdown the machiene/ ctrl+c or sth else?

  • Aggregate value of a transient field is not updated from cache

    Hello together,
    A view object has a transient field which display the count of records from a view accessor. In the EO for the view object ( of the view accessor) opearations on rows are perfomed from a different view object, this changes are not reflected in the transient field value.
    I know is not very clear,here is sample:
    Woker VO
    -Worker EO
    Worker2Department VO
    -Worker2Department EO
    Department VO
    -Deparment EO
    -workerCount: WorkersCounterViewAccesor.count("WorkerID")
    WorkerCounter VO
    -Worker EO
    -Worker2Department EO
    attribute binding: DepartmentID
    If from Worker2Department records are deleted or inserted, the value of workerCount is not updated.
    I've try to executeQuery on each view object,without success. I've notice that the WorkerCounter VO is having always the same records count after Worker2Department VO is updated.
    If the method getDBTransaction().postChanges() is invoked, then the data is correctly fetched but then there are different other problems, and i would like to avoid using of postChanges().
    My question is: why when rows are inserted/removes into/from a view object the changes are not visibile on different view objects declared for the same entiy object? Or how to make sure that the changes from an entity object are reflected in each view object that are using it?
    Thank you a lot,
    Bogdan

    Hi,
    If you place the 0WBS_ELM_EX  in the ODS ,either in the key field or in the data field , you can find it as a charecteristic in the report and you can drag it into the rows.
    To reflet the changes that you made to the masterdata , you need to run the attribute change run every time you load the data .
    regards,
    haritha

  • How to reference a custom property in a vo transient attribute expr + bug

    Hi all
    I have created a transient attribute with an expression that evaluate null content to replace it by a appropriate text.
    <ViewAttribute
        Name="DescriptionUI"
        IsUpdateable="false"
        IsSelected="false"
        IsPersistent="false"
        PrecisionRule="true"
        Type="java.lang.String"
        ColumnType="VARCHAR2"
        AliasName="VIEW_ATTR"
        SQLType="VARCHAR">
        <TransientExpression><![CDATA[((Description == null) ? 'Pas de description' : Description)]]></TransientExpression>
      </ViewAttribute>I have defined a custom property for that attribute that contains the message text. I was surprised to see that the custom property was not associate with the attribute in the source file. Don't understand where the association is done
        <Properties>
          <CustomProperties>
            <Property
              Name="flex.tree.noLabel"
              ResId="flex.noDescription"/>
          </CustomProperties>
        </Properties>I had some difficulties to use the custom property editor. When creating a new related one by using an existing resource the property column value is not changed and the content 'Property' is generated. Because no relationships exists between attribute and the property, the entry is lost in the table referring custom property list for the attribute when your come back into the view object or if you save an another entry in an another attribute.
    So my first question ? Is the attribute editing part the right part to define custom property pairs if they are not related to attributes ? is it a bug ?
    My second question is : is it possible to evaluate the bundle in the expression (replacing the literal 'Pas de description' by an expression) ? What is the expression to use ? Where it is described to do such things in the help or in the documentation ?
    Thank you

    This is wrong
    ((Label == null) ? {FlexParameterModelBundle['flex.tree.noLabel']} : Label)
    What is the correct syntax to refer to the project model standard bundle in the groovy expression ?
    Thank for the help !

  • Error while creating Transient Attribute in VO

    Hi.,
    I am using jdeveloper 11.1.1.5.,
    I had created a GlAcctYearlyBalEO with corresponding VO., I had created an transient attribute GaybCurrBal with type BigDecimal., While i am trying to create another transient attribute GaybCloseBal with type BigDecimal I am getting an error as
    Invalid identifier found in Attribute Name or Type
    GaybCloseBal

    Hello wilhelm,
    If you copy the attribute name from somewhere make sure that your GaybCloseBal has no spaces at the end.

  • Migration issue on default value for transient attribute in 11.1.2

    Experts,
    I migrated my JDev 11.1.1.5 project to JDev 11.1.2. After successful migration i began to run the project and it ran without issue. In the application however when i clicked on any link or button i get the following exception
    oracle.jbo.JboException: JBO-29000: Unexpected exception caught: java.lang.NullPointerException, msg=Cannot get property 'saleType' on null object
    Caused by: java.lang.NullPointerException: Cannot get property 'saleType' on null object
         at org.codehaus.groovy.runtime.NullObject.getProperty(NullObject.java:56)
         at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:154)
         at org.codehaus.groovy.runtime.callsite.NullCallSite.getProperty(NullCallSite.java:29)
         at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:237)
         at bc4j_com_xxx_portal_model_uiView_SaleVO_SaleTypeTransient_null_gs.run(bc4j_com_xxx_portal_model_uiView_SaleVO_SaleTypeTransient_null_gs.groovy:1)
         at oracle.jbo.ExprEval.internalEvaluateGroovyScript(ExprEval.java:1200)
    In my SaleVO i have a transient attribute whos value is set as
    adf.userSession.userData.saleType == 'ORGANIZATION' ?
                               'LOV_PartyTypeOrg' : 'LOV_PartyType'When i print the value from user session i am getting a value there, so a bit confused about the NPE here.
    Please advice
    Jdev 11.1.2

    Hi,
    this is something you should report to customer support to have them looking at this and helping you out
    Frank

Maybe you are looking for

  • Swap hardware to get iPhone 4?

    I have a 3GS and I am not eligible to upgrade until 4/11 (I just checked with AT&T). My wife does not have a contract with AT&T and was thinking of getting an iPhone. Would it be possible for her to buy the iPhone 4 as a new customer, then swap hardw

  • Command Similar to "IN LIKE"

    select * from emp where deptno in like ('10%','20%') i need similar command to perform the above sql. i cannot give or comman as no of departments inside the in like clause is dynamic.. Pls Help Thanks Vinoth Edited by: suzvino on Dec 26, 2011 2:40 P

  • Error "Please contact itunes support to complete this transaction" when in-app purchases

    Dear Sirs, As frequent customer buying iTunes Gift Card, I would appreciate your kind clarification on below points, for my best reference: - I'm using Apple ID Canada and playing a game (i.e. Clash of Clans from http://www.supercell.net) which ident

  • KSPI - Price calculation returns error depending on which periods you plan

    Hi guys, I wanted to share this with you to see if this is a 'Bug', or if it's just the way I'm doing it. Here is step by step of what I did. 1) Created activity-independant cost planning for cost center # 3000 (KP06), for $10,000. It's broken up int

  • Reversing Payroll Posting

    Dear Friends Assuming that an employee is resigning  on 25th May 2008, we did the full and final settlement for this employee.  Now the problem is he withdrawn the offer.  We have done the payroll posting last month for all the employee including thi