Spring threw load exception(java.lang.NoSuchMethodError:) - eclipse

I am trying to run a simple jsp program in eclipse but when i run the program i get following errors.I am working with spring now and i have added all the jars properly in the right path.The jsp program is as follows
<%#taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1>WELCOME TO EMPLOYEE ACCESS SITE.PLEASE ENTER THE FOLLOWING INFORMATION</h1>
<form:form method="POST" action="/Spring/mvc1/addStudent">
<table>
<tr>
<td><form:label path="name">Name</form:label></td>
<td><form:input path="name" /></td>
</tr>
<tr>
<td><form:label path="id">id</form:label></td>
<td><form:input path="id" /></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Submit"/>
</td>
</tr>
</table>
</form:form>
</body>
</html>
and when i run this above program i get the following set of error
SEVERE: Servlet /Spring threw load() exception
java.lang.NoSuchMethodError: org.springframework.web.context.ConfigurableWebApplicationContext.setId(Ljava/lang/String;)V
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:454)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:483)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:358)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:325)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4058)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4364)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Mar 27, 2013 11:02:15 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Mar 27, 2013 11:02:15 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Mar 27, 2013 11:02:15 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/109 config=null
Mar 27, 2013 11:02:15 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2471 ms
Mar 27, 2013 11:02:23 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: No WebApplicationContext found: no
ContextLoaderListener registered?
at org.springframework.web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext(WebApplicationContextUtils.java:84)
at org.springframework.web.servlet.support.RequestContextUtils.getWebApplicationContext(RequestContextUtils.java:81)
at org.springframework.web.servlet.support.RequestContext.initContext(RequestContext.java:219)
at org.springframework.web.servlet.support.JspAwareRequestContext.initContext(JspAwareRequestContext.java:74)
at org.springframework.web.servlet.support.JspAwareRequestContext.<init>(JspAwareRequestContext.java:48)
at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:76)
at org.apache.jsp.mvc11.student_jsp._jspx_meth_form_005fform_005f0(student_jsp.java:104)
at org.apache.jsp.mvc11.student_jsp._jspService(student_jsp.java:73)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
I havent linked the jsp page to spring class yet.I just wanted to see the front end display.I am not sure where the problem is...

Your JSP page should be returned by Spring Controller. It would work if you had no spring form tags in JSP, but your form in JSP has tags which require name and id paths. They should be coming from a bean. So you need to pass that bean/POJO along with the JSP. Add bean in the Model object.
Code would be something like this :
Suppose page URL is : http://localhost:8484/yourappcontext/student
#Controller
public class StudentController {
#RequestMapping(value="/student", method = RequestMethod.GET)
public String showAddStudentPage(Model model) {
// instantiate empty student pojo containing name & id needed by JSP
Student student = new Student();
// add student pojo in model being sent with JSP
model.addSttribute("student", student);
return "addStudent"; // this would be your JSP name.
}
}

Related

JSP doesn't see JavaBeans

