Creating PrimeFaces metergauge chart without #PostConstruct annotation - spring

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)

Related

Spring boot #Cron taking a long time(5 min) to start up

have a cron job class which is annotated with #Component.
when I am running the cron job its taking approx 5 min to start up.
the last logs are mentioned above
eligible.coupon.merchant.scheduler.cron=0 * * * * *
Sep 21, 2020 2:59:43 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {5.2.17.Final}
Sep 21, 2020 2:59:43 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Sep 21, 2020 2:59:43 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
Sep 21, 2020 2:59:44 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.Oracle12cDialect
Sep 21, 2020 2:59:45 PM org.hibernate.type.BasicTypeRegistry register
INFO: HHH000270: Type registration [byte[]] overrides previous : org.hibernate.type.BinaryType#1410d645
Sep 21, 2020 2:59:45 PM org.hibernate.type.BasicTypeRegistry register
INFO: HHH000270: Type registration [[B] overrides previous : org.hibernate.type.BinaryType#1410d645
Sep 21, 2020 2:59:45 PM org.hibernate.type.BasicTypeRegistry register
INFO: HHH000270: Type registration [Byte[]] overrides previous : org.hibernate.type.WrapperBinaryType#13908f9c
Sep 21, 2020 2:59:45 PM org.hibernate.type.BasicTypeRegistry register
#Component
public class EligibleMerchantController extends DigitalApiRestServiceBinding implements MerchantSchedulerService {
protected final Logger log = LoggerFactory.getLogger(EligibleMerchantController.class);
#Value("${eligible.coupon.merchant.pagesize}")
Integer defaultPagesize;
#Autowired
EligibleMerchantBusinessService service;
#Override
#Scheduled(cron = "${eligible.coupon.merchant.scheduler.cron}")
public void eligibleMerchantScheduler() {
// my cron job
}
}
#Bean
public TaskScheduler taskScheduler() {
return new ConcurrentTaskScheduler();
}
}
its taking more than 5 min which it shouldnt
removed a property
spring.jpa.hibernate.ddl-auto=update
this was taking a long time

Spring Rich Client Toolbar Menu won't show

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>

Web.xml still missing when deploying a Spring Boot RESTful Web Service to Tomcat

