Java Object Cache have wired behaviour

HI,
I am trying to get my Oracle Java Object Cache working but I am observing some really stange behaviour which has stop it working. So any help will be really useful (10.1.3 and 10.1.2.0.2). I will explain:
Progammaticly I have setup a parent region call 'DatabaseDataCache' and a sub-region call 'country'. In this region I have defined my object call countriesDto' with a Attribuite that has a CaheLoader attached. In my cache loader I connects to a Entity EJB that loads a bunch of DTOs into the cache.
What is strange is that when i run the unit test on the code (cactus). The cache seems to call the cache loader 3 times consequtively before the EJB will load the data (i know this due to debuging messages)
Then in the actual implmentation I have the cache setup code of the in the init() of the servlet but again the cache loader doesn't seem to able to call the ejb it requires. Ones the cache is access it trys to call the cache loader and of course the ejb dosn't get called and is returning me a NullPointerError as I am trying to acces the local interface (in the cache loader). This is strange as in the cactus test it actually calls the ejb ok bit only on the third attemp.
I am abit puzzled with this so any help will be much appreciated.
Charlie

I think I have got what you need. The following is the cactus test class that test the getCountries method in my session ejb:
public class WebinUtilTest extends ServletTestCase {
private CacheAccess globParCache;
public void setUp() throws Exception {
CacheAccess.defineRegion("DatabaseDataCache");
globParCache = CacheAccess.getAccess("DatabaseDataCache");
globParCache.defineSubRegion("country");
Attributes cAtt = new Attributes();
cAtt.setLoader(new CountryCacheLoader());
CacheAccess globCountCache = globParCache.getSubRegion("country");
globCountCache.defineObject("countriesDto", cAtt);
globCountCache.preLoad("countriesDto");
globCountCache.close();
globParCache.close();
public void testGetCountries() throws Exception{
WebinUtilLocal wuLoc = HomeFactory.getWebinUtilLocalHome().create();
String[] countries = wuLoc.getCountries();
assertTrue(countries.length >0);
public void tearDown() throws Exception {
if (globParCache != null){
CacheAccess gCache = CacheAccess.getAccess("DatabaseDataCache");
gCache.destroy();
When I run this test here is the stack trace I am getting (in order):
06/01/05 15:54:14 load entred for country cache loader: Thu Jan 05 15:54:14 GMT 2006
06/01/05 15:54:14 java.lang.Exception: Stack trace
06/01/05 15:54:14 at java.lang.Thread.dumpStack(Thread.java:1064)
06/01/05 15:54:14 at uk.ac.ebi.submission.util.CountryCacheLoader.load(Unknown Source)
06/01/05 15:54:14 at oracle.ias.cache.CacheLoader.callLoad(Unknown Source)
06/01/05 15:54:14 at oracle.ias.cache.CacheHandle.findObject(Unknown Source)
06/01/05 15:54:14 at oracle.ias.cache.CacheHandle.asyncLoad(Unknown Source)
06/01/05 15:54:14 at oracle.ias.cache.Task.execute(Unknown Source)
06/01/05 15:54:14 at oracle.ias.cache.WorkerThread.run(Unknown Source)
06/01/05 15:54:14 WebinUtil Session Started: Thu Jan 05 15:54:14 GMT 2006
06/01/05 15:54:14 load entred for country cache loader Thu Jan 05 15:54:14 GMT 2006
06/01/05 15:54:14 java.lang.Exception: Stack trace
06/01/05 15:54:14 at java.lang.Thread.dumpStack(Thread.java:1064)
06/01/05 15:54:14 at uk.ac.ebi.submission.util.CountryCacheLoader.load(Unknown Source)
06/01/05 15:54:14 at oracle.ias.cache.CacheLoader.callLoad(Unknown Source)
06/01/05 15:54:14 at oracle.ias.cache.CacheHandle.findObject(Unknown Source)
06/01/05 15:54:14 at oracle.ias.cache.CacheHandle.locateObject(Unknown Source)
06/01/05 15:54:14 at oracle.ias.cache.CacheAccess.get(Unknown Source)
06/01/05 15:54:14 at uk.ac.ebi.submission.ejb.session.WebinUtilBean.getCountries(Unknown Source)
06/01/05 15:54:14 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
06/01/05 15:54:14 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
06/01/05 15:54:14 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
06/01/05 15:54:14 at java.lang.reflect.Method.invoke(Method.java:324)
06/01/05 15:54:14 at com.evermind.server.ejb.interceptor.EJBJoinPointImpl.invoke(EJBJoinPointImpl.java:39)
06/01/05 15:54:14 at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:45)
06/01/05 15:54:14 at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:62)
06/01/05 15:54:14 at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:43)
06/01/05 15:54:14 at com.evermind.server.ejb.interceptor.system.JAASInterceptor$1.run(JAASInterceptor.java:32)
06/01/05 15:54:14 at java.security.AccessController.doPrivileged(Native Method)
06/01/05 15:54:14 at javax.security.auth.Subject.doAs(Subject.java:379)
06/01/05 15:54:14 at com.evermind.server.ThreadState.runAs(ThreadState.java:637)
06/01/05 15:54:14 at com.evermind.server.ejb.interceptor.system.JAASInterceptor.invoke(JAASInterceptor.java:36)
06/01/05 15:54:14 at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:43)
06/01/05 15:54:14 at com.evermind.server.ejb.interceptor.system.TxRequiredInterceptor.invoke(TxRequiredInterceptor.java:56)
06/01/05 15:54:14 at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:43)
06/01/05 15:54:14 at com.evermind.server.ejb.interceptor.system.SecurityRoleInterceptor.invoke(SecurityRoleInterceptor.java:46)
06/01/05 15:54:14 at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:43)
06/01/05 15:54:14 at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:62)
06/01/05 15:54:14 at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:43)
06/01/05 15:54:14 at com.evermind.server.ejb.interceptor.system.RunningStateInterceptor.invoke(RunningStateInterceptor.java:28)
06/01/05 15:54:14 at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:43)
06/01/05 15:54:14 at com.evermind.server.ejb.StatelessSessionEJBObject.OC4J_invokeMethod(StatelessSessionEJBObject.java:106)
06/01/05 15:54:14 at WebinUtilLocal_StatelessSessionBeanWrapper50.getCountries(WebinUtilLocal_StatelessSessionBeanWrapper50.java: 310)
06/01/05 15:54:14 at uk.ac.ebi.submission.cactus.session.WebinUtilTest.testGetCountries(Unknown Source)
06/01/05 15:54:14 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
06/01/05 15:54:14 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
06/01/05 15:54:14 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
06/01/05 15:54:14 at java.lang.reflect.Method.invoke(Method.java:324)
06/01/05 15:54:14 at junit.framework.TestCase.runTest(TestCase.java:154)
06/01/05 15:54:14 at junit.framework.TestCase.runBare(TestCase.java:127)
06/01/05 15:54:14 at org.apache.cactus.internal.AbstractCactusTestCase.runBareServer(AbstractCactusTestCase.java:153)
06/01/05 15:54:14 at org.apache.cactus.internal.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:119)
06/01/05 15:54:14 at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody0(AbstractWebTestControl ler.java:93)
06/01/05 15:54:14 at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody1$advice(AbstractWebTest Controller.java:224)
06/01/05 15:54:14 at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest(AbstractWebTestController.java)
06/01/05 15:54:14 at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody2(ServletTestRedirector.java:101)
06/01/05 15:54:14 at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody3$advice(ServletTestRedirector.java:224)
06/01/05 15:54:14 at org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java)
06/01/05 15:54:14 at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody0(ServletTestRedirector.java:72)
06/01/05 15:54:14 at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody1$advice(ServletTestRedirector.java:224)
06/01/05 15:54:14 at org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.java)
06/01/05 15:54:14 at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
06/01/05 15:54:14 at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
06/01/05 15:54:14 at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
06/01/05 15:54:14 at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:382)
06/01/05 15:54:14 at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:701)
06/01/05 15:54:14 at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:397)
06/01/05 15:54:14 at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:833)
06/01/05 15:54:14 at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:430)
06/01/05 15:54:14 at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:216)
06/01/05 15:54:14 at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:119)
06/01/05 15:54:14 at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
06/01/05 15:54:14 at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:215)
06/01/05 15:54:14 at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:232)
06/01/05 15:54:14 at oracle.oc4j.network.ServerSocketAcceptHandler.access$1000(ServerSocketAcceptHandler.java:35)
06/01/05 15:54:14 at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:819)
06/01/05 15:54:14 at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
06/01/05 15:54:14 at java.lang.Thread.run(Thread.java:534)
Hope this is enough information.
Thanks
Charlie

