- PR -

JBoss Seamでのファイルアップロード

1
投稿者投稿内容
heero
会議室デビュー日: 2006/03/08
投稿数: 11
投稿日時: 2007-01-26 19:12
お世話になります。JBoss Seamでのファイルアップロードを実行したいのですがうまくいきません。
アップするファイルを選択しcommandButtonをクリック時エラーが表示されアクションメソッドが実行できません。
messageタグでエラーを表示しています。
なにがいけないのかご教授願えませんでしょうか?

jboss-4.0.5.GAでtomahawk-1.1.3.jarを使用しファイルアップロードを試みています。
下記のページを参考に作成してみました。
http://wiki.jboss.org/wiki/Wiki.jsp?page=SeamFileUpload


エラーは以下のとおりです。

エラー内容
-----------------------------------------------
Exception setting property file of base with class
demo.upload.dean.UploadBackingBean$$EnhancerByCGLIB$$281bd0cf,
Bean: demo.upload.dean.UploadBackingBean$$EnhancerByCGLIB$$281bd0cf, property: file, argument type mismatch
-----------------------------------------------


FileUp.jsp
------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>FileUp</title>
</head>
<body>
<f:view>
FileUp
<h:form enctype="multipart/form-data">
<p/>
<h:outputText value=""/>
<h:outputText value="画像ファイル"/>
<t:inputFileUpload id="fileupload" storage="file" value="#{uploadBean.file}"/>
<h:message for="fileupload" showDetail="true" />
<f:verbatim><br></f:verbatim>
<h:commandButton value="Submit" action="#{upload.upload}" />
<p/>
</h:form>
</f:view>
</body>
</html>
-------------------------------------



UploadBackingBean.java
--------------------------------------
package demo.upload.dean;

import org.apache.myfaces.custom.fileupload.UploadedFile;
import org.hibernate.validator.NotNull;
import org.jboss.seam.annotations.Name;

@Name("uploadBean")
public class UploadBackingBean {

private UploadedFile file;

public void setFile(UploadedFile file) {
this.file = file;
}

@NotNull
public UploadedFile getFile() {
return this.file;
}

}
-----------------------------------------



UploadAction.java
-----------------------------------------
package demo.upload.action;

import javax.ejb.Stateless;
import javax.interceptor.Interceptors;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.ejb.SeamInterceptor;

import com.cgrip.reg.demo.upload.dean.UploadBackingBean;

@Stateless
@Name("upload")
@Interceptors(SeamInterceptor.class)
public class UploadAction implements IUploadAction {

/**
* O arquivo que foi enviado.
*/
@In
private UploadBackingBean uploadBean;

public String upload() {
System.out.println("upload");

return "success";
}

}
-----------------------------------------



IUploadAction.java
-----------------------------------------
package demo.upload.action;

import javax.ejb.Local;

@Local
public interface IUploadAction {

public String upload();

}
-----------------------------------------



web.xml
-----------------------------------------
<?xml version="1.0" ?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/navigation.xml</param-value>
</context-param>

<listener>
<listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
</listener>

<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>

<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
<!--
<param-value>client</param-value>
<param-value>server</param-value>
-->
</context-param>

<!-- Facelets -->
<!--
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
-->

<!--
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.jsp</param-value>
</context-param>
-->

<!-- Set character encoding on each request -->
<!--
<filter>
<filter-name>Set Character Encoding</filter-name>
<filter-class>filters.SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
-->

<filter>
<filter-name>Seam Exception Filter</filter-name>
<filter-class>org.jboss.seam.servlet.SeamExceptionFilter</filter-class>
</filter>

<filter>
<filter-name>Seam Redirect Filter</filter-name>
<filter-class>org.jboss.seam.servlet.SeamRedirectFilter</filter-class>
</filter>

<filter>
<filter-name>Seam Servlet Filter</filter-name>
<filter-class>org.jboss.seam.servlet.SeamServletFilter</filter-class>
</filter>

<!-- My Faces Extensions Filter -->
<filter>
<filter-name>extensionsFilter</filter-name>
<filter-class>org.apache.myfaces.component.html.util.ExtensionsFilter</filter-class>
<init-param>
<param-name>uploadMaxFileSize</param-name>
<param-value>100m</param-value>
</init-param>
<init-param>
<param-name>uploadThresholdSize</param-name>
<param-value>100k</param-value>
</init-param>

<!--
<init-param>
<param-name>uploadRepositoryPath</param-name>
<param-value>/temp</param-value>
<description>Set the path where the intermediary files will be stored.
</description>
</init-param>
-->
</filter>

<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>*.seam</url-pattern>
</filter-mapping>

<!-- extension mapping for serving page-independent resources (javascript, stylesheets, images, etc.) -->
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
</filter-mapping>

<context-param>
<param-name>facelets.LIBRARIES</param-name>
<param-value>/WEB-INF/tomahawk.taglib.xml</param-value>
</context-param>



<filter-mapping>
<filter-name>Seam Exception Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<filter-mapping>
<filter-name>Seam Redirect Filter</filter-name>
<url-pattern>*.seam</url-pattern>
</filter-mapping>

<filter-mapping>
<filter-name>Seam Servlet Filter</filter-name>
<url-pattern>*.ajax</url-pattern>
</filter-mapping>

<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet>
<servlet-name>Seam Remoting</servlet-name>
<servlet-class>org.jboss.seam.remoting.SeamRemotingServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.seam</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>Seam Remoting</servlet-name>
<url-pattern>/seam/remoting/*</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>

<security-constraint>
<display-name>Restrict Documents</display-name>
<web-resource-collection>
<web-resource-name>Restrict</web-resource-name>
<url-pattern>*.xhtml</url-pattern>
<url-pattern>*.properties</url-pattern>
<url-pattern>*.xml</url-pattern>
<url-pattern>*.jsp</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>NONE</role-name>
</auth-constraint>
</security-constraint>
</web-app>
-----------------------------------------



[ メッセージ編集済み 編集者: heero 編集日時 2007-02-02 18:11 ]
1

スキルアップ/キャリアアップ(JOB@IT)