Seam Export Datatable以Excel格式

时间:2012-03-21 15:25:35

标签: java maven jboss classpath seam

我正在尝试使用seam将richdata表导出为ex​​cel,然后跟随 http://docs.jboss.org/seam/2.1.0.GA/reference/en-US/html/excel.html#excel.intro

它指示“在您的应用程序中包含Microsoft®Excel®电子表格应用程序支持,在您的WEB-INF / libdirectory中包含jboss-seam-excel.jar以及jxl.jar JAR文件。”

我在网上找到了两个依赖于jar的依赖项。

战争 pom.xml

<dependency>
    <groupId>org.jboss.seam</groupId>
    <artifactId>jboss-seam-excel</artifactId>
    <version>2.2.0.GA</version>
</dependency>
<dependency>
    <groupId>net.sourceforge.jexcelapi</groupId>
    <artifactId>jxl</artifactId>
    <version>2.6.12</version>
</dependency>

的web.xml

    <servlet>
      <servlet-name>Document Store Servlet</servlet-name>
      <servlet-class>org.jboss.seam.document.DocumentStoreServlet</servlet-class>
   </servlet>

   <servlet-mapping>
      <servlet-name>Document Store Servlet</servlet-name>
      <url-pattern>*.xls</url-pattern>
   </servlet-mapping>

   <context-param>
     <param-name>webAppRootKey</param-name>
     <param-value>seam-excel</param-value>
   </context-param>

的components.xml

<components
        xmlns:excel="http://jboss.com/products/seam/excel"
        xmlns:document="http://jboss.com/products/seam/document"

         http://jboss.com/products/seam/excel http://jboss.com/products/seam/excel-2.1.xsd
         http://jboss.com/products/seam/document http://jboss.com/products/seam/document-2.1.xsd">

        <excel:document-store use-extensions="true"/>
        <document:document-store use-extensions="true"/>
</components>

之前我在 components.xml

中也有以下内容
<excel:excelFactory>
   <property name="implementations">
      <key>myExcelExporter</key>
      <value>my.excel.exporter.ExcelExport</value>
   </property>
</excel:excelFactory>

这导致部署异常,也没有人在他们的代码中提到它,我摆脱了这个和部署异常。

jboss-seam-excel-2.1.2.jar jxl-2.6.12.jar 部署在WEB-INF / lib下

但是,我没有在任何地方找到.. org.jboss.seam.excel.DocumentStoreServlet,因此在 web.xml中使用org.jboss.seam.document.DocumentStoreServlet

但是,我在登录时遇到属性未找到异常,下面是完整的错误堆栈跟踪.. loginAction.stationID 与我的更改无关...

17:04:24,934 |WARNING|  [lifecycle:81] /login.xhtml @52,138 value="#{loginAction.stationID}": Target Unreachable, identifier 'loginAction' resolved to null |||| 
javax.el.PropertyNotFoundException: /login.xhtml @52,138 value="#{loginAction.stationID}": Target Unreachable, identifier 'loginAction' resolved to null
    at com.sun.facelets.el.TagValueExpression.getType(TagValueExpression.java:62)
    at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:92)
    at javax.faces.component.UIInput.getConvertedValue(UIInput.java:942)
    at javax.faces.component.UIInput.validate(UIInput.java:868)
    at javax.faces.component.UIInput.executeValidate(UIInput.java:1072)
    at javax.faces.component.UIInput.processValidators(UIInput.java:672)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1058)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1058)
    at javax.faces.component.UIForm.processValidators(UIForm.java:235)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1058)
    at org.ajax4jsf.component.AjaxViewRoot$3.invokeContextCallback(AjaxViewRoot.java:439)
    at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:238)
    at org.ajax4jsf.component.AjaxViewRoot.processValidators(AjaxViewRoot.java:455)
    at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:510)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.billmelater.csa.filters.NewSessionFilter.doFilter(NewSessionFilter.java:89)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.billmelater.csa.filters.Perf4JFilter.doFilter(Perf4JFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
    at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
    at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
    at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
    at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
    at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:680)
