Jndi and serializable objects

Hi,
I am attempting to create a cache on the web server to store
frequently accessed reference data. I do so by running a series of
queries in a startup class. The data retrieved from the result set of
each query is stored in a custom class and bound to the server context.
My understanding is that when serializable objects are bound, they are
written to disk (so as not.to waste valuable Heap space I assume). As a
test I made the startup query return a large amount of data and I
expected to see the amount of free disk space decrease as the objects
were bound however I did not see this occurring. I examined the memory
usage of the java process with the NT task manager, and the memory usage
was increasing pretty dramatically as the query results were performed
and new objects created to store this data.
Based on these observations I assume that the objects I created and
bound are stored in the Java Heap and not written to disk. Would
Weblogic at some point write these to disk if memory became tight or is
my understanding that binding an object serializes it incorrect?
If it turns out that what I am attempting here consumes a lot of heap
space, I assume that server performance will suffer which is
unacceptable. Would using read-only entity beans be a better solution?
The container could manage this memory more effectively but it would
seem to add a lot of overhead for a simple read only data cache.
Thanks,
Steve Snodgrass

We never write jndi data to the disk. So if you add more objects your are
going to take up more heap space. You should be looking at other
alternatives to implement this.
-- Prasad
Steve Snodgrass wrote:
Hi,
I am attempting to create a cache on the web server to store
frequently accessed reference data. I do so by running a series of
queries in a startup class. The data retrieved from the result set of
each query is stored in a custom class and bound to the server context.
My understanding is that when serializable objects are bound, they are
written to disk (so as not.to waste valuable Heap space I assume). As a
test I made the startup query return a large amount of data and I
expected to see the amount of free disk space decrease as the objects
were bound however I did not see this occurring. I examined the memory
usage of the java process with the NT task manager, and the memory usage
was increasing pretty dramatically as the query results were performed
and new objects created to store this data.
Based on these observations I assume that the objects I created and
bound are stored in the Java Heap and not written to disk. Would
Weblogic at some point write these to disk if memory became tight or is
my understanding that binding an object serializes it incorrect?
If it turns out that what I am attempting here consumes a lot of heap
space, I assume that server performance will suffer which is
unacceptable. Would using read-only entity beans be a better solution?
The container could manage this memory more effectively but it would
seem to add a lot of overhead for a simple read only data cache.
Thanks,
Steve Snodgrass

