no problem smeruje niekde uplne inde:

pouzivam Hibernate 3.2.5.ga, Hibernate Annotations 3.3.0.GA a Spring 2.5, tomcat 6.0.14, acegi 1.0.6 (a ehcache 1.3.0, to som uz zmenil na 1.2.4 co je dodavane s Spring-with-dependencies)

 subor applicationContext-resources.xml :


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd";>

<beans>

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  <property name="driverClassName" value="org.postgresql.Driver" />
  <property name="url" value="jdbc:postgresql://localhost:5432/xxx" />
  <property name="username" value="xxx" />
  <property name="password" value="iwtbxfm" />
</bean>

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
       <property name="hibernateProperties">
           <props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop> <prop key="hibernate.query.substitutions">true 'T', false 'F'</prop>
           <prop key="hibernate.show_sql">true</prop>
           <prop key="hibernate.format_sql">true</prop>
           <prop key="hibernate.hibernate.generate_statistics">true</prop>

           <prop key="hibernate.cache.use_second_level_cache">false</prop>

<prop key="hibernate.cache.provider_configuration_file_resource_path">classpath:/ehcache.xml</prop>
           </props>
       </property>
       <property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:/hibernate.cfg.xml"/>
   </bean>

</beans>



subor hibernate.cfg.xml:



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

<hibernate-configuration>
   <session-factory>

       <mapping class="com.xxx.model.Carrier"/>
   </session-factory>
</hibernate-configuration>




ale objavuje sa stale tato chyba:


INFO: Initializing Spring root WebApplicationContext
9.1.2008 18:43:15 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext-resources.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Unable to load class declared as <mapping class="com.xxx.model.Carrier"/> in the configuration: at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1362) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:540) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:485)
  at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:407) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:735) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:369) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:251) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:190) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3830) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4337) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
  at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
  at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1206)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
  at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.MappingException: Unable to load class declared as <mapping class="com.freightservice.model.Carrier"/> in the configuration: at org.hibernate.cfg.AnnotationConfiguration.parseMappingElement(AnnotationConfiguration.java:602) at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1555)
  at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534)
  at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508)
  at org.hibernate.cfg.Configuration.configure(Configuration.java:1443)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:572) at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1390) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1359)
  ... 30 more
Caused by: java.lang.ClassNotFoundException: com.freightservice.model.Carrier at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
  at java.lang.ClassLoader.loadClassInternal(Unknown Source)
  at java.lang.Class.forName0(Native Method)
  at java.lang.Class.forName(Unknown Source)
  at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:100)
at org.hibernate.cfg.AnnotationConfiguration.parseMappingElement(AnnotationConfiguration.java:599)
  ... 38 more
9.1.2008 18:43:15 org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext



Carrier.java:



package com.xxx.model;

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

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.CascadeType;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;

@Entity @Table(name="carrier")
@javax.persistence.SequenceGenerator(
   name="seq_carrier",
   sequenceName="s_carrier",
   allocationSize=1
)

public class Carrier extends BaseObject {

   @Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seq_carrier")
   private Long id;

   private String name = null;

   private String address = null;

   public Carrier() {}

   public Long getId() {
       return id;
   }

   public void setId(Long id) {
       this.id = id;
   }

   public String getName() {
       return name;
   }

   public void setName(String name) {
       this.name = name;
   }

   public String getAddress() {
       return address;
   }

   public void setAddress(String address){
       this.address = address;
   }

   public boolean equals(Object o) {
       if (this == o) {
           return true;
       }
       if (!(o instanceof Carrier)) {
           return false;
       }

       final Carrier carrier = (Carrier) o;

return !(name != null ? !name.equals(carrier.getName()) : carrier.getName() != null);

   }

   public int hashCode() {
       return (name != null ? name.hashCode() : 0);
   }

   public String toString() {
       return null;
   }
}



 web.xml:


<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";>

   <display-name>xxx</display-name>

   <!-- Context Configuration locations for Spring XML files -->
   <context-param>
       <param-name>contextConfigLocation</param-name>
       <param-value>
           classpath:/applicationContext.xml
           classpath:/applicationContext-resources.xml
           classpath:/applicationContext-dao.xml
           classpath:/applicationContext-service.xml
           classpath:/applicationContext-business.xml
           classpath:/applicationContext-acegi.xml
       </param-value>
   </context-param>

   <servlet>
       <servlet-name>xxx</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
       <init-param>
           <param-name>contextConfigLocation</param-name>
           <param-value>
               classpath:/webApplicationContext.xml
           </param-value>
       </init-param>
       <load-on-startup>1</load-on-startup>
   </servlet>

   <servlet-mapping>
       <servlet-name>xxx</servlet-name>
       <url-pattern>*.action</url-pattern>
   </servlet-mapping>

   <filter>
       <filter-name>Acegi Filter Chain Proxy</filter-name>
<filter-class>org.acegisecurity.util.FilterToBeanProxy</filter-class>
       <init-param>
           <param-name>targetClass</param-name>
<param-value>org.acegisecurity.util.FilterChainProxy</param-value>
       </init-param>
   </filter>

   <filter-mapping>
       <filter-name>Acegi Filter Chain Proxy</filter-name>
       <url-pattern>/*</url-pattern>
   </filter-mapping>

   <listener>
       <listener-class>
           org.springframework.web.context.ContextLoaderListener
       </listener-class>
   </listener>

   <welcome-file-list>
       <welcome-file>index.jsp</welcome-file>
   </welcome-file-list>

</web-app>

zatial sa mi podarilo vygooglovat ze pravdepodobne hore uvedene verzie jednotlivych kniznic nespolupracuju a treba najst tie "spravne" verzie, ale kazdopadne tato chyba sa velmi casto objavuje vo forach.

Ivan

Ing. Jan Novotný  wrote / napísal(a):
Skoro bych si tipnul, že díky atributu default-lazy-init="true" se vám
ta beana vůbec nevytvořila a k chybě dojde pravděpodobně až když si na
tu beanu (nebo jinou beanu, která se danou beanu odkazuje) šáhnete.
Schválně to zkuste ...

Honza N.

2008/1/9, Ivan Polák <[EMAIL PROTECTED]>:
Dobry den,

aby som odstranil moznost problemov s IDE, teraz to kompilujem pomocou
build.xml skriptu a ANT.

java je 1.5.0 a pouzivam tomcat 6.0.14

povodne som mal v subore applicationContext-acegi.xml iba <beans> a
zmenil som to na:

<beans xmlns="http://www.springframework.org/schema/beans";
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
       xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd";
       default-lazy-init="true">

a uz tam ta chyba nie je, neviem ci toto ma vplyv, pretoze uz fakt
skusam vsetko ?

Ivan

Karel Tejnora  wrote / napísal(a):
Zdravim,

      muzete nam popsat v cem kompilujete (verze + binary kompatible) a na
jakem apl serveru to deployujete (verze javy)? Popr. je to exploded nebo
packed?

Podobne problemy mam nekdy pokud se neschoduji verze jaky vyvojoveho
prostredi (myeclipse) a apl serveru i kdyz tak class tam je zda "ze neni
v classes kdyz ji hleda spring".

Ing. Jan Novotný píše v St 09. 01. 2008 v 10:18 +0100:

Co takhle si hodit breakpoint na AbstractBeanFactory.java:1160
a zkusit si tam inspectnout:
this.getClass().getClassLoader().loadClass("com.house.dao.HibernateAuthenticationDao")

...



__________ Informacia od NOD32 2549 (20070925) __________

Tato sprava bola preverena antivirusovym systemom NOD32.
http://www.eset.sk







Odpovedet emailem