Spring Rich Client Toolbar Menu won't show - spring

I have downloaded Spring Rich Client 1.1.0 from sourceforge and wired up all the beans. When I run the app, I see a pane but no menubar. No warnings or errors in the console.
Here are the menuBar beans:
<bean id="menuBar" class="org.springframework.richclient.command.CommandGroupFactoryBean" >
<property name="members">
<list>
<ref bean="userManagementMenu" />
</list>
</property>
</bean>
<bean id="userManagementMenu" class="org.springframework.richclient.command.CommandGroupFactoryBean" >
<property name="members">
<list>
<ref bean="userCommand"/>
<ref bean="userGroupCommand"/>
<value>separator</value>
</list>
</property>
</bean>
<bean id="fd1" class="org.springframework.richclient.command.config.CommandFaceDescriptor">
<constructor-arg index="0" value="hello"/>
</bean>
<bean id="fd2" class="org.springframework.richclient.command.config.CommandFaceDescriptor">
<constructor-arg index="0" value="there"/>
</bean>
<bean id="userCommand" class="org.springframework.richclient.command.support.WidgetViewCommand">
<property name="widgetViewDescriptorId" value="userView" />
<property name="faceDescriptor" ref="fd1"/>
</bean>
<bean id="userGroupCommand" class="org.springframework.richclient.command.support.WidgetViewCommand">
<property name="widgetViewDescriptorId" value="userGroupView" />
<property name="faceDescriptor" ref="fd2"/>
</bean>
And it is called as follows:
<bean id="lifecycleAdvisor" class="org.springframework.richclient.application.config.DefaultApplicationLifecycleAdvisor">
<property name="windowCommandBarDefinitions" value="ctx/commands.xml"/>
<property name="windowCommandManagerBeanName" value="windowCommandManager"/>
<property name="startingPageId" value="userGroupView"/>
<property name="menubarBeanName" value="menuBar"/>
</bean>
Here are the view related beans:
<bean name="userView" scope="prototype" class="org.springframework.richclient.application.support.DefaultViewDescriptor">
<property name="viewClass" value="com.mycom.views.UserGroupView"/>
</bean>
<bean name="userGroupView" scope="prototype" class="org.springframework.richclient.application.support.DefaultViewDescriptor">
<property name="viewClass" value="com.mycom.views.UserGroupView"/>
</bean>
Here are the misc beans
<bean id="serviceLocator" class="org.springframework.richclient.application.ApplicationServicesLocator">
<property name="applicationServices" ref="applicationServices" />
</bean>
<bean id="applicationServices"
class="org.springframework.richclient.application.support.DefaultApplicationServices" />
<bean id="applicationEventMulticaster"
class="org.springframework.context.event.SimpleApplicationEventMulticaster" />
<bean id="application" class="org.springframework.richclient.application.Application">
<constructor-arg index="0" ref="applicationDescriptor"/>
<constructor-arg index="1" ref="lifecycleAdvisor"/>
</bean>
<bean id="applicationDescriptor" class="org.springframework.richclient.application.support.DefaultApplicationDescriptor">
<property name="version" value="1.0"/>
<property name="buildId" value="20060408-001"/>
</bean>
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>messages</value>
</list>
</property>
</bean>
Here is the UserGroupView:
package com.mycom.views;
import java.awt.BorderLayout;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import org.springframework.richclient.application.support.AbstractView;
public class UserGroupView extends AbstractView {
private JTextField field = new JTextField();
private JLabel lbl = new JLabel("UserGroup:");
public JComponent createControl() {
JPanel view = new JPanel();
view.add(lbl, BorderLayout.NORTH);
view.add(field, BorderLayout.SOUTH);
return view;
}
}
Here is the code for UserView
package com.mycom.views;
import java.awt.BorderLayout;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import org.springframework.richclient.application.support.AbstractView;
public class UserView extends AbstractView {
private JTextField field = new JTextField();
private JLabel lbl = new JLabel("User:");
public JComponent createControl() {
JPanel view = new JPanel();
view.add(lbl, BorderLayout.NORTH);
view.add(field, BorderLayout.SOUTH);
return view;
}
}
Here is the console log:
Feb 24, 2016 9:21:13 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext#45283ce2: display name [org.springframework.context.support.ClassPathXmlApplicationContext#45283ce2]; startup date [Wed Feb 24 09:21:13 PST 2016]; root of context hierarchy
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [ctx/appbundle.xml]
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [ctx/application.xml]
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [ctx/commands.xml]
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [ctx/models.xml]
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [ctx/filters.xml]
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [ctx/filterforms.xml]
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [ctx/editors.xml]
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [ctx/forms.xml]
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [ctx/dataproviders.xml]
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [ctx/services.xml]
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [ctx/views.xml]
Feb 24, 2016 9:21:13 AM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
INFO: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext#45283ce2]: org.springframework.beans.factory.support.DefaultListableBeanFactory#591f989e
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#591f989e: defining beans [serviceLocator,applicationServices,applicationEventMulticaster,application,windowCommandManager,lifecycleAdvisor,applicationDescriptor,messageSource,menuBar,userManagementMenu,fd1,fd2,userCommand,userGroupCommand,baseModel,user,userGroup,userFilter,userGroupFilter,abstractFilterForm,userFilterForm,userGroupFilterForm,abstractDataEditor,userDataEditor,userGroupDataEditor,abstractForm,userForm,userGroupForm,abstractDataProvider,userDataProvider,userGroupDataProvider,userService,userGroupService,userView,userGroupView]; root of factory hierarchy
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.support.DefaultApplicationServices$8 build
INFO: Creating default service impl: CommandConfigurer
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.support.DefaultApplicationServices$7 build
INFO: No object configurer bean Id has been set; configuring defaults.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.support.DefaultApplicationServices$4 build
INFO: Creating default service impl: CommandServices
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userCommand.foreground]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userCommand.background]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userCommand.caption]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userCommand.description]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.support.DefaultApplicationServices$10 build
INFO: Creating default service impl: IconSource
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.support.DefaultApplicationServices$9 build
INFO: Creating default service impl: ImageSource
Feb 24, 2016 9:21:13 AM org.springframework.core.io.support.PropertiesLoaderSupport loadProperties
INFO: Loading properties file from class path resource [org/springframework/richclient/image/images.properties]
Feb 24, 2016 9:21:13 AM org.springframework.richclient.image.DefaultIconSource getIcon
INFO: No image resource found for icon with key 'userCommand.icon'; returning a icon.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.image.DefaultIconSource getIcon
INFO: No image resource found for icon with key 'userCommand.large.icon'; returning a icon.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userCommand.foreground]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userCommand.background]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userCommand.caption]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userCommand.description]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.image.DefaultIconSource getIcon
INFO: No image resource found for icon with key 'userCommand.icon'; returning a icon.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.image.DefaultIconSource getIcon
INFO: No image resource found for icon with key 'userCommand.large.icon'; returning a icon.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userGroupCommand.foreground]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userGroupCommand.background]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userGroupCommand.caption]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userGroupCommand.description]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.image.DefaultIconSource getIcon
INFO: No image resource found for icon with key 'userGroupCommand.icon'; returning a icon.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.image.DefaultIconSource getIcon
INFO: No image resource found for icon with key 'userGroupCommand.large.icon'; returning a icon.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userGroupCommand.foreground]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userGroupCommand.background]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userGroupCommand.caption]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userGroupCommand.description]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.image.DefaultIconSource getIcon
INFO: No image resource found for icon with key 'userGroupCommand.icon'; returning a icon.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.image.DefaultIconSource getIcon
INFO: No image resource found for icon with key 'userGroupCommand.large.icon'; returning a icon.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userManagementMenu.foreground]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userManagementMenu.background]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userManagementMenu.description]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.image.DefaultIconSource getIcon
INFO: No image resource found for icon with key 'userManagementMenu.icon'; returning a icon.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.image.DefaultIconSource getIcon
INFO: No image resource found for icon with key 'userManagementMenu.large.icon'; returning a icon.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.ApplicationLauncher displaySplashScreen
INFO: No splash screen bean found to display. Continuing...
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.support.DefaultApplicationServices$25 build
INFO: Creating default service impl: ApplicationWindowFactory
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.support.DefaultApplicationWindowFactory createApplicationWindow
INFO: Creating new DefaultApplicationWindow
Feb 24, 2016 9:21:13 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.richclient.application.config.DefaultApplicationLifecycleAdvisor$CommandBarApplicationContext#21cf5ed5: display name [org.springframework.richclient.application.config.DefaultApplicationLifecycleAdvisor$CommandBarApplicationContext#21cf5ed5]; startup date [Wed Feb 24 09:21:13 PST 2016]; parent: org.springframework.context.support.ClassPathXmlApplicationContext#45283ce2
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [ctx/commands.xml]
Feb 24, 2016 9:21:13 AM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
INFO: Bean factory for application context [org.springframework.richclient.application.config.DefaultApplicationLifecycleAdvisor$CommandBarApplicationContext#21cf5ed5]: org.springframework.beans.factory.support.DefaultListableBeanFactory#5853b97a
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#5853b97a: defining beans [menuBar,userManagementMenu,fd1,fd2,userCommand,userGroupCommand]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory#591f989e
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.support.DefaultApplicationServices$26 build
INFO: Creating default service impl: ApplicationPageFactory
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.support.DefaultApplicationPageFactory createApplicationPage
INFO: Creating new DefaultApplicationPage
Feb 24, 2016 9:21:13 AM org.springframework.richclient.core.LabeledObjectSupport getDisplayName
INFO: This labeled object's display name is not configured; returning 'displayName'
Feb 24, 2016 9:21:13 AM org.springframework.richclient.core.LabeledObjectSupport getDisplayName
INFO: This labeled object's display name is not configured; returning 'displayName'
Feb 24, 2016 9:21:14 AM org.springframework.richclient.application.support.DefaultApplicationServices$2 build
INFO: Creating default service impl: MenuFactory
Feb 24, 2016 9:21:14 AM org.springframework.richclient.application.support.DefaultApplicationServices$3 build
INFO: Creating default service impl: ButtonFactory
Feb 24, 2016 9:21:14 AM org.springframework.richclient.application.support.DefaultApplicationServices$5 build
INFO: Creating default service impl: ComponentFactory
Feb 24, 2016 9:21:14 AM org.springframework.richclient.application.support.DefaultApplicationServices$19 build
INFO: Creating default service impl: ViewDescriptorRegistry
Feb 24, 2016 9:21:14 AM org.springframework.richclient.application.support.DefaultApplicationServices$27 build
INFO: Creating default service impl: PageComponentPaneFactory
Feb 24, 2016 9:21:14 AM org.springframework.richclient.core.LabeledObjectSupport getDisplayName
INFO: This labeled object's display name is not configured; returning 'displayName'
Feb 24, 2016 9:33:19 AM org.springframework.context.support.AbstractApplicationContext doClose
INFO: Closing org.springframework.context.support.ClassPathXmlApplicationContext#45283ce2: display name [org.springframework.context.support.ClassPathXmlApplicationContext#45283ce2]; startup date [Wed Feb 24 09:21:13 PST 2016]; root of context hierarchy
Feb 24, 2016 9:33:19 AM org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#591f989e: defining beans [serviceLocator,applicationServices,applicationEventMulticaster,application,windowCommandManager,lifecycleAdvisor,applicationDescriptor,messageSource,menuBar,userManagementMenu,fd1,fd2,userCommand,userGroupCommand,baseModel,user,userGroup,userFilter,userGroupFilter,abstractFilterForm,userFilterForm,userGroupFilterForm,abstractDataEditor,userDataEditor,userGroupDataEditor,abstractForm,userForm,userGroupForm,abstractDataProvider,userDataProvider,userGroupDataProvider,userService,userGroupService,userView,userGroupView]; root of factory hierarchy
The label and text box are displayed, but there is no tool bar. Any idea why? Thanking you in anticipation.
package com.mycom.form;
import com.mycom.model.User;
import org.springframework.richclient.form.builder.FormLayoutFormBuilder;
public class UserForm extends AbstractForm{
public UserForm(String formId, User user) throws Exception{
super(formId, user);
}
protected void addComponents(FormLayoutFormBuilder builder){
super.addComponents(builder);
builder.addPropertyAndLabel("dateOfBirth");
builder.nextRow();
builder.addPropertyAndLabel("userGroup");
}
}
AbstractForm code:
package com.mycom.form;
import javax.swing.JComponent;
import com.jgoodies.forms.layout.FormLayout;
import com.mycom.model.BaseModel;
import org.springframework.binding.form.FieldMetadata;
import org.springframework.richclient.form.FormModelHelper;
import org.springframework.richclient.form.TabbedForm;
import org.springframework.richclient.form.builder.FormLayoutFormBuilder;
public class AbstractForm extends TabbedForm{
private String tabName;
public AbstractForm(String formId, BaseModel baseModel) throws Exception{
super(FormModelHelper.createFormModel(baseModel, formId));
}
protected Tab[] getTabs(){
FormLayout layout = new FormLayout("default, 3dlu, fill:pref:nogrow", "default");
FormLayoutFormBuilder builder = new FormLayoutFormBuilder(getBindingFactory(), layout);
addComponents(builder);
return new Tab[] {new Tab(getTabName(), builder.getPanel())};
}
protected void addComponents(FormLayoutFormBuilder builder){
builder.addPropertyAndLabel("id");
builder.nextRow();
JComponent nameComponent = builder.addPropertyAndLabel("name")[1];
builder.nextRow();
FieldMetadata idMetaData = getFormModel().getFieldMetadata("id");
idMetaData.setReadOnly(true);
setFocusControl(nameComponent);
}
protected String getTabName(){
return tabName;
}
public void setTabName(String tabName) {
this.tabName = tabName;
}
}
Form beans:
<bean name="abstractForm" scope="prototype" abstract = "true">
<property name= "tabName" value="Detail" />
</bean>
<bean name="userForm" scope="prototype" class="com.mycom.form.UserForm">
<constructor-arg index = "0" value="userForm" />
<constructor-arg index = "1" ref="user" />
<property name= "tabName" value="User Detail" />
</bean>

Related

web app startup warning:No MyBatis mapper was found in ... ,Please check your configuration

My configuration is:
spring-4.2.3
mybatis-3.3.0
mybatis-spring-1.2.3
mapper looks like:
package com.vsi.idp.map.server.mapper;
//imports...
public interface SeniorMapper extends BaseMapper<Long, Senior>
{
#Results({...})
#Select(...)
public List<Senior> query(...);
}
ServiceImpl looks like:
package com.vsi.idp.map.server;
//imports...
#Service("querySenior")
public class SeniorQueryServiceImpl extends RemoteServiceServlet implements SeniorQueryService
{
#Autowired
SeniorMapper mapper;
#Override
public List<Senior> query(Address address, String careType){...}
}
applicationContext.xml looks like:
<beans ... default-lazy-init="true">
<!-- MyBatis Mapper Interfaces -->
<mybatis:scan base-package="com.vsi.idp.map.server.mapper" />
//other configurations
</beans>
Spock unit test looks like below,and runs as expected
#ContextConfiguration(locations = "file:war/WEB-INF/applicationContext.xml")
public class SeniorQueryServiceImplTest extends Specification{
#Autowired
SeniorQueryServiceImpl service
def "query by full address"(){
//blabla
}
}
But when start web application,I got this warning:
WARNING: No MyBatis mapper was found in '[com.vsi.idp.map.server.mapper]' package. Please check your configuration.
So,how to solve this problem?
UPDATEit is a gwt web application,full error stack is:
INFO: Root WebApplicationContext: initialization started Nov 23, 2015 7:12:29 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFO: Refreshing Root WebApplicationContext: startup date [Mon Nov 23 19:12:29 CST 2015]; root of context hierarchy Nov 23, 2015 7:12:29 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml] Nov 23, 2015 7:12:29 PM org.mybatis.spring.mapper.ClassPathMapperScanner doScan
WARNING: No MyBatis mapper was found in '[com.vsi.idp.map.server.mapper]' package. Please check your configuration.Nov 23, 2015 7:12:30 PM org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor <init>
INFO: JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
Module setup completed in 1698 ms
Nov 23, 2015 7:12:30 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization completed in 1557 ms
#MapperScan(basePackages = "com.vsi.idp.map.server.mapper")
you can try add it!
Have you defined MapperScannerConfigurer in applicationContext.xml? If so, please delete it.
I have the following config in my applicationContext.xml, and when I deleted it, the warning has gone.
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.james.reg.mapper" />
<property name="sqlSessionFactory" ref="sqlSessionFactory" />
</bean>