everybody!
Can't solve this problem:
org.apache.jasper.JasperException: JBWEB004062: Unable to compile class for JSP:
JBWEB004060: An error occurred at line: 14 in the jsp file: /indexJB.jsp
packt.book.jee_eclipse.ch2.bean.LoginBean
cannot be resolved to a type
11: <%if ("POST".equalsIgnoreCase(request.getMethod())&&
12:
request.getParameter("submit")!=null)
13: { %>
14: <jsp:useBean id="loginBean"
15:
class="packt.book.jee_eclipse.ch2.bean.LoginBean">
16:
<jsp:setProperty name="loginBean" property="*"/>
17: </jsp:useBean>
I use:
WildFly 23
Eclipse Version: 2021-09 (4.21.0)
What I found in Internet:
Note
See the detailed error message under More Information.
​This issue occurs because JBoss EAP 6.2 server runtime is using unsupported JDK. Verify the following log statements for reference:
java.library.path = C:\Program Files\Java\jdk1.8.0_20\bin
java.runtime.name = Java(TM) SE Runtime Environment
java.runtime.version = 1.8.0_20-b26
Solution
​To resolve this issue, do as follows:
Point your JBoss EAP 6.2 server to a supported JDK that is JDK 1.7.x
(best is 1.7.0_25).
Restart the application server.
But how to point???
Thanks in ADVANCE!
The whole code is here:
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W#C//DTD HTML 4.01 Transitional//EN"
"http://www.w3org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Login</title>
</head>
<% String errMsg = null; %>
<%if ("POST".equalsIgnoreCase(request.getMethod())&&
request.getParameter("submit")!=null)
{ %>
<jsp:useBean id="loginBean"
class="packt.book.jee_eclipse.ch2.bean.LoginBean">
<jsp:setProperty name="loginBean" property="*"/>
</jsp:useBean>
<%
if (loginBean.isValidUser())
{ out.println("<h2>WElcome, Admin!</h2>");
out.println("You are logged in");
}
else
errMsg = "Invalid user ID or password!";
}
%>
<body>
<h2>Login:</h2>
<%if (errMsg!=null ) {%>
<span style="color: red;"><%out.print(errMsg); %> </span>
<%} %>
<form method="POST">
User Name: <input type="text" name="userName" style="color: Green; background-color: Yellow"><br>
Password: <input type="password" name="password" style="color: Yellow; background-color: Silver"><br>
<button type="submit" name="submit">SUBMIT</button>
<button type="reset">Reset</button>
</form>
</body>
</html>
The problem was solved:
Right click on project-> choose properties -> Java Build Path -> choose third marker Libraries -> put cursor on Classpath -> on right menu choose Add Class Folder -> choose folder for classes -> Apply and Close.
I also restarted Eclipse just in case.
And my JSP finally sees Java Beans!
Hope that will help=)

Mapping some URLS with Spring Boot

