factory.openSession() serializable exeception

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

factory.openSession() serializable exeception

Denis
Can someone tell me why I am getting an exception for the
factory.openSession() in the following code? I am using Oracle
Workshop for Weblogic and I am running the code within the same class
from the main.

public class OracleDBUtil
{

        public SqlSession getSqlSession() throws Exception
        {
                //String resource = "org/mybatis/builder/MapperConfig.xml";
                String resource = "com/dao/sql/SqlMapConfig.xml";
                Reader reader = Resources.getResourceAsReader(resource);
                SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
                SqlSessionFactory factory = builder.build(reader);
                SqlSession sqlSession = factory.openSession();
                return sqlSession;
        }


        public static void main( String[] args ) throws Throwable
        {
                // TODO Auto-generated method stub
                OracleDBUtil myInst = OracleDBUtil.getInstance();
                System.out.println( "Success" );
                OracleDBUtil.logger.info("Logger works");
                SqlSession mySession = myInst.getSqlSession();
        }
}

Success
4 [Main Thread] INFO com.util.OracleDBUtil  - Logger works
Exception in thread "Main Thread" java.lang.ClassCastException:
java.lang.Object cannot be cast to java.io.Serializable
        at
com.sun.corba.se.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:
164)
        at javax.rmi.CORBA.Util.mapSystemException(Util.java:67)
        at
weblogic.jdbc.common.internal._RemoteDataSource_Stub.getConnection(Unknown
Source)
        at
org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSessionFromDataSource(DefaultSqlSessionFactory.java:
72)
        at
org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSession(DefaultSqlSessionFactory.java:
32)
        at com.util.OracleDBUtil.getSqlSession(OracleDBUtil.java:206)
        at com.util.OracleDBUtil.main(OracleDBUtil.java:229)

Reply | Threaded
Open this post in threaded view
|

Re: factory.openSession() serializable exeception

Denis
I should have included the server side stack trace:

<Oct 15, 2010 5:12:31 PM EDT> <Warning> <RMI> <BEA-080003>
<RuntimeException thrown by rmi server:
weblogic.jdbc.common.internal.RmiDataSource.getConnection()
 java.lang.ClassCastException: java.lang.Object cannot be cast to
java.io.Serializable.
java.lang.ClassCastException: java.lang.Object cannot be cast to
java.io.Serializable
        at weblogic.iiop.IIOPOutputStream.writeAny(IIOPOutputStream.java:
1588)
        at weblogic.iiop.IIOPOutputStream.writeObject(IIOPOutputStream.java:
2231)
        at
weblogic.utils.io.ObjectStreamClass.writeFields(ObjectStreamClass.java:
413)
        at
weblogic.corba.utils.ValueHandlerImpl.writeValueData(ValueHandlerImpl.java:
235)
        at
weblogic.corba.utils.ValueHandlerImpl.writeValueData(ValueHandlerImpl.java:
225)
        Truncated. see log file for complete stacktrace

On Oct 15, 3:25 pm, Denis <[hidden email]> wrote:

> Can someone tell me why I am getting an exception for the
> factory.openSession() in the following code? I am using Oracle
> Workshop for Weblogic and I am running the code within the same class
> from the main.
>
> public class OracleDBUtil
> {
>
>         public SqlSession getSqlSession() throws Exception
>         {
>                 //String resource                                       = "org/mybatis/builder/MapperConfig.xml";
>                 String resource                                         = "com/dao/sql/SqlMapConfig.xml";
>                 Reader reader                                           = Resources.getResourceAsReader(resource);
>                 SqlSessionFactoryBuilder builder        = new SqlSessionFactoryBuilder();
>                 SqlSessionFactory factory                       = builder.build(reader);
>                 SqlSession sqlSession                           = factory.openSession();
>                 return sqlSession;
>         }
>
>         public static void main( String[] args ) throws Throwable
>         {
>                 // TODO Auto-generated method stub
>                 OracleDBUtil myInst = OracleDBUtil.getInstance();
>                 System.out.println( "Success" );
>                 OracleDBUtil.logger.info("Logger works");
>                 SqlSession mySession = myInst.getSqlSession();
>         }
>
> }
>
> Success
> 4 [Main Thread] INFO com.util.OracleDBUtil  - Logger works
> Exception in thread "Main Thread" java.lang.ClassCastException:
> java.lang.Object cannot be cast to java.io.Serializable
>         at
> com.sun.corba.se.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:
> 164)
>         at javax.rmi.CORBA.Util.mapSystemException(Util.java:67)
>         at
> weblogic.jdbc.common.internal._RemoteDataSource_Stub.getConnection(Unknown
> Source)
>         at
> org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSessionFrom DataSource(DefaultSqlSessionFactory.java:
> 72)
>         at
> org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSession(Def aultSqlSessionFactory.java:
> 32)
>         at com.util.OracleDBUtil.getSqlSession(OracleDBUtil.java:206)
>         at com.util.OracleDBUtil.main(OracleDBUtil.java:229)
Reply | Threaded
Open this post in threaded view
|