Similar Messages

  • Cache distribution - Java object cache

    Hi.
    I'm trying to use Oracle Java Object Cache (cache.jar), the one included in the 9iAS 9.0.3.
    Everything works fine but the cache distribution between different JVM:s.
    Anyone got this to work?
    Regards
    Jesper
    package test;
    import oracle.ias.cache.*;
    * Singleton Cache class.
    public class Cache {
         /** The singleton instance of the object. */
         private static Cache instance = null;
         /** The root region. */
         private final static String APP_NAME = "Test";
         * Protected constructor - Use <code>getInstance()</code>.
         * @throws Exception if error
         protected Cache() throws Exception {
              CacheAccess.defineRegion(APP_NAME);
         * Gets the singleton instance.
         * @return The instance of the Cache object.
         public static Cache getInstance() throws Exception {
              if (instance==null) {
                   createInstance();
              return instance;
         * Creates the singleton instance in a thread-safe manner.
         synchronized private static void createInstance() throws Exception {
              if (instance==null) {
                   instance = new Cache();
         * Put an object on the cache.
         * @param name The object name
         * @param subRegion The sub region
         * @param object The object to cache
         * @throws Exception if error
         public static void put(String name, String subRegion, Object object) throws Exception {
              CacheAccess appAcc = null;
              CacheAccess subAcc = null;
              try {
                   appAcc = CacheAccess.getAccess(APP_NAME);
                   // Create a group
                   Attributes a = new Attributes();
                   a.setFlags(Attributes.DISTRIBUTE);
                   appAcc.defineSubRegion(subRegion, a);
                   subAcc = appAcc.getSubRegion(subRegion);
                   if (!subAcc.isPresent(name)) {
                        subAcc.put(name, a, object);
                   } else {
                        subAcc.replace(name, object);
              } catch (CacheException ex){
                   // handle exception
                   System.out.println(ex.toString());
              } finally {
                   if (subAcc != null) {
                        subAcc.close();
                   if (appAcc != null) {
                        appAcc.close();
         * Gets a cached object from the specified sub region
         * @param name The object name
         * @param subRegion The sub region
         * @return The cached object
         * @throws Exception if requested object not in cache
         public static Object get(String name, String subRegion) throws Exception {
              CacheAccess appAcc = null;
              CacheAccess subAcc = null;
              Object result = null;
              try {
                   appAcc = CacheAccess.getAccess(APP_NAME);
                   subAcc = appAcc.getSubRegion(subRegion);
                   // define an object and set its attributes
                   result = (Object)subAcc.get(name);
              } catch (CacheException ex){
                   // handle exception
                   throw new Exception("Object '" + name + "' not in cache region '" + subAcc.getRegionName() + "'.");
              } finally {
                   if (subAcc != null) {
                        subAcc.close();
                   if (appAcc != null) {
                        appAcc.close();
              return result;
         * Invalidates all objects in all regions
         public static void invalidateAll() throws Exception {
              CacheAccess appAcc = CacheAccess.getAccess(APP_NAME);
              appAcc.invalidate(); // invalidate all objects
              appAcc.close(); // close the CacheAccess access
         // Main method for testing purposes.
         public static void main(String[] args) throws Exception {
              try {
                   System.out.println(">> Caching object OBJ1 into region TEST1.");
                   Cache.getInstance().put("OBJ1", "TEST1", "Object cached in TEST1.");
                   System.out.println(">> Getting OBJ1 from cache region TEST1.");
                   System.out.println(Cache.getInstance().get("OBJ1", "TEST1"));
              } catch (Exception ex) {
                   System.out.println(ex.getMessage());
    Contents of JAVACACHE.PROPERTIES:
    # discoveryAddress is a list of cache servers and ports
    discoveryAddress = host1.myserver.com:12345,host2.myserver.com:12345
    logFileName = c:\javacache.log
    logSeverity = DEBUG
    distribute = true

    I have same problem
    Exist some reason?
    I'm testing Cache with isDistributed() method and I still got false!
    Thanx

  • Oracle Application Server 10g Java Object Cache

    Hi,
    I am new to Java and looking for a java caching framework and just came across Oracle Application Server 10g Java Object Cache. I am unable to find 11g version of the same. Is it not supported any more?
    Can I use this with weblogic server? Please suggest if any other alternatives.
    Thanks,
    Manoj

    Bump.
    I definitely don't see the same file: C:\dev\jdevstudio10134\javacache\lib\cache.jar in the Oracle JDEV tree. Is there a suggested alternative?

  • Java Object Cache

    With a cache loader, the Java Object Cache automatically determines if an object needs to be loaded into the cache when the object is request.
    Can someone tellme how exactly this works.
    I am trying to get the cache framework to load objects automatically in the cache.
    hwoever unless i explicitly use the CacheAcess.put method. the object is not loaded in the cache.
    Plss lemme knw, how the framework does it automatically.
    Regards,
    Mukta

    Hi Mukta,
    FYI, This discussion forum is all about Web Cache, and not related to Java Object Cache.
    Anyways, to hint you on automatic loading of objects -> use the CacheAccess.preLoad() method.
    You can post this question in a forum related to the Java Object Cache, for better answers.
    Regards,
    Priyanka GES
    Oracle Web Cache Team

  • OracleAS Java Object Cache 10g

    OracleAS Java Object Cache 10g Documentation link on the top right of the page is broken and leads to a 404 page not found.

    Hi,
    apologies for the delay responding.
    Can you please confirm if link is part of the OTN documentation pages at: http://otn.oracle.com/documentation/index.html
    Regards,
    Les

  • Java object caching

    Hi All,
    I need to cache java objects, have anyone a documentation or sample code to help me.
    Thanks in advance

    http://download-uk.oracle.com/docs/cd/B14099_15/web.1012/b14012/objcache.htm#sthref1069
    http://download-uk.oracle.com/docs/cd/B14099_15/web.1012/b14019/toc.htm

  • Declarative java object cache in non oc4j container

    hello,
    i'm trying to use the cache.jar from 10g in a standalone application.
    i've followed the j2ee services guide and use cache.open(path_to_javacache.xml). javacache.xml has preload-file defined, in which i've declared my userdefined classloader and userdefined cached object. the implementations of both implement declarable. however,when i use cacheaccess.getaccess(region_name) i get regionnotfoundexception.
    i've also tried to use the configurator alternative, where i specify the declarative cache xml file. but this gives me a classcastexception.
    any suggestions. better yet is there a sample program that
    shows the use of a decl cache in a non oc4j container.
    thanks

    Hi,
    I ran into the same problem while evaluating OC4J V9 Java Cache standalone.
    Cache.open() silently ignores errors:
    * Cache.open(path_to_javacache.xml) seems to silently swallow alle error messages (in your case the ClassCastException) and the ignore the configuration file
    * so to get meaningful error messages, first attempt to open the file with new Configurator(path_to_javacache.xml)
    * once there are no more errors, you can open it with Cache.open(path_to_javacache.xml)
    Now, to get around the ClassCastException:
    * you need to add xmlparserv2.jar from your oc4j distribution
    * this must be the first xml-parser in your classpath (when e.g. xerces.jar comes first, you will get a ClassCastException)
    A relative javacache.xml is relative to your working directory.
    The preload-file - Path seems to be relative to the javacache.xml path, if it is not absolute. I keep javacache.xml and preload-file together which worked for me.
    Hope this help,
    Andreas

  • How to reference multiple instances of the same Java object from PL/SQL?

    Dear all,
    I'm experimenting with calling Java from PL/SQL.
    My simple attempts work, which is calling public static [java] methods through PL/SQL wrappers from SQL (and PL/SQL). (See my example code below).
    However it is the limitation of the public static methods that puzzels me.
    I would like to do the following:
    - from PL/SQL (in essence it needs to become a forms app) create one or more objects in the java realm
    - from PL/SQL alter properties of a java object
    - from PL/SQL call methods on a java object
    However I fail to see how I can create multiple instances of an object and reference one particular object in the java realm through public static methods.
    My current solution is the singleton pattern: of said java object I have only 1 copy, so I do not need to know a reference to it.
    I can just assume that there will only ever be 1 of said object.
    But I should be able to make more then 1 instance of an object.
    To make it more specific:
    - suppose I have the object car in the java realm
    - from PL/SQL I want to create a car in the java realm
    - from PL/SQL I need to give it license plates
    - I need to start the engine of a scpecific car
    However if I want more then 1 car then I need to be able to refrence them. How is this done?
    Somehow I need to be able to execute the following in PL/SQL:
    DECLARE
    vMyCar_Porsche CAR;
    vMyCar_Fiat CAR;
    BEGIN
    vMyCar_Porsche = new CAR();
    vMyCar_Fiat = new CAR();
    vMyCar_Porsche.setLicensePlates('FAST');
    vMyCar_Porsche.startEngine();
    vMyCar_Fiat.killEngine();
    END;
    Thanks in advance.
    Best Regards,
    Ruben
    My current example code is the following:
    JAVA:
    ===
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED CODAROUL."RMG/BO/RMG_OBJECT" as package RMG.BO;
    public class RMG_OBJECT {
    private static RMG_OBJECT instance = new RMGOBJECT();
    private String rmgObjectNaam;
    private RMG_OBJECT(){
    this.rmgObjectNaam = "NonDetermined";
    public static String GET_RMGOBJECT_NAAM () {
    String toestand = null;
    if (_instance == null) {toestand = "DOES NOT EXIST";} else { toestand = "EXISTS";};
    System.out.println("instance : " + toestand);
    System.out.println("object name is : " + _instance.rmgObjectNaam);
    return _instance.rmgObjectNaam;
    public static Integer SET_RMGOBJECT_NAAM (String IN)
    try
    _instance.rmgObjectNaam = IN;
    return 1;
    catch (Exception e)//catch
    System.out.println("Other Exception: " + e.toString());
    e.printStackTrace();
    return 5;
    } //catch
    PL/SQL Wrapper:
    ==========
    CREATE OR REPLACE FUNCTION CODAROUL.SET_RMGOBJECT_NAAM(NAAM IN VARCHAR2) return NUMBER AS
    LANGUAGE JAVA NAME 'RMG.BO.RMG_OBJECT.SET_RMGOBJECT_NAAM (java.lang.String) return java.lang.Integer';
    Calling from SQL:
    ==========
    CALL dbms_java.set_output(2000);
    select CODAROUL.GET_RMGOBJECT_NAAM() from dual;
    Edited by: RubenS_BE on Apr 6, 2012 5:35 AM
    Edited by: 925945 on Apr 6, 2012 5:41 AM

    You can do this by manually creating a new iterator binding in your binding tab.
    So instead of dragging the VO directly to the page, go to the binding tab, add a new executable iterator binding, and point to that one from your ELs in the page itself.

  • JAVA Object to XML to JAVA to XML

    I have to achieve below in java:-
    -Create input XMLs from Java class (that resides in a jar).
    -Take input from user then store that data to Java object and submit for processing.
    -After processing print response java object again in XML.
    What is the best API to achieve this. Will be helpful if any example is available.

    Thanks for the Reply =)
    I have a Java Object that have some fileds like arraylist<Class> I want to take care of these fields as well.
    If that arrayList<Class> have another fields that can be normal fileds or arraylist of another class, need to take care of all fields during XML generation
    Example:-
    Root Class have below fields
    private int ArCt;
    private ArrayList<ClassChild1> Ar;
    Setters
    Getters
    ClassChild1.class
    private int PlnCd;
    private int cArCt;
    private ArrayList cAr<ClassChild2> cAr;
    ClassChild2.class
    private String PlNm
    XML Needed - Example from above object
    <root>
    <ArCt>1</ArCt>
    <Ar>
    <ClassChild1>
    <PlnCd>S</PlnCd>
    <cArCt>2</<cArCt>
    <cAr>
    <ClassChild2>
    <PlNm>Plan1</PlNm>
    </ClassChild2>
    <ClassChild2>
    <PlNm>Plan2</PlNm>
    </ClassChild2>
    </cAr>
    </ClassChild1>
    </Ar>
    </root>
    Edited by: nitingautam on May 15, 2011 11:01 PM

  • Usage of Object Cache for Java in J2EE apps

    Hi,
    we are investigating on whether we can use the Object Cache for Java
    (OCS4J) for our requirements. The question we have come across is:
    What is the designated way of integration for the Object cache to fit
    into the J2EE environment? Unfortunately, although the current manuals
    group OCS4J into the "Oracle Containers for J2EE Services Guide" and the
    suggested package name for the whole thing in JSR 107 seems to be
    javax.util.jcache, there is very little documentation on how the
    designers would like J2EE programmers to use the cache from within a
    J2EE app and all examples given are not from within a J2EE environment.
    We are in particular thinking about a hierarchy of several cache
    "compartments" (Region->Subregion->group) for different topics and using
    the hierarchical name of the cache (region.subregion.group) as the
    primary key for BMP Entity beans, each of them having their own
    CacheAccess object. Then we would have an API of stateless Session beans
    on top of that, which would be determining the cache "compartment", get
    the appropriate Entity Bean with the Cache Access object and then do the
    required operations on the cache.
    But then we immediately run into the question of how the mapping between
    Cache Objects and CacheAccess objects will be done etc.
    So is there anybody that can give us any hints how to use the OCS4J in
    an EJB scenario?
    Thanks in advance for any help!
    Andreas Loew
    [email protected]

    We have Java client requesting over HTTP to application server. We would like to cache some of the objects created by the servlet while serving the request. Can I use the OCS4J for caching the Java objects. Do I require any software or just copying the JAR file and importing the class would serve the purpose?
    Regards
    Arun

  • How to use Java NIO to implement disk cache for serialized java objects

    Hi,
    I have a cache (implemented as hahstable etc.) that contains java objects (mostly strings) and swaps objects from runtime memory to the disk and back based on some algorithms. Currently, the reading and writing from the disk is implemented using java.io.* package i.e. fileInputstream and FileOutputStream. Essentially, I serialize the java object and write to the disk and the deserialize and give it back to the Hashtable cache.
    The performance of swapping from disk to memory is kinda slow. I have read that memory mapping would improve the performance.
    My idea is to do the following:
    Have one big file mapped to memory. I write the serialized objects to different portions of the file and then read those portions when needed. I can use the MappedByteBuffer for that but then I have the following questions. I will not store objects in the hashtable anymore.
    1. How do I delete things from the cache in the above design i.e. how do I delete portions of a mapped file?
    2. How do I serialize objects using ByteBuffers and then deserialize them? I guess this shouldn't be hard but just want to confirm.
    Do you think this is the right design or should I change? Right now using the old io package, I have a separate file for each object. When using the NIO package, I want to store all objects in a single file in different portions of the file, is that the right way to go?
    As you can see, I am beginner in memory mapped io and need help.

    Have one big file mapped to memory. I write the serialized objects to different portions of the file and then read those portions when needed. I can use the MappedByteBufferThis is a good idea, one that I have worked on. It involves quite a bit of manipulation with temporary buffers and a deep working knowledge of object serialization.
    1. How do I delete things from the cache in the above design i.e. how do I delete portions of a mapped file?The best way to handle this is do a two-step process, cutting the file into two pieces and gluing it back together where the original one is...
    2. How do I serialize objects using ByteBuffers and then deserialize them? I guess this shouldn't be hard but just want to confirm.It is hard. Wrapping the streams and making the IO work properly is not the challenge however. The hard part comes in hacking the object streams. The object input/output streams use a ClassDescriptor object which only gets written once/ read once. This shouldn't be a problem if you will read/write the entire file at once, but will bring you grief if you want random access to your objects. You will also need an indexing mechanism to support random access.
    Do you think this is the right design or should I change? Right now using the old io package, I have a separate file for each object. When using the NIO package, I want to store all objects in a single file in different portions of the file, is that the right way to go?I guess it depends on your needs. Do you require random access to objects? NIO provides some performance gains, but mostly for very large amounts of data (>10M in my experience).
    You can always write all your objects into the same file using normal io techniques and you can still generate an index and acheive random access. It might be easier...
    Good luck

  • Code generation: from resultset to Java Object

    Hello all:
    Is there any utilities that can convert the ResultSet to a list of Java objects? I think that's doable, since we can get the metadata from ResultSetMetaData anyway, which provide a means to construct the internal properties of a java object.
    I just wonder if there is already something doing that out there... rather not to reinvent the wheel...
    Thanks,
    John

    thanks to both.
    You don't create data objects from data rather your data exists within the data objects. Thus the code that is going to use the data objects must already know the form so they can do something intelligent in the first place.So much better to start with a data model and then create code from that then populate from the database.
    >
    Here I just explore the idea and assess its viability. The project is using a cache solution, coherence as matter of fact. it seems the idea is to return a data strcture like a generic resultset from the cache. my understanding is that, when a user sends out a SQL, the database designer wouldn't know the POJOs the user uses from their side, still database is able to return a resultset from which the user will have enough info to populate their POJOs.
    I will take another look at the design, but meanwhile I found BasicDynaBean from apache's bean utilities useful, and came out with the following code:
    public List<BasicDynaBean> execute(final RequestObject ro) throws SQLException {
              List<BasicDynaBean> list = jdbcTemplate.execute(
                        new CallableStatementCreator(){
                             @Override
                             public CallableStatement createCallableStatement(Connection con)
                                       throws SQLException {
                                  CallableStatement cs = con.prepareCall(spName);
                                             // code skipped
                                                                                                    return cs;
                        new CallableStatementCallback<List<BasicDynaBean>>(){
                             @Override
                             public List<BasicDynaBean> doInCallableStatement(CallableStatement cs)
                                       throws SQLException, DataAccessException {
                                  cs.execute();
                                  ResultSet rs = (ResultSet) cs.getObject(outputPos);
                                                                                                    //apache api to convert the rs to list of BasicDynaBean     
                                  RowSetDynaClass rsdc = new RowSetDynaClass(rs);
                                  List<BasicDynaBean> rows = rsdc.getRows();
                                  return rows;
              however, I noticed that each mean contains the column headers, seems to me it's quite a overhead!
    thanks, John
    Edited by: Johnny_hunter on Aug 1, 2011 10:49 AM
    Edited by: Johnny_hunter on Aug 1, 2011 11:57 AM

  • How to reload class file for java objects in CF MX7

    I'm trying to create a simple java object for use in a CFML
    page. According to the topic "About ColdFusion and Java objects" in
    the CF developer's guide, I can compile my java module and put the
    .class file in the CFusionMX7/wwwroot/WEB-INF/classes directory and
    it'll be dynamically reloaded any time CF sees a new .class file
    there. But the dynamic reload isn't happening; I have to restart
    the CF server to get it to pick up a new version.
    I don't believe this directory is in the "general JVM
    classpath"; I don't find "classes" in the Java Class Path in the CF
    Administrator's System Information page. And I have all the caching
    options turned off on the "Server Settings > Caching" page, if
    that has any bearing on it.
    Are there any known issues around this dynamic reload
    capability, or maybe a more definitive way to make sure the
    WEB-INF/classes directory isn't in the classpath?
    Thanks,
    James

    Yes, I understand. But if I'm reading it correctly, what
    you're saying seems to contradict the documentation
    http://livedocs.adobe.com/coldfusion/7/htmldocs/00001561.htm
    ColdFusion dynamically loads classes that are either .class
    files in the web_root/WEB-INF/classes directory or in JAR files in
    the web_root/WEB-INF/lib directory. ColdFusion checks the time
    stamp on the file when it creates an object that is defined in
    either directory, even when the class is already in memory. If the
    file that contains the class is newer than the class in memory,
    ColdFusion loads the class from that directory.
    http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_18228&sliceId=1
    Dynamic class reloading for Java servlets classes and
    forcfobject (sic) Java classes is disabled by default in
    ColdFusion MX. To enable dynamic class reloading, do the following:
    Also, I seem to recall that setting worked in a prior
    version. Though I would have to test it again on another machine to
    be certain.

  • OCI Object Cache leaking memory

    I am performing a select that selects a column object (ie column of user defined type) from a table using OCI. It all works fine. However, the OCI client-side object cache just grows and grows and grows when this query is run regardless of the settings for ATTR_CACHE_MAX_SIZE and ATTR_CACHE_OPT_SIZE. I am not pinning the objects so there should be no reason why the cache should not age the objects out and free the memory. I see no such problems on non-object selects - the cache behaves fine unless I select object types (SQLT_NTY).
    I can workaround the problem by calling OCICacheFree regularly - but I don't like the inelegance of that solution. If I don't do this however, OCI will cache and cache and cache until it has exhausted all the memory on my server !!
    So anyone else see this problem ? Am I doing something wrong ? Is is an Oracle bug ?
    Thanks for any help,
    Steve

    hi there,
    i dunno if my problem is related to the above issue.
    BUT.
    Here is what I have:
    - JBoss-3.2.1 running on Linux RedHat 9
    - Oracle 9 running ... somewhere
    Here is what I want:
    - to regularly transfer big files from the client app thru JBoss/EJBs to Oracle
    Here is what I tried:
    - I tried BLOBs and CLOBs and etc. But the ARRAY choice appeared to be the best and has been working pretty fine till I started getting the problem I am gonna talk about here below.
    Here is what I do (the code snippet of an EJB):
    Connection conn = null;
    CallableStatement stmt = null;
    // some code
    stmt = conn.prepareCall("begin SOME_PROCEDURE");
    // some code
    ArrayList data = new ArrayList();
    ByteArrayInputStream is = new ByteArrayInputStream(fileContent);
    ArrayDescriptor arrdesc = ArrayDescriptor.createDescriptor("RAW_VARRAY", ((JDCConnection)conn).getConnection());
    ARRAY arr = new ARRAY(arrdesc, ((JDCConnection)conn).getConnection(), data.toArray());
    ((oracle.jdbc.OracleCallableStatement)stmt).setARRAY(2, arr);
    // trying to execute the stmt
    stmt.execute();
    Where:
    - RAW_ARRAY is a user-defined Oracle collection type. It is basically 'array[10240] of RAW'
    - JDCConnection implements java.sql.Connection.
    (JDCConnection was created to facilitate connection pooling inside JBoss, but I guess, yes I guess, that's not that relevant here).
    Here is the PROBLEM:
    - the code works pretty fine for a while
    - BUT after some time, the code starts dumping the following exception:
    java.sql.SQLException: OCI-21522: attempted to use an invalid connection in OCI (object mode only)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:169)
    at oracle.jdbc.oci8.OCIDBAccess.check_error(OCIDBAccess.java:1609)
    at oracle.jdbc.oci8.OCIDBAccess.getOracleTypeADT(OCIDBAccess.java:1745)
    at oracle.jdbc.oracore.OracleTypeADT.initMetadata(OracleTypeADT.java:386)
    at oracle.jdbc.oracore.OracleTypeADT.init(OracleTypeADT.java:344)
    at oracle.sql.ArrayDescriptor.initPickler(ArrayDescriptor.java:1002)
    at oracle.sql.ArrayDescriptor.<init>(ArrayDescriptor.java:132)
    at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:97)
    Can anybody let me know if you have any ideas of what's going on here?
    Your help is badly needed, guys!
    Many thx in advance!!
    my best,
    Kanat.

  • Generation of XML file from Java objects using castor

    I have the following java file(Customer.java).
    public class Customer
         private String ID;
         private FirstName firstName;
         private MiddleName middleName;
         private LastName lastName;
         private ArrayList address;
         public ArrayList getAddress() {
              return address;
         public void setAddress(ArrayList address) {
              this.address = address;
         public FirstName getFirstName() {
              return firstName;
         public void setFirstName(FirstName firstName) {
              this.firstName = firstName;
         public String getID() {
              return ID;
         public void setID(String id) {
              ID = id;
         public LastName getLastName() {
              return lastName;
         public void setLastName(LastName lastName) {
              this.lastName = lastName;
         public MiddleName getMiddleName() {
              return middleName;
         public void setMiddleName(MiddleName middleName) {
              this.middleName = middleName;
    Using castor i have created an xml file(customer.xml) which has the following format.
    <?xml version="1.0" encoding="UTF-8" ?>
    - <customer ID="fbs0001">
    <FIRSTNAME>Fred</FIRSTNAME>
    <MIDDLENAME>B</MIDDLENAME>
    <LASTNAME>Scerbo</LASTNAME>
    - <ADDRESS>
    <FIRSTLINE>No 18, Sheshadri road</FIRSTLINE>
    <SECONDLINE>Gandhinagar Bangalore</SECONDLINE>
    </ADDRESS>
    - <ADDRESS>
    <FIRSTLINE>ITPL</FIRSTLINE>
    <SECONDLINE>Whitefield Bangalore</SECONDLINE>
    </ADDRESS>
    </customer>
    I have used a mapping file to get this output.Is there a way where i can get the output xml in the following format without changing the Java object structure.If yes then please suggest how this can be done.
    <?xml version="1.0" encoding="UTF-8" ?>
    - <customer ID="fbs0001">
    <FIRSTNAME>Fred</FIRSTNAME>
    <MIDDLENAME>B</MIDDLENAME>
    <LASTNAME>Scerbo</LASTNAME>
    </customer>
    <ADDRESS>
    <FIRSTLINE>No 18, Sheshadri road</FIRSTLINE>
    <SECONDLINE>Gandhinagar Bangalore</SECONDLINE>
    </ADDRESS>
    - <ADDRESS>
    <FIRSTLINE>ITPL</FIRSTLINE>
    <SECONDLINE>Whitefield Bangalore</SECONDLINE>
    </ADDRESS>
    I mean the output xml file should have the address as a separate tag not withing the root tag customer.

    Hello,
    Castor's own discussion groups might be able to point you to the solution you're looking for (if this use case is possible using Castor).
    Oracle has its own object-to-XML mapping tool that is part of the TopLink product. It allows you to map existing objects to an existing XML Schema. This can be done visually using the TopLink Workbench, or programmatically using the TopLink APIs. TopLink OXM also supports the JAXB specification.
    Using TopLink OXM to get the desired XML result I would recommend the following. Map the Customer and Address classes to XML, but don't map the relationship between Customer and Address. Then make the calls to the marshaller something like the following:
    marshaller.marshal(aCustomer, System.out);
    for(int x=0; x<aCustomer.getAddress().size(); x++) {
         marshal(aCustomer.getAddress().get(x), System.out);
    Example - Using TopLink OXM to map an existing object model to an existing XML Schema:
    http://www.oracle.com/technology/products/ias/toplink/preview/10.1.3dp4/howto/ox/index.htm
    For more information on TopLink object-to-XML mapping:
    http://www.oracle.com/technology/products/ias/toplink/preview/10.1.3dp4/objectxml/index.html
    -Blaise

Maybe you are looking for

  • How to pop up "Drag New signature rectangle" window from plug-in?

    Hi, everybody        I am trying to create a menu that contains menuitem "sign". when the  user click on menu->"sign" a  window  pop-up        asking for "Drag New signature rectangle" from the user.This window is same as poped up by default by digSi

  • Where is the 'Alert Me' option in iTunes 11?

    I can't find the option to 'alert me' or 'follow' an artist in the iTunes store in iTunes 11. I sent an email to support but they didn't help very much: "Greetings from iTunes Store Support. My name is Aparicio. I understand that you are unable to lo

  • I recently updated my iPhone to iOS 6.0 and all my contacts have updated

    Since completing the recent iPhone iOS 6.0 update, all my contact details have updated as well and I'd like to know how this happened. For example, a friend who I only had in with her first name, now has first and last name? Other contacts have added

  • MuVo TX suddenly not recogni

    Hello All I'm hoping someone here has an idea. I just tried by MuVo Tx Fm on my WindowsXP computer for the first time after loading the latest drivers. XP deli'vers a message saying the USB device has failed and is nto recognized. When I click on the

  • Wrong translation for correspondence

    From Class has been translated as "Clase Festivo" in customizing entry Define Standard Form Classes for Correspondence using Spanish like logon language. Form Class = Clase de Formulario