Hi there im new with spring boot and mvc model im trying to create some methods to call some data to the Mongo D.B using postman im getting the data but now i want to show this data in a web page but i cant figure out how mapping works in spring boot.
I have this methods:
#Controller
#RequestMapping("/Informacion")
public class InformacionControlador {
#Autowired
private informacionRepo informacioRepo;
public InformacionControlador(informacionRepo informacioRepo) {
this.informacioRepo = informacioRepo;
}
//This method is comment because using postman get the answer in json format
// #GetMapping("/Listar")
// public List<Informacion> getAll() {
// List<Informacion> info = this.informacioRepo.findAll();
// return info;
// }
//Now this is the method that i want to work like the first one but
//instead of json answer y want to see the data in ListarInformacion page
#GetMapping("/Listar")
public String informacion(ModelMap model) {
model.addAttribute("info", informacioRepo.findAll());
return "ListarInformacion";
}
#PutMapping
public void insert(#RequestBody Informacion informacion) {
this.informacioRepo.insert(informacion);
}
}
Also i put this lines in application.properties file to set the folder where the page will be storage
spring.mvc.view.prefix=/webapp/Vistas
spring.mvc.view.suffix=.jsp
This is my ListarInformacion page
<html>
<%# page contentType="text/html;charset=UTF-8" language="java" %>
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%# taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%# taglib prefix = "fmt" uri = "http://java.sun.com/jsp/jstl/fmt" %>
<head>
<title>Title</title>
</head>
<body>
<form:form method="GET" action="/webapp/Vistas/ListarInformacion" modelAttribute="Informacion">
<table class="table table-striped table-hover">
<thead class="thead-dark">
<tr>
<th scope="col">ID</th>
<th scope="col">Nombre</th>
<th scope="col">Identificación</th>
<th scope="col">Fecha Creación</th>
</tr>
</thead>
<c:forEach var="p" items="${info}">
<tr>
<td>${p.idInformacion}</td>
<td>${p.nombre}</td>
<td>${p.pais}</td>
<td><fmt:formatDate pattern="dd/MM/yyyy" value="${p.fechaCreacion}"/></td>
<td>
</td>
</tr>
</c:forEach>
</table>
</form:form>
</body>
</html>
this is the location of my files
can anyone tell me what am i missin because when i try to access to the url localhost:8080/Informacion/Listar the answer is a String that says /ListarInformacion ant its no redirecting me to the page that its supose to redirect
You should try to access localhost:8080/Informacion/Listar as you have already given mapping to the controller class (/Informacion)
the preferred location to put the jsp in a spring boot project is
--webapp
--WEB-INF
--jsp
--your.jsp
in your case it is
-
-webapp
--WEB-INF(Create WEB-INF directory if you don't have)
--Vistas(folder)
--jsp
--hello.jsp
And your view path in properties file will be spring.mvc.view.prefix=/WEB-INF/Vistas

GWT: getting 404 in GWTTestCase when trying to make an Ajax call

I'm using GWT 2.4. I'm trying to write a test case where I make an Ajax call, but I'm getting a 404. Here is how I define the service in my .gwt.xml file ...
<module>
<!-- Inherit our applications main module. -->
<inherits name='com.myco.clearing.product.ProductPlus' />
<!-- Specify the path to any remote services. -->
<servlet path="/xmlhelperservice" class="com.myco.clearing.product.server.XmlHelperServiceImpl" />
</module>
Here is how the interface that the service implements ...
#RemoteServiceRelativePath( "xmlhelperservice" )
public interface XmlHelperService extends RemoteService {
Node getNode(final String fileName) throws IOException;
}
but in my test class (that extends GWTTestCase), I'm getting a 404 when trying to invoke the service ...
public void testDocument() throws Exception {
xmlHelperService = GWT.create(XmlHelperService.class);
xmlHelperService.getNode("doc.xml", new AsyncCallback<Node>() {
#Override
public void onSuccess(Node node) {
...
}
#Override
public void onFailure(Throwable caught) {
caught.printStackTrace(System.err);
fail(caught.getMessage());
}
});
}
What is the right way to define/invoke my service to avoid the 404? Stack trace below. Thanks, - Dave
[WARN] 404 - POST /com.myco.clearing.product.ProductPlusJUnit.JUnit/xmlhelperservice (10.40.70.197) 1450 bytes
com.google.gwt.user.client.rpc.StatusCodeException: 404 <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 404 NOT_FOUND</title>
</head>
<body><h2>HTTP ERROR: 404</h2><pre>NOT_FOUND</pre>
<p>RequestURI=/com.myco.clearing.product.ProductPlusJUnit.JUnit/xmlhelperservice</p><p><i><small>Powered by Jetty://</small></i></p><br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
</body>
</html>
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:209)
at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
at sun.reflect.GeneratedMethodAccessor27.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:220)
at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:662)
See if you have overlooked this in your web.xml file.
<servlet>
<servlet-name>XmlHelperServiceImpl</servlet-name>
<servlet-class>com.myco.clearing.product.server.XmlHelperServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>XmlHelperServiceImpl</servlet-name>
<url-pattern>/com.myco.clearing.product.ProductPlus/xmlhelperservice</url-pattern>
</servlet-mapping>
Also see common pitfalls in this documentation.

hibernate class not found exception

