Back Forum Reply New

JBoss problems when integrating hibernate with spring mvc

Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) previously initiated loading for a different type with name quot;javax/transaction/xa/XAResourcequot;This is the above error I get.Anyone has some idea what could it be?

mon.model.dao;

import javax.sql.DataSource;

import org..orm.hibernate3.support.HibernateDaoSupport;

public abstract class BaseDAO extends HibernateDaoSupport {   protected DataSource dataSource;
   public void setDataSource(DataSource dataSource) {       this.dataSource = dataSource;   }
}

BaseBean.javaCode:

package com.fp.common.view.bean;

import javax.faces.context.FacesContext;

import javax.servlet.from.fromServletResponse;

import com.fp.common.view.servicelocator.ServiceLocator;

public class BaseBean {   //the service locator of the business services   protected ServiceLocator serviceLocator;
   public ServiceLocator getServiceLocator() {       return this.serviceLocator;   }
   public void setServiceLocator(ServiceLocator newServiceLocator) throws Exception {       this.serviceLocator = newServiceLocator;       this.init();   }
   /**    * Used to initialize the managed bean.    * lt;pgt;    * Called after the service locator is set.    * It is a workaround.    * lt;pgt;    * Once the JSF bean management facility can support init method,    * the init method can be configured and called from the JSF implementation directly.    */   protected void init() throws Exception {       fromServletResponse response = (fromServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();       ;       response.setHeader(quot;Cache-Controlquot;, quot;no-storequot;);       response.setHeader(quotragma\quot;quot;, quot;no-cachequot;);        response.setDateHeader(quot;Expiresquot;,                    0);    }
}

servicelocatorCode:
package com.fp.common.view.servicelocator;
import com.fp.Event.model.service.EventsService;public interface ServiceLocator {   public EventsService getEventsService();
  

}

servicelocatorbeanCode:
package com.fp.common.view.servicelocator.impl;
import javax.faces.context.FacesContext;

import javax.servlet.ServletContext;

import org..context.ApplicationContext;
import org..web.context.support.WebApplicationContextUtils;import com.fp.common.view.servicelocator.ServiceLocator;import com.fp.Event.model.service.EventsService;
public class ServiceLocatorBean implements ServiceLocator {   private ApplicationContext appContext;
   public EventsService eventsService;   
   public ServiceLocatorBean() throws Exception {       ServletContext context = (ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext();       appContext =     WebApplicationContextUtils.getRequiredWebApplicationContext(context);              appContext = WebApplicationContextUtils.getRequiredWebApplicationContext(context);       eventsService = (EventsService)appContext.getBean(quot;eventsServicequot;);          }
     public EventsService getEventsService() {       return eventsService;   }

   public void setEventsService(EventsService eventsService) {       this.eventsService = eventsService;   }
  
}

EventBBCode:
package com.fp.Event.view.backing;

import java.util.ArrayList;
import java.util.List;

import com.fp.Event.model.bo.Events;
import com.fp.common.view.bean.BaseBean;

public class EventBB  extends BaseBean {Listlt;Eventsgt; Events = new ArrayListlt;Eventsgt;();public void init(){Events = this.serviceLocator.getEventsService().getEvents();}
   public void setEvents(Listlt;Eventsgt; events) {       this.Events = events;   }      public Listlt;Eventsgt; getEvents()   {   return Events;   }
}

eventsserviceCode:
package com.fp.Event.model.service;

import java.util.List;

import com.fp.Event.model.bo.Events;

public interface EventsService {
   public Listlt;Eventsgt; getEvents();

}
evebtserviceimplCode:
package com.fp.Event.model.service.impl;

import java.util.List;

import com.fp.Event.model.service.EventsService;
import com.fp.Event.model.bo.Events;
import com.fp.Event.model.dao.EventsDAO;

public class EventsServiceIMPL implements EventsService {
   private EventsDAO eventsDao;