I am trying to deploy a RESTful Web Service built with Spring Boot into a Tomcat instance, with little success.
My software configuration is as follows: my computer is a Mac running OS X Yosemite 10.10.3, with Oracle Java JDK 8 1.8.0_45, Gradle 2.4 and Apache Tomcat 7.0.47. I use IntelliJ IDEA 14.1.4 as development platform.
I started by following this guide and I got a jar that initiates an embedded container which works as expected. Then I followed the document about converting a Spring Boot JAR Application to a WAR linked at the end of the other guide. I followed the instructions in Section 59.4 "Packaging executable jar and war files" and then those in the Section 74.1 "Create a deployable war file". According to the posts of a few other members of this site who were facing the same problem (here, here, here and here, just to name a few), I should be able now to create a create a WAR and deploy it on my Tomcat. Unfortunately, this is not the case.
The project contains the following 3 Java files: Application.java, Greeting.java and GreetingController.java. The first is as follows:
package hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.Configuration;
#Configuration
#EnableAutoConfiguration
#SpringBootApplication
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
}
The second file contains the following:
package hello;
public class Greeting {
private final long id;
private final String content;
public Greeting(long id, String content) {
this.id = id;
this.content = content;
}
public long getId() {
return id;
}
public String getContent() {
return content;
}
}
And, finally, the latter file is:
package hello;
import java.util.concurrent.atomic.AtomicLong;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
#RestController
public class GreetingController {
private static final String template = "Hello, %s!";
private final AtomicLong counter = new AtomicLong();
#RequestMapping("/hello")
public Greeting greeting(#RequestParam(value="name", defaultValue="World") String name) {
return new Greeting(counter.incrementAndGet(), String.format(template, name));
}
}
The project also contains the following build.gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.4.RELEASE")
}
}
apply plugin: 'war'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'spring-boot'
sourceCompatibility = 1.8
targetCompatibility = 1.8
war {
baseName = 'rest'
// version = '0.1.0'
}
repositories {
mavenLocal()
mavenCentral()
}
configurations {
providedRuntime
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
testCompile("junit:junit")
}
Now, if I run the task "gradle war", I generate a WAR file of about 8 Mb. I can successfully deploy it to my local Tomcat, but when I point my browser to http://localhost:8080/rest/hello?name=World I got a blank page rather than the page with the expected JSON. If I run the task "gradle build" or "gradle bootRepackage", I get both a JAR and a WAR and their original versions. I'm mentioning these commands because I haven't seen them anywhere and they might be useful to know. The original versions are both around 8 Mb in size, while the JAR and the WAR of 12 Mb. If I deploy both WARs, I get no error messages but, again, no results in the browser. Somebody here suggested that the web.xml could be missing, and in fact no WAR actually contained such a file. I am saying so because my Tomcat is not very recent and for some reason I thought Spring Boot had to automatically create a web.xml out of the code and annotations above.
As suggested by #dunni in the comments, here are my Tomcat log files. First of all, catalina.log:
giu 24, 2015 10:35:01 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /usr/local/apache-tomcat-7.0.47/webapps/rest.war
Then localhost.log:
giu 24, 2015 10:35:02 AM org.apache.catalina.core.ApplicationContext log
INFO: Spring WebApplicationInitializers detected on classpath: [org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration#4dfaba52]
And finally manager.log:
giu 24, 2015 10:34:43 AM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'
giu 24, 2015 10:34:44 AM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'
giu 24, 2015 10:35:02 AM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'
The above content is what I get after deploy the WAR. Nothing changes if I subsequently try to connect to http://localhost:8080/, http://localhost:8080/rest/, http://localhost:8080/rest/hello or http://localhost:8080/rest/hello?name=World.
What is going on? What am I missing? Can you please explain me what is the problem and what have I to do to successfully deploy this toy service on Tomcat? Many thanks in advance.
Since the above logs were not really helpful, I tried to restart the Tomcat daemon and I got something more meaningful. Now I have the following files: catalina.log, catalina.out, host-manager.log (empty), launchd.stderr (empty), launchd.stdout, localhost_access_log.txt (empty), localhost.log and manager.log (empty). catalina.log and catalina.out now contains the following:
giu 24, 2015 11:11:49 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: /Users/stefano/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
giu 24, 2015 11:11:49 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
giu 24, 2015 11:11:49 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
giu 24, 2015 11:11:49 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 666 ms
giu 24, 2015 11:11:49 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
giu 24, 2015 11:11:49 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
giu 24, 2015 11:11:49 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /usr/local/apache-tomcat-7.0.47/webapps/Plakko.war
giu 24, 2015 11:11:51 AM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [574] milliseconds.
giu 24, 2015 11:11:51 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /usr/local/apache-tomcat-7.0.47/webapps/rest.war
giu 24, 2015 11:11:52 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/local/apache-tomcat-7.0.47/webapps/docs
giu 24, 2015 11:11:52 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/local/apache-tomcat-7.0.47/webapps/host-manager
giu 24, 2015 11:11:53 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/local/apache-tomcat-7.0.47/webapps/manager
giu 24, 2015 11:11:53 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/local/apache-tomcat-7.0.47/webapps/ROOT
giu 24, 2015 11:11:53 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
giu 24, 2015 11:11:53 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
giu 24, 2015 11:11:53 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 3349 ms
launchd.stdout contains:
Wed Jun 24 11:11:48 CEST 2015
Starting Tomcat
Waiting for 89105
And localhost.log contains:
giu 24, 2015 11:11:52 AM org.apache.catalina.core.ApplicationContext log
INFO: Spring WebApplicationInitializers detected on classpath: [org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration#2d5eb959]
If I try to consume the Web Service, localhost_access_log.txt is updated with:
217.20.22.194 - - [24/Jun/2015:11:23:16 +0200] "GET / HTTP/1.1" 200 11444
217.20.22.194 - - [24/Jun/2015:11:23:19 +0200] "GET /rest/ HTTP/1.1" 404 5
217.20.22.194 - - [24/Jun/2015:11:23:19 +0200] "GET /rest/hello HTTP/1.1" 404 5
217.20.22.194 - - [24/Jun/2015:11:23:20 +0200] "GET /rest/hello?name=World HTTP/1.1" 404 5
Since I have the feeling that these logs are not really helpful, I tried to shutdown and startup Tomcat. In this case I find something interesting in catalina.log and catalina.out. The former:
giu 24, 2015 11:36:56 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /usr/local/apache-tomcat-7.0.47/webapps/rest.war
giu 24, 2015 11:36:59 AM org.apache.catalina.core.ContainerBase addChildInternal
SEVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/rest]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:983)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1660)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.NoSuchMethodError: java.lang.reflect.Parameter.isNamePresent()Z
at org.springframework.core.StandardReflectionParameterNameDiscoverer.getParameterNames(StandardReflectionParameterNameDiscoverer.java:56)
at org.springframework.core.PrioritizedParameterNameDiscoverer.getParameterNames(PrioritizedParameterNameDiscoverer.java:65)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:182)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1139)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1042)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry$OptimizedBeanTypeRegistry.getFromFactory(BeanTypeRegistry.java:320)
at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.get(BeanTypeRegistry.java:162)
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.collectBeanNamesForType(OnBeanCondition.java:158)
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:147)
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:119)
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:94)
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:45)
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:102)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:190)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:148)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:124)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:318)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:239)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:606)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:117)
at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:108)
at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:68)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5423)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 10 more
giu 24, 2015 11:36:59 AM org.apache.catalina.startup.HostConfig deployWAR
SEVERE: Error deploying web application archive /usr/local/apache-tomcat-7.0.47/webapps/rest.war
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/rest]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:983)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1660)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
And the latter catalina.out:
giu 24, 2015 11:36:56 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /usr/local/apache-tomcat-7.0.47/webapps/rest.war
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.2.4.RELEASE)
2015-06-24 11:36:59.019 INFO 89274 --- [ost-startStop-1] o.s.boot.SpringApplication : Starting application on Mac-mini-di-Stefano.local with PID 89274 (/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-boot-1.2.4.RELEASE.jar started by stefano in /usr/local/apache-tomcat-7.0.47/bin)
2015-06-24 11:36:59.047 INFO 89274 --- [ost-startStop-1] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#34a13c2b: startup date [Wed Jun 24 11:36:59 CEST 2015]; root of context hierarchy
2015-06-24 11:36:59.648 INFO 89274 --- [ost-startStop-1] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/classes/, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/aopalliance-1.0.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/classmate-1.0.0.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/hibernate-validator-5.1.3.Final.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/jackson-annotations-2.4.0.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/jackson-core-2.4.6.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/jackson-databind-2.4.6.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/jboss-logging-3.1.3.GA.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/jcl-over-slf4j-1.7.12.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/jul-to-slf4j-1.7.12.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/log4j-over-slf4j-1.7.12.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/logback-classic-1.1.3.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/logback-core-1.1.3.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/slf4j-api-1.7.12.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/snakeyaml-1.14.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-aop-4.1.6.RELEASE.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-beans-4.1.6.RELEASE.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-boot-1.2.4.RELEASE.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-boot-autoconfigure-1.2.4.RELEASE.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-boot-starter-1.2.4.RELEASE.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-boot-starter-logging-1.2.4.RELEASE.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-boot-starter-web-1.2.4.RELEASE.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-context-4.1.6.RELEASE.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-core-4.1.6.RELEASE.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-expression-4.1.6.RELEASE.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-web-4.1.6.RELEASE.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-webmvc-4.1.6.RELEASE.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/validation-api-1.1.0.Final.jar]
2015-06-24 11:36:59.663 ERROR 89274 --- [ost-startStop-1] o.s.boot.SpringApplication : Application startup failed
java.lang.NoSuchMethodError: java.lang.reflect.Parameter.isNamePresent()Z
at org.springframework.core.StandardReflectionParameterNameDiscoverer.getParameterNames(StandardReflectionParameterNameDiscoverer.java:56)
at org.springframework.core.PrioritizedParameterNameDiscoverer.getParameterNames(PrioritizedParameterNameDiscoverer.java:65)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:182)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1139)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1042)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry$OptimizedBeanTypeRegistry.getFromFactory(BeanTypeRegistry.java:320)
at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.get(BeanTypeRegistry.java:162)
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.collectBeanNamesForType(OnBeanCondition.java:158)
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:147)
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:119)
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:94)
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:45)
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:102)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:190)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:148)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:124)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:318)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:239)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:606)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:117)
at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:108)
at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:68)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5423)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:983)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1660)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
By looking at these logs, I have the feeling that something is failing in the auto-magical process of Spring but unfortunately I don't know what and how to fix it. Any help?
What version of java are you using? The gradle file indicates you intend to use java 8, but this error indicates you are not...
java.lang.NoSuchMethodError: java.lang.reflect.Parameter.isNamePresent()
The Parameter class was not introduced until java 8. What version of java is your tomcat using?