Creating PrimeFaces metergauge chart without #PostConstruct annotation

I need to retrieve data from spring jpa data to an managed bean class, which creates an MeterGaugeChartView. When I call the values from injected Spring bean within an #PostConstruct method I get java.lang.NullPonterException. When I remove the annotation, then I get the error below.
java.lang.NullPointerException
org.primefaces.component.chart.renderer.MeterGaugeRenderer.encodeData(MeterGaugeRenderer.java:33)
Below is my code and the full stack...
package ch.business.quickline.controller;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import org.primefaces.model.chart.MeterGaugeChartModel;
import org.springframework.stereotype.Component;
import ch.business.quickline.viewservice.MitarbeiterGlobalService;
#ManagedBean
#Component
#ViewScoped
public class MeterGaugeChartView implements Serializable {
private MeterGaugeChartModel masterBewertungenIndividual;
private MeterGaugeChartModel selbstBewertungenIndividual;
private MeterGaugeChartModel masterBewertungenGlobal;
private MeterGaugeChartModel selbstBewertungenGlobal;
#ManagedProperty("#{mitarbeiterGlobalService}")
private MitarbeiterGlobalService mitarbeiterGlobalService;
public void init() {
createMeterGaugeModels();
}
public MeterGaugeChartModel getMasterBewertungenIndividual() {
return masterBewertungenIndividual;
}
public MeterGaugeChartModel getSelbstBewertungenIndividual() {
return selbstBewertungenIndividual;
}
public MeterGaugeChartModel getMasterBewertungenGlobal() {
return masterBewertungenGlobal;
}
public MeterGaugeChartModel getSelbstBewertungenGlobal() {
return selbstBewertungenGlobal;
}
private MeterGaugeChartModel initMeterGaugeModel() {
List<Number> intervals = new ArrayList<Number>() {{
add(1);
add(2);
add(3);
add(4);
add(5);
}
};
return new MeterGaugeChartModel(5, intervals);
}
public void createMeterGaugeModels() {
masterBewertungenIndividual = initMeterGaugeModel();
//masterBewertungenIndividual.setTitle("Masterbewertungen");
masterBewertungenIndividual.setGaugeLabel("Skill");
masterBewertungenIndividual.setValue(mitarbeiterGlobalService.getMasterBewertungIndividualAverage());
selbstBewertungenIndividual = initMeterGaugeModel();
//selbstBewertungenIndividual.setTitle("Selbstbewertungen");
selbstBewertungenIndividual.setGaugeLabel("Interesse");
selbstBewertungenIndividual.setValue(mitarbeiterGlobalService.getSelbstBewertungIndividualAverage());
masterBewertungenGlobal = initMeterGaugeModel();
//masterBewertungenGlobal.setTitle("Masterbewertungen");
masterBewertungenGlobal.setGaugeLabel("Skill");
masterBewertungenGlobal.setValue(mitarbeiterGlobalService.getMasterBewertungGlobalAverage());
selbstBewertungenGlobal = initMeterGaugeModel();
//selbstBewertungenGlobal.setTitle("Selbstbewertungen");
selbstBewertungenGlobal.setGaugeLabel("Interesse");
selbstBewertungenGlobal.setValue(mitarbeiterGlobalService.getSelbstBewertungGlobalAverage());
}
}
package ch.business.quickline.viewservice;
import java.math.BigDecimal;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ch.business.quickline.domain.MitarbeiterSkill;
import ch.business.quickline.service.MitarbeiterService;
import ch.business.quickline.service.MitarbeiterSkillService;
#ManagedBean(name = "mitarbeiterGlobalService")
#Component
#ApplicationScoped
public class MitarbeiterGlobalService {
#Autowired
private MitarbeiterService mitarbeiterService;
#Autowired
private MitarbeiterSkillService mitarbeiterSkillService;
private BigDecimal masterBewertungIndividualAverage;
private BigDecimal selbstBewertungIndividualAverage;
private Double masterBewertungGlobalAverage;
private Double selbstBewertungGlobalAverage;
public void init() {
masterBewertungIndividualAverage = mitarbeiterService.findByMitarbeiterId(1).getMitarbeiterMasterBewertungDurchschnitt();
selbstBewertungIndividualAverage = mitarbeiterService.findByMitarbeiterId(1).getMitarbeiterSelbstBewertungDurchschnitt();
masterBewertungGlobalAverage = retrieveMasterBewertungGlobalAverage();
selbstBewertungGlobalAverage = retrieveSelbstBewertungGlobalAverage();
}
public BigDecimal getMasterBewertungIndividualAverage() {
return masterBewertungIndividualAverage;
}
public void setMasterBewertungIndividualAverage(BigDecimal masterBewertungIndividualAverage) {
this.masterBewertungIndividualAverage = masterBewertungIndividualAverage;
}
public BigDecimal getSelbstBewertungIndividualAverage() {
return selbstBewertungIndividualAverage;
}
public void setSelbstBewertungIndividualAverage(
BigDecimal selbstBewertungIndividualAverage) {
this.selbstBewertungIndividualAverage = selbstBewertungIndividualAverage;
}
public Double getMasterBewertungGlobalAverage() {
return masterBewertungGlobalAverage;
}
public void setMasterBewertungGlobalAverage(Double masterBewertungGlobalAverage) {
this.masterBewertungGlobalAverage = masterBewertungGlobalAverage;
}
public Double getSelbstBewertungGlobalAverage() {
return selbstBewertungGlobalAverage;
}
public void setSelbstBewertungGlobalAverage(Double selbstBewertungGlobalAverage) {
this.selbstBewertungGlobalAverage = selbstBewertungGlobalAverage;
}
public Double retrieveMasterBewertungGlobalAverage() {
Double sum = 0.0;
for (MitarbeiterSkill skill : mitarbeiterSkillService.findAll()) {
sum = sum + skill.getMasterBewertung();
}
return sum / mitarbeiterSkillService.findAll().size();
}
public Double retrieveSelbstBewertungGlobalAverage() {
Double sum = 0.0;
for (MitarbeiterSkill interest : mitarbeiterSkillService.findAll()) {
sum = sum + interest.getSelbstBewertung();
}
return sum / mitarbeiterSkillService.findAll().size();
}
}
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<ui:composition template="/templates/default/template.xhtml">
<ui:define name="content">
<ui:insert>
<div class="ui-grid">
<div class="ui-grid-row">
<div class="ui-grid-col-6">
<p:chart type="metergauge" model="#{meterGaugeChartView.masterBewertungenGlobal}" style="width:400px;height:250px" />
</div>
<div class="ui-grid-col-6">
<p:chart type="metergauge" model="#{meterGaugeChartView.selbstBewertungenGlobal}" style="width:400px;height:250px" />
</div>
</div>
</div>
<div class="ui-grid ui-grid-responsive">
<div class="ui-grid-row">
<div class="ui-grid-col-6">
<p:dataList value="#{rankingDataList.mitarbeiterMasterBewertungRangliste}" var="mitarbeiter" type="ordered">
<f:facet name="header">
Top Mitarbeiter nach Masterbewertung
</f:facet>
#{mitarbeiter.mitarbeiterVorname}
#{mitarbeiter.mitarbeiterNachname}:
#{mitarbeiter.mitarbeiterMasterBewertungDurchschnitt}
</p:dataList>
</div>
<div class="ui-grid-col-6">
<p:dataList value="#{rankingDataList.mitarbeiterSelbstBewertungRangliste}" var="mitarbeiter" type="ordered">
<f:facet name="header">
Top Mitarbeiter nach Selbstbewertung
</f:facet>
#{mitarbeiter.mitarbeiterVorname}
#{mitarbeiter.mitarbeiterNachname}:
#{mitarbeiter.mitarbeiterSelbstBewertungDurchschnitt}
</p:dataList>
</div>
</div>
</div>
</ui:insert>
</ui:define>
</ui:composition>
</html>
Apr 25, 2015 12:10:21 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNUNG: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:skillmanager' did not find a matching property.
Apr 25, 2015 12:10:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Server version: Apache Tomcat/7.0.59
Apr 25, 2015 12:10:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Server built: Jan 28 2015 15:51:10 UTC
Apr 25, 2015 12:10:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Server number: 7.0.59.0
Apr 25, 2015 12:10:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: OS Name: Linux
Apr 25, 2015 12:10:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: OS Version: 3.13.0-24-generic
Apr 25, 2015 12:10:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Architecture: amd64
Apr 25, 2015 12:10:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Java Home: /usr/lib/jvm/java-8-oracle/jre
Apr 25, 2015 12:10:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: JVM Version: 1.8.0_40-b25
Apr 25, 2015 12:10:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: JVM Vendor: Oracle Corporation
Apr 25, 2015 12:10:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: CATALINA_BASE: /home/fanatik/Documents/workspace-sts-3.6.3.SR1/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
Apr 25, 2015 12:10:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: CATALINA_HOME: /home/fanatik/apache-tomcat-7.0.59
Apr 25, 2015 12:10:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Command line argument: -Dcatalina.base=/home/fanatik/Documents/workspace-sts-3.6.3.SR1/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
Apr 25, 2015 12:10:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Command line argument: -Dcatalina.home=/home/fanatik/apache-tomcat-7.0.59
Apr 25, 2015 12:10:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Command line argument: -Dwtp.deploy=/home/fanatik/Documents/workspace-sts-3.6.3.SR1/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps
Apr 25, 2015 12:10:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Command line argument: -Djava.endorsed.dirs=/home/fanatik/apache-tomcat-7.0.59/endorsed
Apr 25, 2015 12:10:21 AM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Command line argument: -Dfile.encoding=UTF-8
Apr 25, 2015 12:10:21 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFORMATION: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
Apr 25, 2015 12:10:21 AM org.apache.coyote.AbstractProtocol init
INFORMATION: Initializing ProtocolHandler ["http-bio-8080"]
Apr 25, 2015 12:10:21 AM org.apache.coyote.AbstractProtocol init
INFORMATION: Initializing ProtocolHandler ["ajp-bio-8009"]
Apr 25, 2015 12:10:21 AM org.apache.catalina.startup.Catalina load
INFORMATION: Initialization processed in 706 ms
Apr 25, 2015 12:10:21 AM org.apache.catalina.core.StandardService startInternal
INFORMATION: Starting service Catalina
Apr 25, 2015 12:10:21 AM org.apache.catalina.core.StandardEngine startInternal
INFORMATION: Starting Servlet Engine: Apache Tomcat/7.0.59
Apr 25, 2015 12:10:22 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFORMATION: validateJarFile(/home/fanatik/Documents/workspace-sts-3.6.3.SR1/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/skillmanager/WEB-INF/lib/el-api-2.2.1-b04.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/el/Expression.class
Apr 25, 2015 12:10:25 AM org.apache.catalina.startup.TaglibUriRule body
INFORMATION: TLD skipped. URI: http://mojarra.dev.java.net/mojarra_ext is already defined
Apr 25, 2015 12:10:25 AM org.apache.catalina.startup.TaglibUriRule body
INFORMATION: TLD skipped. URI: http://java.sun.com/jsf/core is already defined
Apr 25, 2015 12:10:25 AM org.apache.catalina.startup.TaglibUriRule body
INFORMATION: TLD skipped. URI:
http://java.sun.com/jsf/html
is already defined
Apr 25, 2015 12:10:25 AM org.apache.catalina.core.StandardContext addApplicationListener
INFORMATION: The listener "com.sun.faces.config.ConfigureListener" is already configured for this context. The duplicate definition has been ignored.
Apr 25, 2015 12:10:25 AM org.apache.catalina.core.ApplicationContext log
INFORMATION: Spring WebApplicationInitializers detected on classpath: [ch.business.quickline.config.WebAppInitializer#12297d72]
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/fanatik/Documents/workspace-sts-3.6.3.SR1/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/skillmanager/WEB-INF/lib/slf4j-log4j12-1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/fanatik/Documents/workspace-sts-3.6.3.SR1/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/skillmanager/WEB-INF/lib/slf4j-simple-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
Apr 25, 2015 12:10:25 AM com.sun.faces.config.ConfigureListener contextInitialized
INFORMATION: Mojarra 2.2.0 ( 20130502-2118 https://svn.java.net/svn/mojarra~svn/tags/2.2.0#11930) für Kontext '/skillmanager' wird initialisiert.
Apr 25, 2015 12:10:25 AM com.sun.faces.spi.InjectionProviderFactory createInstance
INFORMATION: JSF1048: PostConstruct/PreDestroy-Annotationen vorhanden. Verwaltete Bean-Methoden, die mit diesen Annotationen markiert sind, lassen die entsprechenden Annotationen verarbeiten.
Apr 25, 2015 12:10:26 AM net.bootsfaces.listeners.AddResourcesListener <clinit>
INFORMATION: net.bootsfaces.listeners.AddResourcesListener ready for use.
Apr 25, 2015 12:10:27 AM org.primefaces.webapp.PostConstructApplicationEventListener processEvent
INFORMATION: Running on PrimeFaces 5.1
Apr 25, 2015 12:10:27 AM org.apache.catalina.core.ApplicationContext log
INFORMATION: Initializing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Apr 25, 2015 12:10:31 AM org.apache.coyote.AbstractProtocol start
INFORMATION: Starting ProtocolHandler ["http-bio-8080"]
Apr 25, 2015 12:10:31 AM org.apache.coyote.AbstractProtocol start
INFORMATION: Starting ProtocolHandler ["ajp-bio-8009"]
Apr 25, 2015 12:10:31 AM org.apache.catalina.startup.Catalina start
INFORMATION: Server startup in 9849 ms
Apr 25, 2015 12:10:34 AM com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
SCHWERWIEGEND: Error Rendering View[/index.xhtml]
java.lang.NullPointerException
at org.primefaces.component.chart.renderer.MeterGaugeRenderer.encodeData(MeterGaugeRenderer.java:33)
at org.primefaces.component.chart.renderer.BasePlotRenderer.render(BasePlotRenderer.java:29)
at org.primefaces.component.chart.ChartRenderer.encodeScript(ChartRenderer.java:95)
at org.primefaces.component.chart.ChartRenderer.encodeEnd(ChartRenderer.java:67)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:924)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:894)
at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:79)
at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:66)
at org.primefaces.component.layout.LayoutUnitRenderer.encodeEnd(LayoutUnitRenderer.java:49)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:924)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:443)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Apr 25, 2015 12:10:34 AM org.apache.catalina.core.StandardWrapperValve invoke
SCHWERWIEGEND: Servlet.service() for servlet [Faces Servlet] in context with path [/skillmanager] threw exception [null] with root cause
java.lang.NullPointerException
at org.primefaces.component.chart.renderer.MeterGaugeRenderer.encodeData(MeterGaugeRenderer.java:33)
at org.primefaces.component.chart.renderer.BasePlotRenderer.render(BasePlotRenderer.java:29)
at org.primefaces.component.chart.ChartRenderer.encodeScript(ChartRenderer.java:95)
at org.primefaces.component.chart.ChartRenderer.encodeEnd(ChartRenderer.java:67)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:924)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:894)
at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:79)
at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:66)
at org.primefaces.component.layout.LayoutUnitRenderer.encodeEnd(LayoutUnitRenderer.java:49)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:924)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:443)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)

