-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: was javax.ejb.EJBException: Unexpected Error is now java.lan
PostPosted: Thu Jul 07, 2005 8:50 am 
Newbie

Joined: Thu Jul 07, 2005 6:59 am
Posts: 13
Location: Derry Northern Ireland
Hi have manged to drill the debug further into my HibernateSession single and have dumped out this stack trace, maybe this may trigger a view clues to some people.


Code:
java.lang.ClassCastException: org.jboss.resource.adapter.jdbc.WrapperDataSource
   at server.j2eeHibernate.components.HibernateSession.<clinit>(HibernateSession.java:21)
   at server.j2eeHibernate.deploy.MyMessageBean.onMessage(MyMessageBean.java:44)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.java:458)
   at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
   at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstanceInterceptor.java:62)
   at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
   at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:282)
   at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
   at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:90)
   at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
   at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
   at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:372)
   at org.jboss.ejb.Container.invoke(Container.java:723)
   at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.java:914)
   at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(JMSContainerInvoker.java:1208)
   at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:276)
   at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:871)
   at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:159)
   at org.jboss.mq.SpySession.run(SpySession.java:347)
   at org.jboss.jms.asf.StdServerSession.run0(StdServerSession.java:200)
   at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:180)
   at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:743)
   at java.lang.Thread.run(Thread.java:595)



javax.ejb.EJBException: Unexpected Error

Hi, I am new to Hibernate and Jboss so getting the architecture right here is a little confusing.

This is my problem,

I am getting an unexspected error thrown from my onMessage method in my message driven bean.

As the docs state this will happen for example if the instance failed to open a database connection.

This is what I am doing but through Hibernate.

My onMessage method is trying to open and close a session just at this point.

I'm using JBoss 3.2.5 with Hibernate 2.1.

This is my onMessage method

Code:
public void onMessage(Message message){
       
        try{
           
            ObjectMessage oMessage = (ObjectMessage)message;
            MyTestBean bean = (MyTestBean)oMessage.getObject();
            System.out.println("Received : "+bean.getMessage());
            message.acknowledge();
           
            System.out.println("Trying hiberante connection");
            HibernateSession.currentSession();
            System.out.println("Got Hibernate Session");
            HibernateSession.closeSession();
            System.out.println("Clossed Hibernate Session");

            //sendReply();
       
        }catch(Exception e){
            System.out.println("Error : "+e.getMessage());
        }
       
    }


this is my HibernateSession singleton class that will manage the sessions

Code:
package server.j2eeHibernate.components;

import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.Session;
import net.sf.hibernate.HibernateException;

import javax.naming.Context;
import javax.naming.InitialContext;
       
public class HibernateSession {
   
    private static final SessionFactory sessionFactory;
   
    static{
       
        try{
           
           Context ctx = new InitialContext();
           sessionFactory = (SessionFactory)ctx.lookup("java:/HibernateFactory");
           
        }catch(Exception e){
           
            throw new RuntimeException("SessionFactory Error - " + e.getMessage(),e);
           
        }
       
    }
   
    public static final ThreadLocal session = new ThreadLocal();
   
    public static Session currentSession() throws HibernateException{
       
        Session s = (Session)session.get();
        if(s==null){
            s = sessionFactory.openSession();
            session.set(s);
        }
       
        return s;
       
    }
   
    public static void closeSession() throws HibernateException{
       
        Session s = (Session)session.get();
        session.set(null);
        if(s!=null){
            s.close();
        }
       
    }
   
}



These are my xml config files for Hibernate and Jboss to talk,

Code:
//jboss-service.xml
<server>
<mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=HibernateFactory,name=HibernateFactory">
    <depends>jboss.jca:service=RARDeployer</depends>
    <depends>jboss.jca:service=LocalTxCM,name=asademo</depends>
    <!-- Make it deploy ONLY after DataSource had been started -->
    <attribute name="MapResources">server/j2eeHibernate/deploy/classes/versioning/VModule.hbm.xml</attribute>
    <attribute name="JndiName">java:/com/env/HibernateFactory</attribute>
    <attribute name="Datasource">java:/asademo</attribute>
    <attribute name="Dialect">net.sf.hibernate.dialect.SybaseAnywhereDialect</attribute>
    <attribute name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionFactory</attribute>
    <attribute name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JBossTransactionManagerLookup</attribute>
    <attribute name="UseOuterJoin">false</attribute>
    <attribute name="ShowSql">false</attribute>
    <attribute name="UserTransactionName">UserTransaction</attribute>
</mbean>
</server>

//hibernate.cfg.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>

    <session-factory>
        <property name="connection.driver">com.sybase.jdbc2.jdbc.SybDriver</property>
        <property name="connection.url">jdbc:sybase:Tds:localhost:2638?ServiceName=asademo</property>
        <property name="dialect">net.sf.hibernate.dialect.SybaseAnywhereDialect</property>
        <property name="connection.username">DBA</property>
        <property name="connection.password">SQL</property>

        <mapping resource="server\j2eeHibernate\deploy\classes\versioning\VModule.hbm.xml"/>

    </session-factory>

</hibernate-configuration>

//and hibernatesybase-ds.xml
<datasources>
   <local-tx-datasource>
      <jndi-name>HibernateFactory</jndi-name>
      <connection-url>jdbc:sybase:Tds://localhost:2638/asademo</connection-url>
      <driver-class>com.sybase.jdbc2.jdbc.SybDriver</driver-class>
      <user-name>DBA</user-name>
      <password>SQL</password>
   </local-tx-datasource>
</datasources>


both jboss-service.xml and hibernate.cfg.xml reside in the root of my deployed jar file.

hibernatesybase-ds.xml is sitting in my jboss/server/default/deploy.

Thanks for any help on this,

JP.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.