Dependency Injection, Konfigurationsproblem

T.Otte

Mitglied
Guten morgen,
Ich hoffe dass der Post in diesem Unterforum richtig aufgehoben ist. Da ich Spring und Hibernate benutze könnte der Fehler auch in der Hibernate Konfiguration liegen, aber ich vermute eher das ich im Spring Teil einen Fehler gemacht habe.

Ich benutze insgesammt eine Kombination aus Hibernate + Spring + ZK (Ajax Framework für die Web schicht). Habe mir in applicationConfig.xml die Beans definiert und diese sollen durch setter-based Dependency Injection übergeben werden.
Allerdings erhalte ich immer NullPointerExceptions, da diese Beans anscheinend nicht instantiiert werden.

Habe meine Konfiguration anhand diverser tutorials schon mehrmals überarbeitet, aber bisher noch keine Lösung gefunden.

Hier mal meine momentane Konfiguration:

applicationConfig.xml
[XML]
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
Index of /schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
Index of /schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">


<!-- HIBERNATE DEFINITIONEN -->

<!-- Hibernate SessionFactory -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/test" />
<property name="username" value="root" />
<property name="password" value="aqua" />
</bean>


<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" />
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>domain.Standort</value>
<value>domain.Hersteller</value>
</list>
</property>

<property name="hibernateProperties">
<props>
<prop key="connection.pool_size">1</prop>
<prop key="current_session_context_class">thread</prop>
<prop key="cache.provider_class">org.hibernate.cache.NoCacheProvider</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
</props>
</property>
</bean>

<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory" />
</bean>

<!-- Es wird setter-based dependency injection benutzt -->

<!-- Daos, die Klasse verweist auf die Implementation, nicht auf das Interface -->
<bean id="HerstellerDao" class="dao.HerstellerDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="StandortDao" class="dao.StandortDaoImpl">
<property name="hibernateTemplate" ref="hibernateTemplate"></property>
</bean>

<!-- Service -->
<bean id="HerstellerService" class="service.HerstellerServiceImpl">
<property name="herstellerDao" ref="HerstellerDao"></property>
</bean>
<bean id="StandortService" class="service.StandortServiceImpl">
<property name="standortDao" ref="StandortDao"></property>
</bean>

<!-- Controller -->
<bean id="StandortController" class="controller.StandortController" scope="prototype">
<property name="standortService" ref="StandortService"></property>
</bean>

<bean id="HerstellerController" class="controller.HerstellerController" scope="prototype">
<property name="herstellerService" ref="HerstellerService"></property>
</bean>

<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>

<!-- Transaction Manager, alle mit @Transactional gekennzeichneten Klassen werden damit aktiviert -->
<tx:annotation-driven transaction-manager="transactionManager"/>

<!-- a PlatformTransactionManager is still required -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<!-- (this dependency is defined somewhere else) -->
<property name="dataSource" ref="dataSource"/>
</bean>

<aop:config>
<aop:advisor pointcut="execution(* *..Service.*(..))" advice-ref="txAdvice"/>
</aop:config>

<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="insert*" />
<tx:method name="update*" />
<tx:method name="*" read-only="true" />
</tx:attributes>
</tx:advice>

</beans>
[/XML]

web.xml (Bin mir nicht sicher ob die wichtig ist)
[XML]
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" 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>Stammdatenpflege</display-name>


<!-- AB HIER SPRING -->

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>

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

<!-- ENDE SPRING DEFINITIONEN -->



<listener>
<description>
Used to cleanup when a session is destroyed</description>
<display-name>ZK Session cleaner</display-name>
<listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class>
</listener>
<servlet>
<description>
The ZK loader for ZUML pages</description>
<servlet-name>zkLoader</servlet-name>
<servlet-class>
org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class>
<init-param>
<param-name>update-uri</param-name>
<param-value>/zkau</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<description>
The asynchronous update engine for ZK</description>
<servlet-name>auEngine</servlet-name>
<servlet-class>
org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>zkLoader</servlet-name>
<url-pattern>*.zul</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>zkLoader</servlet-name>
<url-pattern>*.zhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>auEngine</servlet-name>
<url-pattern>/zkau/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
<welcome-file>index.zul</welcome-file>
</welcome-file-list>
</web-app>
[/XML]

Hier mein HerstellerController, dieser benötigt eine Instanz von HerstellerService, die durch setter-based Dependency Injection gesetzt werden sollte. An dieser Stelle bekomme ich dann die NullPointerException, da HerstellerService immer null ist und somit in getAlleHersteller() die Exception fliegt.
Java:
package controller;

import java.util.List;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Window;
import org.zkoss.zul.Listbox;

