olá pessoal do pj estou enfrentando um problema que ja esta quase completando 1 semana.
estou tentando criar 1 componente pra jsf, que extende as funçoes de 1 DataTable da JSF RI.
criei 1 componente que extende DataTable, 1 que extende DataTableTag
criei o tld do meu componente, configurei o faces-config;
quando eu incluo o meu componente jsf em uma pagina jsf, é lançado a seguinte exception:
java.lang.VerifyError: Cannot inherit from final class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1997)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:948)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1428)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1292)
at org.apache.jasper.compiler.JspDocumentParser.parseCustomAction(JspDocumentParser.java:1180)
at org.apache.jasper.compiler.JspDocumentParser.startElement(JspDocumentParser.java:413)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:533)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:330)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
at org.apache.jasper.compiler.JspDocumentParser.parse(JspDocumentParser.java:187)
at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:197)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:113)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:224)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:526)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:507)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:495)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:530)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:412)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:318)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:397)
at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:850)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:697)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:532)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:465)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:353)
at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:413)
at com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:480)
at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:125)
at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:229)
at com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.renderView(ViewHandlerImpl.java:285)
at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:229)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:133)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:244)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:140)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:397)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:184)
at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:96)
at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:220)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:216)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:184)
at com.sun.webui.jsf.util.UploadFilter.doFilter(UploadFilter.java:240)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:216)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:184)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:216)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:184)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:276)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:179)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:182)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:239)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:667)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.java:574)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844)
at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:287)
at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:212)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)
at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)
segue meu tld
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>dl</short-name>
<uri>http://company.com/faces</uri>
<tag>
<name>pagedDataTable</name>
<tag-class>com.company.faces.tags.PagedDataTableTag</tag-class>
atributos.....
<taglib>
seque minha classe que extende o DataTableTag:
package com.company.faces.tags;
import com.sun.faces.taglib.html_basic.DataTableTag;
/**
* @author rafael.bohnen
*/
public class PagedDataTableTag extends DataTableTag {
public String getComponentType() {
System.out.println("PagedDataTableTag.getComponentType");
return "PagedDataTable";
}
public String getRendererType() {
return null;
}
}
no meu faces-config.xml tenho:
<component>
<component-type>pagedDataTable</component-type>
<component-class>com.company.faces.component.PagedDataTable</component-class>
</component>
sedue minha classe que extende DataTable
package com.company.faces.component;
import com.company.faces.model.PagedDataModel;
import java.io.IOException;
import java.util.Map;
import javax.faces.component.UIComponent;
import javax.faces.component.UIForm;
import javax.faces.component.html.HtmlDataTable;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
/**
*
* @author Administrador
*/
public class PagedDataTable extends HtmlDataTable {
public PagedDataModel pagedDataModel;//<- extends DataModel
public PagedDataModel getPagedDataModel() {
return pagedDataModel;
}
public void setPagedDataModel(PagedDataModel pagedDataModel) {
this.pagedDataModel = pagedDataModel;
}
/** Creates a new instance of PagedDataTable */
public PagedDataTable() {
super();
System.out.println("instanciando PagedDataTable!");
}
public void encodeBegin(FacesContext context) throws IOException {
System.out.println("PagedDataTable.encodeBegin");
ResponseWriter writer=context.getResponseWriter();
writer.startElement("table",null);
writer.writeAttribute("border","0",null);
writer.writeAttribute("cellpadding","0",null);
writer.writeAttribute("cellspacing","0",null);
writer.startElement("tr",null);
writer.startElement("td",null);
super.encodeBegin(context);
}
public void encodeEnd(FacesContext context) throws IOException {
System.out.println("PagedDataTable.encodeEnd");
super.encodeEnd(context);
ResponseWriter writer=context.getResponseWriter();
writer.endElement("tr");
writer.endElement("td");
writer.startElement("tr",null);
writer.startElement("td",null);
writer.writeAttribute("align","center",null);
this.encodeHiddenField(context,writer);
writer.endElement("tr");
writer.endElement("tr");
writer.endElement("td");
writer.endElement("table");
}
/**
metodo que cria o componente que armazena o numero da pagina atual
*/
private void encodeHiddenField(FacesContext context,ResponseWriter writer) throws IOException {
writer.startElement("input",null);
writer.writeAttribute("type","hidden",null);
writer.writeAttribute("name",(this.getClientId(context)+super.SEPARATOR_CHAR+"page"),null);
writer.endElement("input");
}
}
e enfin no meu jsp
<dl:pagedDataTable binding="#{teste.pagedDataTable1}" value="#{teste.pagedDataModel1}" var="currentRow">
<h:column binding="#{teste.column2}" id="column2">
<h:outputText binding="#{teste.outputText3}" id="outputText3" value="#{currentRow.nomfilial}"/>
<f:facet name="header">
<h:outputText binding="#{teste.outputText4}" id="outputText4" value="Empresa"/>
</f:facet>
</h:column>
</dl:pagedDataTable>
fazendo alguns testes para tentar descobrir qual o erro, pude notar que o mesmo so ocorria quanto PagedDataTableTag extendia DataTableTag, quando trocava a DataTableTag por UIComponentELTag o componente nao lançava a exception.
por enquanto so vejo como alternativa reimplementar todo corpo de dataTableTag;
mas como vi que outras pessoas conseguiram com sucesso fazer isso que estou tentando fazer, gostaria que alguem que por um acaso ja passou por algum problema na criação de componentes me desse uma luz sobre o que estou fazendo de errado.
Lembrando meu intuito é criar 1 componentre que extenda as funcionalidades de datatable;
desde já muito obrigado a todos.
OBS: jsf poderia ser um pouco mais amigavel na criação de componentes