before reading my problem this work in a normal dynamic web project
i create a web service like this methode:
http://www.youtube.com/watch?v=o2Vjs8ylmFM
using CFX 2.4 and with the 2.5 dynamic web model version and when i run hibernate in this current client web project generated by the web service i get an exception
this is it:
Etat HTTP 500 -
--------------------------------------------------------------------------------
type Rapport d''exception
message
description Le serveur a rencontré une erreur interne () qui l'a empêché de satisfaire la requête.
exception
org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.ExceptionInInitializerError
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:531)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
cause mère
javax.servlet.ServletException: java.lang.ExceptionInInitializerError
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:901)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:830)
org.apache.jsp.index_jsp._jspService(index_jsp.java:112)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
cause mère
java.lang.ExceptionInInitializerError
org.apache.jsp.index_jsp._jspService(index_jsp.java:73)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
cause mère
java.lang.RuntimeException: Problème de configuration : persistent class not found
Base.HibernateUtil.<clinit>(HibernateUtil.java:16)
org.apache.jsp.index_jsp._jspService(index_jsp.java:73)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
cause mère
net.sf.hibernate.MappingException: persistent class not found
net.sf.hibernate.cfg.Binder.bindClass(Binder.java:76)
net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:165)
net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1095)
net.sf.hibernate.cfg.Configuration.add(Configuration.java:230)
net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:252)
net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:273)
net.sf.hibernate.cfg.Configuration.configure(Configuration.java:841)
net.sf.hibernate.cfg.Configuration.configure(Configuration.java:792)
net.sf.hibernate.cfg.Configuration.configure(Configuration.java:732)
net.sf.hibernate.cfg.Configuration.configure(Configuration.java:719)
Base.HibernateUtil.<clinit>(HibernateUtil.java:14)
org.apache.jsp.index_jsp._jspService(index_jsp.java:73)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
cause mère
java.lang.ClassNotFoundException: Favorieensei
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1671)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:169)
net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:268)
net.sf.hibernate.cfg.Binder.bindClass(Binder.java:73)
net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:165)
net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1095)
net.sf.hibernate.cfg.Configuration.add(Configuration.java:230)
net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:252)
net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:273)
net.sf.hibernate.cfg.Configuration.configure(Configuration.java:841)
net.sf.hibernate.cfg.Configuration.configure(Configuration.java:792)
net.sf.hibernate.cfg.Configuration.configure(Configuration.java:732)
net.sf.hibernate.cfg.Configuration.configure(Configuration.java:719)
Base.HibernateUtil.<clinit>(HibernateUtil.java:14)
org.apache.jsp.index_jsp._jspService(index_jsp.java:73)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
note La trace complète de la cause mère de cette erreur est disponible dans les fichiers journaux de Apache Tomcat/7.0.5.
--------------------------------------------------------------------------------
Apache Tomcat/7.0.5
and my class hibernateUtil is :
package DBase;
import net.sf.hibernate.*;
import net.sf.hibernate.cfg.*;
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
// Crée la SessionFactory
sessionFactory =
new Configuration().configure().buildSessionFactory();
} catch (HibernateException ex) {
throw new RuntimeException("Problème de configuration : "
+ ex.getMessage(), ex);
}
}
public static final ThreadLocal session = new ThreadLocal();
public static Session currentSession()
throws HibernateException {
Session s = (Session) session.get();
// Ouvre une nouvelle Session, si ce Thread n'en a aucune
if (s == null) {
s = sessionFactory.openSession();
session.set(s);
}
return s;
}
and my hibernate.cfg.xml page is:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory >
<!-- local connection properties -->
<property name="hibernate.connection.url">jdbc:mysql://localhost/ebook</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">162826</property>
<!-- property name="hibernate.connection.pool_size"></property -->
<!-- dialect for MySQL -->
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<property name="current_session_context_class">thread</property>
<mapping resource="DBase/Favorieensei.hbm" />
<mapping resource="DBase/Ajouter.hbm" />
<mapping resource="DBase/Favorie.hbm" />
<mapping resource="DBase/Enseignant.hbm" />
and this is my page jsp
<%#page import="DBase.HibernateUtil"%>
<%# page import="java.io.*" %>
<%# page import="java.util.*" %>
<%# page import="DBase.*" %>
<%# page import="net.sf.hibernate.*" %>
<%# page import="net.sf.hibernate.cfg.*" %>
<HTML>
<HEAD>
<title>Greetings!</title>
</HEAD>
<BODY>
<%
Session hibernateSession = HibernateUtil.currentSession();
Transaction tx = hibernateSession.beginTransaction();
Etudinat etudiant = new Etudinat();
etudiant.setUserName("davido");
etudiant.setPassword("mioo");
etudiant.setQuestion("best music");
etudiant.setAnswer("rock");
etudiant.setEmail("david#live.fr");
etudiant.setNom(".....");
etudiant.setPrenom("....");
etudiant.setSexe("Homme");
etudiant.setIDFilliere(Filliere.INFORMATIQUE);
hibernateSession.save(etudiant);
tx.commit();
HibernateUtil.closeSession();
%>
<br>
<br>
<br>
<br>
<table width="400" border="0" cellspacing="1" cellpadding="0" align="center" class="tableBox">
<tr>
<td CLASS="bluebanner" align="center"> Greetings, </TD>
</tr>
</table>
</BODY>
</HTML>
this is my screan shot
plz help us we are running on time i have 3 left to finish it
The stack trace clearly states that class Favorieensei is missing. You need to check your project structure.