import service.HerstellerService;
import domain.Hersteller;


public class HerstellerController extends GenericForwardComposer{
	
	HerstellerService herstellerService;
	Hersteller current;
	Window win;
	Listbox box;
	
	public Hersteller getCurrent() {
		return current;
	}
	
	public void setCurrent(Hersteller current) {
		this.current = current;
	}
	
	public void setHerstellerService(HerstellerService herstellerService)
	{
		this.herstellerService = herstellerService;
	}
	
	public List getAlleHersteller() {
		return herstellerService.getAlleHersteller();
	}
	
	public void onClick$add() {	
		Hersteller newHersteller = new Hersteller(current.getNummer(),
			current.getName());
		//check ob es den Hersteller schon gibt momentan noch aus, da man evtl. auch Abkürzungen speichern möchte, z.B. [2,VW]
		//check if the Hersteller already exists, indicated by the same Nummer
		//if (!checkHersteller(newHersteller.getNummer()))
		//{
			//insert into database if the Hersteller is new
			herstellerService.saveOrUpdate(newHersteller, newHersteller.getNummer(), newHersteller.getName());
		//}
	}	
	public void onClick$update() {		
		if (box.getSelectedItem() != null) {
			Hersteller updateHersteller = (Hersteller) box.getSelectedItem().getValue();
			//check ob es den Hersteller schon gibt momentan noch aus, da man evtl. auch Abkürzungen speichern möchte, z.B. [2,VW]
			//check if the Hersteller already exists, indicated by the same Nummer
			//if (!checkHersteller(updateHersteller.getNummer()))
			//{
				//commit changes into database if there is no conflict
				herstellerService.saveOrUpdate(updateHersteller, updateHersteller.getNummer(), updateHersteller.getName());
			//}
		}
	}
	
	//private boolean checkHersteller(int nummer) {
		//if (herstellerDAO.findByNummer(nummer) != null)
		//{
			//alert("Dieser Standort existiert bereits");
			//return true;
		//}
		//return false;
	//}
	
	public void onClick$delete() {		
		if (box.getSelectedItem() != null) {
			herstellerService.delete((Hersteller) box.getSelectedItem().getValue());
		}
	}

}

HerstellerService:
Java:
package service;

import dao.HerstellerDao;
import domain.Hersteller;
import java.util.List;

import org.springframework.transaction.annotation.Transactional;

@Transactional
public class HerstellerServiceImpl implements HerstellerService{
	
	private HerstellerDao herstellerDao;
	
	public void setHerstellerDao(HerstellerDao herstellerDao) {
		this.herstellerDao = herstellerDao;
	}
	
	public Hersteller getHerstellerById(Long id)
	{
		return herstellerDao.findById(id);
	}
	
	public Hersteller getByNummer(int nummer){
		return herstellerDao.findByNummer(nummer);
	}
	
	public List getAlleHersteller() {
		return herstellerDao.findAll();
	}
	
	public void saveOrUpdate(Hersteller hersteller, int nummer, String name) {
		herstellerDao.saveOrUpdate(hersteller, nummer, name);
	}
	
	public void delete(Hersteller hersteller) {
		herstellerDao.delete(hersteller);
	}

}

HerstellerDao
Java:
package dao;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import domain.Hersteller;

@Repository
public class HerstellerDaoImpl implements HerstellerDao{
	
	private SessionFactory sessionFactory;
	
	public void setSessionFactory(SessionFactory sessionFactory)
	{
		this.sessionFactory = sessionFactory;
	}
	
	public void saveOrUpdate(Hersteller einHersteller, int nummer, String name)
	{
		einHersteller.setNummer(nummer);
		einHersteller.setName(name);
		
		sessionFactory.getCurrentSession().saveOrUpdate(einHersteller);
	}

    public void delete(Hersteller einHersteller) {
        sessionFactory.getCurrentSession().delete(einHersteller);
    }
    public Hersteller findById(Long id) {
        return (Hersteller) sessionFactory.getCurrentSession().get(Hersteller.class, id);
    }
    
    public Hersteller findByNummer(int nummer) {
    	List list = sessionFactory.getCurrentSession().createQuery("FROM Hersteller WHERE nummer = ?").setParameter(0, nummer).list();
    	if (!list.isEmpty()) {
    		return (Hersteller) list.get(0);
    	}
    	return null;
    }
    
    public List findAll() {
        return sessionFactory.getCurrentSession().createQuery("FROM Hersteller").list();
    }
}

Hersteller
Java:
package domain;

import javax.persistence.*;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;

@Entity
@Table(name="hersteller")
public class Hersteller implements Serializable{
	
