Topic
  • 27 replies
  • Latest Post - ‏2012-03-27T20:09:18Z by cheng1
PSUM_Tony_Tang
PSUM_Tony_Tang
18 Posts

Pinned topic Use WXS as Hibernate L2 Cache

‏2012-03-20T12:46:03Z |
I use WXS 7.1.1 and Hibernate 3.6 to config WXS as L2 cache and failed.

My Hibernate config file:
<property name="cache.use_query_cache">true</property>
<property name="cache.use_second_level_cache">true</property>
<property name="cache.provider_class">com.ibm.websphere.objectgrid.hibernate.cache.ObjectGridHibernateCacheProvider</property>
<property name="objectgrid.configuration">ObjectGridType=EMBEDDED,ObjectGridName=myGridNameeee</property>
<property name="objectgrid.hibernate.regionNames">studentregion</property>
I add this line in my Entity Mapping file: <cache usage="read-only" region="studentregion" />

This jar file is added in my project classpath: oghibernate-cache.jar, objectgrid.jar, ibmorb.jar
I also check the 2809 port is not use by any other program.

The detail error message is:

org.hibernate.cache.CacheException: java.lang.reflect.InvocationTargetException
at com.ibm.ws.objectgrid.hibernate.cache.ObjectGridHibernateCache.getSession(ObjectGridHibernateCache.java:178)
at com.ibm.ws.objectgrid.hibernate.cache.ObjectGridHibernateCache.get(ObjectGridHibernateCache.java:310)12-3-20 20:40:10:024 CST 0000000a ServiceLogger I com.ibm.ws.ffdc.IncidentStreamImpl resetIncidentStream FFDC0010I: FFDC 已关闭附带的流文件 E:\androidws\cacheeXtreamOracle\logs\ffdc\ogserver_0000000a_12.03.20_20.40.10_2.txt

at org.hibernate.cache.ReadOnlyCache.get(ReadOnlyCache.java:58)
at org.hibernate.cache.impl.bridge.EntityAccessStrategyAdapter.get(EntityAccessStrategyAdapter.java:55)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromSecondLevelCache(DefaultLoadEventListener.java:587)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:459)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:147)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090)
at org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:1026)
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:176)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:215)
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190)
at domain.Student_$$_javassist_0.getCOLUMN1(Student_$$_javassist_0.java)
at domain.Test1.queryById(Test1.java:111)
at domain.Test1.main(Test1.java:19)
Caused by: java.lang.reflect.InvocationTargetException
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:597)
at com.ibm.ws.objectgrid.hibernate.cache.ObjectGridHibernateCache.getSession(ObjectGridHibernateCache.java:167)
... 15 more
Caused by: java.lang.RuntimeException: org.hibernate.cache.CacheException: org.hibernate.cache.CacheException: Failed to get ObjectGrid server.
at com.ibm.websphere.objectgrid.hibernate.cache.ObjectGridHibernateCacheProvider.initializeObjectGrid(ObjectGridHibernateCacheProvider.java:506)
... 20 more
Caused by: org.hibernate.cache.CacheException: org.hibernate.cache.CacheException: Failed to get ObjectGrid server.
at com.ibm.ws.objectgrid.hibernate.cache.HibernateObjectGridResourceFactory.getObjectGridResource(HibernateObjectGridResourceFactory.java:885)
at com.ibm.websphere.objectgrid.hibernate.cache.ObjectGridHibernateCacheProvider.initializeObjectGrid(ObjectGridHibernateCacheProvider.java:497)
... 20 more
Caused by: org.hibernate.cache.CacheException: Failed to get ObjectGrid server.
at com.ibm.ws.objectgrid.hibernate.cache.HibernateObjectGridResourceFactory.getObjectGridResource(HibernateObjectGridResourceFactory.java:816)
... 21 more

Also have some error message like this:

OBJECTGRID_CACHE_INITIALIZE_OBJECTGRID_FAILED_CWOBJ3133E=CWOBJ3133E: ObjectGrid cache plug-in initialization with ObjectGrid {1} failed with org.hibernate.cache.CacheException: Failed to get ObjectGrid server.

I found this error is in the trubleshooting list:
http://publib.boulder.ibm.com/infocenter/wxsinfo/v7r1/index.jsp?topic=%2Fcom.ibm.websphere.extremescale.messages.doc%2FCWOBJ3133E.html

But I still do not know how to fix it.
Any help/suggestion is welcome.