   public Listlt;Eventsgt; getEvents() {       return eventsDao.getEvents();   }

}mon.model.dao.BaseDAO;
import com.fp.Event.model.dao.EventsDAO;

public class EventsDAOHibernateIMPL extends BaseDAO implements EventsDAO { public Listlt;Eventsgt; getEvents() {    Listlt;Eventsgt; eventList;
       eventList =     (ArrayListlt;Eventsgt;)getHibernateTemplate().find(quot; from Events where type_Code is null and deal_Id is null and global_Flag = 'Y'  and name is not null order by name  quot;);
       return eventList;
}
}

events.javaCode:
package com.fp.Event.model.bo;

import java.math.BigDecimal;
import java.util.Date;public class Events {   int id;   String typeCode;   String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTypeCode() {
return typeCode;
}
public void setTypeCode(String typeCode) {
this.typeCode = typeCode;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}Events.hbm.xmlCode:
lt;?xml version=quot;1.0quot;?gt;

lt;!DOCTYPE hibernate-mapping PUBLIC quot;-//Hibernate/Hibernate Mapping DTD 3.0//ENquot; quot;hibernate-mapping-3.0.dtdquot;gt;

lt;hibernate-mapping package=quot;com.fp.events.model.boquot; auto-import=quot;truequot;
default-lazy=quot;falsequot;gt;

lt;class name=quot;Eventsquot; table=quot;fpi_deal_eventsquot;gt;
lt;id name=quot;idquot; column=quot;deal_event_idquot;gt;
lt;generator class=quot;incrementquot;gt;
lt;/generatorgt;
lt;/idgt;
lt;property name=quot;typeCodequot; column=quot;type_codequot; /gt;
lt;property name=quot;namequot; column=quot;namequot; /gt;

lt;/classgt;
lt;/hibernate-mappinggt;mon.view.servicelocator.impl.ServiceLocatorBean
lt;/managed-bean-classgt;
lt;managed-bean-scopegt;sessionlt;/managed-bean-scopegt;
lt;/managed-beangt;
lt;managed-beangt;
lt;managed-bean-namegt;eventslt;/managed-bean-namegt;
lt;managed-bean-classgt;
com.fp.Event.view.backing.EventBB
lt;/managed-bean-classgt;
lt;managed-bean-scopegt;sessionlt;/managed-bean-scopegt;
lt;managed-propertygt;
lt;property-namegt;serviceLocatorlt;/property-namegt;
lt;valuegt;#{serviceLocatorBean}lt;/valuegt;
lt;/managed-propertygt;
lt;/managed-beangt;lt;/faces-configgt;

daoContext.xmlCode:
lt;?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?gt;
lt;!DOCTYPE beans PUBLIC quot;-//SPRING//DTD BEAN//ENquot; quot;dtd/spring-beans.dtdquot;gt;

lt;beansgt;

lt;bean parent=quot;BaseDAOquot; id=quot;eventsDaoquot;
class=quot;com.fp.Event.model.dao.hibernate.EventsDAOHibernateIMPLquot;gt;
lt;/beangt;
lt;/beansgt;
serviceContext.xmlCode:
lt;?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?gt;
lt;!DOCTYPE beans PUBLIC quot;-//SPRING//DTD BEAN//ENquot; quot;dtd/spring-beans.dtdquot;gt;

lt;beansgt;

lt;bean singleton=quot;truequot; id=quot;eventsServicequot;
class=quot;com.fp.Event.model.service.impl.EventsServiceIMPLquot;gt;
lt;property name=quot;eventsDaoquot;gt;
lt;ref bean=quot;eventsDaoquot; /gt;
lt;/propertygt;
lt;/beangt;
lt;/beansgt;

jboss-web.xmlCode:
lt;?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?gt;

lt;!DOCTYPE jboss-web PUBLIC   quot;-//JBoss//DTD Web Application 2.4//ENquot;   quot;j2ee/dtd/jboss-web_4_2.dtdquot;gt;

lt;jboss-webgt;
lt;context-rootgt;Hibernatelt;/context-rootgt;

lt;/jboss-webgt;

There is also applicationcontext.xmlCode:
lt;?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?gt;
lt;!DOCTYPE beans PUBLIC quot;-//SPRING//DTD BEAN//ENquot; quot;dtd/spring-beans.dtdquot;gt;

lt;beansgt;
lt;!--JNDI based - Please make sure this is enabled when deploying--gt;
lt;!--lt;bean id=quot;dataSourcequot; class=quot;org..jndi.JndiObjectFactoryBeanquot;gt;
lt;property name=quot;jndiNamequot;gt;
lt;valuegt;jdbc/DMDataSourcelt;/valuegt;
lt;/propertygt;
lt;/beangt;--gt;lt;!-- OTDEV --gt;
lt;bean id=quot;dataSourcequot;
class=quot;org..jdbc.datasource.DriverManagerDataSourcequot;gt;
lt;property name=quot;driverClassNamequot;gt;
lt;valuegt;oracle.jdbc.driver.OracleDriverlt;/valuegt;
lt;/propertygt;
lt;property name=quot;uclquot;gt;
lt;valuegt;jdbcracle:thinjok.jok.com:1439:OT2lt;/valuegt;
lt;/propertygt;
lt;property name=quot;usernamequot;gt;
lt;valuegt;USERlt;/valuegt;
lt;/propertygt;
lt;property name=quot;passwordquot;gt;
lt;valuegt;passwordlt;/valuegt;
lt;/propertygt;
lt;/beangt;
lt;bean id=quot;sessionFactoryquot;
class=quot;org..orm.hibernate3.LocalSessionFactoryBeanquot;gt;
lt;property name=quot;mappingDirectoryLocationsquot;gt;
lt;listgt;
lt;valuegt;classpath:/com/fp/Events/model/bolt;/valuegt;

lt;/listgt;
lt;/propertygt;

lt;property name=quot;hibernatePropertiesquot;gt;
lt;propsgt;
lt;prop key=quot;hibernate.dialectquot;gt;
org.hibernate.dialect.OracleDialect
lt;/propgt;
lt;!--lt;prop key=quot;hibernate.transaction.flush_before_completionquot;gt;truelt;/propgt;--gt;
lt;!--lt;prop key=quot;hibernate.transaction.auto_close_sessionquot;gt;truelt;/propgt;--gt;
lt;!--lt;prop key=quot;hibernate.connection.release_modequot;gt;after_transactionlt;/propgt;--gt;
lt;prop key=quot;hibernate.show_sqlquot;gt;falselt;/propgt;
lt;prop
key=quot;hibernate.bytecode.use_reflection_optimizerquot;gt;
false
lt;/propgt;
lt;!--org.hibernate.cache.HashtableCacheProvider EhCacheProvider--gt;
lt;prop key=quot;hibernate.jdbc.batch_versioned_dataquot;gt;
true
lt;/propgt;
lt;prop key=quot;hibernate.generate_statisticsquot;gt;falselt;/propgt;
lt;prop key=quot;hibernate.order_insertsquot;gt;truelt;/propgt;
lt;prop key=quot;hibernate.order_updatesquot;gt;truelt;/propgt;
lt;prop key=quot;hibernate.cache.provider_classquot;gt;
org.hibernate.cache.EhCacheProvider
lt;/propgt;
lt;prop key=quot;hibernate.cache.use_second_level_cachequot;gt;
false
lt;/propgt;
lt;prop key=quot;hibernate.cache.use_query_cachequot;gt;falselt;/propgt;
lt;prop key=quot;hibernate.query.factory_classquot;gt;
org.hibernate.hql.classic.ClassicQueryTranslatorFactory
lt;/propgt;
lt;prop key=quot;hibernate.jdbc.batch_sizequot;gt;20lt;/propgt;
lt;prop key=quot;hibernate.current_session_context_classquot;gt;
thread
lt;/propgt;
lt;prop key=quot;hibernate.transaction.factory_classquot;gt;
org.hibernate.transaction.JDBCTransactionFactory
lt;/propgt;
lt;/propsgt;
lt;/propertygt;

lt;property name=quot;dataSourcequot;gt;
lt;ref local=quot;dataSourcequot; /gt;
lt;/propertygt;
lt;/beangt;

lt;bean id=quot;jdbcExceptionTranslatorquot;
class=quot;org..jdbc.support.SQLErrorCodeSQLExceptionTranslatorquot;gt;
lt;property name=quot;dataSourcequot;gt;
lt;ref bean=quot;dataSourcequot; /gt;
lt;/propertygt;
lt;/beangt;

lt;bean id=quot;hibernateTemplatequot;
class=quot;org..orm.hibernate3.HibernateTemplatequot;gt;
lt;property name=quot;sessionFactoryquot;gt;
lt;ref bean=quot;sessionFactoryquot; /gt;
lt;/propertygt;
lt;property name=quot;jdbcExceptionTranslatorquot;gt;
lt;ref bean=quot;jdbcExceptionTranslatorquot; /gt;
lt;/propertygt;
lt;/beangt;lt;bean id=quot;baseTransactionProxyquot; abstract=quot;truequot;
class=quot;org..transaction.interceptor.TransactionProxyFactoryBeanquot;gt;

lt;property name=quot;transactionManagerquot;gt;
lt;bean id=quot;transactionManagerquot;
class=quot;org..orm.hibernate3.HibernateTransactionManagerquot;gt;
lt;property name=quot;sessionFactoryquot;gt;
lt;ref local=quot;sessionFactoryquot; /gt;
lt;/propertygt;
lt;/beangt;
lt;/propertygt;

lt;property name=quot;transactionAttributesquot;gt;
lt;propsgt;
lt;prop key=quot;save*quot;gtROPAGATION_REQUIRED,-Exceptionlt;/propgt;
lt;/propsgt;
lt;/propertygt;
lt;/beangt;lt;bean abstract=quot;truequot; id=quot;BaseDAOquot;gt;
lt;property name=quot;dataSourcequot;gt;
lt;ref bean=quot;dataSourcequot; /gt;
lt;/propertygt;
lt;property name=quot;hibernateTemplatequot;gt;
lt;ref bean=quot;hibernateTemplatequot; /gt;
lt;/propertygt;
lt;/beangt;

lt;/beansgt;mon.view.servicelocator.impl.ServiceLoca  torBean.lt;initgt;(ServiceLocatorBean.java:31)
at sun.reflect.NativeConstructorAccessorImpl.newInsta  nce0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInsta  nce(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newI  nstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Construc  tor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(B  eanBuilder.java:188)
... 72 more

10:05:59,084 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/Hibernate].[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception: java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
at org..web.context.support.WebApplica  tionContextUtils.getRequiredWebApplicationContext(  WebApplicationContextUtils.java:84)
at com.fp.common.view.servicelocator.impl.ServiceLoca  torBean.lt;initgt;(ServiceLocatorBean.java:31)
at sun.reflect.NativeConstructorAccessorImpl.newInsta  nce0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInsta  nce(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newI  nstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Construc  tor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(B  eanBuilder.java:188)
.
.
.
.
.
Libraries I have used

aspectjrt-1.6.8.jar
sprin.oxm-3.0.2.jar
spring.aop-3.0.2.jar
spring.asm-3.0.2.jar
spring.beans-3.0.2.jar
spring.context.support-3.0.2.jar
spring.core-3.0.2.jar
spring.expression-3.0.2.jar
spring.jdbc-3.0.2.jar
spring.orm-3.0.2.jar
spring.test-3.0.2.jar
spring.transaction-3.0.2.jar
spring.web.portlet-3.0.2.jar
spring.web.servlet-3.0.2.jar
spring.web.struts-3.0.2.jar
spring.web-3.0.2.jar
spring-security-acl-3.0.2.RELEASE.jar
spring-security-config-3.0.2.RELEASE.jar
spring-security-core-3.0.2.RELEASE.jar
spring-security-taglibs-3.0.2.RELEASE.jar
spring-security-web-3.0.2.RELEASE.jar
aspectjweaver-1.6.8.jar
commons-beanutils-1.8.0.jar
commons-collections-3.2.jar
commons-digester-2.0.jar
commons-logging.jar
hibernate3.jar
hibernate-annotations.jar
hibernate-commons-annotations.jar
hibernate-entitymanager.jar
hibernate-validator-4.0.2.GA.jar
richfaces-api-3.3.1.GA.jar
richfaces-impl-3.3.1.GA.jar
richfaces-ui-3.3.1.GA.jar
standard-1.1.2.jar

.uclClassLoader$1.run(uclClassLoader.java:  200)ERROR [[/Hibernate]] Exception sending context initialized event to listener instance of class org..web.context.ContextLoaderListe  ner: org..beans.factory.CannotLoadBeanCl  assException: Cannot find class [org..orm.hibernate3.LocalSessionFac  toryBean] for bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: org..orm.hibernate3.LocalSessionFac  toryBean
¥
Back Forum Reply New