When I call the following reproducible doce:
install.packages("h2o", type = "source", repos =
"http://h2o-release.s3.amazonaws.com/h2o/rel-ueno/8/R")
library(rsparkling)
library(h2o)
library(sparklyr)
library(dplyr)
library(DBI)
library(readr)
library(stringr)
conf <- spark_config()
conf$'sparklyr.shell.executor-memory' <- "460G"
conf$'sparklyr.shell.driver-memory' <- "460G"
conf$spark.executor.cores <- 32
conf$spark.executor.memory <- "460G"
conf$spark.executor.instances <- 8
conf$spark.dynamicAllocation.enabled <- "false"
conf$maximizeResourceAllocation <- "true"
conf$spark.default.parallelism <- 32
sc <- spark_connect(master = "local", config = conf, version = "2.0.2")
h2o_context(sc ,strict_version_check = T)
h2o.init(nthreads = -1)
NFLPlayers <- c('Von Miller','Christian McCaffrey','Joe Thomas')
salary <- c(21000, 23400, 26800)
Valuable = c(1,1,1)
Rdata <- data.frame(NFLPlayers, salary, Valuable)
system.time(Test <- copy_to(sc, Rdata, "Rdata"))
Test1 = as_h2o_frame(sc, Test, strict_version_check = FALSE)
Test1$Valuable<-as.factor(Test1$Valuable)
On an H2O dataframe I get the following error.
ERROR: Unexpected HTTP Status code: 500 Server Error (url = http://127.0.0.1:54321/99/Rapids)
Error: lexical error: invalid char in json text.
<html> <head> <meta http-equiv=
(right here) ------^
This is brand new and it is not only happening in my computer but also on that of a colleague. I have restarted the cluster. Reinstalled sparklyr and Rsparkling. I have also changed versions and am constantly getting the same error. Any ideas?
Some of the logs:
06-19 22:46:24.991 127.0.0.1:54321 2158 #2868-244 INFO: POST /99/Rapids, parms: {ast=(tmp= RTMP_sid_8db5_1 (:= frame_rdd_58_b5fd354222706e76381948c109884d05 (as.factor (cols frame_rdd_58_b5fd354222706e76381948c109884d05 [8])) [8] [])), session_id=_sid_8db5}
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: java.lang.NoClassDefFoundError: no/priv/garshol/duke/Comparator
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at water.rapids.Env.<clinit>(Env.java:278)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at water.rapids.Session.exec(Session.java:86)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at water.rapids.Rapids.exec(Rapids.java:93)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at water.api.RapidsHandler.exec(RapidsHandler.java:41)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at java.lang.reflect.Method.invoke(Method.java:498)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at water.api.Handler.handle(Handler.java:63)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at water.api.RequestServer.serve(RequestServer.java:448)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at water.api.RequestServer.doGeneric(RequestServer.java:297)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at water.api.RequestServer.doPost(RequestServer.java:223)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:503)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at water.JettyHTTPD$LoginHandler.handle(JettyHTTPD.java:183)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at org.eclipse.jetty.server.Server.handle(Server.java:370)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:982)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1043)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at java.lang.Thread.run(Thread.java:748)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: Caused by: java.lang.ClassNotFoundException: no.priv.garshol.duke.Comparator
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
06-19 22:46:25.081 127.0.0.1:54321 2158 #2868-244 ERRR: ... 37 more
This was a bug and is fixed in latest Sparkling Water versions for Spark 2.0, Spark 2.1 and Spark 2.2
Related
The error log says that the function can't find the file ("Location is required"), and as far as I know, the fxml file name is right because it is in the same package as the main. I really don't know what to do because it works just fine with the sample fxml file created with the project.
package clfx;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class CLFX extends Application {
#Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("MenuPrincipal.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
And the error log:
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$99(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException: Location is required.
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3207)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
at clfx.CLFX.start(CLFX.java:22)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$106(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$119(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$117(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$118(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.lambda$null$450(GtkApplication.java:139)
... 1 more
Exception running application clfx.CLFX
Java Result: 1
Some time ago I started javafx tutorials from Oracle website. During doing this tutorial https://docs.oracle.com/javase/8/javafx/get-started-tutorial/fxml_tutorial.htm I encountered a problem. Here is a code:
1) fxml_example.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import java.net.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<GridPane fx:controller="fxmlexample.FXMLExampleController"
xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
<fx:script>
function handleSubmitButtonAction(){
actiontarget.setText("Calling the JavaScript");
}
</fx:script>
<padding>
<Insets top="25" right="25" bottom="10" left="25" />
</padding>
<Text text="Welcome" GridPane.columnIndex="0"
GridPane.columnSpan="2" GridPane.rowIndex="0" />
<Label text="User Name:" GridPane.columnIndex="0"
GridPane.rowIndex="1" />
<TextField GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Label text="Password:" GridPane.columnIndex="0"
GridPane.rowIndex="2" />
<PasswordField fx:id="passwordField"
GridPane.columnIndex="1" GridPane.rowIndex="2" />
<HBox alignment="bottom_right" spacing="10"
GridPane.columnIndex="1" GridPane.rowIndex="4">
<Button text="Button" onAction="#handleSubmitButtonAction" />
</HBox>
<Text fx:id="actiontarget" GridPane.columnIndex="0"
GridPane.columnSpan="2" GridPane.halignment="RIGHT"
GridPane.rowIndex="6" />
</GridPane>
2) FXMLExample.java
package application;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class FXMLExample extends Application{
#Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("fxml_example.fxml"));
Scene scene = new Scene(root, 300, 275);
stage.setTitle("FXML Welcome");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args){
launch(args);
}
}
3) FXMLExampleController.java
package application;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.text.Text;
public class FXMLExampleController {
#FXML private Text actiontarget;
#FXML protected void handleSubmitButtonAction(ActionEvent event) {
actiontarget.setText("Sign in button pressed");
}
}
And here is a listing of exceptions:
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
at java.lang.Thread.run(Unknown Source)
Caused by: javafx.fxml.LoadException:
/C:/Users/.../eclipse-workspace/FXMLExample/bin/application /fxml_example.fxml:10
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
at javafx.fxml.FXMLLoader.access$700(FXMLLoader.java:103)
at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:922)
at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader. java:971)
at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:220)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:744)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2707)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
at application.FXMLExample.start(FXMLExample.java:12)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(Launcher Impl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.jav a:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
... 1 more
Caused by: java.lang.ClassNotFoundException: fxmlexample.FXMLExampleController
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:920)
... 22 more
Exception running application application.FXMLExample
So, is something wrong with FXMLLoader? But what? And how to fix it?
Your FXML sets the fx:controller to fxmlexample.FXMLExampleController, yet your package name is application, so the fx:controller value should be application.FXMLExampleController (or you could change your package name to fxmlexample to match the example code).
I am getting a NullPointerException when I try to execute the checkCredentials function in my LoginController. I think the problem is not with my Service Implementation but with DAO Implementation. But I am not able to find what causes the issue. I am not sure if the problem is with the
#Autowired
private LoginDAO loginDAO;
or the
#Repository("loginDAO")
When I submit the login credentials I get the following
DEBUG - Returning handler method [public java.lang.String com.accademics.web.controllers.LoginController.checkCredentials(com.accademics.web.models.LoginModel,org.springframework.validation.BindingResult)]
DEBUG - Returning cached instance of singleton bean 'loginController'
inside controller checkCredentials
LoginModel [username=admin, password=password]
service checking login of admin and password
DEBUG - Resolving exception from handler [public java.lang.String com.accademics.web.controllers.LoginController.checkCredentials(com.accademics.web.models.LoginModel,org.springframework.validation.BindingResult)]: java.lang.NullPointerException
DEBUG - Resolving exception from handler [public java.lang.String com.accademics.web.controllers.LoginController.checkCredentials(com.accademics.web.models.LoginModel,org.springframework.validation.BindingResult)]: java.lang.NullPointerException
DEBUG - Resolving exception from handler [public java.lang.String com.accademics.web.controllers.LoginController.checkCredentials(com.accademics.web.models.LoginModel,org.springframework.validation.BindingResult)]: java.lang.NullPointerException
DEBUG - Could not complete request
java.lang.NullPointerException
at com.accademics.data.services.LoginServiceImpl.checkCredentials(LoginServiceImpl.java:18)
at com.accademics.web.controllers.LoginController.checkCredentials(LoginController.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
So here is the root, applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd">
<bean id="loginService" class="com.accademics.data.services.LoginServiceImpl"/>
</beans>
The dispatcher-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">
<mvc:annotation-driven />
<context:component-scan base-package="com.accademics.web.controllers"></context:component-scan>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="messages"></property>
</bean>
<mvc:resources location="/resources/" mapping="/resources/**"></mvc:resources>
</beans>
student_login.jsp actual content part
<form action='<spring:url value="/student/login"></spring:url>' method="post" autocomplete="on">
<h1>Log in</h1>
<p>
<label for></label>
</p>
<p>
<label for="username" class="uname" > Username </label>
<input id="username" name="username" required="required" type="text" placeholder="Username"/>
</p>
<p>
<label for="password" class="passwd"> Password </label>
<input id="password" name="password" required="required" type="password" placeholder="Password" />
</p>
<p class="keeplogin">
<input type="checkbox" name="saveLogin" id="saveLogin" value="saveLogin" />
<label for="saveLogin">Keep me logged in</label>
</p>
<p class="login button">
<input type="submit" value="Login" />
</p>
</form>
LoginController.java
package com.accademics.web.controllers;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.accademics.data.services.LoginService;
import com.accademics.web.models.LoginModel;
#Controller
#RequestMapping("/student")
public class LoginController {
#Autowired
public LoginService loginService;
#Autowired
MessageSource messagesource;
#RequestMapping(value="/login", method=RequestMethod.GET)
public String displayLogin(Model model){
return "student_login";
}
#RequestMapping(value="/login", method=RequestMethod.POST)
public String checkCredentials(#Valid #ModelAttribute LoginModel loginModel, BindingResult result){
System.out.println("inside controller checkCredentials");
if(result.hasErrors()){
return "student_login";
}
System.out.println(loginModel);
boolean userExists = loginService.checkCredentials(loginModel.getUsername(), loginModel.getPassword());
if(userExists){
System.out.println("valid");
return "dashboard";
}else{
System.out.println("invalid");
result.rejectValue("userName", "NotNull.login.invalidUser");
return "student_login";
}
}
}
LoginServiceImpl.java
package com.accademics.data.services;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.accademics.web.DAO.LoginDAO;
#Service("loginService")
public class LoginServiceImpl implements LoginService {
#Autowired
private LoginDAO loginDAO;
#Override
public boolean checkCredentials(String username, String password) {
// TODO Auto-generated method stub
System.out.println("service checking login of "+username+" and "+password);
return loginDAO.checkCredentials(username, password);
}
}
LoginDAO.java
package com.accademics.web.DAO;
public interface LoginDAO {
public boolean checkCredentials(String username, String password);
}
LoginDAOImpl.java
package com.accademics.web.DAO;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
#Repository("loginDAO")
public class LoginDAOImpl implements LoginDAO {
#Autowired
private SessionFactory sessionFactory;
protected Session getSession(){
return sessionFactory.getCurrentSession();
}
#Override
public boolean checkCredentials(String username, String password) {
System.out.println("Checking login");
//HQL
String hquery = "from student_credentials where student_credentials.username=? and student_credentials.password=?";
boolean userFound = false;
Session session = getSession();
Query query = session.createSQLQuery(hquery);
query.setParameter(0, username);
query.setParameter(1, password);
List list = query.list();
if(!list.isEmpty()){
userFound = true;
}
session.close();
return userFound;
}
}
and relevant entry in messages.properties
NotNull.login.invalidUser = Invalid Username/Password
Please help me to resolve this issue.
I have made the following changes to my dispatcher-servlet and removed the bean tag from applicationContext.xml,
<?xml version="1.0" encoding="UTF-8"?>
http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">
<mvc:annotation-driven />
<context:component-scan base-package="com.accademics.web" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="messages"></property>
</bean>
<mvc:resources location="/resources/" mapping="/resources/**"></mvc:resources>
which created this new exception.
ERROR - Context initialization failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'loginController': Unsatisfied dependency expressed through field 'loginService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'loginService': Unsatisfied dependency expressed through field 'loginDAO'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'loginDAO': Unsatisfied dependency expressed through field 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in com.accademics.web.configuration.HibernateConfiguration: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.annotations.common.reflection.java.JavaReflectionManager
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:138)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1183)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1099)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:779)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:133)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'loginService': Unsatisfied dependency expressed through field 'loginDAO'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'loginDAO': Unsatisfied dependency expressed through field 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in com.accademics.web.configuration.HibernateConfiguration: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.annotations.common.reflection.java.JavaReflectionManager
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
... 39 more
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'loginDAO': Unsatisfied dependency expressed through field 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in com.accademics.web.configuration.HibernateConfiguration: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.annotations.common.reflection.java.JavaReflectionManager
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
... 52 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in com.accademics.web.configuration.HibernateConfiguration: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.annotations.common.reflection.java.JavaReflectionManager
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
... 65 more
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.annotations.common.reflection.java.JavaReflectionManager
at org.hibernate.cfg.Configuration.createReflectionManager(Configuration.java:2547)
at org.hibernate.cfg.Configuration.createReflectionManager(Configuration.java:2543)
at org.hibernate.cfg.Configuration.reset(Configuration.java:298)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:289)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:293)
at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.<init>(LocalSessionFactoryBuilder.java:140)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:343)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
... 75 more
I really dont understand what is wrong with my code.
I now have the solution, which is decribed in the below answer. The second problem was actually related to dependencies.
I found the solution to the second issue (first which was solved Thanks to #JBNizet)
It was actually regarding the dependencies added in the pom.xml, which I havnt included here. What I did is I actually upgraded my hibernate version to 5.1.0 and then added hibernate-commons-annotations 5.0.1.Final. So my dependencies are now like below.
The specific, Hibernate core will have hibernate-common-annotation and this has the missing class
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.annotations.common.reflection.java.JavaReflectionManager
I create web app with controller, service, dao, entities, but now I'm needing replaced dao layer to spring data, but I have error.
I'm working with postgres database.
Stacktrace:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pupilController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private service.PupilService controller.PupilController.pupilService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pupilServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private dao.PupilDAO service.implement.PupilServiceImpl.pupilDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pupilDAOImpl' defined in file [/opt/tomcat/apache-tomcat-8.0.24/webapps/ROOT/WEB-INF/classes/dao/implement/PupilDAOImpl.class]: Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:834)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4729)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1648)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:463)
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:413)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1471)
at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1312)
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1404)
at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:832)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$79(TCPTransport.java:683)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private service.PupilService controller.PupilController.pupilService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pupilServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private dao.PupilDAO service.implement.PupilServiceImpl.pupilDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pupilDAOImpl' defined in file [/opt/tomcat/apache-tomcat-8.0.24/webapps/ROOT/WEB-INF/classes/dao/implement/PupilDAOImpl.class]: Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:571)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
... 58 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pupilServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private dao.PupilDAO service.implement.PupilServiceImpl.pupilDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pupilDAOImpl' defined in file [/opt/tomcat/apache-tomcat-8.0.24/webapps/ROOT/WEB-INF/classes/dao/implement/PupilDAOImpl.class]: Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1145)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1069)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:967)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:543)
... 60 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private dao.PupilDAO service.implement.PupilServiceImpl.pupilDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pupilDAOImpl' defined in file [/opt/tomcat/apache-tomcat-8.0.24/webapps/ROOT/WEB-INF/classes/dao/implement/PupilDAOImpl.class]: Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:571)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
... 71 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pupilDAOImpl' defined in file [/opt/tomcat/apache-tomcat-8.0.24/webapps/ROOT/WEB-INF/classes/dao/implement/PupilDAOImpl.class]: Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1105)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1050)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1145)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1069)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:967)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:543)
... 73 more
Caused by: java.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1098)
... 84 more
Caused by: org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class="entities.Pupil"/>
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1606)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1561)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1540)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1514)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1434)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1420)
at dao.implement.PupilDAOImpl.<clinit>(PupilDAOImpl.java:20)
... 91 more
spring-serlvet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
<context:annotation-config/>
<context:component-scan base-package="controller"/>
<context:component-scan base-package="dao.implement"/>
<context:component-scan base-package="service.implement"/>
<jpa:repositories base-package="repositories"/>
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="pupilService" class="service.implement.PupilServiceImpl" autowire="byName"/>
<bean id="pupilDAO" class="dao.implement.PupilDAOImpl" autowire="byName"/>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.postgresql.Driver"/>
<property name="url" value="jdbc:postgresql://localhost:5432/hibernatedb"/>
<property name="username" value="postgres"/>
<property name="password" value="password"/>
</bean>
<bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true"/>
<property name="generateDdl" value="true"/>
<property name="database" value="POSTGRESQL"/>
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="jpaVendorAdapter" ref="jpaVendorAdapter"/>
<!-- spring based scanning for entity classes-->
<property name="packagesToScan" value="entities"/>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"/>
</beans>
This is service layer:
#Service
public class PupilServiceImpl implements PupilService {
#Autowired
private PupilRepositories pupilRepositories;
public void setPupilRepositories(PupilRepositories pupilRepositories) {
this.pupilRepositories = pupilRepositories;
}
...
}
PupilRepositories
package repositories;
import entities.Pupil;
import org.springframework.data.repository.CrudRepository;
public interface PupilRepositories extends CrudRepository<Pupil, Long> {
long count();
}
PupilDAOImpl class
#Repository
public class PupilDAOImpl implements PupilDAO {
private static SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
public static Session getCurrentSession(){
Session session = sessionFactory.openSession();
session.beginTransaction();
return session;
}
public static void closeCurrentSession(Session session){
session.getTransaction().commit();
session.close();
}
/**
* Get all pupils
* #return all pupils from database
* */
public List<Pupil> getAllPupils() {
Session session = getCurrentSession();
List<Pupil> pupilList = session.createCriteria(Pupil.class).list();
closeCurrentSession(session);
return pupilList;
}
Make sure you have below dependency in your classpath:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.3.2.GA</version>
</dependency>
Finally after lot of refactoring got a working code with Connection Refuse to Database, which you can fork from GitHub.
Hope it helps :)
I am getting this error and i don't know how to fix:
java.io.NotSerializableException:
com.procc.dao.EJB31_Generated_AlertFacade_Intf_Bean_ at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180)
at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
at java.util.HashMap.writeObject(HashMap.java:1100) 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:601) at
java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975)
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
at
java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1362)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1170)
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
at java.util.HashMap.writeObject(HashMap.java:1100) 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:601) at
java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975)
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
at
com.sun.faces.renderkit.ClientSideStateHelper.doWriteState(ClientSideStateHelper.java:325)
at
com.sun.faces.renderkit.ClientSideStateHelper.writeState(ClientSideStateHelper.java:173)
at
com.sun.faces.renderkit.ResponseStateManagerImpl.writeState(ResponseStateManagerImpl.java:122)
at
com.sun.faces.application.StateManagerImpl.writeState(StateManagerImpl.java:166)
at
com.sun.faces.application.view.WriteBehindStateWriter.flushToWriter(WriteBehindStateWriter.java:225)
at
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:419)
at
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
at
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) at
org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at
org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at
com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)
this is AlertFacade:
#Stateless public class AlertFacade extends AbstractFacade {
#PersistenceContext(unitName = "flams_pu")
private EntityManager em;
#Override
protected EntityManager getEntityManager() {
return em;
}
public AlertFacade() {
super(Alert.class);
} }
which i use in a JSF Managed bean.
is the EJB supposed to be Serializable ? I don't get it.
Please help
I would try and add to the class signature implements Serializable. Since it's a marker interface, you don't have to implement any method.