Similar Messages

  • Concept and situation to use Serializable Object?

    Hi Guys ,
    i Have read through the java ApI Specs about Serializable Object..
    I would like to know in what circumstances we need to serialize / implementing the Serializable class.
    Can anyone give me real world analogy?
    Then what will happen if we dont serializable our class/object?
    Thanks in advance,
    Regards,
    Willy

    you might think about serialization as an easy way to send an object over a stream...
    examples could be: save an object on a disk, over the network, over diferent vms, etc...

  • Issues in persisting dynamic entity and view objects using MDS

    Hi All,
    I'm trying to create dynamic entity and view objects per user session and to persist these objects throughout the session, I'm trying to use MDS configurations(either file or Database) in adf-config.xml.
    I'm facing following two errors while trying to run the app module:
    1. MDS error (MetadataNotFoundException): MDS-00013: no metadata found for metadata object "/model/DynamicEntityGenModuleOperations.xml"
    2. oracle.mds.exception.ReadOnlyStoreException: MDS-01273: The operation on the resource /sessiondef/dynamic/DynamicDeptEntityDef.xml failed because source metadata store mapped to the namespace / DEFAULT is read only.
    I've gone through the following links which talks about the cause of the issue, but still can't figure out the issue in the code or the config file. Please help if, someone has faced a similar issue.
    [http://docs.oracle.com/cd/E28271_01/doc.1111/e25450/mds_trouble.htm#BABIAGBG |http://docs.oracle.com/cd/E28271_01/doc.1111/e25450/mds_trouble.htm#BABIAGBG ]
    [http://docs.oracle.com/cd/E16162_01/core.1112/e22506/chapter_mds_messages.htm|http://docs.oracle.com/cd/E16162_01/core.1112/e22506/chapter_mds_messages.htm]
    Attached is the code for dynamic entity/view object generation and corresponding adf-config.xml used.
    ///////////App Module Implementation Class/////////////////////////
    public class DynamicEntityGenModuleImpl extends ApplicationModuleImpl implements DynamicEntityGenModule {
    private static final String DYNAMIC_DETP_VO_INSTANCE = "DynamicDeptVO";
    * This is the default constructor (do not remove).
    public DynamicEntityGenModuleImpl() {
    public ViewObjectImpl getDepartmentsView1() {
    return (ViewObjectImpl) findViewObject("DynamicDeptVO");
    public void buildDynamicDeptComp() {
    ViewObject internalDynamicVO = findViewObject(DYNAMIC_DETP_VO_INSTANCE);
    if (internalDynamicVO != null) {
    System.out.println("OK VO exists, return Defn- " + internalDynamicVO.getDefFullName());
    return;
    EntityDefImpl deptEntDef = buildDeptEntitySessionDef();
    ViewDefImpl viewDef = buildDeptViewSessionDef(deptEntDef);
    addViewToPdefApplicationModule(viewDef);
    private EntityDefImpl buildDeptEntitySessionDef() {
    try {
    EntityDefImpl entDef = new EntityDefImpl(oracle.jbo.server.EntityDefImpl.DEF_SCOPE_SESSION, "DynamicDeptEntityDef");
    entDef.setFullName(entDef.getBasePackage() + ".dynamic." + entDef.getName());
    entDef.setName(entDef.getName());
    System.out.println("Application Module Path name: " + getDefFullName());
    System.out.println("EntDef :" + entDef.getFileName() + " : " + entDef.getBasePackage() + ".dynamic." + entDef.getName());
    entDef.setAliasName(entDef.getName());
    entDef.setSource("DEPT");
    entDef.setSourceType("table");
    entDef.addAttribute("ID", "ID", Integer.class, true, false, true);
    entDef.addAttribute("Name", "NAME", String.class, false, false, true);
    entDef.addAttribute("Location", "LOCATION", Integer.class, false, false, true);
    entDef.resolveDefObject();
    entDef.registerSessionDefObject();
    entDef.writeXMLContents();
    entDef.saveXMLContents();
    return entDef;
    } catch (Exception ex) {
    System.out.println(ex.getLocalizedMessage());
    return null;
    private ViewDefImpl buildDeptViewSessionDef(EntityDefImpl entityDef) {
    try {
    ViewDefImpl viewDef = new oracle.jbo.server.ViewDefImpl(oracle.jbo.server.ViewDefImpl.DEF_SCOPE_SESSION, "DynamicDeptViewDef");
    viewDef.setFullName(viewDef.getBasePackage() + ".dynamic." + viewDef.getName());
    System.out.println("ViewDef :" + viewDef.getFileName());
    viewDef.setUseGlueCode(false);
    viewDef.setIterMode(RowIterator.ITER_MODE_LAST_PAGE_FULL);
    viewDef.setBindingStyle(SQLBuilder.BINDING_STYLE_ORACLE_NAME);
    viewDef.setSelectClauseFlags(ViewDefImpl.CLAUSE_GENERATE_RT);
    viewDef.setFromClauseFlags(ViewDefImpl.CLAUSE_GENERATE_RT);
    viewDef.addEntityUsage("DynamicDeptUsage", entityDef.getFullName(), false, false);
    viewDef.addAllEntityAttributes("DynamicDeptUsage");
    viewDef.resolveDefObject();
    viewDef.registerSessionDefObject();
    viewDef.writeXMLContents();
    viewDef.saveXMLContents();
    return viewDef;
    } catch (Exception ex) {
    System.out.println(ex.getLocalizedMessage());
    return null;
    private void addViewToPdefApplicationModule(ViewDefImpl viewDef) {
    oracle.jbo.server.PDefApplicationModule pDefAM = oracle.jbo.server.PDefApplicationModule.findDefObject(getDefFullName());
    if (pDefAM == null) {
    pDefAM = new oracle.jbo.server.PDefApplicationModule();
    pDefAM.setFullName(getDefFullName());
    pDefAM.setEditable(true);
    pDefAM.createViewObject(DYNAMIC_DETP_VO_INSTANCE, viewDef.getFullName());
    pDefAM.applyPersonalization(this);
    pDefAM.writeXMLContents();
    pDefAM.saveXMLContents();
    ////////adf-config.xml//////////////////////
    <?xml version="1.0" encoding="windows-1252" ?>
    <adf-config xmlns="http://xmlns.oracle.com/adf/config" xmlns:config="http://xmlns.oracle.com/bc4j/configuration" xmlns:adf="http://xmlns.oracle.com/adf/config/properties"
    xmlns:sec="http://xmlns.oracle.com/adf/security/config">
    <adf-adfm-config xmlns="http://xmlns.oracle.com/adfm/config">
    <defaults useBindVarsForViewCriteriaLiterals="true"/>
    <startup>
    <amconfig-overrides>
    <config:Database jbo.locking.mode="optimistic"/>
    </amconfig-overrides>
    </startup>
    </adf-adfm-config>
    <adf:adf-properties-child xmlns="http://xmlns.oracle.com/adf/config/properties">
    <adf-property name="adfAppUID" value="TestDynamicEC-8827"/>
    </adf:adf-properties-child>
    <sec:adf-security-child xmlns="http://xmlns.oracle.com/adf/security/config">
    <CredentialStoreContext credentialStoreClass="oracle.adf.share.security.providers.jps.CSFCredentialStore" credentialStoreLocation="../../src/META-INF/jps-config.xml"/>
    </sec:adf-security-child>
    <persistence-config>
    <metadata-namespaces>
    <namespace metadata-store-usage="mdsRepos" path="/sessiondef/"/>
    <namespace path="/model/" metadata-store-usage="mdsRepos"/>
    </metadata-namespaces>
    <metadata-store-usages>
    <metadata-store-usage default-cust-store="true" deploy-target="true" id="mdsRepos">
    <metadata-store class-name="oracle.mds.persistence.stores.file.FileMetadataStore">
    <property name="metadata-path" value="/tmp"/>
    <!-- <metadata-store class-name="oracle.mds.persistence.stores.db.DBMetadataStore">
    <property name="jndi-datasource" value="jdbc/TestDynamicEC"/>
    <property name="repository-name" value="TestDynamicEC"/>
    <property name="jdbc-userid" value="adfmay28"/>
    <property name="jdbc-password" value="adfmay28"/>
    <property name="jdbc-url" value="jdbc:oracle:thin:@localhost:1521:XE"/>-->
    </metadata-store>
    </metadata-store-usage>
    </metadata-store-usages>
    </persistence-config>
    </adf-config>
    //////////////////////////////////////////////////////////////////////////////////////////////////////////

    Hi Frank,
    I m trying to save entity and view object xml by calling writeXMLContents() and saveXMLContents() so that these objects can be retrieved using the xmls later on.
    These methods internally use MDS configuration in adf-config.xml, which is creating the issue.
    Please share your thoughts on resolving this or if, there is any other way of creating dynamic entity/view objects for db tables created at runtime.
    Nik

  • Returning a serializable object from a java stored procedure

    [Server : Oracle 8.1.6 on WinNT4 server. Client : java 1.2.2 on WinNT4 workstation.]
    I am attempting to use a java stored procedure to build a complex serializable java object on the database (to minimise number of requests/queries on the network) and then return this object in response to the original query.
    I have it writing a BLOB by means of
    OutputStream os = retval.getBinaryOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(os);
    oos.writeObject(v);
    return retval;
    where retval is a blob selected from a dummy table (created for this purpose) and v is a vector containing only serializable objects.
    However, on the client side when I attempt to recover the object by
    OracleResultSet rs = (OracleResultSet)stmt.executeQuery("SELECT javatest FROM DUAL");
    oracle.sql.BLOB blob=rs.getBLOB(1);
    InputStream inp = blob.getBinaryStream();
    ObjectInputStream oinp = new ObjectInputStream(inp);
    Vector retval = (Vector)oinp.readObject();
    I get an exception telling me that the input stream does not contain an object at the line containing new ObjectInputStream(inp);
    The full exception is :
    java.io.StreamCorruptedException: InputStream does not contain a serialized object
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:731)
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java:165)
    at eRespond.DBLayer.JavaStoredProcedures.testdbobj.test2(testdbobj.java:143)
    at eRespond.DBLayer.JavaStoredProcedures.testdbobj.main(testdbobj.java, Compiled Code)
    I've checked that the returned blob is non-null, and that oracle.sql.BLOB is used throughout.
    Any thoughts?
    Thanks,
    mark.

    Firstly I guess to be able to new B() as a Thread, B
    should extends Thread.
    Secondly the constructor should not have any return
    type:
    public B(String cmd)
    instead of
    public void B(String cmd)
    Lastly there is no need to override the start() method
    if all it does is to call the superclass. The subclass
    automatically inherits the method.
    Hope this helps.thanks for replying so soon...
    yes, you are right, it should extends Thread and it is, i forgot to out in this example... my mistake!
    i'll try the construnctor thing to see if it works. bare in mind that i working with java stored procedures, it should work even so, right?
    thanks

  • Best practice for saving and recalling objects from disk?

    I've been using the OOP features of LabVIEW for various projects lately and one thing that I struggle with is a clean method to save and recall objects.
    Most of my design schemes have consisted of a commanding objects which holds a collection of worker objects.  Its a pretty simple model, but seems to work for some design problems.  The commander and my interface talk to each other and the commander sends orders to his minions in order to get things done.  For example, one parrent class might be called "Data Device Collection" and it has a property that is an array of "Data Device" objects.
    The Data Device object is a parent class and its children consist of various data devices such as "DAQmx Device", "O-Scope Device", "RS-232 Device", etc.
    When it comes to saving and loading data, the commanding class's "Save" or "Load" routine is called and at that time all of the minions' settings are saved or recalled from disk.
    My save routine is more-or-less straight forward, although it still requires an overwriting "Save" and "Load" vi.  Here is an example:
    It isn't too bad in that it is pretty straight forward and simple and there also would be no changes to this if the data structure of the class changed at all.  It also can save more generalized settings from it's parrent's class which is also a good feature.  What I don't like is that it looks essentially the same for each child class, but I'm at a loss on an effective way to move the handling of the save routing into the parent class.
    The load routine is more problematic for me.  Here is an example:
    Again, the desirability of moving this into the parent class would be awesome.  But the biggest complaint here is that I can't maintain my dynamic dispatch input-output requirements because the object that I load is strictly typed.  Instead I have to rely on reading the information from the loaded object and then writing that information to the object that exists on the dynamic dispatch wire.  I also dislike that unlike my Save Routine, I will need to modify this VI if my data structure of my object changes.
    Anyway, any input and insight would be great.  I'm really tired of writing these same VIs over-and-over-and-over again, and am after a better way to take care of this in the parent class by keeping the code generalized but still maintain the ability to bring back the saved parameters of each of the children classes.
    Thanks for your time.

    I'm with Ben. Don't rely on the current ability to serialize an object. Create a save method and implement some form of data persistence there. If you modify your class you might be disappointed when you cannot load objects you previously saved. It mostly works but as soon as you reset the version information in the class, you can no longer load the old objects. This is fine if you know how to avoid resetting the history. One thing that will do this is if you move the class into or out of a library. It becomes a new class with version 1.0.0 and it no longer recognizes the old objects.
    [Edit:  I see that you are just writing to a binary file. I'm not sure you can load older objects anyway using that method but I have never tried it.]
    This will not help you right now but there are plans for a nice robust API for saving objects.
    =====================
    LabVIEW 2012

  • Explicity mapping between ActionScript and Java objects for the BlazeDS Messaging Service

    The BlazeDS documentation shows how to explicitly map between ActionScript and Java objects. For example, this works fine for RPC services, e.g.
    import flash.utils.IExternalizable;
    import flash.utils.IDataInput;
    import flash.utils.IDataOutput;
    [Bindable]
    [RemoteClass(alias="javaclass.User")]
    public class User implements IExternalizable {
            public var id : String;
            public var secret : String;
            public function User() {
            public function readExternal(input : IDataInput) : void {
                    id = input.readObject() as String;
            public function writeExternal(output : IDataOutput) : void {
                    output.writeObject(id);
    and
    import java.io.Externalizable;
    import java.io.IOException;
    import java.io.ObjectInput;
    import java.io.ObjectOutput;
    import java.util.HashSet;
    import java.util.Iterator;
    import java.util.Set;
    public class User implements Externalizable {
        protected String id;
        protected String secret;
        public String getId() {
            return id;
        public void setId(String id) {
            this.id = id;
        public String getSecret() {
            return secret;
        public void setSecret(String secret) {
            this.secret = secret;
        public void readExternal(ObjectInput in) throws IOException,
                    ClassNotFoundException {
            id = (String) in.readObject();
        public void writeExternal(ObjectOutput out) throws IOException {
            out.writeObject(id);
    If I called an RPC service that returns a User, the secret is not sent over the wire.  Is it also possible to do this for the messaging service? That is, if I create a custom messaging adapter and use the function below, can I also prevent secret from being sent?
    MessageBroker messageBroker = MessageBroker.getMessageBroker(null);
    AsyncMessage message = new AsyncMessage();
    message.setDestination("MyMessagingService");
    message.setClientId(UUIDUtils.createUUID());
    message.setMessageId(UUIDUtils.createUUID());
    User user = new User();
    user.setId("id");
    user.setSecret("secret");
    message.setBody(user);
    messageBroker.routeMessageToService(message, null);

    Hi Martin. The way that AMF serialization/deserialization works for BlazeDS is the same regardless of which service is being used, so yes that code will work for messaging as well. On the server, the serialization/deserialization of messages happens at the endpoint. For an incoming message for example, the endpoint deserializes the message and then hands it off to the MessageBroker which decides which service/destination to deliver the message to.
    That was a good question. Thanks for asking it. Lots of people are used to doing custom serialization/deserialization with the RPC services (RemoteObject/RemotingService) but I'm not sure everyone realizes they can do this for messaging as well.
    -Alex

  • Custom Deserialization for a List of serializable objects

    I'm running into trouble creating custom deserialization using the readObject method.
    Here is the code the reads the blob from the database:
    Blob blob = rs.getBlob(idx++);
                InputStream iStream = blob.getBinaryStream();
                try {
                    ObjectInputStream oiStream = new ObjectInputStream(iStream);
                    Object object = oiStream.readObject();
                    List data = (List) object;
                    report.setData(data);
                catch (EOFException ignored) {}
                finally {
                    iStream.close();               
                }And my class:
    public class PerformanceReportRowInfo extends PerformanceInfo
        private static final long serialVersionUID = 20060406L;
        private String _dateStr;
        private long _queries;
        private void readObject (ObjectInputStream ois) throws IOException,
                ClassNotFoundException
            ObjectInputStream.GetField fields = ois.readFields();
            _dateStr = (String) fields.get("_dateStr", null);
            try {
                _queries = fields.get("_queries", 0L);
            } catch (IOException io) {
                int intQueries = fields.get("_queries", 0);
                _queries = (long) intQueries;
    }The reason custom deserialization is needed is because we are converting the "_queries" attribute from an int to a long, and do not want to have to replace all the blobs in our DB with long types.
    For some reason, however, the readObject method never gets called in the PerformanceReportRowInfo, and instead i continue to get the error message:
    java.io.InvalidClassException: PerformanceReportRowInfo; incompatible types for field _queries
    I even added logging to the readObject method to make sure it wasnt getting called, and my suspicion was confirmed, it was indeed not getting called. Is my problem related to the fact that it is extending another serializable object (in this case PerformanceInfo) that doesnt have a custom readObject method? Or is it because of how im converting the blob to a List in the first block of code? BTW, the exception occurs at this line:
    Object object = oiStream.readObject();
    Thanks for the help!

    It is Serializable and does not extend any other class (except Object of course), here is the full stack trace:
    Caused by: java.io.InvalidClassException: PerformanceReportRowInfo; incompatible types for field _queries
         at java.io.ObjectStreamClass.matchFields(ObjectStreamClass.java:2175)
         at java.io.ObjectStreamClass.getReflector(ObjectStreamClass.java:2070)
         at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:586)
         at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1552)
         at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
         at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1552)
         at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1699)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
         at java.util.ArrayList.readObject(ArrayList.java:591)
         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 java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:946)
         at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1809)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
         at MyClass.readReport(MyClass.java:332)

  • Created serializable object, but get "Class not found" on "createObjectMessage()" cal

    I'm using OC4J 9.0.2.1 and JDeveloper 9.0.2 with Oracle db. I have a set of queues created in the database.
    Before I try to send my request, I create an instance of the serializable object I want to send. I do all of my queue connection setup, then I call:
    queueSession.createObjectMessage(request);
    Where "queueSession" is a QueueSession obtained from "queueConnection.createQueueSession()".
    When I step over this function call, I get the following:
    oracle.jms.AQjmsException: JMS-109: Class not found: com.attws.it.bsa.felix.mci.common.ServiceInfoRequest
    (The indicated class name is the type of the "request" object.)
    What could I be doing wrong?

    The code below creates the following classes when I compile it (using jsk1.3):
    DistanceBarApplication2.class
    DistanceBarApplication2$1
    DistanceBarApplication2$2
    DistanceBarApplication2$3
    DistanceBarApplication2$DistanceBar2
    The error I receive is: load: class DistanceBarApplication2 not found
    Here is my HTML code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    </HEAD>
    <BODY>
    <applet code="DistanceBarApplication2.class" width=300 height=50>
    </applet>
    </BODY>
    </HTML>
    Here is the Java code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class DistanceBarApplication2 extends JApplet {
    private final DistanceBar2 bar = new DistanceBar2();
    public void init() {
    bar.setMaximum(100);
    bar.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    bar.stop();
    JOptionPane.showMessageDialog(bar, bar.getValue() + " yards");
    bar.start();
    this.getContentPane().add(bar);
    bar.start();
    static class DistanceBar2 extends JProgressBar {
    private Thread mThread;
    private boolean mRunning= false;
    private int mValue = 0;
    private boolean mUp = true;
    private Runnable updater = new Runnable() {
    public void run() {
    setValue(mValue);
    public void start() {
    if (mRunning) {
    return;
    mRunning = true;
    mThread = new Thread(new Runnable() {
    public void run() {
    while (mRunning) {
    try {
    Thread.sleep(30);
    } catch (InterruptedException e) { }
    adjust();
    mThread.setDaemon(true);
    mThread.start();
    public void stop() {
    mRunning= false;
    // Best to let a thread run itself out
    // if (mThread != null)
    // mThread.interrupt();
    // Don't need this for this applet, but possibly later
    // public Dimension getPreferredSize() {
    // return new Dimension(300,70);
    private void adjust() {
    int delta = getMaximum() / 40;
    mValue += delta * (mUp ? 1 : -1);
    if (mValue >= getMaximum()) {
    mValue = getMaximum();
    mUp = false;
    } else if (mValue <= 0) {
    mValue = 0;
    mUp = true;
    SwingUtilities.invokeLater(updater);

  • Configure JNDI and deploy crystal report in Infoview

    Hi all,
    I am trying to create a JNDI context and use it while generating a
    crystal report.Now this report is deployed in Business Objects XI R3.1 Edge repository so users can view them through Infoview. The main reason I wanted to use JNDI is so I dont need to specify the database connection credentials in every report.
    Issue is that I am not able to figure out the process to achieve this. I created a JNDI in tomcat as per instructions in the one of the SAP notes but there is no information of how to configure the same in CMC / Infoview. If I can get information on how to
    1. configure crconfig.xml (if need be) for jndi or specify jndi while creating connection in crystal report
    2. configure the JNDI in CMC or Infoview so that we dont have to specify the db connection credentials for every report
    that would be great.
    we are using crystal reports 2008 sp1.
    thanks
    Joe.
    Edited by: Joe P Kumar on Jan 31, 2011 5:30 PM

    I guess I found the issue. I was missing weblogic.jar in the classpath. After adding this, it worked.
    Just noting the steps so anyone who comes here could be benefited. This is for Weblogic app server using Oracle 10g and Crystal reports 2008
    1. Open CRConfig.xml in C:\Program Files\Business Objects\common\4.0\java
    2. Inside <DataDriverCommon> and <Classpath> add the path of your ojdbc and weblogic jars
    3. For the JDBC tag, the entry would be like. The <JNDIUserName> tag should reference your weblogic app server user. This is generally the userid you would use to login to weblogic console.
    <JDBC>
         <CacheRowSetSize>100</CacheRowSetSize>
         <JDBCURL>jdbc:oracle:thin:<db_user_name>/<db_pwd>@<server_where_db_runs>:1521/<SID></JDBCURL>
         <JDBCClassName>oracle.jdbc.driver.OracleDriver</JDBCClassName>
         <JDBCUserName><db_user_name></JDBCUserName>
            <JNDIURL>t3://localhost:7001</JNDIURL>
         <JNDIConnectionFactory>weblogic.jndi.WLInitialContextFactory</JNDIConnectionFactory>
         <JNDIInitContext>/</JNDIInitContext>
         <JNDIUserName>weblogic</JNDIUserName>
         <GenericJDBCDriver>
              <Default>
                   <ServerType>UNKNOWN</ServerType>
                   <QuoteIdentifierOnOff>ON</QuoteIdentifierOnOff>
                   <StoredProcType>Standard</StoredProcType>
                   <LogonStyle>Standard</LogonStyle>
              </Default>
              <Sybase>
                   <ServerType>SYBASE</ServerType>
                   <QuoteIdentifierOnOff>OFF</QuoteIdentifierOnOff>
                   <DriverClassName>com.sybase.jdbc2.jdbc.SybDriver</DriverClassName>
                   <StoredProcType>Standard</StoredProcType>
                   <LogonStyle>MySQL</LogonStyle>
              </Sybase>
         </GenericJDBCDriver>
    </JDBC>
    4. Open Crystal reports designer and when you create a new connection, choose JDBC / JNDI
    5. In the pop-up choose JNDI (you will see the values for Provider URL, username and context as how you specified in the CRConfig.xml file). Specify the password for weblogic user
    6. Hit next and it should show you the available jndi
    7. Choose a JNDI and create the report
    8. Enjoy.

  • Attributes in a Serializable object in a file

    Hello,
    I have an application that stores a Serializable object into a file, but when I edit the file I can see the attributes from the stored object. And I thought that when you do that the stored data where bytes, instead of strings.
    Can somebody explain me how can I store an object into a file that cannot be shown the content?
    Here is my code:
    String fichero_datos = "D:\\workspace2\\Cliente\\Datos.dat"; //That is the file
    Cliente elCliente = new Cliente ("Fulanito"); //That is the object that stores a String
    FileOutputStream fo = new FileOutputStream(fichero_datos);
    ObjectOutputStream salida = new ObjectOutputStream(fo);
    salida.writeObject(elCliente);
    salida.flush();
    salida.close();
    fo.close();And the result file:
    �..sr..ClienteJB``}\..L. nombreq..Ljava/lang/String;L ..Fulanito
    I do not want the string �Fulanito� to be accesible by editing the file.
    Thanks a lot for your attention,
    - Susana

    And I thought that when you do that the stored data where bytes, instead of strings. When encoded as UTF-8, String are made up of bytes. You cannot assume that because bytes are used, that the file should be completely unreadable.
    You will have trouble editing the file in a text editor as the binary values will get changed and the the stream will appear to be corrupted.
    The only way to ensure the data is unmodifyable is to encrypt the data.
    If you want the data to be mearly unreadable, add a DeflatorOutputStream between the ObjectOutputStream and the FileOutputStream. This will compress the data and make it unreadbale unless you use an InflatorInputStream.

  • Sending Non-Serializable Objects

    I'm trying to make my server program send a non-serializable object to the client program. But I'm getting a 'java.io.NotSerializableException'. Is there any way to send a non-serializable object through an ObjectOutputStream, or through some other type of stream object?
    Thanks.
    ~jon

    I have some experience before, here is one solutions:Well, nice to know, but its not a solution to the problem discussed in this topic though.
    >
    >
    using toByteArray to get a byte[] and a length of the
    array
    then using the following format to send through
    sockets,
    [bytearray.length][byte array content]
    It really works in a project of a MMS system I have
    worked on.

  • Serialializing non serializable objects

    Hi guys,
    I have to serialize (and then send through socket) a class which implements java.io.Serializable. This class also has some reference with other classes, which should be serialized togheter.
    But when I run the main class (which only serializes) , java.io.NotSerializableException is thrown.
    How do I recognize if a class is effectively serializable?
    How do I serialize too even with non-serializable objects?
    (I need all these objects)
    note : In the class I have only put the marker "implements java.io.Serializable",should I have to do somenthing else?
    Thank You for your great help!

    Hi guys,
    I have to serialize (and then send through socket)a
    class which implements java.io.Serializable. This
    class also has some reference with other classes,
    which should be serialized togheter.
    But when I run the main class (which onlyserializes)
    , java.io.NotSerializableException is thrown.
    How do I recognize if a class is effectively
    serializable?
    How do I serialize too even with non-serializable
    objects?
    (I need all these objects)
    note : In the class I have only put the marker
    "implements java.io.Serializable",should I have todo
    somenthing else?
    Thank You for your great help!I wish there was a utility that could inspect a
    Class, traverse its containment tree and flag
    serializability issues. This could be more powerful
    if generics are used.
    To solve your problem besides the marker, implement
    methods writeObject and readObject and serializing
    the contained object that is not serializable by
    hand. For example if your class is X which contains Y
    that is not serializable then you need to serialize
    fields Y in X.writeObject and construct a Y object in
    X.readObject:
    class Y { // not serializable and you cannot modify
    it
    int i;
    int j;
    Y(int i, int j)
    class X implements Serializable {
    String xyz;
    Y y;
    private void writeObject(ObjectOutputStream out)
    throws IOException{
    out.writeObject(xyz);
    out.writeInt(y.getI());
    out.writeInt(y.getJ());
    private void readObject(ObjectInputStream in)
    throws IOException{
    xyz = (String) in.readObject();
    int i = in.readInt();
    int j = in.readInt();
    y = new Y(i, j);Remember to maintain the same order in readObject and
    writeObject.
    Hi guys,
    I have to serialize (and then send through socket)a
    class which implements java.io.Serializable. This
    class also has some reference with other classes,
    which should be serialized togheter.
    But when I run the main class (which onlyserializes)
    , java.io.NotSerializableException is thrown.
    How do I recognize if a class is effectively
    serializable?
    How do I serialize too even with non-serializable
    objects?
    (I need all these objects)
    note : In the class I have only put the marker
    "implements java.io.Serializable",should I have todo
    somenthing else?
    Thank You for your great help!I wish there was a utility that could inspect a
    Class, traverse its containment tree and flag
    serializability issues. This could be more powerful
    if generics are used.
    To solve your problem besides the marker, implement
    methods writeObject and readObject and serializing
    the contained object that is not serializable by
    hand. For example if your class is X which contains Y
    that is not serializable then you need to serialize
    fields Y in X.writeObject and construct a Y object in
    X.readObject:
    class Y { // not serializable and you cannot modify
    it
    int i;
    int j;
    Y(int i, int j)
    class X implements Serializable {
    String xyz;
    Y y;
    private void writeObject(ObjectOutputStream out)
    throws IOException{
    out.writeObject(xyz);
    out.writeInt(y.getI());
    out.writeInt(y.getJ());
    private void readObject(ObjectInputStream in)
    throws IOException{
    xyz = (String) in.readObject();
    int i = in.readInt();
    int j = in.readInt();
    y = new Y(i, j);Remember to maintain the same order in readObject and
    writeObject.

  • Returning Non Serializable Objects

    Is it possible in anyway to return non serializable objects from the remote method of an EJB, for instance return a result set. Everytime i try, i get a CORBA marshalling exception, i tried to put the resultset in a serilized object such as an enumeration or vector but got the same error when retreiving it from the enumeration or vector. Help is needed and appreciated. Thanx.

    Is it possible in anyway to return non serializable objects from the remote method of an EJB, for instance return a result set. Everytime i try, i get a CORBA marshalling exception, i tried to put the resultset in a serilized object such as an enumeration or vector but got the same error when retreiving it from the enumeration or vector. Help is needed and appreciated. Thanx.

  • Inserting non-serializable objects

    Is there any way to insert non-serializable objects into a database? (Or to convert them to bytes?)

    Is there any way to insert non-serializable objectsinto a database?
    A joke right?No, it's not a joke. It would be a pretty bad one if it were.
    Yes, there is a way. Create a table that corresponds
    to the object where each attribute in the object
    corresponds to field in the object. Add a unique key
    if one doesn't exist.I wish it were that simple. I don't have access to those attributes...
    >
    To create an object insert a row into the table. To
    load the object use the unique key to query for the
    row. To 'delete' the object delete the row from the
    table.BTW, the object in question is the java.awt.geom.Area object (http://java.sun.com/j2se/1.3/docs/api/java/awt/geom/Area.html ).
    The only way I can think of to insert an object that doesn't map to a SQL type is to convert it to bytes through serialization, and insert it as RAW data.
    I've extended Area to add a name and made my class serializable. However, since Area is not serializable, the only data I can retrieve after deserializing is the name I added (from my understanding of serialization, I have to save Area's data myself, but can't since I don't have access to it, so the deserialization process calls the Area() constructor which initializes the object to empty).

  • Non Serializable Objects

    I am working on a java project and I have to serialize a class (created by me) which has many references to other classes that should be serialized too.
    I add the marker "implements serializable" to all the necessary classes, but when I run I get a non serializable exception.
    Maybe one ore more objects are non serializable, but how do I identify them?
    I've read that If I have to serialize non serializable objects, I need to write my own writeObject(ObjectOutputStream out)throws IOException and readObject(ObjectInputStream in) , but I don't know how to implement and us them.
    note : I can't use transient beacuse I need everything to be serialized!
    Thanks a lot. Bye!

    Now I'll post my code, If anyone knows how to serialize (and then deseserialize) the class "AgentMessage" , and its subclasses "StaticPart" and "DynElement" from the main class , I'll be grateful.. It's about 2 days I'm working on it and I continue getting "nonserialializable exception" ...
    thank you guys
    package agentsLibrary;
    //some imports
    public class AgentMessage implements Serializable{
         private static final long serialVersionUID = 1L;
         private StaticPart sp;
         private DynElement de;
         public AgentMessage(String agent,byte[] code,String mainclass,Certificate signerId,PrivateKey priv,String configuration,Serializable dclear,byte[] dsecret,PathEl[] dpath,byte[] c){ //costruttore
              sp=new StaticPart(agent,code,mainclass,signerId,priv,configuration);
              de=new DynElement(dclear,dsecret,c,dpath);
         public StaticPart getSp(){
              return sp;
         public DynElement getDe(){
              return de;
         private void writeObject(java.io.ObjectOutputStream out) throws IOException{
              System.out.println("class implements writeObject( )");
              //depends on the method to store out all the important state
              //out.defaultWriteObject();//perform the default serialization(va sempre fatto il default)
              out.writeObject(sp);
              out.writeObject(de);
         private void readObject(java.io.ObjectInputStream in)throws ClassNotFoundException, IOException {
              System.out.println("class implements readObject( )");
              //in.defaultReadObject();
              sp=(StaticPart)in.readObject();
              de=(DynElement)in.readObject();
    package agentsLibrary;
    public class StaticPart implements Serializable{
         private static final long serialVersionUID = 1L;
         private String agent="";
         private byte[] code=null;
         private String mainclass="";
         private Certificate signerid=null;
         private PrivateKey priv=null;
         private Calendar timestamp=null;
         private Signature sig=null;
         private byte[] buffertotale=null;
         private byte[] firma=null;
         private String configuration="";
         public StaticPart(String agent, byte[] code, String mainclass, Certificate signerid, PrivateKey priv,String configuration){
              this.configuration=configuration;
              this.code=code;
              this.mainclass=mainclass;
              this.agent=agent;
              this.priv=priv;
              this.signerid=signerid;
              timestamp=Calendar.getInstance();
              Date time=new Date();
              time=timestamp.getTime();//Gets this Calendar's current time.
              try {
                   byte[] nomeagent=agent.getBytes("8859_1");//converto stringa
                   byte[] mainclas=mainclass.getBytes("8859_1");//converto stringa
                   byte[] signer=signerid.getEncoded();
                   byte[] priva=priv.getEncoded();
                   byte[] dat=null;
                   dat=time.toString().getBytes("8859_1");
                   buffertotale=new byte[nomeagent.length+mainclas.length+signer.length+priva.length+dat.length+code.length];
                   System.arraycopy(nomeagent, 0, buffertotale, 0, nomeagent.length);
                   System.arraycopy(code, 0, buffertotale, nomeagent.length, code.length);
                   System.arraycopy(mainclas, 0, buffertotale, code.length, mainclas.length);
                   System.arraycopy(signer, 0, buffertotale, mainclas.length, signer.length);
                   System.arraycopy(priva, 0, buffertotale, signer.length, priva.length);
                   System.arraycopy(dat, 0, buffertotale, priva.length, dat.length);
              } catch (UnsupportedEncodingException e) {
                   e.printStackTrace();
                   System.exit(1);
              } catch (CertificateEncodingException e) {
                   e.printStackTrace();
                   System.exit(1);
              try {
                   sig = Signature.getInstance(priv.getAlgorithm());
                   sig.initSign(priv);
                   sig.update(buffertotale, 0, buffertotale.length);
                   firma=sig.sign();
              } catch (SignatureException e) {
                   e.printStackTrace();
                   System.exit(1);
              } catch (InvalidKeyException e) {
                   e.printStackTrace();
                   System.exit(1);
              } catch (NoSuchAlgorithmException e) {
                   e.printStackTrace();
                   System.exit(1);
         public boolean verify() {
              try{
                   PublicKey pub=signerid.getPublicKey();
                   Signature sig = Signature.getInstance(pub.getAlgorithm());
                   sig.initVerify(pub);
                   sig.update(buffertotale, 0, buffertotale.length);
                   return sig.verify(firma);
              } catch (SignatureException e) {
                   e.printStackTrace();
                   System.exit(1);
              } catch (InvalidKeyException e) {
                   e.printStackTrace();
                   System.exit(1);
              } catch (NoSuchAlgorithmException e) {
                   e.printStackTrace();
                   System.exit(1);
              return false;
         public String getAgentName() {
              return agent;
         public byte[] getCode() {
              return code;
         public String getClassName() {
              return mainclass;
         public PrivateKey getPrivate() {
              return priv;
         public Certificate getId() {
              return signerid;
         public byte[] getSignature(){
              return firma;
         public String getConfiguration(){
              return configuration;
    package agentsLibrary;
    import java.io.Serializable;
    public class DynElement implements java.io.Serializable{
         private static final long serialVersionUID = 1L;
         private Serializable dclear=null;
         private byte[] dsecret=null;
         private PathEl[] dpath=null;
         private byte[]c=null;
         public DynElement(Serializable dclear,byte[] dsecret,byte[]c,PathEl[] dpath){
              this.dclear=dclear;
              this.dsecret=dsecret;
              this.c=c;
              this.dpath=dpath;
         public byte[] getC() {
              return c;
         public Serializable getDclear() {
              return dclear;
         public PathEl[] getDpath() {
              return dpath;
         public byte[] getDsecret() {
              return dsecret;
    //finally the following is the main class that should serialize
    AgentMessage msg=new AgentMessage(name,code,mainclass,signerId,privata,configuration,dclear,dsecret,dpath,c);
              try {
                   System.out.println("Sending Agent Message to Server "+ip+":"+port);
                   Socket s = new Socket(ip,port);
                   ObjectOutputStream out=new ObjectOutputStream(s.getOutputStream());
                   out.writeObject(msg);
                   out.flush();
                   s.close();
              } catch (Exception e) {
                   return false;
              return true;
         }

Maybe you are looking for