	private int hersteller_id;
	private int nummer;
	private String name;
	protected Collection<Standort> standorte = new ArrayList<Standort>();
	
	public Hersteller() {}
	public Hersteller(int nummer, String name) {
		setNummer(nummer);
		setName(name);
	}
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="hersteller_id")
	public int getHersteller_id() {
		return hersteller_id;
	}
	
	@Column(name="nummer")
	public int getNummer() {
		return nummer;
	}
	
	@Column(name="name")
	public String getName() {
		return name;
	}
	
	private void setHersteller_id(int hersteller_id) {
		this.hersteller_id = hersteller_id;
	}
	
	public void setNummer(int nummer) {
		this.nummer = nummer;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	@OneToMany(cascade = CascadeType.ALL, mappedBy="hersteller", fetch = FetchType.EAGER)
	public Collection<Standort> getStandorte() {
		return standorte;
	}
	public void setStandorte(Collection<Standort> coll) {
		standorte = coll;
	}
	public void addStandort(Standort standort) {
		standorte.add(standort);
	}
	public void removeStandort(Standort standort) {
		standorte.remove(standort);
	}

}



Dieses Problem beschäftigt mich schon seit einigen Tagen und ich habe leider keine Idee wo mein Fehler liegt. Daher habe ich mehr als nur die Konfigurationsdateien hier eingefügt, evtl. gibt das ja jemandem Aufschluss über das Problem.
Wenn ich den HerstellerService übergehe und stattdessen direkt auf das Dao zugreife ist dieses NULL, das injecten scheint daher allgemein nicht zu funktionieren, weshalb ich glaube dass der Fehler in der applicationContext.xml liegen muss.

Vielen Dank schonmal für eure Hilfe!
 
G

Gast2

Gast
Also ich habe den HibernateTransactionManager
[XML]
<tx:annotation-driven transaction-manager="transactionManager" />

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
[/XML]

Und diese Einstellung musst du dann auch rausmachen in der hibernate config:
[XML]
<!-- Enable Hibernate's automatic session context management
<property name="current_session_context_class">thread</property>-->
[/XML]

2. Injeziere ich meine Beans mit der Annotaion @Autowired
 

T.Otte

Mitglied
Danke für deine Antwort, hab das mal umgesetzt. Allerdings hat sich mein Fehler leider nicht verändert.

Evtl. ist der Output der Konsole aufschlussreich? Es gibt dort zahlreiche Infos, aber ich habe bisher noch keine erkannt die mir fehlerhaft erscheint.