Spring, JPA,JSF - null pointer exception on the access to data

I write web application with spring, jpa and jsf support. In my xhtml web page is table(primefaces) and button, which refresh database. When I try click the button i get this:
gru 23, 2014 10:01:10 PM org.apache.catalina.core.AprLifecycleListenerinit INFO: The APR based Apache Tomcat Native library which allowsoptimal performance in production environments was not found on thejava.library.path: C:\ProgramFiles\Java\jdk1.7.0_45\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\oraclexe\app\oracle\product\11.2.0\server\bin;;C:\ProgramFiles (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLSClient\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\ProgramFiles (x86)\Windows Live\Shared;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 (x86)\Intel\OpenCLSDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCLSDK\2.0\bin\x64;D:\maven\bin;.
gru 23, 2014 10:01:10 PM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING:[SetPropertiesRule]{Server/Service/Engine/Host/Context} Settingproperty 'source' to 'org.eclipse.jst.jee.server:SJM' did not find amatching property.
gru 23, 2014 10:01:11 PM org.apache.coyote.AbstractProtocol init INFO: InitializingProtocolHandler ["http-bio-8081"]
gru 23, 2014 10:01:11 PM org.apache.coyote.AbstractProtocol init INFO: InitializingProtocolHandler ["ajp-bio-8010"]
gru 23, 2014 10:01:11 PM org.apache.catalina.startup.Catalina load INFO: Initializationprocessed in 1193 ms
gru 23, 2014 10:01:11 PM org.apache.catalina.core.StandardService startInternal INFO: Startingservice Catalina
gru 23, 2014 10:01:11 PM org.apache.catalina.core.StandardEngine startInternal INFO: StartingServlet Engine: Apache Tomcat/7.0.56
gru 23, 2014 10:01:16 PM org.apache.catalina.core.ApplicationContext log INFO: No SpringWebApplicationInitializer types detected on classpath
gru 23, 2014 10:01:16 PM org.apache.catalina.core.ApplicationContext log INFO:Initializing Spring root WebApplicationContext
22:01:21,254 DEBUG FlowDefinitionRegistryImpl:100 - Registering flow definition'ServletContext resource [/WEB-INF/flows/main/main-flow.xml]' under id'main'
22:01:21,280 DEBUG ConditionalFlowExecutionListenerLoader:59 -Adding flow execution listenerorg.springframework.webflow.persistence.JpaFlowExecutionListener#16495871with criteria *
22:01:21,282 DEBUGConditionalFlowExecutionListenerLoader:59 - Adding flow executionlistenerorg.springframework.faces.webflow.FlowFacesContextLifecycleListener#294d6e25with criteria *
gru 23, 2014 10:01:21 PM com.sun.faces.config.ConfigureListener contextInitialized INFO:Initializing Mojarra 2.1.10 (-SNAPSHOT 20120625-1354) for context'/SJM'
gru 23, 2014 10:01:22 PM com.sun.faces.spi.InjectionProviderFactory createInstance INFO:JSF1048: PostConstruct/PreDestroy annotations present. ManagedBeansmethods marked with these annotations will have said annotationsprocessed.
gru 23, 2014 10:01:24 PM org.primefaces.webapp.PostConstructApplicationEventListenerprocessEvent INFO: Running on PrimeFaces 3.4
gru 23, 2014 10:01:24 PM org.apache.catalina.core.ApplicationContext log INFO: InitializingSpring FrameworkServlet 'Spring MVC Dispatcher Servlet'
gru 23, 2014 10:01:24 PM org.apache.coyote.AbstractProtocol start INFO: StartingProtocolHandler ["http-bio-8081"]
gru 23, 2014 10:01:24 PM org.apache.coyote.AbstractProtocol start INFO: StartingProtocolHandler ["ajp-bio-8010"]
gru 23, 2014 10:01:24 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 13692 ms
22:01:25,527 DEBUG FlowHandlerMapping:108 - Mapping requestwith URI '/SJM/app/main' to flow with id 'main'
22:01:25,539 DEBUGFlowExecutorImpl:135 - Launching new execution of flow 'main' withinput null
22:01:25,539 DEBUG FlowDefinitionRegistryImpl:59 - GettingFlowDefinition with id 'main'
22:01:25,555 DEBUG DefaultFlowHolder:83- Assembling the flow for the first time
22:01:25,664 DEBUG FlowExecutionImplFactory:78 - Creating new execution of 'main'
22:01:25,680 DEBUG ConditionalFlowExecutionListenerLoader:87 - Loaded[2] of possible 2 listeners for this execution request for flow'main', the listeners to attach are list[org.springframework.webflow.persistence.JpaFlowExecutionListener#16495871,org.springframework.faces.webflow.FlowFacesContextLifecycleListener#294d6e25]
22:01:25,680 DEBUG FlowExecutionImpl:215 - Starting in org.springframework.webflow.mvc.servlet.MvcExternalContext#6f98bf1with input null
22:01:25,758 DEBUG ViewState:189 - Entering state'welcome' of flow 'main' 22:01:25,774 DEBUGSessionBindingConversationManager:78 - Putting conversation attribute'name' with value main
22:01:25,774 DEBUG SessionBindingConversationManager:78 - Putting conversation attribute'caption' with value null
22:01:25,774 DEBUG SessionBindingConversationManager:78 - Putting conversation attribute'description' with value null
22:01:25,774 DEBUG SessionBindingConversationManager:78 - Putting conversation attribute'flowExecutionSnapshotGroup' with value org.springframework.webflow.execution.repository.impl.SimpleFlowExecutionSnapshotGroup#67079bb1
22:01:25,774 DEBUG FlowExecutionImpl:419 - Assigned key e1s1
22:01:25,774 DEBUG SessionBindingConversationManager:67 - Lockingconversation 1
22:01:25,774 DEBUG DefaultFlowExecutionRepository:121 -Putting flow execution '[FlowExecutionImpl#277b5201 flow = 'main',flowSessions = list[[FlowSessionImpl#1144d3e7 flow = 'main', state ='welcome', scope = map['viewScope' -map[[empty]]]]]]' intorepository
22:01:25,789 DEBUG DefaultFlowExecutionRepository:128 -Adding snapshot to group with id 1
22:01:25,789 DEBUG SessionBindingConversationManager:78 - Putting conversation attribute'scope' with value map['flashScope' -map['messagesMemento' ->map[[null] -list[[empty]]]]]
22:01:25,789 DEBUG SessionBindingConversationManager:99 - Unlocking conversation 1
22:01:25,789 DEBUG FlowHandlerAdapter:367 - Sending flow executionredirect to '/SJM/app/main?execution=e1s1'
22:01:25,961 DEBUG FlowHandlerMapping:108 - Mapping request with URI '/SJM/app/main' toflow with id 'main'
22:01:25,961 DEBUG FlowExecutorImpl:161 - Resumingflow execution with key 'e1s1 22:01:25,961 DEBUGSessionBindingConversationManager:67 - Locking conversation 1
22:01:25,961 DEBUG DefaultFlowExecutionRepository:106 - Getting flowexecution with key 'e1s1'
22:01:25,961 DEBUG FlowDefinitionRegistryImpl:59 - Getting FlowDefinition with id 'main'
22:01:25,961 DEBUG ConditionalFlowExecutionListenerLoader:87 - Loaded[2] of possible 2 listeners for this execution request for flow'main', the listeners to attach arelist[org.springframework.webflow.persistence.JpaFlowExecutionListener#16495871,org.springframework.faces.webflow.FlowFacesContextLifecycleListener#294d6e25]
22:01:25,961 DEBUG FlowExecutionImpl:249 - Resuming inorg.springframework.webflow.mvc.servlet.MvcExternalContext#21d18342
22:01:26,519 DEBUG ViewState:289 - Rendering + [JSFView ='/WEB-INF/flows/main/welcome.xhtml']
22:01:26,519 DEBUG ViewState:290- Flash scope = map[[empty]]
22:01:26,520 DEBUG ViewState:291 - Messages = [DefaultMessageContext#60573326 sourceMessages = map[[null]-list[[empty]]]]
22:01:26,631 DEBUG DefaultFlowExecutionRepository:121 - Putting flow execution'[FlowExecutionImpl#3fcc8fc7 flow = 'main', flowSessions =list[[FlowSessionImpl#ef3728a flow = 'main', state = 'welcome', scope= map['viewScope' -map['flowSerializedViewState' -[FlowSerializedView#10e4c9b1 viewId ='/WEB-INF/flows/main/welcome.xhtml']]]]]]' into repository
22:01:26,636 DEBUG DefaultFlowExecutionRepository:128 - Addingsnapshot to group with id 1
22:01:26,636 DEBUG SessionBindingConversationManager:78 - Putting conversation attribute'scope' with value map['flashScope' -map['messagesMemento' ->map[[empty]]]] 22:01:26,637 DEBUG SessionBindingConversationManager:99- Unlocking conversation 1
22:01:28,327 DEBUG FlowHandlerMapping:108 - Mapping request with URI '/SJM/app/main' to flow with id 'main'
22:01:28,327 DEBUG FlowExecutorImpl:161 - Resuming flow execution withkey 'e1s1
22:01:28,327 DEBUG SessionBindingConversationManager:67 -Locking conversation 1
22:01:28,343 DEBUG DefaultFlowExecutionRepository:106 - Getting flow execution with key'e1s1'
22:01:28,343 DEBUG FlowDefinitionRegistryImpl:59 - GettingFlowDefinition with id 'main'
22:01:28,345 DEBUG ConditionalFlowExecutionListenerLoader:87 - Loaded [2] of possible 2listeners for this execution request for flow 'main', the listeners to attach are list [org.springframework.webflow.persistence.JpaFlowExecutionListener#16495871,org.springframework.faces.webflow.FlowFacesContextLifecycleListener#294d6e25]
22:01:28,345 DEBUG FlowExecutionImpl:249 - Resuming inorg.springframework.webflow.mvc.servlet.MvcExternalContext#19f6d704
22:01:28,360 DEBUG FlowExecutionImpl:590 - Attempting to handle[org.springframework.webflow.execution.FlowExecutionException:Exception thrown in state 'welcome' of flow 'main'] with root cause[java.lang.NullPointerException]
22:01:28,360 DEBUGFlowExecutionImpl:611 - Rethrowing unhandled flow execution exception22:01:28,360 DEBUG SessionBindingConversationManager:99 - Unlockingconversation 1
gru 23, 2014 10:01:28 PMorg.apache.catalina.core.StandardWrapperValve invoke SEVERE:Servlet.service() for servlet [Spring MVC Dispatcher Servlet] incontext with path [/SJM] threw exception [Request processing failed;nested exception isorg.springframework.webflow.execution.FlowExecutionException:Exception thrown in state 'welcome' of flow 'main'] with root causejava.lang.NullPointerException
at com.sjm.dao.ModelDao.findByStartTime(ModelDao.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.el.parser.AstValue.invoke(AstValue.java:278)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:273)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
at org.springframework.faces.webflow.FlowActionListener.processAction(FlowActionListener.java:81)
at org.springframework.faces.model.SelectionTrackingActionListener.processAction(SelectionTrackingActionListener.java:55)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at org.springframework.faces.webflow.FlowLifecycle.invokePhase(FlowLifecycle.java:127)
at org.springframework.faces.webflow.FlowLifecycle.execute(FlowLifecycle.java:70)
at org.springframework.faces.webflow.JsfView.processUserEvent(JsfView.java:120)
at org.springframework.webflow.engine.ViewState.handleEvent(ViewState.java:226)
at org.springframework.webflow.engine.ViewState.resume(ViewState.java:196)
at org.springframework.webflow.engine.Flow.resume(Flow.java:545)
at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:258)
at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
at org.springframework.faces.webflow.JsfFlowHandlerAdapter.handle(JsfFlowHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
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.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
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:503)
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:1070)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$Wrappingrunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:744)
NawNeHier.java
package com.sjm.model;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity
#Table(name="NAW_NE_HIER")
public class NawNeHier implements Serializable {
private static final long serialVersionUID = 1L;
#Id
private int hierId;
private int parentHierId;
private String type;
private String name;
private String display_name;
public NawNeHier() {
}
public int getHierId() {
return hierId;
}
public void setHierId(int hierId) {
this.hierId = hierId;
}
public int getParentHierId() {
return parentHierId;
}
public void setParentHierId(int parentHierId) {
this.parentHierId = parentHierId;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDisplay_name() {
return display_name;
}
public void setDisplay_name(String display_name) {
this.display_name = display_name;
}
}
ModelDao.java
package com.sjm.dao;
import javax.faces.bean.ManagedBean;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import com.sjm.model.NawNeHier;
#ManagedBean(name="modelDao")
public class ModelDao {
#PersistenceContext
private EntityManager entityManager;
private NawNeHier nawNeHier;
public ModelDao () {}
public NawNeHier getNawNeHier() {
return nawNeHier;
}
public void setNawNeHier(NawNeHier nawNeHier) {
this.nawNeHier = nawNeHier;
}
public EntityManager getEntityManager() {
return entityManager;
}
public void setEntityManager(EntityManager entityManager) {
this.entityManager = entityManager;
}
public void findByStartTime() {
String jpql = "SELECT n FROM NAW_NE_HIER n";
this.nawNeHier = entityManager.createQuery(jpql, NawNeHier.class).getSingleResult();
}
}
index.xhtml
<h:form id="myform">
<p:commandButton value="Count" action="#{modelDao.findByStartTime}" update="dataTable"/>
<p:dataTable id="dataTable" var="nawNeHier" value="#{modelDao.nawNeHier}">
<p:column headerText="hierId">
<h:outputText value="#{nawNeHier.hierId}" />
</p:column>
<p:column headerText="parentHierId">
<h:outputText value="#{nawNeHier.parentHierId}" />
</p:column>
<p:column headerText="type">
<h:outputText value="#{nawNeHier.type}" />
</p:column>
<p:column headerText="name">
<h:outputText value="#{nawNeHier.name}" />
</p:column>
<p:column headerText="display_name">
<h:outputText value="#{nawNeHier.display_name}" />
</p:column>
</p:dataTable>
</h:form>

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>

Resources