<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Últimas mensagens do tópico "Problema: javax.servlet.ServletException"]]></title>
		<link>http://www.guj.com.br/posts/list/6.java</link>
		<description><![CDATA[Últimas mensagens enviadas no tópico "Problema: javax.servlet.ServletException"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>Problema: javax.servlet.ServletException</title>
				<description><![CDATA[ Pessoal, <br /> <br /> estou desenvolvendo um sistema usando JSF, MyFaces, Tomahawk e Hibernate. <br /> O erro que recebo na página é o seguinte: [quote]HTTP Status 500 - <br /> <br /> --------------------------------------------------------------------------------<br /> <br /> type Exception report<br /> <br /> message <br /> <br /> description The server encountered an internal error () that prevented it from fulfilling this request.<br /> <br /> exception <br /> <br /> javax.servlet.ServletException: Filter execution threw an exception<br /> <br /> <br /> root cause <br /> <br /> java.lang.NoClassDefFoundError: Could not initialize class br.com.acesso.jsf.hibernate.hibernateutil.HibernateUtil<br /> 	br.com.acesso.jsf.hibernate.sessionfilter.HibernateSessionFilter.doFilter(HibernateSessionFilter.java:23)<br /> <br /> <br /> note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.<br /> [/quote]<br /> No console: [quote]SEVERE: Servlet.service() for servlet FacesServlet threw exception<br /> java.lang.NoClassDefFoundError: Could not initialize class br.com.acesso.jsf.hibernate.hibernateutil.HibernateUtil<br /> 	at br.com.acesso.jsf.hibernate.sessionfilter.HibernateSessionFilter.doFilter(HibernateSessionFilter.java:23)<br /> 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)<br /> 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)<br /> 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)<br /> 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)<br /> 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)<br /> 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)<br /> 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)<br /> 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)<br /> 	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)<br /> 	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)<br /> 	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)<br /> 	at java.lang.Thread.run(Unknown Source)<br /> [/quote]<br /> Segue o arquivo web.xml: [code]&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br /> &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br /> 	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"<br /> 	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"<br /> 	id="WebApp_ID" version="2.5"&gt;<br /> <br /> 	&lt;!-- Welcome files --&gt;<br /> 	&lt;welcome-file-list&gt;<br /> 		&lt;welcome-file&gt;index.html&lt;/welcome-file&gt;<br /> 		&lt;welcome-file&gt;index.htm&lt;/welcome-file&gt;<br /> 		&lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;<br /> 	&lt;/welcome-file-list&gt;<br /> <br /> 	&lt;description&gt;debug web.xml&lt;/description&gt;<br /> <br /> 	&lt;!-- Context Param --&gt;<br /> 	&lt;context-param&gt;<br /> 		&lt;param-name&gt;javax.faces.STATE_SAVING_METHOD&lt;/param-name&gt;<br /> 		&lt;param-value&gt;server&lt;/param-value&gt;<br /> 	&lt;/context-param&gt;<br /> 	<br /> 	&lt;context-param&gt;<br /> 		&lt;param-name&gt;org.apache.myfaces.ALLOW_JAVASCRIPT&lt;/param-name&gt;<br /> 		&lt;param-value&gt;true&lt;/param-value&gt;<br /> 	&lt;/context-param&gt;<br /> 	<br /> 	&lt;context-param&gt;<br /> 		&lt;param-name&gt;org.apache.myfaces.DETECT_JAVASCRIPT&lt;/param-name&gt;<br /> 		&lt;param-value&gt;false&lt;/param-value&gt;<br /> 	&lt;/context-param&gt;<br /> 	<br /> 	&lt;context-param&gt;<br /> 		&lt;param-name&gt;org.apache.myfaces.PRETTY_HTML&lt;/param-name&gt;<br /> 		&lt;param-value&gt;true&lt;/param-value&gt;<br /> 	&lt;/context-param&gt;<br /> 	<br /> 	&lt;context-param&gt;<br /> 		&lt;param-name&gt;org.apache.myfaces.AUTO_SCROLL&lt;/param-name&gt;<br /> 		&lt;param-value&gt;true&lt;/param-value&gt;<br /> 	&lt;/context-param&gt;<br /> <br /> 	&lt;!-- Faces Servlet --&gt;<br /> 	&lt;servlet&gt;<br /> 	  &lt;servlet-name&gt;FacesServlet&lt;/servlet-name&gt; <br />   	  &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt; <br />   		&lt;load-on-startup&gt;1&lt;/load-on-startup&gt; <br /> 	 &lt;/servlet&gt;<br /> 	&lt;servlet-mapping&gt;<br />   		&lt;servlet-name&gt;FacesServlet&lt;/servlet-name&gt; <br />   		&lt;url-pattern&gt;*.jsf&lt;/url-pattern&gt; <br />   	&lt;/servlet-mapping&gt;<br /> <br /> 	&lt;!-- Hibernate Filter --&gt;<br /> 	&lt;filter&gt;<br /> 		&lt;filter-name&gt;hibernateFilter&lt;/filter-name&gt;<br /> 		&lt;filter-class&gt;br.com.acesso.jsf.hibernate.sessionfilter.HibernateSessionFilter&lt;/filter-class&gt;<br /> 	&lt;/filter&gt;<br /> 	&lt;filter-mapping&gt;<br /> 		&lt;filter-name&gt;hibernateFilter&lt;/filter-name&gt;<br /> 		&lt;url-pattern&gt;*.jsf&lt;/url-pattern&gt;<br /> 	&lt;/filter-mapping&gt;<br /> <br /> 	&lt;!-- Extensions Filter --&gt;<br /> 	&lt;filter&gt;<br /> 		&lt;filter-name&gt;MyFacesExtensionsFilter&lt;/filter-name&gt;<br /> 		&lt;filter-class&gt;org.apache.myfaces.webapp.filter.ExtensionsFilter&lt;/filter-class&gt;<br /> 		&lt;init-param&gt;<br /> 			&lt;param-name&gt;uploadMaxFileSize&lt;/param-name&gt;<br /> 			&lt;param-value&gt;20m&lt;/param-value&gt;<br /> 		&lt;/init-param&gt;<br /> 		&lt;init-param&gt; <br /> 			&lt;param-name&gt;uploadThresholdSize&lt;/param-name&gt; <br />   			&lt;param-value&gt;100k&lt;/param-value&gt; <br /> 		&lt;/init-param&gt;<br /> 	&lt;/filter&gt;<br /> 	&lt;filter-mapping&gt;<br /> 		&lt;filter-name&gt;MyFacesExtensionsFilter&lt;/filter-name&gt;<br /> 		&lt;url-pattern&gt;*.jsf&lt;/url-pattern&gt;<br /> 	&lt;/filter-mapping&gt;<br /> 	&lt;filter-mapping&gt;<br /> 		&lt;filter-name&gt;MyFacesExtensionsFilter&lt;/filter-name&gt;<br /> 		&lt;url-pattern&gt;/faces/*&lt;/url-pattern&gt;<br /> 	&lt;/filter-mapping&gt;<br /> <br /> &lt;/web-app&gt;[/code]<br /> <br /> HibernateSessionFilter.java: [code]package br.com.acesso.jsf.hibernate.sessionfilter;<br /> <br /> public class HibernateSessionFilter implements Filter {<br /> 	public void doFilter(ServletRequest servletRequest,	ServletResponse servletResponse, FilterChain filterChain) throws ServletException {<br /> 		try {<br /> 			HibernateUtil.openSession();<br /> 			HibernateUtil.currentSession().beginTransaction();<br /> 			filterChain.doFilter(servletRequest, servletResponse);<br /> 			HibernateUtil.currentSession().getTransaction().commit();<br /> 		} catch (Exception e) {<br /> 			HibernateUtil.currentSession().getTransaction().rollback();<br /> 			throw new ServletException(e);<br /> 		} finally {<br /> 			HibernateUtil.closeCurrentSession();<br /> 		}<br /> 	}<br /> <br /> 	public void destroy() {<br /> <br /> 	}<br /> <br /> 	public void init(FilterConfig arg0) throws ServletException {<br /> <br /> 	}<br /> }[/code]<br /> HibernateUtil.java: [code]package br.com.acesso.jsf.hibernate.hibernateutil;<br /> <br /> public class HibernateUtil {<br /> 	private static ThreadLocal&lt;Session&gt; sessions;<br /> <br /> 	private static SessionFactory sessionFactory;<br /> 	static {<br /> 		sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();<br /> 		sessions= new ThreadLocal&lt;Session&gt;();<br /> 	}<br /> <br /> 	public static Session openSession() {<br /> 		return sessionFactory.openSession();<br /> 	}<br /> <br /> 	public static Session getCurrentSession() {<br /> 		if (sessions.get() == null) {<br /> 			sessions.set(openSession());<br /> 		}<br /> 		return sessions.get();<br /> 	}<br /> <br /> 	public static void closeCurrentSession() {<br /> 		getCurrentSession().close();<br /> 		sessions.set(null);<br /> 	}<br /> }[/code]<br /> <br /> Alguém pode ajudar?<br /> <br /> Abraços...]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/195462/981352/problema-javaxservletservletexception
</guid>
				<link>http://www.guj.com.br/prepost/195462/981352/problema-javaxservletservletexception
</link>
				<pubDate><![CDATA[Mon, 22 Dec 2008 18:09:13]]> GMT</pubDate>
				<author><![CDATA[ serjaumfantinPJ]]></author>
			</item>
			<item>
				<title>Re:Problema: javax.servlet.ServletException</title>
				<description><![CDATA[ O seu problema é classpath mesmo...<br /> <br /> O teu filter não está encontrando em tempo de runtime esta classe: br.com.acesso.jsf.hibernate.hibernateutil.HibernateUtil <br /> <br /> Verifique onde ela está e se está sendo empacotada junto com o teu war.<br /> <br /> Abraços]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/195462/981362/reproblema-javaxservletservletexception
</guid>
				<link>http://www.guj.com.br/prepost/195462/981362/reproblema-javaxservletservletexception
</link>
				<pubDate><![CDATA[Fri, 26 Dec 2008 17:04:18]]> GMT</pubDate>
				<author><![CDATA[ eltonkPJ]]></author>
			</item>
	</channel>
</rss>