17:04:24,942 |SEVERE|  [lifecycle:104] JSF1054: (Phase ID: PROCESS_VALIDATIONS 3, View ID: /login.xhtml) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@42a46d79] |||| 

Deployment Exception : Could not create Component: org.jboss.seam.excel.excelFactory
**Could not create Component: org.jboss.seam.excel.excelFactory** 

添加seam excel依赖项时会发生PropertyNotFoundException。

我在依赖树中看到了这个.. mvn dependency:tree并发现了这个..

[INFO] +- org.jboss.seam:jboss-seam-excel:jar:2.2.0.GA:compile
[INFO] |  \- org.jboss.seam:jboss-seam:ejb:2.2.0.GA:compile
[INFO] |     +- xstream:xstream:jar:1.1.3:compile
[INFO] |     +- xpp3:xpp3_min:jar:1.1.3.4.O:compile
[INFO] |     \- org.jboss.el:jboss-el:jar:1.0_02.CR4:compile
[INFO] +- net.sourceforge.jexcelapi:jxl:jar:2.6.12:compile`

excel jar附带jboss-seam ejb和jboss-el等。我认为org.jboss.el:jboss-el已经与我项目中的那个碰撞..也.. jboss-seam:ejb: 2.2.0.GA ..,尝试将下面的排除放在maven中..但是工作要么......

   <dependency>
        <groupId>org.jboss.seam</groupId>
        <artifactId>jboss-seam-excel</artifactId>
        <version>2.2.0.GA</version>
        <exclusions>
            <exclusion>
                <groupId>ejb</groupId>
                <artifactId>ejb</artifactId>
            </exclusion>
            <exclusion>
                <groupId>javax.el</groupId>
                <artifactId>el-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

2 个答案:

答案 0 :(得分:0)

您使用的是哪个JBoss版本?我假设JBoss 5

检查此参考: https://community.jboss.org/thread/186791

这是旧版本,但也很有帮助:

https://community.jboss.org/thread/184757

我剪切并粘贴了下面的代码,因为我现在无法访问代码,但如果它不正确则会关闭。 您需要在web.xml中引用

<servlet-name>Document Store Servlet Excel</servlet-name>
<servlet-class>org.jboss.seam.excel.DocumentStoreServlet</servlet-class>


<servlet-mapping>
<servlet-name>Document Store Servlet Excel</servlet-name>
<url-pattern>*.xls</url-pattern>
</servlet-mapping>


<context-param>
<param-name>webAppRootKey</param-name>
<param-value>seam-excel</param-value>
</context-param> 

的JBoss-web.xml中

<jboss-web>
<class-loading java2ClassLoadingCompliance="false">
<loader-repository>
seam.jboss.org:loader=seam-excel
<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
</loader-repository>
</class-loading>
</jboss-web>

和components.xml

<components xmlns:excel="http://jboss.com/products/seam/excel"
xmlns:document="http://jboss.com/products/seam/document"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.com/products/seam/document http://jboss.com/products/seam/document-2.1.xsd
http://jboss.com/products/seam/excel http://jboss.com/products/seam/excel-2.1.xsd">

<document:document-store use-extensions="true"></document:document-store>

</components>

答案 1 :(得分:0)

正如我想的那样,我没有正确排除依赖关系,并且与其他依赖项发生冲突。

这是正确的版本......

<dependency>
    <groupId>org.jboss.seam</groupId>
    <artifactId>jboss-seam-excel</artifactId>
    <version>2.2.0.GA</version>
    <exclusions>
        <exclusion>
            <groupId>org.jboss.seam</groupId>
            <artifactId>jboss-seam</artifactId>
         </exclusion>
        <exclusion>
             <groupId>org.jboss.el</groupId>
             <artifactId>jboss-el</artifactId>
          </exclusion>
    </exclusions>
</dependency>

希望这有助于将来的其他人。我必须说这个功能的文档很少,必须去几个论坛才能知道究竟需要什么。我将停止使用POI方法导出excel:)。