Issues with Oracle JDBC with Hibernate... Sometimes

I'm having a bit of a unique issue.
I'm able to successfully connect and manage entities when running JUnit tests, but once I start my actual application, I get "Specified JDBC Driver oracle.jdbc.OracleDriver class not found."
What confuses me is that it is there. It works when running my JUnit Tests.
Any insights are appreciated!
hibernate.cfg.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="db">
<property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:#host:port/db</property>
<property name="hibernate.connection.username">username</property>
<property name="hibernate.connection.password">password</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.default_schema">db</property>
<property name="show_sql">true</property>
<mapping resource="org/entity/RunResultEntity.hbm.xml"/>
<mapping resource="org/entity/TransactionResultEntity.hbm.xml"/>
<mapping resource="org/entity/FailureResultEntity.hbm.xml"/>
</session-factory>
</hibernate-configuration>
HibernateUtil.java
package org.util;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.*;
public class HibernateUtil {
private static SessionFactory sessionFactory = buildSessionFactory();
private static SessionFactory buildSessionFactory() {
try {
// Create the SessionFactory from hibernate.cfg.xml
Configuration configuration = new Configuration();
configuration.configure();
ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(
configuration.getProperties()
).buildServiceRegistry();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
return sessionFactory;
} catch (Throwable ex) {
// Exception thrown here!
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
public static void shutdown() {
// Close caches and connection pools
getSessionFactory().close();
}
}
pom.xml (dependency added to local repository)
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3.0</version>
<scope>provided</scope>
</dependency>
log
Oct 09, 2014 3:02:58 PM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
Oct 09, 2014 3:02:58 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.0.1.Final}
Oct 09, 2014 3:02:58 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Oct 09, 2014 3:02:58 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Oct 09, 2014 3:02:58 PM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
Oct 09, 2014 3:02:58 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
Oct 09, 2014 3:02:58 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: org/entity/RunResultEntity.hbm.xml
Oct 09, 2014 3:02:59 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: org/entity/TransactionResultEntity.hbm.xml
Oct 09, 2014 3:02:59 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: org/entity/FailureResultEntity.hbm.xml
Oct 09, 2014 3:02:59 PM org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: db
Oct 09, 2014 3:02:59 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!)
Initial SessionFactory creation failed.org.hibernate.HibernateException: Specified JDBC Driver oracle.jdbc.OracleDriver class not found
Exception in thread "main" java.lang.ExceptionInInitializerError
I found my problem. Lower in my pom.xml I had this little snippet
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>4.0.1.Final</version>
<classifier>tests</classifier>
</dependency>
The classifier was only giving access to my test suite. Removing the classifier fixed the issue.
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>4.0.1.Final</version>
</dependency>

