XMLEncoder problem

Hi all!!
when i was using XMLEncoder class for serializing some objects in a xml file using Jrun4 application server, it is creating the file(xml) in bin folder.But i need to have a xml file to have in webapp folder...
please guide me on this......

Just use the standard Java 1.4 API to serialize your object. And explicitaly state the destination file:
     * Serialize a Java object to XML. All attributes that have getter and
     * setter methods will be serialized to elements.
     * @param serializable Java object that implements Serializable.
     * @param outputStream Output stream to write XML to.
    static public void serialize(Serializable serializable, OutputStream outputStream) throws Exception {
        //todo: accept vector of serializables ...
        if (outputStream != null) {
            XMLEncoder encoder = new XMLEncoder(outputStream);
            encoder.writeObject(serializable);
            encoder.close();
    }//serialize()e.g. serialize(myObject, new FileOutputStream(new File("c:\whatever\webapp\myObject.xml")))

Similar Messages

  • XMLEncoder problems

    Hi all
    I am using the XMLEncoder to encode a simple JComponent
    JButton jButton = new JButton("Hello, world");
    It seems to encode ok if I write it to a file, but I need to send it over the nework using Axis as a String, so I write it to a ByteArrayOutputStream :
    baos = new ByteArrayOutputStream( BUFSIZ );
    and toString the buffer to get a String Object.
    When I decode the String I get this
    java.io.UTFDataFormatException: invalid byte 1 of 1-byte UTF-8 sequence (0xac)
    Continuing ...
    13/05/2003 11:15:05,927 [main     ] ERROR VModStaticFx.encode: exception, java.util.NoSuchElementException
    E
    Time: 62.049
    There was 1 error:
    1) testEncodeXml(com.viewdu.gen.test.XmlEncoderTest)java.lang.NullPointerException
         at com.viewdu.gen.test.XmlEncoderTest.testEncodeXml(XmlEncoderTest.java:91)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at com.intellij.rt.execution.junit.TextTestRunner.main(TextTestRunner.java:12)
    FAILURES!!!
    Tests run: 1, Failures: 0, Errors: 1
    I read in the String
    byte [] objectBytes = encodedObject.getBytes();
    // create the streams
    bais = new ByteArrayInputStream( objectBytes );
    e = new XMLDecoder(bais);
    obj = e.readObject();
    This is not going across the network it is all being run from a unit test, locally.
    If you have any experience with the proccess of encoding and decoding Swing Objects using the XMLEncoder and XMLDecoder, I would greatly appreciate a response.

    Hello.
    It seems to encode ok if I write it to a file, but I need to send it
    over the nework using Axis as a String, so I write it to a
    ByteArrayOutputStream :First, you can send it like a byte array with AXIS.
    baos = new ByteArrayOutputStream( BUFSIZ );
    and toString the buffer to get a String Object.Second, try to use the ByteArrayOutputStream method toString(String enc).
    baos.toString("UTF8");

  • 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

  • XMLEncoder stackoverflow problem with custom classloader

    Hi, All
    I'm tring encoding my object using XMLEncoder, the objects are from the custom classloader like URLClassLoader which is importing several jar files at run-time.
    source code is like this:
    XMLEncoder e = new XMLEncoder(new BufferedOutputStream(os));
    e.writeObject( sourceObj);
    When I run it, I experienced this error:
    XMLEncoder has "ClassNotFoundException" or "InstantiationException" problem.
    so I found very similar posting for this problem and modified it so that the XMLEncoder can find my classes from custom classloader:
    ClassLoader cl = this.getClass().getClassLoader();
    URLClassLoader urlClassLoader = new URLClassLoader(urls, cl);
    Thread.currentThread().setContextClassLoader(urlClassLoader);
    XMLEncoder e = new XMLEncoder(new BufferedOutputStream(os));
    e.writeObject( sourceObj);
    The result was slightly changed. However, still disappointing:
    java.lang.StackOverflowError
         at java.lang.Class.getMethod0(Class.java:1734)
         at java.lang.Class.getMethod(Class.java:951)
         at java.beans.Statement.findPublicMethod(Statement.java:230)
         at java.beans.Statement.findMethod(Statement.java:270)
         at java.beans.Statement.getMethod(Statement.java:366)
         at java.beans.Statement.invoke(Statement.java:439)
         at java.beans.Expression.getValue(Expression.java:101)
         at java.beans.Encoder.getValue(Encoder.java:84)
         at java.beans.Encoder.get(Encoder.java:186)
         at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:97)
         at java.beans.Encoder.writeObject(Encoder.java:55)
         at java.beans.XMLEncoder.writeObject(XMLEncoder.java:250)
         at java.beans.Encoder.writeExpression(Encoder.java:260)
         at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:351)
         at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:100)
         at java.beans.Encoder.writeObject(Encoder.java:55)
         at java.beans.XMLEncoder.writeObject(XMLEncoder.java:250)
         at java.beans.Encoder.writeExpression(Encoder.java:260)
         at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:351)
         at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:100)
         at java.beans.Encoder.writeObject(Encoder.java:55)
         at java.beans.XMLEncoder.writeObject(XMLEncoder.java:250)
         at java.beans.Encoder.writeExpression(Encoder.java:260)
         at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:351)
         at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:100)
         at java.beans.Encoder.writeObject(Encoder.java:55)
    When I finally include the jar files into the classpath so that the default classloader can reference them, the encoder worked properly.
    Anyone can help me?

    StackOverFlow is quite a gotcha in XMLEncoder it is often because of the following code in java.beans.PersistenceDelegate:
    public void writeObject(Object oldInstance, Encoder out) {
    Object newInstance = out.get(oldInstance);
    if (!mutatesTo(oldInstance, newInstance)) {
    out.remove(oldInstance);
    out.writeExpression(instantiate(oldInstance, out));
    else {
    initialize(oldInstance.getClass(), oldInstance, newInstance, out);
    and the following code in java.beans.DefaultPersistenceDelegate:
    protected boolean mutatesTo(Object oldInstance, Object newInstance) {
    // Assume the instance is either mutable or a singleton
    // if it has a nullary constructor.
    return (constructor.length == 0) || !definesEquals(oldInstance) ?
    super.mutatesTo(oldInstance, newInstance) :
    oldInstance.equals(newInstance);
    What this means is if you have a class (you want to persist) that has a constructor that takes arguments AND defines an equals method AND you have overridden initialize in DefaultPersistenceDelegate to do some extra work after it instantiates newInstance, then while the PersistenceDelegate is trying to generate you newInstance, oldInstance.equals(newInstance) will return false, and PersistenceDelegate will keep trying to instantiate a newInstance that does equal the oldInstance.
    So if you do use DefaultPersistenceDelegate then ensure that you override mutatesTo so that it is:
    protected boolean mutatesTo(Object oldInstance, Object newInstance) {
    return (newInstance != null && oldInstance.getClass() == newInstance.getClass());
    Here is an example PersistenceDelegate that persistence a class called PersistentBeanCollection, it calls its constructor with the property "type" and then calls the method add() on the newInstance.
    new DefaultPersistenceDelegate(new String[]{"type"}) {
    protected void initialize(Class type, Object oldInstance, Object newInstance, Encoder out) {
    PersistentBeanCollection oldBeanCollection = (PersistentBeanCollection) oldInstance;
    for (Iterator iterator = oldBeanCollection.iterator(); iterator.hasNext();) {
    out.writeStatement(new Statement(oldInstance, "add", new Object[]{iterator.next()}));
    protected boolean mutatesTo(Object oldInstance, Object newInstance) {
    return (newInstance != null && oldInstance.getClass() == newInstance.getClass());
    Cheers
    Parwy

  • Serialization using XMLEncoder/XMLDecoder - problems for SpringLayout

    I am using JDK 1.4.0 (obviously, as I have problems with XMLEncoder... :o)
    What I need to do is create a JFrame with some Swing components inside (JPanel's, JLabel's, etc.), to save it as an XML file and be able to restore it later.
    Everything went OK at the beginning, but there came the time to manage the layout part. For various reasons, the most appropriate layout manager for my application is SpringLayout.
    The first step was again OK: when defining a SpringLayout for a panel, this property was transferred to the XML by XMLEncoder and restored by XMLDecoder.
    But then, the happy days are over! In order for a SpringLayout to work, one must obviously define lots of SpringLayout.Constraints, using Spring's. But none of these things are transferred by XMLEncoder to the XML.
    And, quite naturally, even if I modify manually the XML to include some constraint info, the XMLDecoder won't read that info!
    Does anybody know if there is any trick about this? Or is there a known bug concerning the serialization of Spring's, and you know about a workaround?
    Thanks a lot,
    Adrian

    Hi Adrian, there are no persistence delegates defined for SpringLayout and its children.
    I spent quite some time over the last six months trying to get SpringLayouts to save
    correctly - but failed. There are two bugs in the way - both of which should be fixed for
    1.4.1 (I think). One was in SpringLayout - the other in XMLEncoder itself:
    http://developer.java.sun.com/developer/bugParade/bugs/4679556.html
    One thing you said in your note that I thought Id comment on. You can edit the XML file manually
    and this will (probably) lead to a solution. The XMLDecoder is an interpreter - it doesn't need access
    to persistence delegates or require any knowledge of the swing APIs to work.
    Hope that helps.
    Philip

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

  • Problem when use XMLEncoder/XMLDecoder avoid Serilization VersionID change

    I want to save my object in XML format,
    So I use XMLEncoder to write my object,
    And it will do well.
    But when my object has member with type of "java.sql.Date",
    (the date been getted from database).
    The XMLEncode can not save this member.
    What is the reason for it.
    How to solve.
    Thanks in advanced

    According to its documentation, XMLEncoder allows you to save JavaBeans. Unfortunately it doesn't bother to mention what a JavaBean is and doesn't provide a link to any documentation that explains that.
    One feature of a JavaBean is that it has a zero-argument constructor, so that you have a guaranteed way to create an object of that class. But java.sql.Date doesn't have a zero-argument constructor so it isn't a JavaBean. So it can't be saved by XMLEncoder.
    How to solve? Use java.util.Date instead.
    PC²

  • Persisting raw file data using XMLEncoder

    Guys
    I am trying to persist the 'Buffer' object which has a 'fileName' property. I dont want my object to be dependent on the machine containing the file 'fileName'. So I want to persist the data for 'fileName' file when XMLEncoder is used to persist 'Buffer' object. So I extended DefaultPersistenceDelegate. However I get OutOfMemoryError inside the initialize method. It seems that even though I am setting byTmp array to null after out.writeStatement the array byTmp is not garbage collected. Apparently the encoder is holding a reference to the byTmp array. Also note that the file is huge and cannot be loaded into a single byte array completely.
    Can anyone think of a work around for this problem?
    Thanks
    Rahul
    public class Buffer() {
    private String fileName;
    //These methods will be invoked by the XMLDecoder
    public void startWritingBytes(String fileName) {
    //open tmp file for writing
    public void writeBytes(byte[] b) {
    //write to tmp file
    public void doneWritingBytes() {
    //close file.
    //uncompress tmp file and write to file 'fileName'
    public static class BufferPersistenceDelegate extends
    DefaultPersistenceDelegate {
    public UnlimitedBufferPersistenceDelegate() {
    super();
    protected void initialize(Class<? > type, Object oldInstance, Object
    newInstance, Encoder out) {
    // Note, the "fileName" property will be set here.
    super.initialize(type, oldInstance, newInstance, out);
    try {
    //First compress the file.
    //Persist compressed data
    try {
    java.beans.Statement sm = null;
    sm = new java.beans.Statement(oldInstance, "startWritingBytes",
    new Object[] {fileName});
    out.writeStatement(sm);
    byte[] byTmp = null;
    byte b = 0;
    //Get OutOfMemoryError here
    while ( (bytesRead = fin.read(buffer)) > 0) {
    byTmp = new byte[bytesRead];
    System.arraycopy(buffer, 0, byTmp, 0, bytesRead);
    sm = new java.beans.Statement(oldInstance, "writeBytes",
    new Object[] {byTmp});
    out.writeStatement(sm);
    byTmp = null;
    sm = new java.beans.Statement(oldInstance, "doneWritingBytes",
    null);
    out.writeStatement(sm);
    finally {
    //close compressed file
    //delete compressed file
    catch (Throwable ex) {       
    }

    Sorry guys, I think I had the answer to the question in the question itself!!
    I was not freeing the statement object. The problem disappears when I set sm to null.

  • Problem in deserialization with different versions of JDK

    I have problem related to serialization, pls suggest the most appropriate solution, the problem is that I have a class AAAA.java which extends AbstractListModel.java class of JDK, and it is serializable. When i saw the serialVersionUID of AbstractListModel.java using the java tool serialver in jdk 1.3.1 from the command line it gives 2622425607724314306 (Unique ID of class) but when i saw it in JDK 1.4.1 then it given -3285184064379168730. As the UID is changed from JDK1.3.1 to 1.4.1, Now the problem is that i serialized a file which uses AAAA.java using the 1.3.1 and now i want to open that file in my project using 1.4.1 it gives exception.
    java.io.InvalidClassException: javax.swing.AbstractListModel; local class incompatible: stream classdesc serialVersionUID = 2622425607724314306, local class serialVersionUID = -3285184064379168730
    at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:459)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1521)
    Can u suggest me appropriate solution as this file must be desirialized (Compatibility issue) as it is generated from project.
    U may also try using this command in jdk 1.3.1 & 1.4.1
    on command prompt
    serialver javax.swing.AbstractListModel.

    From the API (you already know this, though through experience...)
    Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
    So there seems to be no easy solution (in 1.4 you would use XMLEncoder for persistence with future versions, no possible in 1.3.1). You will probably have to study the serialized code and figure out how to deserialize manually... like find what the header size and format is, how objects' classes and values are labeled etc, then rebuild the object on the receiving end using a datainput stream or something...

  • The Problem in serialization.

    The serialization issue is a trivial one at the moment. However the threat of a version change is imminent considering the next release of JDK 6 "Mustang" may have considerable improvements especially on the Swing side. Therefore, I strongly encourage you to write your own code to persist the tree data into a file. Such a logic is much preferable as it will over-come the issues with serialization.
    The main problem with a version change is that every serializable class uses a special random number stored in a private static field called serialVersionUID. So when the serializable class is serialized, this number is also persisted to the serialized form.
    When the object is de-serialized, the number is also deserialized. Java checks the de-serialized number against the serialVersionUID field of the class and verifies if the two match. If they do, it means that the deserialized data is in the right format of the class. If they differ, a InvalidClassException is thrown. Every new version of the class changes this unique number. Hence an object serialized with an older version of the class will not be allowed to be de-serialized by a new version of that class and vice-versa.
    This mechanism allows developers to version their new releases and ensures that serialization and deserialization operations remain consistent across multiple-versions and prevent invalid state of the object.

    The serialization issue is a trivial one at the moment. However the threat of a version change is imminent considering the next release of JDK 6 "Mustang" may have considerable improvements especially on the Swing side.Don't make statements like this unless you know what you're talking about. Do you know that Sun's JDK release policies prevent them from doing that in the middle of a release? and that they haven't done such a thing in 13 years? Do you have any actual evidence that they are going to change serialVersionUIDs in the middle of a release?
    Therefore, I strongly encourage you to write your own code to persist the tree data into a file.
    I would strongly encourage developers not to use Serialization on Swing objects at all, which curiously enough is what the Javadoc has been saying for ten years. You should use java.beans.XMLEncoder for this. That's what it is for.
    Such a logic is much preferable as it will over-come the issues with serialization.Home-grown code is never preferable to what is provided in the JDK.
    The main problem with a version change is that every serializable class uses a special random number stored in a private static field called serialVersionUID.That's not a 'problem'. That's part of the solution.
    Every new version of the class changes this unique number.Only if you don't declare your own static final long serialVersionUID.
    This mechanism allows developers to version their new releases and ensures that serialization and deserialization operations remain consistent across multiple-versions and prevent invalid state of the object.Exactly. I suggest you read the Versioning section of the Serialization specification before posting again on this topic, and also read up on Long Term Persistence in Java Beans. You have much of this information back to front, and you don't appear to have heard of either defining your own serialVersionUID or Long Term Persistence.
    And your claim that Sun will change serialVersionUIDs in the middle of Java release 6 is just ludicrous.

  • Weblogic 8.1 using JRockit 1.4.2_15 and XMLEncoder on 64-bit Linux

    I am using Weblogic 8.1 sp6 with JRockit 1.4.2_15. When I call XMLEncoder the following exception below is thrown. When I use the Sun JDK, all is fine. We need to use JRockit. It appears that some awt shared library is not found. Further attempts to change the LD_LIBRARY_PATH uncovered some additional information that impilied that s shared library libXp.so was missing or not referred to correctly (possibily in the start up script?). I have tried several attempts to fix this but haven't been able to do so. This works fine under WIndows and on 32-bit Linux. It appears to be something with the 64-bit Linux. Any help would be appreciated.
    javax.transaction.TransactionRolledbackException: EJB Exception: : java.lang.UnsatisfiedLinkError: no awt in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1517)
    at java.lang.Runtime.loadLibrary0(Runtime.java:788)
    at java.lang.System.loadLibrary(System.java:834)
    at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
    at sun.awt.NativeLibLoader.loadLibraries(NativeLibLoader.java:38)
    at sun.awt.DebugHelper.<clinit>(DebugHelper.java:29)
    at java.awt.Component.<clinit>(Component.java:506)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:141)
    at java.beans.DefaultPersistenceDelegate.class$(DefaultPersistenceDelegate.java:83)
    at java.beans.DefaultPersistenceDelegate.initBean(DefaultPersistenceDelegate.java:285)
    at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java:395)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:103)
    at java.beans.Encoder.writeObject(Encoder.java:54)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:249)
    at java.beans.Encoder.writeExpression(Encoder.java:256)
    at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:361)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:100)
    at java.beans.Encoder.writeObject(Encoder.java:54)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:249)
    at java.beans.Encoder.writeExpression(Encoder.java:256)
    at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:361)
    at java.beans.DefaultPersistenceDelegate.doProperty(DefaultPersistenceDelegate.java:219)
    at java.beans.DefaultPersistenceDelegate.initBean(DefaultPersistenceDelegate.java:254)
    at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java:395)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:103)
    at java.beans.Encoder.writeObject(Encoder.java:54)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:249)
    at java.beans.Encoder.writeExpression(Encoder.java:256)
    at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:361)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:100)
    at java.beans.Encoder.writeObject(Encoder.java:54)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:249)
    at java.beans.Encoder.writeObject1(Encoder.java:182)
    at java.beans.Encoder.cloneStatement(Encoder.java:195)
    at java.beans.Encoder.writeStatement(Encoder.java:226)
    at java.beans.XMLEncoder.writeStatement(XMLEncoder.java:324)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:252)
    at fedex.focus.session.ReserveLevelingSessionBean.publishReserveLevelingEvent(ReserveLevelingSessionBean.java:53)
    at fedex.focus.session.ReserveLevelingSession_ncr8js_EOImpl.publishReserveLevelingEvent(ReserveLevelingSession_ncr8js_EOImpl.java:46)
    at fedex.focus.session.TripAssignmentSessionBean.unassign(TripAssignmentSessionBean.java:3814)
    at fedex.focus.session.TripAssignmentSessionBean.unassign(TripAssignmentSessionBean.java:3245)
    at fedex.focus.session.TripAssignmentSessionBean.unassign(TripAssignmentSessionBean.java:3214)
    at fedex.focus.session.TripAssignmentSession_yif9zk_EOImpl.unassign(TripAssignmentSession_yif9zk_EOImpl.java:2012)
    at fedex.focus.session.FocusClientSessionBean.unassign(FocusClientSessionBean.java:2901)
    at fedex.focus.session.FocusClientSessionBean_qkjepy_EOImpl.unassign(FocusClientSessionBean_qkjepy_EOImpl.java:3008)
    at fedex.focus.session.FocusClientSessionBean_qkjepy_EOImpl_WLSkel.invoke(Unknown Source)
    at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:491)
    at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:120)
    at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:434)
    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:429)
    at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:35)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
    ; nested exception is:
    java.lang.UnsatisfiedLinkError: no awt in java.library.path
    at weblogic.ejb20.internal.EJBRuntimeUtils.throwTransactionRolledback(EJBRuntimeUtils.java:202)
    at weblogic.ejb20.internal.BaseEJBHome.handleSystemException(BaseEJBHome.java:326)
    at weblogic.ejb20.internal.BaseEJBObject.postInvoke(BaseEJBObject.java:284)
    at weblogic.ejb20.internal.StatelessEJBObject.postInvoke(StatelessEJBObject.java:168)
    at fedex.focus.session.ReserveLevelingSession_ncr8js_EOImpl.publishReserveLevelingEvent(ReserveLevelingSession_ncr8js_EOImpl.java:56)
    at fedex.focus.session.TripAssignmentSessionBean.unassign(TripAssignmentSessionBean.java:3814)
    at fedex.focus.session.TripAssignmentSessionBean.unassign(TripAssignmentSessionBean.java:3245)
    at fedex.focus.session.TripAssignmentSessionBean.unassign(TripAssignmentSessionBean.java:3214)
    at fedex.focus.session.TripAssignmentSession_yif9zk_EOImpl.unassign(TripAssignmentSession_yif9zk_EOImpl.java:2012)
    at fedex.focus.session.FocusClientSessionBean.unassign(FocusClientSessionBean.java:2901)
    at fedex.focus.session.FocusClientSessionBean_qkjepy_EOImpl.unassign(FocusClientSessionBean_qkjepy_EOImpl.java:3008)
    at fedex.focus.session.FocusClientSessionBean_qkjepy_EOImpl_WLSkel.invoke(Unknown Source)
    at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:491)
    at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:120)
    at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:434)
    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:429)
    at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:35)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
    Caused by: java.lang.UnsatisfiedLinkError: no awt in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1517)
    at java.lang.Runtime.loadLibrary0(Runtime.java:788)
    at java.lang.System.loadLibrary(System.java:834)
    at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
    at sun.awt.NativeLibLoader.loadLibraries(NativeLibLoader.java:38)
    at sun.awt.DebugHelper.<clinit>(DebugHelper.java:29)
    at java.awt.Component.<clinit>(Component.java:506)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:141)
    at java.beans.DefaultPersistenceDelegate.class$(DefaultPersistenceDelegate.java:83)
    at java.beans.DefaultPersistenceDelegate.initBean(DefaultPersistenceDelegate.java:285)
    at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java:395)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:103)
    at java.beans.Encoder.writeObject(Encoder.java:54)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:249)
    at java.beans.Encoder.writeExpression(Encoder.java:256)
    at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:361)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:100)
    at java.beans.Encoder.writeObject(Encoder.java:54)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:249)
    at java.beans.Encoder.writeExpression(Encoder.java:256)
    at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:361)
    at java.beans.DefaultPersistenceDelegate.doProperty(DefaultPersistenceDelegate.java:219)
    at java.beans.DefaultPersistenceDelegate.initBean(DefaultPersistenceDelegate.java:254)
    at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java:395)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:103)
    at java.beans.Encoder.writeObject(Encoder.java:54)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:249)
    at java.beans.Encoder.writeExpression(Encoder.java:256)
    at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:361)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:100)
    at java.beans.Encoder.writeObject(Encoder.java:54)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:249)
    at java.beans.Encoder.writeObject1(Encoder.java:182)
    at java.beans.Encoder.cloneStatement(Encoder.java:195)
    at java.beans.Encoder.writeStatement(Encoder.java:226)
    at java.beans.XMLEncoder.writeStatement(XMLEncoder.java:324)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:252)
    at fedex.focus.session.ReserveLevelingSessionBean.publishReserveLevelingEvent(ReserveLevelingSessionBean.java:53)
    at fedex.focus.session.ReserveLevelingSession_ncr8js_EOImpl.publishReserveLevelingEvent(ReserveLevelingSession_ncr8js_EOImpl.java:46)

    Sounds like a library path problem. Check your LD_LIBRARY_PATH variable, maybe it includes a harcoded path to your Sun JDK installation which overrides whatever JRockit tries to load?
    What Linux and JRockit version are you using?
    Henrik

  • StackOverflowError with XMLEncoder on my objects.

    Works fine when I run the example:
    XMLEncoder e = new XMLEncoder(
    new BufferedOutputStream(
    new FileOutputStream("Test.xml")));
    e.writeObject(new JButton("Hello, world"));
    e.close()
    but when i run my little class I get java.lang.StackOverflowError below.
    Could anyone help? (I'm new to XMLEncoder and relatively new to JavaBeans).
    Thanks in advance.
    Morten
    java.lang.StackOverflowError
    at java.lang.Class.getMethod0(Class.java:1756)
    at java.lang.Class.getMethod(Class.java:963)
    at java.beans.Statement.findPublicMethod(Statement.java:230)
    at java.beans.Statement.findMethod(Statement.java:270)
    at java.beans.Statement.getMethod(Statement.java:366)
    at java.beans.Statement.invoke(Statement.java:439)
    at java.beans.Expression.getValue(Expression.java:101)
    at java.beans.Encoder.getValue(Encoder.java:84)
    at java.beans.Encoder.get(Encoder.java:186)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:97)
    at java.beans.Encoder.writeObject(Encoder.java:55)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:250)
    at java.beans.Encoder.writeExpression(Encoder.java:260)
    at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:363)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:100)
    at java.beans.Encoder.writeObject(Encoder.java:55)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:250)
    at java.beans.Encoder.writeExpression(Encoder.java:260)
    at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:363)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:100)
    at java.beans.Encoder.writeObject(Encoder.java:55)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:250)
    at java.beans.Encoder.writeExpression(Encoder.java:260)
    at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:363)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:100)
    at java.beans.Encoder.writeObject(Encoder.java:55)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:250)
    at java.beans.Encoder.writeExpression(Encoder.java:260)
    at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:363)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:100)
    at java.beans.Encoder.writeObject(Encoder.java:55)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:250)
    at java.beans.Encoder.writeExpression(Encoder.java:260)
    at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:363)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:100)
    at java.beans.Encoder.writeObject(Encoder.java:55)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:250)
    at java.beans.Encoder.writeExpression(Encoder.java:260)
    at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:363)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:100)
    at java.beans.Encoder.writeObject(Encoder.java:55)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:250)
    at java.beans.Encoder.writeExpression(Encoder.java:260)
    at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:363)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:100)
    at java.beans.Encoder.writeObject(Encoder.java:55)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:250)
    at java.beans.Encoder.writeExpression(Encoder.java:260)
    at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:363)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:100)
    ...

    I think the problem here may be that the BeanBox does not
    remove itself as a listener from its components before it
    tries to serialise them. The XMLEncoder works out that the
    JellyBean and co have listeners (because they are derivatives
    of Component - which has a getListeners() method) and will attempt
    to serialise those listeners. I suspect that one of these is
    the BeanBox itself - or a component inside it. If that component
    also knows about the beans it contains there is a possibility
    the archiving process will loop - though somthing odd is happening
    as the XMLEncoder should detect identical instances in the object
    graph and mark them with an "idref" attribute - rather than looping.
    It may be that the BeanBox clones part of itself when certain
    getters are called. (I don't have your code so this is all a
    bit of a guess.)
    Anyway, if you want to look at this sort of thing a better
    place to start is the BeanBuilder which is availible on the
    SwingConnection website. The BeanBox predates all of the
    archiving work - whereas the BeanBuilder was purpose built to
    demonstrate it and the other new features in SDK 1.4.
    Hope that helps.
    Philip

  • XMLEncoding of a custom class

    I'm trying to save game levels as XML code using the XMLEncoder. I've made getters and setters for every attribute and a no-arg constructor, but still some attributes are missing in the XML code. I've spent a LOT of time reading about different XML APIs, without learning anything to help me.
    I've made a TestClass to illustrate the problem:
    public class TestClass {
        private Polygon polygon;
        private Rectangle rectangle;
        public TestClass() {
            polygon = new Polygon();
            rectangle = new Rectangle();
        public Polygon getPolygon() {
            return polygon;
        public void setPolygon(Polygon polygon) {
            this.polygon = polygon;
        public Rectangle getRectangle() {
            return rectangle;
        public void setRectangle(Rectangle rectangle) {
            this.rectangle = rectangle;
    }The code to encode a TestClass object:
    public class XMLProcessor {
        public static void main(String[] args) {
            TestClass tc = new TestClass();
            Polygon p = new Polygon();
            p.addPoint(5, 6);
            p.addPoint(7, 8);
            tc.setPolygon(p);
            Rectangle r = new Rectangle();
            r.setBounds(1, 1, 10, 10);
            tc.setRectangle(r);
            try {
                XMLEncoder e = new XMLEncoder(new FileOutputStream("Test.xml"));
                e.writeObject(tc);
                e.close();
            } catch(Exception e) {
                System.out.println(e);
    }This produces the following XML document:
    <?xml version="1.0" encoding="UTF-8"?>
    <java version="1.5.0_06" class="java.beans.XMLDecoder">
    <object class="xmltest.TestClass">
      <void property="rectangle">
       <object class="java.awt.Rectangle">
        <int>1</int>
        <int>1</int>
        <int>10</int>
        <int>10</int>
       </object>
      </void>
    </object>
    </java>As you can see, the polygon is missing, although it has a set- and get-method. The encoding also works for java.awt.Point, but not for java.awt.Point2D.
    What can I do to fix this?

    Set a PersistenceDelegate?

  • Java.lang.StackOverflowError due to java.beans.XMLEncoder class

    Hello,
    I am using the XMLEncoder class as follows :
    private byte[] serialize(Map decodedBlob) {
    ByteArrayOutputStream bObjOut = new ByteArrayOutputStream();
    if (decodedBlob == null) {
    return null;
    } else {
    try {
    XMLEncoder encode = new XMLEncoder(new GZIPOutputStream(bObjOut));
    encode.writeObject(decodedBlob);
    encode.flush();
    encode.close();
    } catch (Exception e) {
    e.printStackTrace();
    return bObjOut.toByteArray();
    } The object decodedBlob is of type HashMap and further contains other HashMaps and ArrayLists as its values. Including values in all the childs there are more than a 200 variables conatined in this HashMap. I need to call the above serialize method for some 2000 such decodedBlob objects .However when i do run my program it gives me the following error after processing some 168 objects only:
    Exception in thread "main" java.lang.StackOverflowError
    at java.util.Collections$SynchronizedMap.containsKey(Collections.java:1988)
    at java.lang.reflect.Proxy.isProxyClass(Proxy.java:630)
    at java.beans.MetaData.getPersistenceDelegate(MetaData.java:890)
    at java.beans.Encoder.getPersistenceDelegate(Encoder.java:144)
    at java.beans.Encoder.writeObject(Encoder.java:68)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:269)
    at java.beans.Encoder.writeObject1(Encoder.java:201)
    at java.beans.Encoder.cloneStatement(Encoder.java:209)
    at java.beans.Encoder.writeExpression(Encoder.java:273)
    at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:384)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:112)
    at java.beans.Encoder.writeObject(Encoder.java:69)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:269)
    at java.beans.Encoder.writeObject1(Encoder.java:201)
    at java.beans.Encoder.cloneStatement(Encoder.java:209)
    at java.beans.Encoder.writeExpression(Encoder.java:273)
    at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:384)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:112)
    at java.beans.Encoder.writeObject(Encoder.java:69)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:269)
    at java.beans.Encoder.writeObject1(Encoder.java:201)
    at java.beans.Encoder.cloneStatement(Encoder.java:209)
    at java.beans.Encoder.writeExpression(Encoder.java:273)
    at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:384)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:112)
    at java.beans.Encoder.writeObject(Encoder.java:69)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:269)
    at java.beans.Encoder.writeObject1(Encoder.java:201)
    at java.beans.Encoder.cloneStatement(Encoder.java:209)
    at java.beans.Encoder.writeExpression(Encoder.java:273)As can be seen the following lines keep repeating in the error:
    at java.beans.Encoder.writeObject(Encoder.java:68)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:269)
    at java.beans.Encoder.writeObject1(Encoder.java:201)
    at java.beans.Encoder.cloneStatement(Encoder.java:209)
    at java.beans.Encoder.writeExpression(Encoder.java:273)
    at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:384)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:112)I have seen the other posts regarding the same on the forum but even overriding the mutatesTo as described there doesnt help.
    I have also tried increasing the heap size but that also doesnt seem to solve the problem.
    Please please help me sort this problem out. Thanks in advance

    hey ... i just found a way out .... when i upgraded to version 6 the error simply vanished ... seems there was a bug in d previous version for the XMLEncoder class. Thanks anyway.
    So for all the others who are facing similar problem try running the code with jre 1.6 too and see if it solves your problem

  • Using XMLEncoder in Applet causes securityexception

    I've written a simple Applet which should be able to XMLEncode a bean and write the XML-code to the standard output. (later it should be expanded to place various beans on a panel and write the XML to the server the applet is placed on, to be able to retrieve it later for further editing, but which is not the point right now)
    The problem is when I run it in Internet Explorer or Netscape with Java plug-in 1.4.01, I get 9 times the following security exception before I get the output.
    My question is, is there some way to prevent this security exception from occuring?
    java.security.AccessControlException: access denied (java.lang.reflect.ReflectPermission suppressAccessChecks)
    Continuing ...
    <?xml version="1.0" encoding="UTF-8"?>
    <java version="1.4.0" class="java.beans.XMLDecoder">
    <object class="javax.swing.JButton">
    <void property="actionCommand">
    <string>Hello, world</string>
    </void>
    <void property="label">
    <string>Hello, world</string>
    </void>
    <void property="model">
    <void property="actionCommand">
    <null/>
    </void>
    </void>
    </object>
    </java>
    I've got this simple code:
    public class XMLTest extends javax.swing.JApplet {
    public XMLTest() {
    public void init() {
    java.beans.XMLEncoder xmle = new java.beans.XMLEncoder(System.out);
    xmle.writeObject(new javax.swing.JButton("Hello, world"));
    xmle.close();
    <HTML>
    <HEAD>
    <TITLE>Applet HTML Page</title>
    </head>
    <BODY>
    <APPLET code="XMLTest.class" width=200 height=100>
    </applet>
    </body>
    </html>

    Thanks for the info; if it's really the last opportunity, I'll sign it, but it's not the intention at all to step out of the sandbox. The Applet doesn't need to write to the local file-system, all what it needs to do is read out the parameters of the beans it contains with XMLEncoder and put it in a string so I can send to the server it came from (this is no security issue).
    The output XMLEncoder produces after the security exceptions (see the first message) is sufficient, contains enough parameters and can be used well the reverse way with XMLDecoder and without any security exceptions.
    My question is this: Is XMLEncoder itself using code which bypasses the sandbox (probably yes) and is there some way to influence the process of encoding so the security exceptions don't occur?

Maybe you are looking for

  • Migrating discoverer queries from 10g to 11g

    We are thinking about upgrading Discoverer 10G to 11G. Is there any type of query migration process necessary? Or will the 10G queries run just fine in 11G? Thanks!

  • How do i set up columns in pages

    How do I set up 2 columns within a page. That is full page, no column text above the columns and text below the columns? I have made columns, and have the text above, how do I turn off or set the bottom border of the columns/ Thanks

  • Flash player flv format

    hi guys looking for some assistance, I have lots of video files i wish to place in my website.  These videos are all AVI format and i have been told this is too large for the web and it would be better to convert them, so off i went and purchased son

  • How do I reduce a Pages file size so I can create a pdf for e-mailing?

    I recently upgraded from Tiger to OS X Leopard. In Tiger, I was able to reduce file size and create a 700 to 800kb file by going to print/color sync/quartz filter/reduce file size/save as pdf. But in Leopard those options can't be accessed from my pa

  • Lost all iPhone files after iMac restore

    Hi there, A family member when trying to back their iPhone onto our old iMac, used the iTunes 'Restore' function which wiped the iPhone.  I assume the files should be somewhere on the iMac.  It is an old G5 running OS/X 10.5.8.  The iPhone is a 4S ru