Re: factory.openSession() serializable exeception

Eduardo Macarron
I don´t know what happened but it does not seem to be related to
mybatis.

Seems that you are trying to get a datasource from a remote jndi
lookup. Try to do the lookup by yourself and you will see the same
error.

This should go better in weblogic forums, for instance:

http://forums.oracle.com/forums/thread.jspa?threadID=731055&tstart=195

On 15 oct, 23:24, Denis <[hidden email]> wrote:

> I should have included the server side stack trace:
>
> <Oct 15, 2010 5:12:31 PM EDT> <Warning> <RMI> <BEA-080003>
> <RuntimeException thrown by rmi server:
> weblogic.jdbc.common.internal.RmiDataSource.getConnection()
>  java.lang.ClassCastException: java.lang.Object cannot be cast to
> java.io.Serializable.
> java.lang.ClassCastException: java.lang.Object cannot be cast to
> java.io.Serializable
>         at weblogic.iiop.IIOPOutputStream.writeAny(IIOPOutputStream.java:
> 1588)
>         at weblogic.iiop.IIOPOutputStream.writeObject(IIOPOutputStream.java:
> 2231)
>         at
> weblogic.utils.io.ObjectStreamClass.writeFields(ObjectStreamClass.java:
> 413)
>         at
> weblogic.corba.utils.ValueHandlerImpl.writeValueData(ValueHandlerImpl.java:
> 235)
>         at
> weblogic.corba.utils.ValueHandlerImpl.writeValueData(ValueHandlerImpl.java:
> 225)
>         Truncated. see log file for complete stacktrace
>
> On Oct 15, 3:25 pm, Denis <[hidden email]> wrote:
>
>
>
> > Can someone tell me why I am getting an exception for the
> > factory.openSession() in the following code? I am using Oracle
> > Workshop for Weblogic and I am running the code within the same class
> > from the main.
>
> > public class OracleDBUtil
> > {
>
> >         public SqlSession getSqlSession() throws Exception
> >         {
> >                 //String resource                                       = "org/mybatis/builder/MapperConfig.xml";
> >                 String resource                                         = "com/dao/sql/SqlMapConfig.xml";
> >                 Reader reader                                           = Resources.getResourceAsReader(resource);
> >                 SqlSessionFactoryBuilder builder        = new SqlSessionFactoryBuilder();
> >                 SqlSessionFactory factory                       = builder.build(reader);
> >                 SqlSession sqlSession                           = factory.openSession();
> >                 return sqlSession;
> >         }
>
> >         public static void main( String[] args ) throws Throwable
> >         {
> >                 // TODO Auto-generated method stub
> >                 OracleDBUtil myInst = OracleDBUtil.getInstance();
> >                 System.out.println( "Success" );
> >                 OracleDBUtil.logger.info("Logger works");
> >                 SqlSession mySession = myInst.getSqlSession();
> >         }
>
> > }
>
> > Success
> > 4 [Main Thread] INFO com.util.OracleDBUtil  - Logger works
> > Exception in thread "Main Thread" java.lang.ClassCastException:
> > java.lang.Object cannot be cast to java.io.Serializable
> >         at
> > com.sun.corba.se.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:
> > 164)
> >         at javax.rmi.CORBA.Util.mapSystemException(Util.java:67)
> >         at
> > weblogic.jdbc.common.internal._RemoteDataSource_Stub.getConnection(Unknown
> > Source)
> >         at
> > org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSessionFrom DataSource(DefaultSqlSessionFactory.java:
> > 72)
> >         at
> > org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSession(Def aultSqlSessionFactory.java:
> > 32)
> >         at com.util.OracleDBUtil.getSqlSession(OracleDBUtil.java:206)
> >         at com.util.OracleDBUtil.main(OracleDBUtil.java:229)
Reply | Threaded
Open this post in threaded view
|