WARNING: No mapping found for HTTP request with URI [/CustomerDetails/] in DispatcherServlet with name 'customerdispatcher' [duplicate]

This question already has answers here:
Why does Spring MVC respond with a 404 and report "No mapping found for HTTP request with URI [...] in DispatcherServlet"?
(13 answers)
Closed 6 years ago.
I had a issue in spring3 frameowrk.org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/CustomerDetails/] in DispatcherServlet with name 'customerdispatcher'
Please see the following
Jun 01, 2014 11:16:27 AM 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\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\PC Connectivity Solution\;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Sony\VAIO Improvement\;C:\Program Files (x86)\Sony\VAIO Startup Setting Tool;C:\Program Files\MySQL\MySQL Server 5.1\bin;;.
Jun 01, 2014 11:16:28 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:CustomerDetails' did not find a matching property.
Jun 01, 2014 11:16:28 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jun 01, 2014 11:16:28 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jun 01, 2014 11:16:28 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1635 ms
Jun 01, 2014 11:16:28 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jun 01, 2014 11:16:28 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.50
Jun 01, 2014 11:16:30 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\Users\Smileanbu\Documents\Spring_JDBC\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\CustomerDetails\WEB-INF\lib\servlet-api.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core_rt is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt_rt is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/functions is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/permittedTaglibs is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/scriptfree is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql_rt is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/sql is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml_rt is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/xml is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Jun 01, 2014 11:16:33 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'customerdispatcher'
Jun 01, 2014 11:16:33 AM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'customerdispatcher': initialization started
Jun 01, 2014 11:16:33 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'customerdispatcher-servlet': startup date [Sun Jun 01 11:16:33 IST 2014]; root of context hierarchy
Jun 01, 2014 11:16:34 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/customerdispatcher-servlet.xml]
Jun 01, 2014 11:16:34 AM org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider registerDefaultFilters
INFO: JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
Jun 01, 2014 11:16:35 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#19705d39: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,viewResolver,dataSource,sessionFactory,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,transactionManager,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy
300 [localhost-startStop-1] INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.2.0.Final
312 [localhost-startStop-1] INFO org.hibernate.cfg.Environment - Hibernate 3.6.10.Final
315 [localhost-startStop-1] INFO org.hibernate.cfg.Environment - hibernate.properties not found
321 [localhost-startStop-1] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
327 [localhost-startStop-1] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
479 [localhost-startStop-1] INFO org.hibernate.cfg.Configuration - configuring from url: file:/C:/Users/Smileanbu/Documents/Spring_JDBC/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/CustomerDetails/WEB-INF/classes/hibernate.cfg.xml
538 [localhost-startStop-1] WARN org.hibernate.util.DTDEntityResolver - recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
594 [localhost-startStop-1] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
688 [localhost-startStop-1] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: com.springforbeginners.model.Customer
778 [localhost-startStop-1] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity com.springforbeginners.model.Customer on table CUSTOMER
900 [localhost-startStop-1] INFO org.hibernate.cfg.Configuration - Hibernate Validator not found: ignoring
Jun 01, 2014 11:16:36 AM org.springframework.orm.hibernate3.LocalSessionFactoryBean buildSessionFactory
INFO: Building new Hibernate SessionFactory
919 [localhost-startStop-1] INFO org.hibernate.cfg.search.HibernateSearchEventListenerRegister - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
929 [localhost-startStop-1] INFO org.hibernate.connection.ConnectionProviderFactory - Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider
1606 [localhost-startStop-1] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQLDialect
1641 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Database ->
name : MySQL
version : 5.1.73-community
major : 5
minor : 1
1641 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Driver ->
name : MySQL-AB JDBC Driver
version : mysql-connector-java-5.1.14 ( Revision: ${bzr.revision-id} )
major : 5
minor : 1
1644 [localhost-startStop-1] INFO org.hibernate.transaction.TransactionFactoryFactory - Transaction strategy: org.springframework.orm.hibernate3.SpringTransactionFactory
1648 [localhost-startStop-1] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
1648 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
1648 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
1649 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
1649 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
1651 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
1651 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled
1651 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto
1653 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Maximum outer join fetch depth: 2
1654 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
1654 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
1654 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
1654 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
1654 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
1661 [localhost-startStop-1] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
1661 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
1661 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: disabled
1663 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
1663 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
1663 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
1681 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
1681 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
1699 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout
1701 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled
1702 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
1702 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
1702 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Named query checking : enabled
1702 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Check Nullability in Core (should be disabled when Bean Validation is on): enabled
1751 [localhost-startStop-1] INFO org.hibernate.impl.SessionFactoryImpl - building session factory
1788 [localhost-startStop-1] INFO org.hibernate.type.BasicTypeRegistry - Type registration [characters_clob] overrides previous : org.hibernate.type.PrimitiveCharacterArrayClobType#236f7565
1788 [localhost-startStop-1] INFO org.hibernate.type.BasicTypeRegistry - Type registration [clob] overrides previous : org.hibernate.type.ClobType#6a844c0f
1788 [localhost-startStop-1] INFO org.hibernate.type.BasicTypeRegistry - Type registration [java.sql.Clob] overrides previous : org.hibernate.type.ClobType#6a844c0f
1788 [localhost-startStop-1] INFO org.hibernate.type.BasicTypeRegistry - Type registration [wrapper_characters_clob] overrides previous : org.hibernate.type.CharacterArrayClobType#139da36b
1788 [localhost-startStop-1] INFO org.hibernate.type.BasicTypeRegistry - Type registration [materialized_clob] overrides previous : org.hibernate.type.MaterializedClobType#5253cfdc
1788 [localhost-startStop-1] INFO org.hibernate.type.BasicTypeRegistry - Type registration [materialized_blob] overrides previous : org.hibernate.type.MaterializedBlobType#7c739ebd
1788 [localhost-startStop-1] INFO org.hibernate.type.BasicTypeRegistry - Type registration [wrapper_materialized_blob] overrides previous : org.hibernate.type.WrappedMaterializedBlobType#abaca20
1789 [localhost-startStop-1] INFO org.hibernate.type.BasicTypeRegistry - Type registration [blob] overrides previous : org.hibernate.type.BlobType#6d2c0060
1789 [localhost-startStop-1] INFO org.hibernate.type.BasicTypeRegistry - Type registration [java.sql.Blob] overrides previous : org.hibernate.type.BlobType#6d2c0060
2313 [localhost-startStop-1] INFO org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
Jun 01, 2014 11:16:38 AM org.springframework.orm.hibernate3.HibernateTransactionManager afterPropertiesSet
INFO: Using DataSource [org.apache.commons.dbcp.BasicDataSource#1c53ccd6] of Hibernate SessionFactory for HibernateTransactionManager
Jun 01, 2014 11:16:38 AM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'customerdispatcher': initialization completed in 4758 ms
Jun 01, 2014 11:16:38 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jun 01, 2014 11:16:38 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jun 01, 2014 11:16:38 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 10104 ms
Jun 01, 2014 11:16:40 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/CustomerDetails/] in DispatcherServlet with name 'customerdispatcher'
customerdispatcher-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
<context:annotation-config />
<context:component-scan base-package="com.springforbeginners.controller.CustomerController" />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/customerdb"/>
<property name="username" value="root"/>
<property name="password" value="123456"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
<property name="configurationClass">
<value>org.hibernate.cfg.AnnotationConfiguration</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<tx:annotation-driven />
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
</beans>
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<servlet>
<servlet-name>customerdispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>customerdispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/index</welcome-file>
</welcome-file-list>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</web-app>
CustomerController class
package com.springforbeginners.controller;
import com.springforbeginners.model.Customer;
import com.springforbeginners.service.CustomerService;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
#Controller
public class CustomerController {
#Autowired
private CustomerService customerService;
#RequestMapping("/index")
public String listCustomers(Map<String, Object> map) {
map.put("customer", new Customer());
map.put("customerList", customerService.listCustomer());
return "customer";
}
#RequestMapping(value = "/add", method = RequestMethod.POST)
public String addCustomer(#ModelAttribute("customer") Customer customer, BindingResult result) {
customerService.addCustomer(customer);
return "redirect:/index";
}
#RequestMapping("/delete/{customerId}")
public String deleteCustomer(#PathVariable("customerId") Integer customerId) {
customerService.removeCustomer(customerId);
return "redirect:/index";
}
}
I am not able to get my customer.jsp page it is present in my WEB_INF/jsp/customer.jsp.Please help me from this error No matching Http request for URL
WARNING: No mapping found for HTTP request with URI [/CustomerDetails/] in DispatcherServlet with name 'customerdispatcher'
In your controller or your web.xml, there's nothing that maps yor URI to CustomerDetails. You should either change
<url-pattern>/</url-pattern> to <url-pattern>/CustomerDetails</url-pattern>
or add this in your controller
#Controller
#RequestMapping(value = "CustomerDetails")
public class CustomerController {
...
}
And then you can call the url by:
Context/CustomerDetails/index
And by the way, in your <welcome-file-list>, if you are trying to call the servlet on initializing, it won't work, the <welcome-file> has to be a "file".

