2013-03-13 1 views
0

maven에서 Jboss7.1.1.Final Jndi 검색을 사용하여 sessionFactory에 액세스하려고합니다.Jboss Jndi 검색을 사용하여 sessionFactory에 액세스합니다. java :/hibernate/SessionFactory

지금 주조시에 다음 코드

Context ctx1=new InitialContext(); 
Object obj1=ctx1.lookup("java:/hibernate/SessionFactory"); 
SessionFactoryImpl sess= (SessionFactoryImpl)obj1; 

를 사용

17:28:33,670 INFO [org.hibernate.cfg.Configuration] (http-localhost-127.0.0.1-8080-1) configuring from resource: /hibernate.cfg.xml 
17:28:33,671 INFO [org.hibernate.cfg.Configuration] (http-localhost-127.0.0.1-8080-1) Configuration resource: /hibernate.cfg.xml 
17:28:34,026 INFO [org.hibernate.cfg.Configuration] (http-localhost-127.0.0.1-8080-1) Configured SessionFactory: java:/hibernate/SessionFactory 

17:28:35,785 INFO [org.hibernate.impl.SessionFactoryImpl] (http-localhost-127.0.0.1-8080-1) building session factory 
17:28:36,535 INFO [org.hibernate.impl.SessionFactoryObjectFactory] (http-localhost-127.0.0.1-8080-1) Factory name: java:/hibernate/SessionFactory 
17:28:36,537 INFO [org.hibernate.util.NamingHelper] (http-localhost-127.0.0.1-8080-1) JNDI InitialContext properties:{} 

17:28:36,546 INFO [org.hibernate.impl.SessionFactoryObjectFactory] (http-localhost-127.0.0.1-8080-1) Bound factory to JNDI name: java:/hibernate/SessionFactory 

을 다음 내가 로그에 얻고 그것을 배포하는 동안

17:28:36,691 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) java.lang.ClassCastException: org.hibernate.impl.SessionFactoryImpl cannot be cast to org.hibernate.impl.SessionFactoryImpl 

을 다음과 같이 나는 예외를 받고 있어요 이 용도로 사용하는 종속성은

입니다.
<dependency> 
<groupId>org.hibernate</groupId> 
<artifactId>hibernate-entitymanager</artifactId> 
<version>4.0.1.Final</version> 
</dependency> 

617,451,515,내 XML은 제발 도와주세요

<?xml version='1.0' encoding='utf-8'?> 
<!DOCTYPE hibernate-configuration PUBLIC 
    "-//Hibernate/Hibernate Configuration DTD//EN" 
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> 
<hibernate-configuration> 
    <session-factory name="java:/hibernate/SessionFactory"> 
    <property name="connection.url">jdbc:postgresql://localhost:5432/DUMY</property> 
    <property name="connection.driver_class">org.postgresql.Driver</property> 
    <property name="connection.username">postgres</property> 
    <property name="connection.password">postgres</property> 
    <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>   

    <property name="hibernate.session_factory_name">java:/hibernate/SessionFactory</property>   
    . 
    . 
    . 

    </session-factory> 
</hibernate-configuration> 

입니다.

답변

1

무 상태 세션 빈 안에 전체 데이터베이스 접근 로직을 넣고 작업 해 주었고 나에게 잘 돌아왔다.