HtmlUnit & GWT error

I've a GWT application that I try to index.
I am using HtmlUnit to get the content of the generated HTML:
WebClient webClient = new WebClient(BrowserVersion.FIREFOX_3_6);
HtmlPage refDesing = webClient.getPage("http://localhost:8080/MyGWTApp/#page2");
FileOutputStream fos1 = new FileOutputStream("D:\\work\\out\\page2.html");
fos1.write(refDesing.asXml().getBytes());
fos1.close();
But I get the following error and the page returned approximately empty!
Dec 22, 2010 6:16:25 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNING: Expected content type of 'application/javascript' or 'application/ecmascript' for remotely loaded JavaScript element at 'http://xxxxxxxxxxxx/xxxxxxxx/xxxxxxxx/xxxxxxxxxx.nocache.js', but got 'application/x-javascript'.
Dec 22, 2010 6:16:27 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [485:24] Error in expression. Invalid token "=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>, <STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>, <FUNCTION>, <IDENT>.
Dec 22, 2010 6:16:27 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [485:29] Error in style rule. Invalid token "\n". Was expecting one of: "}", ";".
Dec 22, 2010 6:16:27 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning
WARNING: CSS warning: null [485:29] Ignoring the following declarations in this rule.
Dec 22, 2010 6:16:27 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [518:24] Error in expression. Invalid token "=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>, <STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>, <FUNCTION>, <IDENT>.
Dec 22, 2010 6:16:27 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [518:29] Error in style rule. Invalid token "\n ". Was expecting one of: "}", ";".
Dec 22, 2010 6:16:27 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning
WARNING: CSS warning: null [518:29] Ignoring the following declarations in this rule.
Dec 22, 2010 6:16:27 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [541:24] Error in expression. Invalid token "=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>, <STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>, <FUNCTION>, <IDENT>.
Dec 22, 2010 6:16:27 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [541:29] Error in style rule. Invalid token "\n ". Was expecting one of: "}", ";".
Dec 22, 2010 6:16:27 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning
WARNING: CSS warning: null [541:29] Ignoring the following declarations in this rule.
Dec 22, 2010 6:16:27 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [951:24] Error in expression. Invalid token "=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>, <STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>, <FUNCTION>, <IDENT>.
Dec 22, 2010 6:16:27 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [951:29] Error in style rule. Invalid token "\n". Was expecting one of: "}", ";".
Dec 22, 2010 6:16:27 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning
WARNING: CSS warning: null [951:29] Ignoring the following declarations in this rule.
Dec 22, 2010 6:16:27 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [977:24] Error in expression. Invalid token "=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>, <STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>, <FUNCTION>, <IDENT>.
Dec 22, 2010 6:16:27 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [977:29] Error in style rule. Invalid token "\n". Was expecting one of: "}", ";".
Dec 22, 2010 6:16:27 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning
WARNING: CSS warning: null [977:29] Ignoring the following declarations in this rule.
EDIT:
What I mean by approximately empty is, here's snapshot of the returned HTML:
Please note that, not all data that is displayed in the original page (which original got from DB) is returned by HtmlUnit. Also What "?" means? I don't think it means any encoding error cause all words are clear ASCII characters.
<td align="center" style="vertical-align: top;">
<table class="refDesignGrid" cellspacing="5">
<colgroup>
<col/>
</colgroup>
<tbody align="left">
<tr>
<td align="left" style="vertical-align: top;">
<table cellpadding="0" class="categoryItem" cellspacing="0">
<tbody align="left">
<tr>
<td align="left" style="vertical-align: top;">
<div class="header4">
C++
</div>
</td>
</tr>
</tbody>
</table>
</td>
<td align="left" style="vertical-align: top;">
<table cellpadding="0" class="categoryItem" cellspacing="0">
<tbody align="left">
<tr>
<td align="left" style="vertical-align: top;">
<div class="header4">
Java
</div>
</td>
</tr>
</tbody>
</table>
</td>
<td align="left">
<table cellpadding="0" class="categoryItem" cellspacing="0">
<tbody align="left">
<tr>
<td align="left" style="vertical-align: top;">
<div class="header4">
C#
</div>
</td>
</tr>
</tbody>
</table>
</td>
<td>
?
</td>
</tr>
<tr>
<td>
?
</td>
<td>
?
</td>
<td>
?
</td>
<td>
?
</td>
</tr>
<tr>
<td>
?
</td>
<td>
?
</td>
<td>
?
</td>
<td>
?
</td>
</tr>
<tr>
<td>
?
</td>
<td>
?
</td>
<td>
?
</td>
<td>
?
</td>
</tr>
<tr>
<td>
?
</td>
<td>
?
</td>
<td>
?
</td>
<td>
?
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
HtmlUnit can be kinda chatty, and in particular can make things look worse than they are.
Create these two classes:
import org.w3c.css.sac.CSSException;
import org.w3c.css.sac.CSSParseException;
import com.gargoylesoftware.htmlunit.DefaultCssErrorHandler;
/*
* get rid of warnings... and provide a place to hang a break point
*/
public class QuietCssErrorHandler
extends DefaultCssErrorHandler
{
#Override public void error( CSSParseException e ) throws CSSException
{
super.error( e ) ;
}
#Override public void fatalError( CSSParseException e ) throws CSSException
{
super.fatalError( e ) ;
}
#Override public void warning( CSSParseException e ) throws CSSException
{
}
}
and
import com.gargoylesoftware.htmlunit.IncorrectnessListener;
public class SilentIncorrectnessListener
implements IncorrectnessListener
{
#Override public void notify( String message, Object origin )
{
// do nuttin' honey!
}
}
then when you create your WebClient...
wc.setIncorrectnessListener( new SilentIncorrectnessListener() ) ;
wc.setCssErrorHandler( new QuietCssErrorHandler() ) ;
And you should then get fewer warnings.
As for "approximately empty"... what does that mean?
Answer is here:
http://htmlunit.sourceforge.net/faq.html#AJAXDoesNotWork
The main thread using HtmlUnit may be finishing execution before
allowing background threads to run. You have a couple of options:
webClient.setAjaxController(new
NicelyResynchronizingAjaxController()); will tell your WebClient
instance to re-synchronize asynchronous XHR.
webClient.waitForBackgroundJavaScript(10000); or
webClient.waitForBackgroundJavaScriptStartingBefore(10000); just after
getting the page and before manipulating it. Explicitly wait for a
condition that is expected be fulfilled when your JavaScript runs,
e.g.
//try 20 times to wait .5 second each for filling the page.
for (int i = 0; i < 20; i++) {
if (condition_to_happen_after_js_execution) {
break;
}
synchronized (page) {
page.wait(500);
}
}