Code:
01.02.2010 14:19:06 org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNUNG: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:Stammdatenpflege' did not find a matching property.
01.02.2010 14:19:06 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre6\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\ThinkPad\Bluetooth Software\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Common Files\Lenovo;C:\Program Files\Common Files\Roxio Shared\10.0\DLLShared\;C:\Program Files\Common Files\Roxio Shared\DLLShared\;C:\Program Files\Lenovo\Access Connections\;C:\Program Files\Lenovo\Client Security Solution;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Java\jdk1.6.0_18\bin
01.02.2010 14:19:06 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
01.02.2010 14:19:06 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 288 ms
01.02.2010 14:19:06 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
01.02.2010 14:19:06 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.20
01.02.2010 14:19:06 org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
01.02.2010 14:19:06 org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization started
01.02.2010 14:19:06 org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.web.context.support.XmlWebApplicationContext@1be0f0a: display name [Root WebApplicationContext]; startup date [Mon Feb 01 14:19:06 CET 2010]; root of context hierarchy
01.02.2010 14:19:06 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
01.02.2010 14:19:07 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
INFO: Bean factory for application context [org.springframework.web.context.support.XmlWebApplicationContext@1be0f0a]: org.springframework.beans.factory.support.DefaultListableBeanFactory@12884e0
01.02.2010 14:19:07 org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName
INFO: Loaded JDBC driver: com.mysql.jdbc.Driver
01.02.2010 14:19:07 org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker postProcessAfterInitialization
INFO: Bean 'dataSource' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
01.02.2010 14:19:07 org.hibernate.cfg.annotations.Version <clinit>
INFO: Hibernate Annotations 3.3.1.GA
01.02.2010 14:19:07 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.6
01.02.2010 14:19:07 org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
01.02.2010 14:19:07 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
01.02.2010 14:19:07 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
01.02.2010 14:19:07 org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class: domain.Standort
01.02.2010 14:19:07 org.hibernate.cfg.annotations.EntityBinder bindTable
INFO: Bind entity domain.Standort on table standortneu
01.02.2010 14:19:07 org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class: domain.Hersteller
01.02.2010 14:19:07 org.hibernate.cfg.annotations.EntityBinder bindTable
INFO: Bind entity domain.Hersteller on table hersteller
01.02.2010 14:19:07 org.hibernate.cfg.annotations.CollectionBinder bindOneToManySecondPass
INFO: Mapping collection: domain.Hersteller.standorte -> standortneu
01.02.2010 14:19:07 org.hibernate.cfg.AnnotationConfiguration secondPassCompile
INFO: Hibernate Validator not found: ignoring
01.02.2010 14:19:07 org.springframework.orm.hibernate3.LocalSessionFactoryBean buildSessionFactory
INFO: Building new Hibernate SessionFactory
01.02.2010 14:19:07 org.hibernate.cfg.Environment verifyProperties
WARNUNG: Property [hibernate.cglib.use_reflection_optimizer] has been renamed to [hibernate.bytecode.use_reflection_optimizer]; update your properties appropriately
01.02.2010 14:19:07 org.hibernate.connection.ConnectionProviderFactory newConnectionProvider
INFO: Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: MySQL, version: 5.1.42-community
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.10 ( Revision: ${svn.Revision} )
01.02.2010 14:19:07 org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLDialect
01.02.2010 14:19:07 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
01.02.2010 14:19:07 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: on_close
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 2
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL inserts for batching: disabled
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
01.02.2010 14:19:07 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JPA-QL strict compliance: disabled
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.NoCacheProvider
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Echoing all SQL to stdout
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
01.02.2010 14:19:07 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Named query checking : enabled
01.02.2010 14:19:07 org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
01.02.2010 14:19:08 org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
01.02.2010 14:19:08 org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker postProcessAfterInitialization
INFO: Bean 'sessionFactory' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
01.02.2010 14:19:08 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@12884e0: defining beans [org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,dataSource,sessionFactory,hibernateTemplate,HerstellerDao,StandortDao,HerstellerService,StandortService,StandortController,HerstellerController,org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.config.internalTransactionAdvisor,transactionManager,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0,txAdvice]; root of factory hierarchy
01.02.2010 14:19:08 org.springframework.orm.hibernate3.HibernateTransactionManager afterPropertiesSet
INFO: Using DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource@1f47ae8] of Hibernate SessionFactory for HibernateTransactionManager
01.02.2010 14:19:08 org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization completed in 1696 ms
01.02.2010 14:19:08 org.zkoss.zk.ui.http.WebManager <init>:113
INFO: Starting ZK 5.0.0-FL Standard (build: 10011818)
01.02.2010 14:19:08 org.zkoss.zk.ui.sys.ConfigParser parseConfigXml:147
INFO: Loading system default
01.02.2010 14:19:08 org.zkoss.zk.ui.sys.ConfigParser parse:247
INFO: Parsing jndi:/localhost/Stammdatenpflege/WEB-INF/zk.xml
01.02.2010 14:19:09 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
01.02.2010 14:19:09 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
01.02.2010 14:19:09 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/25  config=null
01.02.2010 14:19:09 org.apache.catalina.startup.Catalina start
INFO: Server startup in 2673 ms
 

ck2003

Mitglied
Code:
    <!-- AB HIER SPRING -->
 
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>

Hier mal meine momentane Konfiguration:

applicationConfig.xml

Was fällt dir hier auf (falls du dich nicht verschrieben hast)?
 
Zuletzt bearbeitet:

T.Otte

Mitglied
Danke für die antworten.
@Autowired verwende ich jetzt, aber das hat leider nichts geändert.

applicationConfig war leider nur ein Tippfehler von mir hier im Thread
 

T.Otte

Mitglied
Habe es jetzt gerade wieder zum Laufen bekommen indem ich einen ServiceLocator definiert hab. Dieser wird vom Controller aufgerufen um den Service zu übergeben anstatt den Service in den Controller zu "injecten".

Das wichtige daran ist wohl dass dort der ApplicationContext dann auch mal aufgerufen wird.
static {
ctx = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
}
Ich dachte vorher eigentlich das würde durch die definition in der web.xml automatisch beim laden passieren. Hab das mit dem Service Locator aber erst in einem Beispiel so gesehen. Ist das jetzt in Ordnung so wie ich es mache oder sollte es normalerweise auch durchgängig mit Injection funktionieren?

edit: Denn eigentlich ist ServiceLocator ja genau das Gegenteil von Dependency Injection. Da kommt es mir jetzt komisch vor das gemischt zu benutzen, auch wenn Servie Locator dann zwischen business und web tier ist und Dependency Injection zwischen data und business tier.
 
Zuletzt bearbeitet:

gustav

Aktives Mitglied
Zuletzt bearbeitet:

Ähnliche Java Themen

Neue Themen


Oben