public ListBroadcast()
{
/*A Wicket - style Loop/List of Items*/
add(new ListView<Broadcast>("people", (broadcastService.getAllBroadcast())) {
private static final long serialVersionUID = 1L;
// This method is called for each 'entry' in the list.
@SuppressWarnings("unchecked")
protected void populateItem(ListItem<Broadcast> item) {
Broadcast brd = (Broadcast)item.getModelObject();
item.add(new Label("b.bday", brd.getBday()));
item.add(new Label("b.ch",(channelService.getChannel(brd.getChid()).getChannelname()) ));
item.add(new DateTextField("b.time",(IModel<Date>) programService.getProgram(brd.getPrid()).getProgramstart()));
item.add(new Label("b.pr",(programService.getProgram(brd.getPrid()).getProgramname())));
}
});
}
Wicket + Hibernate + Spring Ant builder
Использую hibernatetemplate hibernatedaosupport для DAO, имеет слой сервисов и entity. Но никак не могу связать, то что уже имею с Wicket. Собственно очень интересуют настройки web.xml и Applicationcontext.xml. Если кто разбирается прошу помочь. Интересует также настройка build.xml. Как прописывать чтобы нормально проект запускался на сервере(Tomcat).
Заранее благодарен.
о том как викет со спрингом скрестить инфы полно
Код:
Вот ошибки которые Томкат выбрасывает на эту страницу.
Код:
WicketMessage: Can't instantiate page using constructor public web.ListBroadcast()
Root cause:
java.lang.NullPointerException
at web.ListBroadcast.<init>(ListBroadcast.java:26)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.apache.wicket.session.DefaultPageFactory.createPage(DefaultPageFactory.java:192)
at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:57)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.newPage(BookmarkablePageRequestTarget.java:298)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.getPage(BookmarkablePageRequestTarget.java:320)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.processEvents(BookmarkablePageRequestTarget.java:234)
at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1250)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:479)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:312)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
at java.lang.Thread.run(Unknown Source)
Complete stack:
org.apache.wicket.WicketRuntimeException: Can't instantiate page using constructor public web.ListBroadcast()
at org.apache.wicket.session.DefaultPageFactory.createPage(DefaultPageFactory.java:212)
at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:57)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.newPage(BookmarkablePageRequestTarget.java:298)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.getPage(BookmarkablePageRequestTarget.java:320)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.processEvents(BookmarkablePageRequestTarget.java:234)
at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1250)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:479)
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.apache.wicket.session.DefaultPageFactory.createPage(DefaultPageFactory.java:192)
at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:57)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.newPage(BookmarkablePageRequestTarget.java:298)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.getPage(BookmarkablePageRequestTarget.java:320)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.processEvents(BookmarkablePageRequestTarget.java:234)
at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1250)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:479)
Root cause:
java.lang.NullPointerException
at web.ListBroadcast.<init>(ListBroadcast.java:26)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.apache.wicket.session.DefaultPageFactory.createPage(DefaultPageFactory.java:192)
at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:57)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.newPage(BookmarkablePageRequestTarget.java:298)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.getPage(BookmarkablePageRequestTarget.java:320)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.processEvents(BookmarkablePageRequestTarget.java:234)
at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1250)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:479)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:312)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
at java.lang.Thread.run(Unknown Source)
Complete stack:
org.apache.wicket.WicketRuntimeException: Can't instantiate page using constructor public web.ListBroadcast()
at org.apache.wicket.session.DefaultPageFactory.createPage(DefaultPageFactory.java:212)
at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:57)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.newPage(BookmarkablePageRequestTarget.java:298)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.getPage(BookmarkablePageRequestTarget.java:320)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.processEvents(BookmarkablePageRequestTarget.java:234)
at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1250)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:479)
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.apache.wicket.session.DefaultPageFactory.createPage(DefaultPageFactory.java:192)
at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:57)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.newPage(BookmarkablePageRequestTarget.java:298)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.getPage(BookmarkablePageRequestTarget.java:320)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.processEvents(BookmarkablePageRequestTarget.java:234)
at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1250)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:479)
Можно взять тут
А вообще, я бы заменил Wicket на Struts или GWT.
Возможно в решении вашей проблемы необходима библиотека joda-time-1.6.jar с Wicket. Странно, но она с Wicket порой решает некоторые проблемы.
А вообще, я бы заменил Wicket на Struts или GWT.
по теме - покажи, как обявлен член broadcastService. и было бы неплохо, если бы конкретно показал строчку, на которой вываливает NullPointerException (скорее всего на broadcastService.getAllBroadcast(), но гадать не хочется)
либа wicket-spring используется? если используется, проверь, что SpringInjector правильно установлен в приложении
При том, что это очень даже дельная альтернатива. С Wicket и геморою больше, и сырцов больше и настроек тоже больше.
Интересно, что попользовавшись Wicket люди потом прибывают в поисках альтернатив. Вот обзор/сравнение.
Это как GlassFish альтернатива Tomcat. Кто-то скажет - "ха, ха! Это абсолютно разные вещи!". Но при умелом подходе очень даже заменяемо + избавление от лишнего гемора.
мы сейчас достаточно успешно использует и GWT, и Wicket в одном проекте и довольны и тем, и другим - потому что каждое на своём месте.
писать RPC вызовы на GWT - просто мука! в викете что понравилось - он достаточно просто на первый взгляд, им можно быстро начать пользоваться (мы начали проект на викете при том, что ни один из разработчиков с ним до этого не работал. пока всё идёт хорошо), но при этом он обладает достаточной гибкостью, чтобы контроллировать процесс изнутри
Код:
package service;
import java.util.List;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import DAO.IbroadcastDAO;
import entity.Broadcast;
public class BroadcastService implements IBroadcastService{
private static IbroadcastDAO dao;
@SuppressWarnings("static-access")
public void setDao(IbroadcastDAO dao){
this.dao = dao;
}
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void saveBroadcast(Broadcast brd)
{
dao.save(brd);
}
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void deleteBroadcast(Broadcast brd)
{
dao.delete(brd);
}
@Transactional(readOnly = true, propagation = Propagation.REQUIRED)
public List<Broadcast> getAllBroadcast()
{
return dao.getAll();
}
}
import java.util.List;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import DAO.IbroadcastDAO;
import entity.Broadcast;
public class BroadcastService implements IBroadcastService{
private static IbroadcastDAO dao;
@SuppressWarnings("static-access")
public void setDao(IbroadcastDAO dao){
this.dao = dao;
}
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void saveBroadcast(Broadcast brd)
{
dao.save(brd);
}
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void deleteBroadcast(Broadcast brd)
{
dao.delete(brd);
}
@Transactional(readOnly = true, propagation = Propagation.REQUIRED)
public List<Broadcast> getAllBroadcast()
{
return dao.getAll();
}
}
Код:
package DAO;
//import java.math.BigDecimal;
import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import entity.Broadcast;
public class broadcastDAO extends HibernateDaoSupport implements IbroadcastDAO{
public void save(Broadcast brd)
{
getHibernateTemplate().saveOrUpdate(brd);
}
public void delete(Broadcast brd)
{
getHibernateTemplate().delete(brd);
}
@SuppressWarnings("unchecked")
public List<Broadcast> getAll()
{
return getHibernateTemplate().findByNamedQuery("Broadcast.findAll");
}
/*public List<Broadcast> getBroadcast(String day, BigDecimal chid, BigDecimal prid)
{
return getHibernateTemplate().findByNamedQuery("Broadcast.findByProps", );
}*/
}
//import java.math.BigDecimal;
import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import entity.Broadcast;
public class broadcastDAO extends HibernateDaoSupport implements IbroadcastDAO{
public void save(Broadcast brd)
{
getHibernateTemplate().saveOrUpdate(brd);
}
public void delete(Broadcast brd)
{
getHibernateTemplate().delete(brd);
}
@SuppressWarnings("unchecked")
public List<Broadcast> getAll()
{
return getHibernateTemplate().findByNamedQuery("Broadcast.findAll");
}
/*public List<Broadcast> getBroadcast(String day, BigDecimal chid, BigDecimal prid)
{
return getHibernateTemplate().findByNamedQuery("Broadcast.findByProps", );
}*/
}
Скажите а как правильно настроить wicket-spring.
P.S. У меня нет никакой альтернативы. Именно Hibernate-Spring-Wicket.
http://www.nikisoft.ru/blog/java/sovmestnoe-ispolzovanie-spring-framework-i-wicket/
немного скомканная статья, но зато полная
внимание надо обратить на @SpringBean на страницах, addComponentInstantiationListener в Application и на web.xml
немного скомканная статья, но зато полная
внимание надо обратить на @SpringBean на страницах, addComponentInstantiationListener в Application и на web.xml
Спасио за статью.