How to configure Hazelcast for session caching using spring while limiting it to a set of nodes?

I need to set up Hazelcast session caching using Spring. Using the configuration from the hazelcast docs is simple. However, its insufficient. I need to use a different configuration file for each one of my environments (DEV, QA, PROD). Alternatively (Ideally), I would like to use several properties from a spring bean that would be set during the initialization of the spring container. According to the hazelcast documentation, all I need to do set a group for each of my environments. like so:
<hazelcast>
<group>
<name>dev</name>
<password>dev-pass</password>
</group>
...
</hazelcast>
As a bonus, I would like the cache to be a single cache used for both sessions and application level objects (Maps, Queues, etc).
Could anyone share an example on how they would do this? Thank you for your help.
Thank you for the suggested answer. However, I think I've solved this using the following configuration. I would appreciate any feedback from anyone about this configuration.
My approach:
1) Establish the instance with a spring configuration.
2) Enhance the instance with a minimally configured hazelcast.xml file with the Web filter configuration. Note that mulitcast and tcp-ip joiners are false.
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/servlet-context.xml,
/WEB-INF/spring/root-context.xml,
....
/WEB-INF/spring/hazelcastContext.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
....
<filter>
<filter-name>hazelcast-filter</filter-name>
<filter-class>com.hazelcast.web.WebFilter</filter-class>
<!--
Name of the distributed map storing
your web session objects
-->
<init-param>
<param-name>map-name</param-name>
<param-value>my-sessions</param-value>
</init-param>
<!--
How is your load-balancer configured?
stick-session means all requests of a session
is routed to the node where the session is first created.
This is excellent for performance.
If sticky-session is set to false, when a session is updated
on a node, entry for this session on all other nodes is invalidated.
You have to know how your load-balancer is configured before
setting this parameter. Default is true.
-->
<init-param>
<param-name>sticky-session</param-name>
<param-value>true</param-value>
</init-param>
<!--
Name of session id cookie
-->
<init-param>
<param-name>cookie-name</param-name>
<param-value>hazelcast.sessionId</param-value>
</init-param>
<!--
Domain of session id cookie. Default is based on incoming request.
-->
<init-param>
<param-name>cookie-domain</param-name>
<param-value>.mycompany.com</param-value>
</init-param>
<!--
Should cookie only be sent using a secure protocol? Default is false.
-->
<init-param>
<param-name>cookie-secure</param-name>
<param-value>false</param-value>
</init-param>
<!--
Should HttpOnly attribute be set on cookie ? Default is false.
-->
<init-param>
<param-name>cookie-http-only</param-name>
<param-value>false</param-value>
</init-param>
<!--
Are you debugging? Default is false.
-->
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<!--
Configuration xml location;
* as servlet resource OR
* as classpath resource OR
* as URL
Default is one of hazelcast-default.xml
or hazelcast.xml in classpath.
-->
<init-param>
<param-name>config-location</param-name>
<param-value>/WEB-INF/classes/hazelcast.xml</param-value>
</init-param>
<!--
Do you want to use an existing HazelcastInstance?
Default is null.
-->`enter code here`
<init-param>
<param-name>instance-name</param-name>
<param-value>myapp</param-value>
</init-param>
<!--
Do you want to connect as a client to an existing cluster?
Default is false.
-->
<init-param>
<param-name>use-client</param-name>
<param-value>false</param-value>
</init-param>
<!--
Client configuration location;
* as servlet resource OR
* as classpath resource OR
* as URL
Default is null.
-->
<init-param>
<param-name>client-config-location</param-name>
<param-value>/WEB-INF/classes/hazelcast-client.properties</param-value>
</init-param>
<!--
Do you want to shutdown HazelcastInstance during
web application undeploy process?
Default is true.
-->
<init-param>
<param-name>shutdown-on-destroy</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>hazelcast-filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
...
</web-app>
hazelcast.xml (copied from hazelcast.xml inside jar file)...
<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-2.4.xsd"
xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
...
<network>
<port auto-increment="true">5701</port>
<outbound-ports>
<!--
Allowed port range when connecting to other nodes.
0 or * means use system provided port.
-->
<ports>0</ports>
</outbound-ports>
<join>
<multicast enabled="false">
<multicast-group>224.2.2.3</multicast-group>
<multicast-port>54327</multicast-port>
</multicast>
<tcp-ip enabled="false">
<interface>127.0.0.1</interface>
</tcp-ip>
...
</join>
...
</network>
...
</hazelcast>
Spring config....
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:hz="http://www.hazelcast.com/schema/spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.hazelcast.com/schema/spring
http://www.hazelcast.com/schema/spring/hazelcast-spring-2.4.xsd">
<bean id="hazelcast" class="com.hazelcast.core.Hazelcast" />
<!-- Hazelcast Instance configuration -->
<hz:hazelcast id="myapp">
<hz:config>
<!-- Hazelcast Instance Name -->
<hz:instance-name>${hz.instance.name}</hz:instance-name>
<!-- Hazelcast Group Name and Password -->
<hz:group name="${hz.group.name}" password="${hz.group.password}" />
<!-- Hazelcast Management Center URL -->
<hz:management-center enabled="${hz.management.center.enabled}" url="${hz.management.center.url}" />
<!-- Hazelcast Tcp based network configuration -->
<hz:network port="${hz.network.port}" port-auto-increment="${hz.network.port.auto.increment}">
<hz:join>
<hz:multicast enabled="${hz.multicast.enabled}" multicast-group="224.2.2.3" multicast-port="54327" />
<hz:tcp-ip enabled="${hz.tcp.ip.enabled}">
<hz:members>${hz.members}</hz:members>
</hz:tcp-ip>
</hz:join>
</hz:network>
<!-- Hazelcast Distributed Map configuration -->
<hz:map name="map" backup-count="${hz.map.backup.count}" max-size="${hz.map.max.size}" eviction-percentage="${hz.map.eviction.percentage}"
read-backup-data="${hz.map.read.backup.data}" eviction-policy="${hz.map.eviction.policy}" merge-policy="${hz.map.merge.policy}" />
</hz:config>
</hz:hazelcast>
Property file....
#-- Hazelcast properties.
hz.instance.name = myapp
hz.group.name = CERT
hz.group.password = cert
hz.management.center.enabled = true
hz.management.center.url = http://127.0.0.1:8080/mancenter
hz.network.port = 5701
hz.network.port.auto.increment = true
hz.multicast.enabled = true
hz.tcp.ip.enabled = false
hz.members = 127.0.0.1
hz.executor.service.core.pool.size = 2
hz.executor.service.max.pool.size = 30
hz.executor.service.keep.alive.seconds = 30
hz.map.backup.count=2
hz.map.max.size=0
hz.map.eviction.percentage=30
hz.map.read.backup.data=true
hz.map.cache.value=true
hz.map.eviction.policy=NONE
hz.map.merge.policy=hz.ADD_NEW_ENTRY
Root Context.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:hz="http://www.hazelcast.com/schema/spring"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
http://www.hazelcast.com/schema/spring
http://www.hazelcast.com/schema/spring/hazelcast-spring-2.4.xsd">
...
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<jee:jndi-lookup jndi-name="java:comp/env/config_file" />
</list>
</property>
</bean>
...
</beans>
Tomcat Config...
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
...
<Context docBase="myapp" path="/myapp" reloadable="true" source="org.eclipse.jst.j2ee.server:pwc-ws">
<Environment description="" name="config_file" override="false" type="java.lang.String" value="file:c:/path/to/config/myapp.properties" />
</Context>
...
</Host>
Tomcat output (Note: This is a restart scenario of a two node hazelcast group. In this scenario, Node 1 is restarted. The output of Node 2 shows the drop of node 1 from the group and then its return to the group).
Node 1 of Group CERT
Nov 19, 2013 4:27:56 PM com.hazelcast.impl.AddressPicker
INFO: Prefer IPv4 stack is true.
Nov 19, 2013 4:27:56 PM com.hazelcast.impl.AddressPicker
INFO: Picked Address[10.23.43.13]:5701, using socket ServerSocket[addr=/0:0:0:0:0:0:0:0,localport=5701], bind any local is true
Nov 19, 2013 4:27:57 PM com.hazelcast.system
INFO: [10.23.43.13]:5701 [CERT] Hazelcast Community Edition 2.4 (20121017) starting at Address[10.23.43.13]:5701
Nov 19, 2013 4:27:57 PM com.hazelcast.system
INFO: [10.23.43.13]:5701 [CERT] Copyright (C) 2008-2012 Hazelcast.com
Nov 19, 2013 4:27:57 PM com.hazelcast.impl.LifecycleServiceImpl
INFO: [10.23.43.13]:5701 [CERT] Address[10.23.43.13]:5701 is STARTING
Nov 19, 2013 4:27:57 PM com.hazelcast.impl.Node
INFO: [10.23.43.13]:5701 [CERT] ** setting master address to Address[10.23.43.14]:5701
Nov 19, 2013 4:27:57 PM com.hazelcast.impl.MulticastJoiner
INFO: [10.23.43.13]:5701 [CERT] Connecting to master node: Address[10.23.43.14]:5701
Nov 19, 2013 4:27:57 PM com.hazelcast.nio.ConnectionManager
INFO: [10.23.43.13]:5701 [CERT] 54106 accepted socket connection from /10.23.43.14:5701
Nov 19, 2013 4:27:57 PM com.hazelcast.impl.Node
INFO: [10.23.43.13]:5701 [CERT] ** setting master address to Address[10.23.43.14]:5701
Nov 19, 2013 4:27:57 PM com.hazelcast.impl.Node
INFO: [10.23.43.13]:5701 [CERT] ** setting master address to Address[10.23.43.14]:5701
Nov 19, 2013 4:27:58 PM com.hazelcast.impl.Node
INFO: [10.23.43.13]:5701 [CERT] ** setting master address to Address[10.23.43.14]:5701
Nov 19, 2013 4:27:58 PM com.hazelcast.impl.Node
INFO: [10.23.43.13]:5701 [CERT] ** setting master address to Address[10.23.43.14]:5701
Nov 19, 2013 4:27:59 PM com.hazelcast.impl.Node
INFO: [10.23.43.13]:5701 [CERT] ** setting master address to Address[10.23.43.14]:5701
Nov 19, 2013 4:27:59 PM com.hazelcast.impl.Node
INFO: [10.23.43.13]:5701 [CERT] ** setting master address to Address[10.23.43.14]:5701
Nov 19, 2013 4:28:00 PM com.hazelcast.impl.Node
INFO: [10.23.43.13]:5701 [CERT] ** setting master address to Address[10.23.43.14]:5701
Nov 19, 2013 4:28:00 PM com.hazelcast.impl.Node
INFO: [10.23.43.13]:5701 [CERT] ** setting master address to Address[10.23.43.14]:5701
Nov 19, 2013 4:28:01 PM com.hazelcast.impl.Node
INFO: [10.23.43.13]:5701 [CERT] ** setting master address to Address[10.23.43.14]:5701
Nov 19, 2013 4:28:01 PM com.hazelcast.impl.Node
INFO: [10.23.43.13]:5701 [CERT] ** setting master address to Address[10.23.43.14]:5701
Nov 19, 2013 4:28:02 PM com.hazelcast.impl.Node
INFO: [10.23.43.13]:5701 [CERT] ** setting master address to Address[10.23.43.14]:5701
Nov 19, 2013 4:28:02 PM com.hazelcast.impl.Node
INFO: [10.23.43.13]:5701 [CERT] ** setting master address to Address[10.23.43.14]:5701
Nov 19, 2013 4:28:02 PM com.hazelcast.cluster.ClusterManager
INFO: [10.23.43.13]:5701 [CERT]
Members [2] {
Member [10.23.43.14]:5701
Member [10.23.43.13]:5701 this
}
Nov 19, 2013 4:28:04 PM com.hazelcast.impl.LifecycleServiceImpl
INFO: [10.23.43.13]:5701 [CERT] Address[10.23.43.13]:5701 is STARTED
Nov 19, 2013 4:28:04 PM com.hazelcast.impl.management.ManagementCenterService
INFO: [10.23.43.13]:5701 [CERT] Hazelcast will connect to Management Center on address: http://localhost:8080/mancenter/
Nov 19, 2013 4:28:04 PM com.hazelcast.config.UrlXmlConfig
INFO: Configuring Hazelcast from 'jndi:/localhost/pwc-ui/WEB-INF/classes/hazelcast.xml'.
Nov 19, 2013 4:28:04 PM com.hazelcast.web.WebFilter
INFO: sticky:true, debug: true, shutdown-on-destroy: true, map-name: my-sessions
Nov 19, 2013 4:28:05 PM org.apache.catalina.startup.HostConfig deployDescriptor
Node 2 of Group CERT (note the drop and re-add)
Nov 19, 2013 4:27:11 PM com.hazelcast.nio.Connection
INFO: [10.23.43.14]:5701 [CERT] Connection [Address[10.23.43.13]:5701] lost. Reason: java.io.IOException[Connection reset by peer]
Nov 19, 2013 4:27:11 PM com.hazelcast.nio.ReadHandler
WARNING: [10.23.43.14]:5701 [CERT] hz.pwc.IO.thread-1 Closing socket to endpoint Address[10.23.43.13]:5701, Cause:java.io.IOException: Connection reset by peer
Nov 19, 2013 4:27:12 PM com.hazelcast.nio.SocketConnector
INFO: [10.23.43.14]:5701 [CERT] Could not connect to: /10.23.43.13:5701. Reason: ConnectException[Connection refused]
Nov 19, 2013 4:27:13 PM com.hazelcast.nio.SocketConnector
INFO: [10.23.43.14]:5701 [CERT] Could not connect to: /10.23.43.13:5701. Reason: ConnectException[Connection refused]
Nov 19, 2013 4:27:14 PM com.hazelcast.nio.SocketConnector
INFO: [10.23.43.14]:5701 [CERT] Could not connect to: /10.23.43.13:5701. Reason: ConnectException[Connection refused]
Nov 19, 2013 4:27:14 PM com.hazelcast.nio.ConnectionMonitor
WARNING: [10.23.43.14]:5701 [CERT] Removing connection to endpoint Address[10.23.43.13]:5701 Cause => java.net.ConnectException {Connection refused}, Error-Count: 5
Nov 19, 2013 4:27:14 PM com.hazelcast.cluster.ClusterManager
INFO: [10.23.43.14]:5701 [CERT] Removing Address Address[10.23.43.13]:5701
Nov 19, 2013 4:27:14 PM com.hazelcast.impl.PartitionManager
INFO: [10.23.43.14]:5701 [CERT] Starting to send partition replica diffs...true
Nov 19, 2013 4:27:14 PM com.hazelcast.cluster.ClusterManager
INFO: [10.23.43.14]:5701 [CERT]
Members [1] {
Member [10.23.43.14]:5701 this
}
Nov 19, 2013 4:27:18 PM com.hazelcast.impl.PartitionManager
INFO: [10.23.43.14]:5701 [CERT] Total 0 partition replica diffs have been processed.
Nov 19, 2013 4:27:18 PM com.hazelcast.impl.PartitionManager
INFO: [10.23.43.14]:5701 [CERT] Re-partitioning cluster data... Immediate-Tasks: 0, Scheduled-Tasks: 0
Nov 19, 2013 4:27:57 PM com.hazelcast.nio.SocketAcceptor
INFO: [10.23.43.14]:5701 [CERT] 5701 is accepting socket connection from /10.23.43.13:54106
Nov 19, 2013 4:27:57 PM com.hazelcast.nio.ConnectionManager
INFO: [10.23.43.14]:5701 [CERT] 5701 accepted socket connection from /10.23.43.13:54106
Nov 19, 2013 4:27:57 PM com.hazelcast.web.WebFilter
INFO: Created new session with id: HZ650FDF62693F45A99AC0C30BBD8840B0
Nov 19, 2013 4:27:57 PM com.hazelcast.web.WebFilter
INFO: 195 is sessions.size and originalSessions.size: 195
Nov 19, 2013 4:27:57 PM com.hazelcast.web.WebFilter
INFO: PUTTING SESSION HZ650FDF62693F45A99AC0C30BBD8840B0
Nov 19, 2013 4:28:02 PM com.hazelcast.cluster.ClusterManager
INFO: [10.23.43.14]:5701 [CERT]
Members [2] {
Member [10.23.43.14]:5701 this
Member [10.23.43.13]:5701
}
Nov 19, 2013 4:28:02 PM com.hazelcast.impl.PartitionManager
INFO: [10.23.43.14]:5701 [CERT] Re-partitioning cluster data... Immediate-Tasks: 271, Scheduled-Tasks: 0
Nov 19, 2013 4:28:24 PM com.hazelcast.web.WebFilter
INFO: Created new session with id: HZAD50E5F483CC448C9FA7CB66D65848BB
Nov 19, 2013 4:28:24 PM com.hazelcast.web.WebFilter
INFO: 196 is sessions.size and originalSessions.size: 196
Nov 19, 2013 4:28:24 PM com.hazelcast.web.WebFilter
INFO: PUTTING SESSION HZAD50E5F483CC448C9FA7CB66D65848BB
Nov 19, 2013 4:28:24 PM com.hazelcast.web.WebFilter
INFO: Request is instance of RequestWrapper! Continue...
Nov 19, 2013 4:28:24 PM com.hazelcast.web.WebFilter
INFO: Request is instance of RequestWrapper! Continue...
Nov 19, 2013 4:28:24 PM com.hazelcast.web.WebFilter
INFO: Request is instance of RequestWrapper! Continue...
Nov 19, 2013 4:28:24 PM com.hazelcast.web.WebFilter
INFO: Request is instance of RequestWrapper! Continue...
Nov 19, 2013 4:28:50 PM com.hazelcast.web.WebFilter
INFO: Created new session with id: HZC9553A4C330044CA8A0C20549EE23BF0
Nov 19, 2013 4:28:50 PM com.hazelcast.web.WebFilter
INFO: 197 is sessions.size and originalSessions.size: 197
Nov 19, 2013 4:28:50 PM com.hazelcast.web.WebFilter
INFO: PUTTING SESSION HZC9553A4C330044CA8A0C20549EE23BF0
Nov 19, 2013 4:28:50 PM com.hazelcast.web.WebFilter
INFO: Request is instance of RequestWrapper! Continue...
Nov 19, 2013 4:28:50 PM com.hazelcast.web.WebFilter
INFO: Request is instance of RequestWrapper! Continue...
Nov 19, 2013 4:28:50 PM com.hazelcast.web.WebFilter
INFO: Request is instance of RequestWrapper! Continue...
Nov 19, 2013 4:28:50 PM com.hazelcast.web.WebFilter
INFO: Request is instance of RequestWrapper! Continue...
10069.275: [GC [PSYoungGen: 693173K->3458K(695488K)] 877908K->188718K(2093632K), 0.0224650 secs] [Times: user=0.04 sys=0.00, real=0.02 secs]
Nov 19, 2013 4:29:18 PM com.hazelcast.web.WebFilter
INFO: Created new session with id: HZE46365454C2C45F98A7947AC40E404BB
Nov 19, 2013 4:29:18 PM com.hazelcast.web.WebFilter
INFO: 198 is sessions.size and originalSessions.size: 198
Nov 19, 2013 4:29:18 PM com.hazelcast.web.WebFilter
INFO: PUTTING SESSION HZE46365454C2C45F98A7947AC40E404BB
The following only works with Hazelcast 3.2-SNAPSHOT.
Lets start with the single HazelcastInstance that is shared between session replication and the application. You can do it like this:
public class HazelcastInstanceLoader {
private final static ILogger logger = Logger.getLogger(HazelcastInstanceLoader.class);
public static HazelcastInstance load(String instanceName) throws Exception {
String configName = System.getProperty("hazelcast.config");
if (configName == null) {
configName = "hazelcast.xml";
}
Config config;
if (configName.startsWith("file:")) {
String filename = configName.substring("file:".length());
logger.info("Using hazelcast configuration file: " + filename);
config = new FileSystemXmlConfig(filename);
} else {
logger.info("Using hazelcast classpath resource: " + configName);
config = new ClasspathXmlConfig(configName);
}
config.setInstanceName(instanceName);
return Hazelcast.getOrCreateHazelcastInstance(config);
}
}
And now the Spring configuration:
<bean id="hazelcastInstance"
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="staticMethod" value="com.hazelcast.webmonitor.HazelcastInstanceLoader.load"/>
<property name="arguments">
<list>
<value>default</value>
</list>
</property>
</bean>
So when this is loaded, we have a named HazelcastInstance 'default'.
When I configure the session replication like this:
<filter>
<filter-name>hazelcast-filter</filter-name>
<filter-class>com.hazelcast.web.WebFilter</filter-class>
<init-param>
<param-name>instance-name</param-name>
<param-value>default</param-value>
</init-param>
</filter>
Then the session filter will try to load the hazelcastinstance with that name. Since the 'default' HazelcastInstance already is created because the Spring applicationcontext is loaded, the session filter will use that instance and not create a new one.
If you need to have fully seperate configuration files, just specify a file using the 'hazelcast.conf' system property (see the code of the HazelcastInstanceLoader). Instead of relying on a system property, you could also modify the HazelcastInstanceLoader.load method to accept a 'path' property, which you can inject from Spring.
Setting different groups for different environments is a useful way to make sure that machines in these environments, don't form a group. But if you want to share configuration, and only on the details there are differences (e.g. groupnames), then you can also make use of variables in the xml:
<hazelcast>
<group>
<name>${groupname}</name>
<password>${password}</password>
</group>
...
</hazelcast>
Does this answer your question?
Why dont you jat put in src/main/resources a file per environement.
So that you have: dev.properties,qa.properties,prod.properties
use an environement variable such as ENV. which in my situation i have put ENV=dev
and then inside my spring-servlet.xml i have:
<property name="locations">
<list>
<value>classpath:/${SERVER_ENV}.hazelcast.properties</value>
</list>
</property>
and then in the same file i use properties this way:
<hz:hazelcast id="myapp">
<hz:config>
<!-- Hazelcast Instance Name -->
<hz:instance-name>${hz.instance.name}</hz:instance-name>
<!-- Hazelcast Group Name and Password -->
<hz:group name="${hz.group.name}" password="${hz.group.password}" />
<!-- Hazelcast Management Center URL -->
<hz:management-center enabled="${hz.management.center.enabled}" url="${hz.management.center.url}"
/>
<!-- Hazelcast Tcp based network configuration -->
<hz:network port="${hz.network.port}" port-auto-increment="${hz.network.port.auto.increment}">
<hz:join>
<hz:multicast enabled="${hz.multicast.enabled}" multicast-group="224.2.2.3" multicast-port="54327"
/>
<hz:tcp-ip enabled="${hz.tcp.ip.enabled}">
<hz:members>${hz.members}</hz:members>
</hz:tcp-ip>
</hz:join>
</hz:network>
<!-- Hazelcast Distributed Map configuration -->
<hz:map name="map" backup-count="${hz.map.backup.count}" max-size="${hz.map.max.size}"
eviction-percentage="${hz.map.eviction.percentage}" read-backup-data="${hz.map.read.backup.data}"
eviction-policy="${hz.map.eviction.policy}" merge-policy="${hz.map.merge.policy}"
/>
</hz:config>
</hz:hazelcast>

Resources