Thanks!
Updated on 2012-03-27T20:09:18Z at 2012-03-27T20:09:18Z by cheng1
  • cheng1
    cheng1
    44 Posts

    Re: Use WXS as Hibernate L2 Cache

    ‏2012-03-20T22:22:10Z  
    Can you attach your testcase ? so I can take a look.
  • PSUM_Tony_Tang
    PSUM_Tony_Tang
    18 Posts

    Re: Use WXS as Hibernate L2 Cache

    ‏2012-03-21T01:40:35Z  
    • cheng1
    • ‏2012-03-20T22:22:10Z
    Can you attach your testcase ? so I can take a look.
    Just a Query by id and make sure it is putted into L2 cache

    With out L2 cache this case works fine(the data will be fetch from database.)
    public class Test1 {

    static SessionFactory sf;
    static Session session;

    public static void main(String[] args) {
    try {
    int studentId = 5;
    init();
    // query by id, this record exist in database
    Student student = queryById(studentId);

    // delete from session cache
    session.evict(student);

    // make sure we still can get this entity without query from database.
    queryById(studentId);
    close();

    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }

    static void init() {
    sf = new Configuration().configure().buildSessionFactory();
    session = sf.openSession();
    }

    static void close() {
    session.close();
    sf.close();
    }

    static Student queryById(int id) {

    System.out.println("QUERY STUDENT-" + id);
    Student student = (Student) session.load(Student.class, id);
    student.getCOLUMN1();

    return student;
    }

    }

    from the error message it is look like this error:
    CWOBJ3133E
    OBJECTGRID_CACHE_INITIALIZE_OBJECTGRID_FAILED_CWOBJ3133E=CWOBJ3133E: ObjectGrid cache plug-in initializes with failed ObjectGrid: {0}

    Explanation
    An exception occurred while attempting to initialize ObjectGrid for an ObjectGrid cache plug-in. Possible causes are problems during creating ObjectGrid server or container, connecting to catalog service, or duplicate ObjectGrid name

    http://publib.boulder.ibm.com/infocenter/wxsinfo/v7r0/index.jsp?topic=%2Fcom.ibm.websphere.extremescale.messages.doc%2FCWOBJ3133E.html
  • PSUM_Tony_Tang
    PSUM_Tony_Tang
    18 Posts

    Re: Use WXS as Hibernate L2 Cache

    ‏2012-03-21T02:21:55Z  
    • cheng1
    • ‏2012-03-20T22:22:10Z
    Can you attach your testcase ? so I can take a look.
    I use the trial version of eXtreme Scale
    Is this the problem?
  • PSUM_Tony_Tang
    PSUM_Tony_Tang
    18 Posts

    Re: Use WXS as Hibernate L2 Cache

    ‏2012-03-21T08:04:24Z  
    I use the trial version of eXtreme Scale
    Is this the problem?
    all the log I got from Eclipse Console:
    Mar 21, 2012 3:44:55 PM com.ibm.websphere.objectgrid.server.ServerFactory
    INFO: LOADED_PROPERTY_FILES_CWOBJ0913
    3/21/12 15:44:55:780 CST 0000000a ServerFactory I CWOBJ0913I: Server property files have been loaded: file:/E:/task/extremescaletrial711/ObjectGrid/gettingstarted/client/bin/objectGridServer.properties.
    Mar 21, 2012 3:44:56 PM com.ibm.ws.objectgrid.server.DefaultDependencyProvider
    INFO: ORB_DEFAULT_PROPERTY_SET_CWOBJ0063
    3/21/12 15:44:56:202 CST 0000000a DefaultDepend I CWOBJ0063I: The com.ibm.CORBA.FragmentTimeout property was not configured. The com.ibm.CORBA.FragmentTimeout property is being set to 30.
    Mar 21, 2012 3:44:56 PM com.ibm.ws.objectgrid.server.DefaultDependencyProvider
    INFO: ORB_DEFAULT_PROPERTY_SET_CWOBJ0063
    3/21/12 15:44:56:202 CST 0000000a DefaultDepend I CWOBJ0063I: The com.ibm.CORBA.ConnectTimeout property was not configured. The com.ibm.CORBA.ConnectTimeout property is being set to 10.
    Mar 21, 2012 3:44:56 PM com.ibm.ws.objectgrid.server.DefaultDependencyProvider
    INFO: ORB_DEFAULT_PROPERTY_SET_CWOBJ0063
    3/21/12 15:44:56:202 CST 0000000a DefaultDepend I CWOBJ0063I: The com.ibm.CORBA.MinOpenConnections property was not configured. The com.ibm.CORBA.MinOpenConnections property is being set to 1024.
    Mar 21, 2012 3:44:56 PM com.ibm.ws.objectgrid.server.DefaultDependencyProvider
    INFO: ORB_DEFAULT_PROPERTY_SET_CWOBJ0063
    3/21/12 15:44:56:202 CST 0000000a DefaultDepend I CWOBJ0063I: The com.ibm.CORBA.iiop.NoLocalCopies property was not configured. The com.ibm.CORBA.iiop.NoLocalCopies property is being set to true.
    Mar 21, 2012 3:44:56 PM com.ibm.ws.objectgrid.server.DefaultDependencyProvider
    INFO: ORB_DEFAULT_PROPERTY_SET_CWOBJ0063
    3/21/12 15:44:56:202 CST 0000000a DefaultDepend I CWOBJ0063I: The com.ibm.CORBA.ThreadPool.MaximumSize property was not configured. The com.ibm.CORBA.ThreadPool.MaximumSize property is being set to 256.
    3/21/12 15:44:56:202 CST 0000000a DefaultDepend I CWOBJ0063I: The com.ibm.CORBA.ConnectionMultiplicity property was not configured. The com.ibm.CORBA.ConnectionMultiplicity property is being set to 1.
    Mar 21, 2012 3:44:56 PM com.ibm.ws.objectgrid.server.DefaultDependencyProvider
    INFO: ORB_DEFAULT_PROPERTY_SET_CWOBJ0063
    Mar 21, 2012 3:44:56 PM com.ibm.ws.objectgrid.server.DefaultDependencyProvider
    INFO: ORB_DEFAULT_PROPERTY_SET_CWOBJ0063
    3/21/12 15:44:56:202 CST 0000000a DefaultDepend I CWOBJ0063I: The com.ibm.ws.orb.transport.DeferSSLHandshake property was not configured. The com.ibm.ws.orb.transport.DeferSSLHandshake property is being set to true.
    3/21/12 15:44:56:202 CST 0000000a DefaultDepend I CWOBJ0063I: The com.ibm.CORBA.RequestTimeout property was not configured. The com.ibm.CORBA.RequestTimeout property is being set to 30.
    Mar 21, 2012 3:44:56 PM com.ibm.ws.objectgrid.server.DefaultDependencyProvider
    INFO: ORB_DEFAULT_PROPERTY_SET_CWOBJ0063
    Mar 21, 2012 3:44:56 PM com.ibm.ws.objectgrid.server.DefaultDependencyProvider
    INFO: ORB_DEFAULT_PROPERTY_SET_CWOBJ0063
    Mar 21, 2012 3:44:56 PM com.ibm.ws.objectgrid.server.DefaultDependencyProvider
    INFO: ORB_DEFAULT_PROPERTY_SET_CWOBJ0063
    3/21/12 15:44:56:202 CST 0000000a DefaultDepend I CWOBJ0063I: The com.ibm.CORBA.ServerSocketQueueDepth property was not configured. The com.ibm.CORBA.ServerSocketQueueDepth property is being set to 1024.
    3/21/12 15:44:56:202 CST 0000000a DefaultDepend I CWOBJ0063I: The com.ibm.CORBA.ThreadPool.IsGrowable property was not configured. The com.ibm.CORBA.ThreadPool.IsGrowable property is being set to false.
    Mar 21, 2012 3:44:56 PM com.ibm.ws.objectgrid.server.DefaultDependencyProvider
    INFO: ORB_DEFAULT_PROPERTY_SET_CWOBJ0063
    3/21/12 15:44:56:202 CST 0000000a DefaultDepend I CWOBJ0063I: The com.ibm.CORBA.FragmentSize property was not configured. The com.ibm.CORBA.FragmentSize property is being set to 0.
    3/21/12 15:44:56:218 CST 0000000a DefaultDepend I CWOBJ0063I: The com.ibm.CORBA.SocketWriteTimeout property was not configured. The com.ibm.CORBA.SocketWriteTimeout property is being set to 30.
    3/21/12 15:44:56:218 CST 0000000a DefaultDepend I CWOBJ0063I: The com.ibm.CORBA.NoLocalInterceptors property was not configured. The com.ibm.CORBA.NoLocalInterceptors property is being set to true.
    Mar 21, 2012 3:44:56 PM com.ibm.ws.objectgrid.server.DefaultDependencyProvider
    INFO: ORB_DEFAULT_PROPERTY_SET_CWOBJ0063
    Mar 21, 2012 3:44:56 PM com.ibm.ws.objectgrid.server.DefaultDependencyProvider
    INFO: ORB_DEFAULT_PROPERTY_SET_CWOBJ0063
    Mar 21, 2012 3:44:56 PM com.ibm.ws.objectgrid.server.DefaultDependencyProvider
    INFO: ORB_DEFAULT_PROPERTY_SET_CWOBJ0063
    3/21/12 15:44:56:218 CST 0000000a DefaultDepend I CWOBJ0063I: The com.ibm.CORBA.MaxOpenConnections property was not configured. The com.ibm.CORBA.MaxOpenConnections property is being set to 1024.
    Mar 21, 2012 3:44:56 PM com.ibm.ws.objectgrid.server.DefaultDependencyProvider
    INFO: ORB_DEFAULT_PROPERTY_SET_CWOBJ0063
    3/21/12 15:44:56:218 CST 0000000a DefaultDepend I CWOBJ0063I: The com.ibm.CORBA.ThreadPool.MinimumSize property was not configured. The com.ibm.CORBA.ThreadPool.MinimumSize property is being set to 256.
    3/21/12 15:44:56:218 CST 0000000a DefaultDepend I CWOBJ0063I: The com.ibm.CORBA.LocateRequestTimeout property was not configured. The com.ibm.CORBA.LocateRequestTimeout property is being set to 10.
    Mar 21, 2012 3:44:56 PM com.ibm.ws.objectgrid.server.DefaultDependencyProvider
    INFO: ORB_DEFAULT_PROPERTY_SET_CWOBJ0063
    Mar 21, 2012 3:44:56 PM com.ibm.websphere.objectgrid.hibernate.cache.ObjectGridHibernateCacheProvider
    SEVERE: OBJECTGRID_CACHE_INITIALIZE_OBJECTGRID_FAILED_CWOBJ3133E
    3/21/12 15:44:56:265 CST 0000000a ObjectGridHib E CWOBJ3133E: ObjectGrid cache plug-in initialization with ObjectGrid myOGName failed with exception org.hibernate.cache.CacheException: Failed to get ObjectGrid server..
    org.hibernate.cache.CacheException: java.lang.reflect.InvocationTargetException
    at com.ibm.ws.objectgrid.hibernate.cache.ObjectGridHibernateCache.getSession(ObjectGridHibernateCache.java:187)
    at com.ibm.ws.objectgrid.hibernate.cache.ObjectGridHibernateCache.get(ObjectGridHibernateCache.java:319)
    at org.hibernate.cache.NonstrictReadWriteCache.get(NonstrictReadWriteCache.java:69)
    at org.hibernate.cache.impl.bridge.EntityAccessStrategyAdapter.get(EntityAccessStrategyAdapter.java:55)
    at org.hibernate.event.def.DefaultLoadEventListener.loadFromSecondLevelCache(DefaultLoadEventListener.java:587)
    at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:459)
    at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227)
    at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:147)
    at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090)
    at org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:1026)
    at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:176)
    at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:215)
    at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190)
    at domain.Student_$$_javassist_0.getCOLUMN1(Student_$$_javassist_0.java)
    at com.br.test.TestCase1.init(TestCase1.java:37)
    at com.br.test.TestCase1.main(TestCase1.java:19)
    Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.ibm.ws.objectgrid.hibernate.cache.ObjectGridHibernateCache.getSession(ObjectGridHibernateCache.java:167)
    ... 15 more
    Caused by: java.lang.RuntimeException: org.hibernate.cache.CacheException: org.hibernate.cache.CacheException: Failed to get ObjectGrid server.
    at com.ibm.websphere.objectgrid.hibernate.cache.ObjectGridHibernateCacheProvider.initializeObjectGrid(ObjectGridHibernateCacheProvider.java:506)
    ... 20 more
    Caused by: org.hibernate.cache.CacheException: org.hibernate.cache.CacheException: Failed to get ObjectGrid server.
    at com.ibm.ws.objectgrid.hibernate.cache.HibernateObjectGridResourceFactory.getObjectGridResource(HibernateObjectGridResourceFactory.java:920)
    at com.ibm.websphere.objectgrid.hibernate.cache.ObjectGridHibernateCacheProvider.initializeObjectGrid(ObjectGridHibernateCacheProvider.java:497)
    ... 20 more
    Caused by: org.hibernate.cache.CacheException: Failed to get ObjectGrid server.
    at com.ibm.ws.objectgrid.hibernate.cache.HibernateObjectGridResourceFactory.getObjectGridResource(HibernateObjectGridResourceFactory.java:831)
    ... 21 more
  • PSUM_Tony_Tang
    PSUM_Tony_Tang
    18 Posts

    Re: Use WXS as Hibernate L2 Cache

    ‏2012-03-21T12:18:44Z  
    I use the trial version of eXtreme Scale
    Is this the problem?
    I find below lines in Administration Guide

    Before you begin
    v You must determine the JPA cache plug-in topology that you want to use. See
    “JPA level 2 (L2) cache plug-in” on page 313 for more information about the
    different configurations.
    v You must have an application that uses the JPA APIs. If you want to use
    WebSphere eXtreme Scale APIs to access data with JPA, use the JPA loader. For
    more information, see “Configuring JPA loaders” on page 334.
    Then I change to use JPA API to test, the result is the same.

    persistence file:

    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
    <persistence-unit name="StudentGrid">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <class>domain.Student</class>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
    <property name="hibernate.show_sql" value="false" />
    <property name="hibernate.connection.url" value="jdbc:oracle:thin:@172.16.4.131:1521:HCache" />
    <property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver" />
    <property name="hibernate.connection.username" value="br"/>
    <property name="hibernate.connection.password" value="br123"/>
    <!-- Cache -->
    <property name="hibernate.cache.provider_class"
    value="com.ibm.websphere.objectgrid.hibernate.cache.ObjectGridHibernateCacheProvider" />
    <property name="hibernate.cache.use_query_cache" value="true" />
    <property name="objectgrid.configuration"
    value="ObjectGridType=EMBEDDED,ObjectGridName=BROG, MaxNumberOfReplicas=4" />
    </properties>
    </persistence-unit>
    </persistence>
    My Entity:
    package domain;

    import java.io.Serializable;

    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.SequenceGenerator;

    import org.hibernate.annotations.Cache;
    import org.hibernate.annotations.CacheConcurrencyStrategy;

    @Entity(name = "brtest")
    @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
    public class Student implements Serializable {

    /**
    *
    */
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @SequenceGenerator(name = "BRTEST50_SEQUENCE")
    @Column(name = "id")
    private int id;

    @Column(name = "column1")
    private String COLUMN1;

    @Column(name = "cloumn2")
    private String COLUMN2;

    @Column(name = "column3")
    private String COLUMN3;

    @Column(name = "column4")
    private String COLUMN4;

    @Column(name = "column5")
    private String COLUMN5;

    @Column(name = "cloumn6")
    private String COLUMN6;

    @Column(name = "column7")
    private String COLUMN7;

    @Column(name = "column8")
    private String COLUMN8;

    @Column(name = "column9")
    private String COLUMN9;

    public Student() {}

    public int getId() {
    return id;
    }

    public void setId(int id) {
    this.id = id;
    }

    public String getCOLUMN1() {
    return COLUMN1;
    }

    public void setCOLUMN1(String cOLUMN1) {
    COLUMN1 = cOLUMN1;
    }

    public String getCOLUMN2() {
    return COLUMN2;
    }

    public void setCOLUMN2(String cOLUMN2) {
    COLUMN2 = cOLUMN2;
    }

    public String getCOLUMN3() {
    return COLUMN3;
    }

    public void setCOLUMN3(String cOLUMN3) {
    COLUMN3 = cOLUMN3;
    }

    public String getCOLUMN4() {
    return COLUMN4;
    }

    public void setCOLUMN4(String cOLUMN4) {
    COLUMN4 = cOLUMN4;
    }

    public String getCOLUMN5() {
    return COLUMN5;
    }

    public void setCOLUMN5(String cOLUMN5) {
    COLUMN5 = cOLUMN5;
    }

    public String getCOLUMN6() {
    return COLUMN6;
    }

    public void setCOLUMN6(String cOLUMN6) {
    COLUMN6 = cOLUMN6;
    }

    public String getCOLUMN7() {
    return COLUMN7;
    }

    public void setCOLUMN7(String cOLUMN7) {
    COLUMN7 = cOLUMN7;
    }

    public String getCOLUMN8() {
    return COLUMN8;
    }

    public void setCOLUMN8(String cOLUMN8) {
    COLUMN8 = cOLUMN8;
    }

    public String getCOLUMN9() {
    return COLUMN9;
    }

    public void setCOLUMN9(String cOLUMN9) {
    COLUMN9 = cOLUMN9;
    }

    }
    My test case:

    public class Test1 {

    public static void main(String[] args) {
    try {
    HibernatePersistence hp = new HibernatePersistence();

    EntityManagerFactory ef = hp.createEntityManagerFactory("StudentGrid", new HashMap());

    EntityManager em = ef.createEntityManager();

    Student s = em.find(Student.class, new Integer(10));
    System.out.println(s.getCOLUMN1());
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }

    System.exit(0);
    }
    }

    The error message is the same.

    I really need some help.

    Thanks!!!
  • cheng1
    cheng1
    44 Posts

    Re: Use WXS as Hibernate L2 Cache

    ‏2012-03-21T14:23:54Z  
    I find below lines in Administration Guide

    Before you begin
    v You must determine the JPA cache plug-in topology that you want to use. See
    “JPA level 2 (L2) cache plug-in” on page 313 for more information about the
    different configurations.
    v You must have an application that uses the JPA APIs. If you want to use
    WebSphere eXtreme Scale APIs to access data with JPA, use the JPA loader. For
    more information, see “Configuring JPA loaders” on page 334.
    Then I change to use JPA API to test, the result is the same.

    persistence file:

    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
    <persistence-unit name="StudentGrid">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <class>domain.Student</class>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
    <property name="hibernate.show_sql" value="false" />
    <property name="hibernate.connection.url" value="jdbc:oracle:thin:@172.16.4.131:1521:HCache" />
    <property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver" />
    <property name="hibernate.connection.username" value="br"/>
    <property name="hibernate.connection.password" value="br123"/>
    <!-- Cache -->
    <property name="hibernate.cache.provider_class"
    value="com.ibm.websphere.objectgrid.hibernate.cache.ObjectGridHibernateCacheProvider" />
    <property name="hibernate.cache.use_query_cache" value="true" />
    <property name="objectgrid.configuration"
    value="ObjectGridType=EMBEDDED,ObjectGridName=BROG, MaxNumberOfReplicas=4" />
    </properties>
    </persistence-unit>
    </persistence>
    My Entity:
    package domain;

    import java.io.Serializable;

    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.SequenceGenerator;

    import org.hibernate.annotations.Cache;
    import org.hibernate.annotations.CacheConcurrencyStrategy;

    @Entity(name = "brtest")
    @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
    public class Student implements Serializable {

    /**
    *
    */
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @SequenceGenerator(name = "BRTEST50_SEQUENCE")
    @Column(name = "id")
    private int id;

    @Column(name = "column1")
    private String COLUMN1;

    @Column(name = "cloumn2")
    private String COLUMN2;

    @Column(name = "column3")
    private String COLUMN3;

    @Column(name = "column4")
    private String COLUMN4;

    @Column(name = "column5")
    private String COLUMN5;

    @Column(name = "cloumn6")
    private String COLUMN6;

    @Column(name = "column7")
    private String COLUMN7;

    @Column(name = "column8")
    private String COLUMN8;

    @Column(name = "column9")
    private String COLUMN9;

    public Student() {}

    public int getId() {
    return id;
    }

    public void setId(int id) {
    this.id = id;
    }

    public String getCOLUMN1() {
    return COLUMN1;
    }

    public void setCOLUMN1(String cOLUMN1) {
    COLUMN1 = cOLUMN1;
    }

    public String getCOLUMN2() {
    return COLUMN2;
    }

    public void setCOLUMN2(String cOLUMN2) {
    COLUMN2 = cOLUMN2;
    }

    public String getCOLUMN3() {
    return COLUMN3;
    }

    public void setCOLUMN3(String cOLUMN3) {
    COLUMN3 = cOLUMN3;
    }

    public String getCOLUMN4() {
    return COLUMN4;
    }

    public void setCOLUMN4(String cOLUMN4) {
    COLUMN4 = cOLUMN4;
    }

    public String getCOLUMN5() {
    return COLUMN5;
    }

    public void setCOLUMN5(String cOLUMN5) {
    COLUMN5 = cOLUMN5;
    }

    public String getCOLUMN6() {
    return COLUMN6;
    }

    public void setCOLUMN6(String cOLUMN6) {
    COLUMN6 = cOLUMN6;
    }

    public String getCOLUMN7() {
    return COLUMN7;
    }

    public void setCOLUMN7(String cOLUMN7) {
    COLUMN7 = cOLUMN7;
    }

    public String getCOLUMN8() {
    return COLUMN8;
    }

    public void setCOLUMN8(String cOLUMN8) {
    COLUMN8 = cOLUMN8;
    }

    public String getCOLUMN9() {
    return COLUMN9;
    }

    public void setCOLUMN9(String cOLUMN9) {
    COLUMN9 = cOLUMN9;
    }

    }
    My test case:

    public class Test1 {

    public static void main(String[] args) {
    try {
    HibernatePersistence hp = new HibernatePersistence();

    EntityManagerFactory ef = hp.createEntityManagerFactory("StudentGrid", new HashMap());

    EntityManager em = ef.createEntityManager();

    Student s = em.find(Student.class, new Integer(10));
    System.out.println(s.getCOLUMN1());
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }

    System.exit(0);
    }
    }

    The error message is the same.

    I really need some help.

    Thanks!!!
    The error "Caused by: org.hibernate.cache.CacheException: Failed to get ObjectGrid server." indicates the creation of ObjectGrid server failed. I am not sure why this happen in your environment. Can you zip up your eclipse project and attach it here. Then I can download and run it to see how it goes. If you put the zip file today, I can get back to you today.
  • PSUM_Tony_Tang
    PSUM_Tony_Tang
    18 Posts

    Re: Use WXS as Hibernate L2 Cache

    ‏2012-03-21T14:40:15Z  
    • cheng1
    • ‏2012-03-21T14:23:54Z
    The error "Caused by: org.hibernate.cache.CacheException: Failed to get ObjectGrid server." indicates the creation of ObjectGrid server failed. I am not sure why this happen in your environment. Can you zip up your eclipse project and attach it here. Then I can download and run it to see how it goes. If you put the zip file today, I can get back to you today.
    Hi Cheng,

    Please find the project.

    I will upload related jar files soon.

    Thanks,
  • cheng1
    cheng1
    44 Posts

    Re: Use WXS as Hibernate L2 Cache

    ‏2012-03-21T15:43:54Z  
    Hi Cheng,

    Please find the project.

    I will upload related jar files soon.

    Thanks,
    Tony,
    I modified the persistence.xml to use derby database, and it runs just fine. My environment has hiberntae 3.2.3 and derby. I will download hibernate 3.6 to see how it goes.
  • PSUM_Tony_Tang
    PSUM_Tony_Tang
    18 Posts

    Re: Use WXS as Hibernate L2 Cache

    ‏2012-03-21T15:47:13Z  
    • cheng1
    • ‏2012-03-21T14:23:54Z
    The error "Caused by: org.hibernate.cache.CacheException: Failed to get ObjectGrid server." indicates the creation of ObjectGrid server failed. I am not sure why this happen in your environment. Can you zip up your eclipse project and attach it here. Then I can download and run it to see how it goes. If you put the zip file today, I can get back to you today.
    this is the oghibernate-cache.jar I used

    I copy this jar file form :WXS_ObjectGrid_07-26-2010_7.0.0.0_cumulative_Fix.pak
    because we I can not find this file from WAS 8
  • PSUM_Tony_Tang
    PSUM_Tony_Tang
    18 Posts

    Re: Use WXS as Hibernate L2 Cache

    ‏2012-03-21T15:49:16Z  
    • cheng1
    • ‏2012-03-21T15:43:54Z
    Tony,
    I modified the persistence.xml to use derby database, and it runs just fine. My environment has hiberntae 3.2.3 and derby. I will download hibernate 3.6 to see how it goes.
    Could you please use the oghibernate-cache.jar I uploaded to test it.

    if it is not works, could you please upload the oghibernate-cache.jar file you used.

    Thanks,
  • cheng1
    cheng1
    44 Posts

    Re: Use WXS as Hibernate L2 Cache

    ‏2012-03-21T15:49:23Z  
    • cheng1
    • ‏2012-03-21T15:43:54Z
    Tony,
    I modified the persistence.xml to use derby database, and it runs just fine. My environment has hiberntae 3.2.3 and derby. I will download hibernate 3.6 to see how it goes.
    Tony,
    The environment only needs objetcgrid.jar. Trial version is fine. I attatch my version of your project that works with derby. You can check out the build path and library to see the difference.
  • cheng1
    cheng1
    44 Posts

    Re: Use WXS as Hibernate L2 Cache

    ‏2012-03-21T15:53:37Z  
    • cheng1
    • ‏2012-03-21T15:49:23Z
    Tony,
    The environment only needs objetcgrid.jar. Trial version is fine. I attatch my version of your project that works with derby. You can check out the build path and library to see the difference.
    The oghibernate-cache.jar can only be used in WAS environment to bundle with hibernate library. In standalone env, like in eclipse, you only need objectgrid.jar.
  • PSUM_Tony_Tang
    PSUM_Tony_Tang
    18 Posts

    Re: Use WXS as Hibernate L2 Cache

    ‏2012-03-21T15:57:54Z  
    • cheng1
    • ‏2012-03-21T15:53:37Z
    The oghibernate-cache.jar can only be used in WAS environment to bundle with hibernate library. In standalone env, like in eclipse, you only need objectgrid.jar.
    I just delete this jar from my classpath, and run it again,
    The result is still the same, the error message is the same.

    Could you please have a try with Hibernate 3.6 please.

    I will have a try with derby, and the Hibernate version you used.

    P.S I found you use WXS 7.1.1.1, this is the latest fix version right?
    I will download the trial version and test it.
    Thanks,
  • cheng1
    cheng1
    44 Posts

    Re: Use WXS as Hibernate L2 Cache

    ‏2012-03-21T20:18:26Z  
    I just delete this jar from my classpath, and run it again,
    The result is still the same, the error message is the same.

    Could you please have a try with Hibernate 3.6 please.

    I will have a try with derby, and the Hibernate version you used.

    P.S I found you use WXS 7.1.1.1, this is the latest fix version right?
    I will download the trial version and test it.
    Thanks,
    I attach the working copy with all required jar files (hibernate 3.6, derby 10.8.2.2, slf4j 1.6.4. ..), except objectgrid.jar.

    You can unzip and open the project in your eclipse, then resolve the classpath to your objectgrid.jar.
    You will find console_output.txt file after you unzip. It has my running result, so you can see how it is run.
  • PSUM_Tony_Tang
    PSUM_Tony_Tang
    18 Posts

    Re: Use WXS as Hibernate L2 Cache

    ‏2012-03-22T02:31:01Z  
    • cheng1
    • ‏2012-03-21T20:18:26Z
    I attach the working copy with all required jar files (hibernate 3.6, derby 10.8.2.2, slf4j 1.6.4. ..), except objectgrid.jar.

    You can unzip and open the project in your eclipse, then resolve the classpath to your objectgrid.jar.
    You will find console_output.txt file after you unzip. It has my running result, so you can see how it is run.
    Hi Cheng

    Thanks for your help.

    I download you code and run in my environment, it is still failed. the error message is still the same

    From console_output.txt I found you use IBM SDK and JVM, but i use JAVA standard platform and the version is version 6 update 27.

    Then I download IBM_DevelopmentPackage_for_Eclipse_Win32_3.0.0.zip from IBM web site.
    and run your code.

    Magic happened,it work ok...

    I found below in the readme.html when I install the WXS 7.1.1. Looks like it is support J2SE Standard Edition.
    objectgrid.jar: Available for Java Platform, Standard Edition version 5 and later and Java Platform, Enterprise Edition environments that are not running WebSphere Application Server, and Eclipse Gemini OSGi frameworks, version 3.6.1 or later. Note: This JAR is not available with the client install package or when the server install option is not selected during install.
    Could you please help me to confirm, we must use IBM SDK and JVM?
  • PSUM_Tony_Tang
    PSUM_Tony_Tang
    18 Posts

    Re: Use WXS as Hibernate L2 Cache

    ‏2012-03-22T12:22:37Z  
    • cheng1
    • ‏2012-03-21T20:18:26Z
    I attach the working copy with all required jar files (hibernate 3.6, derby 10.8.2.2, slf4j 1.6.4. ..), except objectgrid.jar.

    You can unzip and open the project in your eclipse, then resolve the classpath to your objectgrid.jar.
    You will find console_output.txt file after you unzip. It has my running result, so you can see how it is run.
    Hi Cheng,
    After I change to use IBM SDK and JVM, The Embedded topology is works ok know, both use Hibernate API and JPA API.
    But the Remote topology is still have problem with Hibernate API, The JPA API is works ok in this topology.

    I add Hibernate related jar file to classpath when I start remote WXS server.

    Attached is the code I used to test.

    Please find
    cacheeXtremeOracle_tony\server_config this folder has two xml file this is for WXS server
    cacheeXtremeOracle_tony\console_output.txt this is the my eclipse console output

    Please help me to take a look.

    P.S both hibernate and WXS server run in IBM JVM
  • cheng1
    cheng1
    44 Posts

    Re: Use WXS as Hibernate L2 Cache

    ‏2012-03-22T15:02:15Z  
    Hi Cheng,
    After I change to use IBM SDK and JVM, The Embedded topology is works ok know, both use Hibernate API and JPA API.
    But the Remote topology is still have problem with Hibernate API, The JPA API is works ok in this topology.

    I add Hibernate related jar file to classpath when I start remote WXS server.

    Attached is the code I used to test.

    Please find
    cacheeXtremeOracle_tony\server_config this folder has two xml file this is for WXS server
    cacheeXtremeOracle_tony\console_output.txt this is the my eclipse console output

    Please help me to take a look.

    P.S both hibernate and WXS server run in IBM JVM
    WXS can run on any jdk that has ORB. I think your previous jdk (non IBM) probably does not have ORB and you have to include an ORB in it.

    The error in remote scenario probably is due to missing map definition. You have configured regionNames property to include "domain.Student". Thus, you need one more map definition in wxs configuration xml files.

    <property name="objectgrid.hibernate.regionNames">domain.Student</property>

    Both JPA and hibernate approach behave slightly different. The JPA approach works probably because hibernate does not try to create cache for unused region name.
  • PSUM_Tony_Tang
    PSUM_Tony_Tang
    18 Posts

    Re: Use WXS as Hibernate L2 Cache

    ‏2012-03-22T15:09:20Z  
    • cheng1
    • ‏2012-03-22T15:02:15Z
    WXS can run on any jdk that has ORB. I think your previous jdk (non IBM) probably does not have ORB and you have to include an ORB in it.

    The error in remote scenario probably is due to missing map definition. You have configured regionNames property to include "domain.Student". Thus, you need one more map definition in wxs configuration xml files.

    <property name="objectgrid.hibernate.regionNames">domain.Student</property>

    Both JPA and hibernate approach behave slightly different. The JPA approach works probably because hibernate does not try to create cache for unused region name.
    Please take a look the xml file in cacheeXtremeOracle_tony\server_config which I attached in my last post.

    I already add the mapset named "domain.Student".

    Thanks
  • PSUM_Tony_Tang
    PSUM_Tony_Tang
    18 Posts

    Re: Use WXS as Hibernate L2 Cache

    ‏2012-03-22T15:36:30Z  
    • cheng1
    • ‏2012-03-22T15:02:15Z
    WXS can run on any jdk that has ORB. I think your previous jdk (non IBM) probably does not have ORB and you have to include an ORB in it.

    The error in remote scenario probably is due to missing map definition. You have configured regionNames property to include "domain.Student". Thus, you need one more map definition in wxs configuration xml files.

    <property name="objectgrid.hibernate.regionNames">domain.Student</property>

    Both JPA and hibernate approach behave slightly different. The JPA approach works probably because hibernate does not try to create cache for unused region name.
    If I delete this line from hibernate config file, it is still the same error.

    <property name="objectgrid.hibernate.regionNames">domain.Student</property>

    Please help me to take look the server config xml files.
  • cheng1
    cheng1
    44 Posts

    Re: Use WXS as Hibernate L2 Cache

    ‏2012-03-22T16:20:38Z  
    If I delete this line from hibernate config file, it is still the same error.

    <property name="objectgrid.hibernate.regionNames">domain.Student</property>

    Please help me to take look the server config xml files.
    Tony,
    Regarding JDK, WXS works with both the Oracle (Sun) and IBM JDKs, but require the IBM ORB. The following documentation describes how to configure Oracle JDK with IBM ORB:

    http://publib.boulder.ibm.com/infocenter/wxsinfo/v7r1m1/topic/com.ibm.websphere.extremescale.doc/txscfgorb.html

    Regarding remote scenario, we do need a special map in case hiberntae needs additional cache for dynamically created regions, this map is "defaultCacheMap".

    The attached zip file contains server side configuration xml template files. You can just use them for your remote scenario.
  • cheng1
    cheng1
    44 Posts

    Re: Use WXS as Hibernate L2 Cache

    ‏2012-03-22T16:28:44Z  
    • cheng1
    • ‏2012-03-22T16:20:38Z
    Tony,
    Regarding JDK, WXS works with both the Oracle (Sun) and IBM JDKs, but require the IBM ORB. The following documentation describes how to configure Oracle JDK with IBM ORB:

    http://publib.boulder.ibm.com/infocenter/wxsinfo/v7r1m1/topic/com.ibm.websphere.extremescale.doc/txscfgorb.html

    Regarding remote scenario, we do need a special map in case hiberntae needs additional cache for dynamically created regions, this map is "defaultCacheMap".

    The attached zip file contains server side configuration xml template files. You can just use them for your remote scenario.
    Tony,
    In your case, if you want to use Oracle JDK, you can simply add the following to VM arguments of run configuration in eclipse when Oracle JDK is selected:

    -Djava.endorsed.dirs=<OG_STANDALONE_INSTALL>\ObjectGrid\lib\endorsed;<JAVA_HOME>\jre\lib\endorsed

    replace =<OG_STANDALONE_INSTALL> and <JAVA_HOME> with actual location in your system.
  • PSUM_Tony_Tang
    PSUM_Tony_Tang
    18 Posts

    Re: Use WXS as Hibernate L2 Cache

    ‏2012-03-25T14:00:32Z  
    • cheng1
    • ‏2012-03-22T16:20:38Z
    Tony,
    Regarding JDK, WXS works with both the Oracle (Sun) and IBM JDKs, but require the IBM ORB. The following documentation describes how to configure Oracle JDK with IBM ORB:

    http://publib.boulder.ibm.com/infocenter/wxsinfo/v7r1m1/topic/com.ibm.websphere.extremescale.doc/txscfgorb.html

    Regarding remote scenario, we do need a special map in case hiberntae needs additional cache for dynamically created regions, this map is "defaultCacheMap".

    The attached zip file contains server side configuration xml template files. You can just use them for your remote scenario.
    After we add defaultCacheMap to gridobject and deploy configuration file still have the same error
  • PSUM_Tony_Tang
    PSUM_Tony_Tang
    18 Posts

    Re: Use WXS as Hibernate L2 Cache

    ‏2012-03-26T10:17:11Z  
    • cheng1
    • ‏2012-03-22T16:20:38Z
    Tony,
    Regarding JDK, WXS works with both the Oracle (Sun) and IBM JDKs, but require the IBM ORB. The following documentation describes how to configure Oracle JDK with IBM ORB:

    http://publib.boulder.ibm.com/infocenter/wxsinfo/v7r1m1/topic/com.ibm.websphere.extremescale.doc/txscfgorb.html

    Regarding remote scenario, we do need a special map in case hiberntae needs additional cache for dynamically created regions, this map is "defaultCacheMap".

    The attached zip file contains server side configuration xml template files. You can just use them for your remote scenario.
    Hi Cheng

    Below is the command to start WXS server

    1> use this command to start catalog service first: startOgServer brcatserver -catalogServiceEndPoints brcatserver:172.16.4.13:6600:6601

    2> use this command to start ogserver: startOgServer brserver -objectgridFile hibernate-objectGrid.xml -deploymentPolicyFile hibernate-objectGridDeployment.xml -catalogServiceEndPoints 172.16.4.131:2809

    I just use the configurations files you attached.
  • PSUM_Tony_Tang
    PSUM_Tony_Tang
    18 Posts

    Re: Use WXS as Hibernate L2 Cache

    ‏2012-03-26T10:18:02Z  
    • cheng1
    • ‏2012-03-22T16:28:44Z
    Tony,
    In your case, if you want to use Oracle JDK, you can simply add the following to VM arguments of run configuration in eclipse when Oracle JDK is selected:

    -Djava.endorsed.dirs=<OG_STANDALONE_INSTALL>\ObjectGrid\lib\endorsed;<JAVA_HOME>\jre\lib\endorsed

    replace =<OG_STANDALONE_INSTALL> and <JAVA_HOME> with actual location in your system.
    This is the code I use for test.

    Thanks very much!!