Re: factory.openSession() serializable exeception

Denis
Thank you Eduardo.

I added the JNDI Explorer plugin to the Workshop IDE.  Once I tried to configure the initial context it told me it could not find the WLInitialContextFactory class.  After searching for it I added the weblogic.jar file to the build path, configured the initial context and then it started working.

I just don't know why these things are not more clearly documented in application servers and why did it take a third party plugin for me have to figure this out?  I am being rhetorical, but thank you for responding.

-Denis

On Sat, Oct 16, 2010 at 11:40 AM, Eduardo <[hidden email]> wrote:
I don´t know what happened but it does not seem to be related to
mybatis.

Seems that you are trying to get a datasource from a remote jndi
lookup. Try to do the lookup by yourself and you will see the same
error.

This should go better in weblogic forums, for instance:

http://forums.oracle.com/forums/thread.jspa?threadID=731055&tstart=195

On 15 oct, 23:24, Denis <[hidden email]> wrote:
> I should have included the server side stack trace:
>
> <Oct 15, 2010 5:12:31 PM EDT> <Warning> <RMI> <BEA-080003>
> <RuntimeException thrown by rmi server:
> weblogic.jdbc.common.internal.RmiDataSource.getConnection()
>  java.lang.ClassCastException: java.lang.Object cannot be cast to
> java.io.Serializable.
> java.lang.ClassCastException: java.lang.Object cannot be cast to
> java.io.Serializable
>         at weblogic.iiop.IIOPOutputStream.writeAny(IIOPOutputStream.java:
> 1588)
>         at weblogic.iiop.IIOPOutputStream.writeObject(IIOPOutputStream.java:
> 2231)
>         at
> weblogic.utils.io.ObjectStreamClass.writeFields(ObjectStreamClass.java:
> 413)
>         at
> weblogic.corba.utils.ValueHandlerImpl.writeValueData(ValueHandlerImpl.java:
> 235)
>         at
> weblogic.corba.utils.ValueHandlerImpl.writeValueData(ValueHandlerImpl.java:
> 225)
>         Truncated. see log file for complete stacktrace
>
> On Oct 15, 3:25 pm, Denis <[hidden email]> wrote:
>
>
>
> > Can someone tell me why I am getting an exception for the
> > factory.openSession() in the following code? I am using Oracle
> > Workshop for Weblogic and I am running the code within the same class
> > from the main.
>
> > public class OracleDBUtil
> > {
>
> >         public SqlSession getSqlSession() throws Exception
> >         {
> >                 //String resource                                       = "org/mybatis/builder/MapperConfig.xml";
> >                 String resource                                         = "com/dao/sql/SqlMapConfig.xml";
> >                 Reader reader                                           = Resources.getResourceAsReader(resource);
> >                 SqlSessionFactoryBuilder builder        = new SqlSessionFactoryBuilder();
> >                 SqlSessionFactory factory                       = builder.build(reader);
> >                 SqlSession sqlSession                           = factory.openSession();
> >                 return sqlSession;
> >         }
>
> >         public static void main( String[] args ) throws Throwable
> >         {
> >                 // TODO Auto-generated method stub
> >                 OracleDBUtil myInst = OracleDBUtil.getInstance();
> >                 System.out.println( "Success" );
> >                 OracleDBUtil.logger.info("Logger works");
> >                 SqlSession mySession = myInst.getSqlSession();
> >         }
>
> > }
>
> > Success
> > 4 [Main Thread] INFO com.util.OracleDBUtil  - Logger works
> > Exception in thread "Main Thread" java.lang.ClassCastException:
> > java.lang.Object cannot be cast to java.io.Serializable
> >         at
> > com.sun.corba.se.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:
> > 164)
> >         at javax.rmi.CORBA.Util.mapSystemException(Util.java:67)
> >         at
> > weblogic.jdbc.common.internal._RemoteDataSource_Stub.getConnection(Unknown
> > Source)
> >         at
> > org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSessionFrom DataSource(DefaultSqlSessionFactory.java:
> > 72)
> >         at
> > org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSession(Def aultSqlSessionFactory.java:
> > 32)
> >         at com.util.OracleDBUtil.getSqlSession(OracleDBUtil.java:206)
> >         at com.util.OracleDBUtil.main(OracleDBUtil.java:229)