我的大學正在設置CAS。目前,我的工作得到與CAS休眠集成,因此,CAS可以連接到數據庫,並已在本指南如下: https://wiki.jasig.org/display/CASUM/Configuringorg.hibernate.MappingException將休眠狀態與CAS集成在一起
完整的堆棧跟蹤:
SEVERE: Exception starting filter springSecurityFilterChain
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'servicesManager' defined in ServletContext resource [/WEB-INF/spring-configuration/applicationContext.xml]: Cannot resolve reference to bean 'serviceRegistryDao' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceRegistryDao' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: CasPersistence] Unable to build EntityManagerFactory
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:616)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1003)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:907)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized_aroundBody0(SafeContextLoaderListener.java:62)
at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized_aroundBody1$advice(SafeContextLoaderListener.java:44)
at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized(SafeContextLoaderListener.java:1)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceRegistryDao' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: CasPersistence] Unable to build EntityManagerFactory
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 28 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: CasPersistence] Unable to build EntityManagerFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 38 more
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: CasPersistence] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
... 45 more
Caused by: org.hibernate.MappingException: Could not determine type for: java.util.List, at table: RegisteredServiceImpl, for columns: [org.hibernate.mapping.Column(a_name)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:304)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:288)
at org.hibernate.mapping.Property.isValid(Property.java:216)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:467)
at org.hibernate.mapping.RootClass.validate(RootClass.java:268)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1287)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1718)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:76)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)
... 51 more
我serviceRegistryDao和數據源豆:
<bean id="serviceRegistryDao" class="org.jasig.cas.services.JpaServiceRegistryDaoImpl"
p:entityManagerFactory-ref="entityManagerFactory" />
<!-- This is the EntityManagerFactory configuration for Hibernate -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="generateDdl" value="true"/>
<property name="showSql" value="true" />
</bean>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean
id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
p:driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
p:url="jdbc:sqlserver://xx.xx.xx.xx:xxxx;databaseName=XXX"
p:password="XXXXX"
p:username="XXXXX" />
我也會把我的persistence.xml文件在這裏,但我還沒有從默認的改變了它在所有:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="CasPersistence" transaction-type="RESOURCE_LOCAL">
<class>org.jasig.cas.services.RegisteredServiceImpl</class>
<class>org.jasig.cas.ticket.TicketGrantingTicketImpl</class>
<class>org.jasig.cas.ticket.ServiceTicketImpl</class>
</persistence-unit>
</persistence>
RegisteredServiceImpl.java(從CAS服務器核心 - 3.4.10.jar可以在這裏探索:http://www.jarvana.com/jarvana/inspect/org/jasig/cas/cas-server-core/3.4.10/cas-server-core-3.4.10-sources.jar
/*
* Copyright 2007 The JA-SIG Collaborative. All rights reserved. See license
* distributed with this file and available online at
* http://www.uportal.org/license.html
*/
package org.jasig.cas.services;
import java.sql.Array;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinTable;
import javax.persistence.GenerationType;
import org.apache.commons.lang.builder.ToStringBuilder;Class search for 'org.apache.commons.lang.builder.ToStringBuilder'
import org.apache.commons.lang.builder.ToStringStyle;Class search for 'org.apache.commons.lang.builder.ToStringStyle'
import org.hibernate.annotations.CollectionOfElements;Class search for 'org.hibernate.annotations.CollectionOfElements'
import org.hibernate.annotations.IndexColumn;Class search for 'org.hibernate.annotations.IndexColumn'
import org.jasig.cas.authentication.principal.Service;Class search for 'org.jasig.cas.authentication.principal.Service'
import org.springframework.util.AntPathMatcher;Class search for 'org.springframework.util.AntPathMatcher'
import org.springframework.util.Assert;Class search for 'org.springframework.util.Assert'
import org.springframework.util.PathMatcher;Class search for 'org.springframework.util.PathMatcher'
/**
* Mutable implementation of a RegisteredService.
*
* @author Scott Battaglia
* @version $Revision: 22918 $ $Date: 2011-02-06 23:02:50 -0500 (Sun, 06 Feb 2011) $
* @since 3.1
*/
@Entity
public class RegisteredServiceImpl
implements RegisteredService, Comparable<RegisteredService> {
/** Unique Id for serialization. */
private static final long serialVersionUID = -5136788302682868276L;
private static final PathMatcher PATH_MATCHER = new AntPathMatcher();
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id = -1;
@CollectionOfElements(targetElement = String.class, fetch = FetchType.EAGER)
@JoinTable(name = "rs_attributes")
@Column(name = "a_name", nullable = false)
@IndexColumn(name = "a_id")
private List<String> allowedAttributes = new ArrayList<String>();
private String description;
private String serviceId;
private String name;
private String theme;
private boolean allowedToProxy = true;
private boolean enabled = true;
private boolean ssoEnabled = true;
private boolean anonymousAccess = false;
private boolean ignoreAttributes = false;
@Column(name = "evaluation_order", nullable = false)
private int evaluationOrder;
public boolean isAnonymousAccess() {
return this.anonymousAccess;
}
public void setAnonymousAccess(final boolean anonymousAccess) {
this.anonymousAccess = anonymousAccess;
}
public List<String> getAllowedAttributes() {
return this.allowedAttributes;
}
public long getId() {
return this.id;
}
public String getDescription() {
return this.description;
}
public String getServiceId() {
return this.serviceId;
}
public String getName() {
return this.name;
}
public String getTheme() {
return this.theme;
}
public boolean isAllowedToProxy() {
return this.allowedToProxy;
}
public boolean isEnabled() {
return this.enabled;
}
public boolean isSsoEnabled() {
return this.ssoEnabled;
}
public boolean matches(final Service service) {
return service != null && PATH_MATCHER.match(this.serviceId.toLowerCase(), service.getId().toLowerCase());
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof RegisteredServiceImpl)) return false;
RegisteredServiceImpl that = (RegisteredServiceImpl) o;
if (allowedToProxy != that.allowedToProxy) return false;
if (anonymousAccess != that.anonymousAccess) return false;
if (enabled != that.enabled) return false;
if (evaluationOrder != that.evaluationOrder) return false;
if (ignoreAttributes != that.ignoreAttributes) return false;
if (ssoEnabled != that.ssoEnabled) return false;
if (allowedAttributes != null ? !allowedAttributes.equals(that.allowedAttributes) : that.allowedAttributes != null)
return false;
if (description != null ? !description.equals(that.description) : that.description != null) return false;
if (name != null ? !name.equals(that.name) : that.name != null) return false;
if (serviceId != null ? !serviceId.equals(that.serviceId) : that.serviceId != null) return false;
if (theme != null ? !theme.equals(that.theme) : that.theme != null) return false;
return true;
}
@Override
public int hashCode() {
int result = allowedAttributes != null ? allowedAttributes.hashCode() : 0;
result = 31 * result + (description != null ? description.hashCode() : 0);
result = 31 * result + (serviceId != null ? serviceId.hashCode() : 0);
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (theme != null ? theme.hashCode() : 0);
result = 31 * result + (allowedToProxy ? 1 : 0);
result = 31 * result + (enabled ? 1 : 0);
result = 31 * result + (ssoEnabled ? 1 : 0);
result = 31 * result + (anonymousAccess ? 1 : 0);
result = 31 * result + (ignoreAttributes ? 1 : 0);
result = 31 * result + evaluationOrder;
return result;
}
public void setAllowedAttributes(final List<String> allowedAttributes) {
if (allowedAttributes == null) {
this.allowedAttributes = new ArrayList<String>();
} else {
this.allowedAttributes = allowedAttributes;
}
}
public void setAllowedToProxy(final boolean allowedToProxy) {
this.allowedToProxy = allowedToProxy;
}
public void setDescription(final String description) {
this.description = description;
}
public void setEnabled(final boolean enabled) {
this.enabled = enabled;
}
public void setServiceId(final String id) {
this.serviceId = id;
}
public void setId(final long id) {
this.id = id;
}
public void setName(final String name) {
this.name = name;
}
public void setSsoEnabled(final boolean ssoEnabled) {
this.ssoEnabled = ssoEnabled;
}
public void setTheme(final String theme) {
this.theme = theme;
}
public boolean isIgnoreAttributes() {
return this.ignoreAttributes;
}
public void setIgnoreAttributes(final boolean ignoreAttributes) {
this.ignoreAttributes = ignoreAttributes;
}
public void setEvaluationOrder(final int evaluationOrder) {
this.evaluationOrder = evaluationOrder;
}
public int getEvaluationOrder() {
return this.evaluationOrder;
}
public Object clone() throws CloneNotSupportedException {
final RegisteredServiceImpl registeredServiceImpl = new RegisteredServiceImpl();
registeredServiceImpl.setAllowedAttributes(this.allowedAttributes);
registeredServiceImpl.setAllowedToProxy(this.allowedToProxy);
registeredServiceImpl.setDescription(this.description);
registeredServiceImpl.setEnabled(this.enabled);
registeredServiceImpl.setId(this.id);
registeredServiceImpl.setName(this.name);
registeredServiceImpl.setServiceId(this.serviceId);
registeredServiceImpl.setSsoEnabled(this.ssoEnabled);
registeredServiceImpl.setTheme(this.theme);
registeredServiceImpl.setAnonymousAccess(this.anonymousAccess);
registeredServiceImpl.setIgnoreAttributes(this.ignoreAttributes);
registeredServiceImpl.setEvaluationOrder(this.evaluationOrder);
return registeredServiceImpl;
}
public int compareTo(final RegisteredService other) {
final int result = this.evaluationOrder - other.getEvaluationOrder();
if (result == 0) {
return (int)(this.id - other.getId());
}
return result;
}
@Override
public String toString() {
final ToStringBuilder toStringBuilder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
toStringBuilder.append("id", this.id);
toStringBuilder.append("name", this.name);
toStringBuilder.append("description", this.description);
toStringBuilder.append("serviceId", this.serviceId);
toStringBuilder.append("attributes", this.allowedAttributes.toArray());
return toStringBuilder.toString();
}
}
任何幫助/建議將不勝感激。讓我知道是否有任何其他信息我應該發佈。
發佈類** RegisteredServiceImpl **的hibernate映射。 – ManuPK
我已經根據請求添加了RegisteredServiceImpl的映射。 – Artemis
如果有人在後面看這個,我們永遠無法解決它;相反,我們只需在deployerConfigContext.xml中的serviceRegistryDao bean中手動列出服務。但是,如果我要猜測導致錯誤的原因,我想說這是因爲我正在使用受限訪問的服務器,所以可能需要從互聯網和無法。祝這個錯誤的人更好! – Artemis