[JBoss Seam] - s:fileUpload error
by demetrio812
Hi,
I read about 50 posts, tried a lot of combination but a simple file upload is not working in my app (Seam 2B1, JBoss AS 4.2.1GA)...I made to work about 2 months ago (Seam 1.2.1GA, JBoss AS 4.0.X).
I tried SEAM POJO, SLSB, SFSB with CONVERSATION or EVENT scope, tried InputStream for data field but also byte[], add Seam Multipart Filter (org.jboss.seam.web.MultipartFilter) to web.xml but it doesn't work!
this is my configuration:
web.xml:
| <?xml version="1.0" ?>
| <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
| version="2.5">
|
| <!-- Ajax4jsf -->
|
| <context-param>
| <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
| <param-value>com.sun.facelets.FaceletViewHandler</param-value>
| </context-param>
|
| <context-param>
| <param-name>org.ajax4jsf.SKIN</param-name>
| <param-value>blueSky</param-value>
| </context-param>
|
| <!-- Seam -->
|
| <listener>
| <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
| </listener>
|
| <filter>
| <filter-name>Seam Filter</filter-name>
| <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
| </filter>
|
| <filter-mapping>
| <filter-name>Seam Filter</filter-name>
| <url-pattern>/*</url-pattern>
| </filter-mapping>
|
| <servlet>
| <servlet-name>Seam Resource Servlet</servlet-name>
| <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
| </servlet>
|
| <servlet-mapping>
| <servlet-name>Seam Resource Servlet</servlet-name>
| <url-pattern>/seam/resource/*</url-pattern>
| </servlet-mapping>
|
| <!-- Facelets development mode (disable in production) -->
|
| <context-param>
| <param-name>facelets.DEVELOPMENT</param-name>
| <param-value>true</param-value>
| </context-param>
|
| <!-- JSF -->
|
| <context-param>
| <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
| <param-value>.xhtml</param-value>
| </context-param>
|
| <servlet>
| <servlet-name>Faces Servlet</servlet-name>
| <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
| <load-on-startup>1</load-on-startup>
| </servlet>
|
| <servlet-mapping>
| <servlet-name>Faces Servlet</servlet-name>
| <url-pattern>*.seam</url-pattern>
| </servlet-mapping>
|
| <security-constraint>
| <display-name>Restrict raw XHTML Documents</display-name>
| <web-resource-collection>
| <web-resource-name>XHTML</web-resource-name>
| <url-pattern>*.xhtml</url-pattern>
| </web-resource-collection>
| <auth-constraint/>
| </security-constraint>
|
| <context-param>
| <param-name>facelets.LIBRARIES</param-name>
| <param-value>/WEB-INF/tomahawk.taglib.xml</param-value>
| </context-param>
| <!-- Tomahawk -->
| <filter>
| <filter-name>MyFacesExtensionsFilter</filter-name>
| <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
| <init-param>
| <param-name>maxFileSize</param-name>
| <param-value>20m</param-value>
| </init-param>
| </filter>
|
| <!-- extension mapping for adding <script/>, <link/>, and other resource tags to JSF-pages -->
| <filter-mapping>
| <filter-name>MyFacesExtensionsFilter</filter-name>
| <!-- servlet-name must match the name of your javax.faces.webapp.FacesServlet entry -->
| <servlet-name>Faces Servlet</servlet-name>
| </filter-mapping>
|
| <!-- extension mapping for serving page-independent resources (javascript, stylesheets, images, etc.) -->
| <filter-mapping>
| <filter-name>MyFacesExtensionsFilter</filter-name>
| <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
| </filter-mapping>
|
| <!-- Parametri applicazione -->
| <context-param>
| <param-name>id_tipologia_admin</param-name>
| <param-value>1</param-value>
| </context-param>
| <context-param>
| <param-name>id_tipologia_editor</param-name>
| <param-value>2</param-value>
| </context-param>
| <context-param>
| <param-name>id_tipologia_guest</param-name>
| <param-value>3</param-value>
| </context-param>
| <context-param>
| <param-name>id_tipologia_iscritto_newsletter</param-name>
| <param-value>4</param-value>
| </context-param>
| <context-param>
| <param-name>id_lingua_default</param-name>
| <param-value>1</param-value>
| </context-param>
| <context-param>
| <param-name>id_configurazione</param-name>
| <param-value>1</param-value>
| </context-param>
|
|
| </web-app>
|
|
component.xml:
| <?xml version="1.0" encoding="UTF-8"?>
| <components xmlns="http://jboss.com/products/seam/components"
| xmlns:core="http://jboss.com/products/seam/core"
| xmlns:persistence="http://jboss.com/products/seam/persistence"
| xmlns:drools="http://jboss.com/products/seam/drools"
| xmlns:bpm="http://jboss.com/products/seam/bpm"
| xmlns:security="http://jboss.com/products/seam/security"
| xmlns:mail="http://jboss.com/products/seam/mail"
| xmlns:web="http://jboss.com/products/seam/web"
| xmlns:framework="http://jboss.com/products/seam/framework"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation=
| "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd
| http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd
| http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.0.xsd
| http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.0.xsd
| http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
| http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.0.xsd
| http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.0.xsd
| http://jboss.com/products/seam/framework http://jboss.com/products/seam/framework-2.0.xsd
| http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd">
|
| <core:init debug="@debug@" jndi-pattern="@jndiPattern@"/>
|
| <core:manager concurrent-request-timeout="500"
| conversation-timeout="120000"
| conversation-id-parameter="cid"/>
|
| <persistence:managed-persistence-context name="entityManager"
| auto-create="true"
| persistence-unit-jndi-name="java:/unica2EntityManagerFactory"/>
|
| <drools:rule-base name="securityRules">
| <drools:rule-files>
| <value>/security.drl</value>
| </drools:rule-files>
| </drools:rule-base>
|
| <security:identity authenticate-method="#{authenticator.authenticate}"
| security-rules="#{securityRules}"/>
|
| <event type="org.jboss.seam.notLoggedIn">
| <action expression="#{redirect.captureCurrentView}"/>
| </event>
| <event type="org.jboss.seam.postAuthenticate">
| <action expression="#{redirect.returnToCapturedView}"/>
| </event>
|
| <mail:mail-session host="out.virgilio.it" port="25" debug="true"
| ssl="false" />
|
| <!-- For use with jBPM pageflow or process management -->
| <!--
| <bpm:jbpm>
| <bpm:process-definitions></bpm:process-definitions>
| <bpm:pageflow-definitions></bpm:pageflow-definitions>
| </bpm:jbpm>
| -->
|
| <web:multipart-filter create-temp-files="true"
| max-request-size="10000000" url-pattern="*.seam">
| </web:multipart-filter>
|
| <core:resource-loader>
| <core:bundle-names>
| <value>messages</value>
| <value>messages_site</value>
| <value>messages_articles</value>
| <value>messages_articles_list</value>
| <value>messages_articles_form</value>
| </core:bundle-names>
| </core:resource-loader>
|
| </components>
|
home.xhtml:
| <?xml version="1.0" encoding="iso-8859-1"?>
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
| "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
| <ui:composition xmlns="http://www.w3.org/1999/xhtml"
| xmlns:s="http://jboss.com/products/seam/taglib"
| xmlns:ui="http://java.sun.com/jsf/facelets"
| xmlns:f="http://java.sun.com/jsf/core"
| xmlns:h="http://java.sun.com/jsf/html"
| xmlns:rich="http://richfaces.ajax4jsf.org/rich"
| template="layout/template.xhtml">
|
| <ui:define name="body">
|
| <h:messages styleClass="message"/>
|
| <h:form enctype="multipart/form-data">
| <rich:panel>
| <f:facet name="header">Test</f:facet>
|
| <s:decorate id="fileUploadDecoration" template="layout/edit.xhtml">
| <ui:define name="label">Image</ui:define>
| <s:fileUpload id="file" data="#{uploadFile.uploadedFile}"
| />
| </s:decorate>
|
| <div style="clear:both"/>
| </rich:panel>
| <div class="actionButtons">
| <h:commandButton value="Upload" action="#{uploadFile.parse}">
|
| </h:commandButton>
| </div>
| </h:form>
| </ui:define>
| </ui:composition>
|
UploadFile.java:
| package com.novaware.unica;
|
| import java.io.InputStream;
| import java.io.Serializable;
|
| import javax.ejb.Remove;
| import javax.ejb.Stateful;
| import javax.ejb.Stateless;
|
| import org.jboss.seam.ScopeType;
| import org.jboss.seam.annotations.Destroy;
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Logger;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.Scope;
| import org.jboss.seam.faces.FacesMessages;
| import org.jboss.seam.log.Log;
|
|
| @Name("uploadFile")
| @Stateful // I also tried Stateless
| @Scope(ScopeType.EVENT) //I also tried CONVERSATION
| public class UploadFile implements IUploadFile { // Also tried Seam Pojo
| @Logger
| Log log;
|
| @In FacesMessages facesMessages;
|
| private byte[] uploadedFile; // I also tried with InputStream
| private String uploadedFileName;
| private String contentType;
|
| public void parse() throws Exception {
| log.info("File:"+uploadedFile+" - "+uploadedFileName+" - "+contentType);
| }
|
| public void setUploadedFile(byte[] uploadedFile)
| {
| this.uploadedFile = uploadedFile;
| }
|
| public byte[] getUploadedFile()
| {
| return uploadedFile;
| }
|
| public String getUploadedFileName() {
| return uploadedFileName;
| }
|
|
| public void setUploadedFileName(String uploadedFileName) {
| this.uploadedFileName = uploadedFileName;
| }
|
| public String getContentType() {
| return contentType;
| }
|
| public void setContentType(String contentType) {
| this.contentType = contentType;
| }
|
| @Destroy @Remove
| public void destroy() {
| }
| }
|
IUploadFile.java:
| package com.novaware.unica;
|
| import java.io.InputStream;
|
| import javax.ejb.Local;
|
| @Local
| public interface IUploadFile {
|
| public abstract void parse() throws Exception;
|
| public abstract void setUploadedFile(byte[] uploadedFile);
|
| public abstract byte[] getUploadedFile();
|
| public abstract String getUploadedFileName();
|
| public abstract void setUploadedFileName(String uploadedFileName);
|
| public abstract String getContentType();
|
| public abstract void setContentType(String contentType);
|
| public void destroy();
| }
|
where is the error?
thanks!
Demetrio Filocamo
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4077020#4077020
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4077020
18Â years, 8Â months
[JBoss Seam] - Identity check during hibernate operaiotn in application com
by rpochet
Hi,
I'm trying to execute database insert during creation of an application scope component
| @Scope(value=ScopeType.APPLICATION)
| @Name("initialisation")
| @Startup(depends="hibernateSessionFactory")
| public class Initialisation
| {
| @Logger
| private Log logger = null;
|
| @In
| private Session homeDatabase = null;
|
| @Create
| @CreateProcess(definition="discoveryAll")
| public void init()
| {
| homeDatabase.save(...);
| }
| {
but I got a
java.lang.IllegalStateException: No active session context
| at org.jboss.seam.security.Identity.instance(Identity.java:157)
| at org.jboss.seam.security.HibernateSecurityInterceptor.onSave(HibernateSecurityInterceptor.java:73)
| at org.hibernate.event.def.AbstractSaveEventListener.substituteValuesIfNecessary(AbstractSaveEventListener.java:394)
| at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:270)
| at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
| at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107)
| at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
| at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
| at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
| at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
| at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
| at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
| at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
| at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
| at org.hibernate.search.impl.FullTextSessionImpl.save(FullTextSessionImpl.java:439)
| at org.jboss.seam.persistence.HibernateSessionProxy.save(HibernateSessionProxy.java:335)
|
because there is no identity currently defined.
By setting
Identity.setSecurityEnabled(false);
it works but this disabled all security check.
Any idea on how to handle such feature?
Thanks,
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4077019#4077019
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4077019
18Â years, 8Â months
[EJB 3.0] - Re: EJB3 client error - java.io.EOF exception
by Jihnd
whooohoo, got the ejb deployed, turns out i had to adjust the jndi properties file in the conf directory -
here's what workedanonymous wrote :
| java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
| java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
| java.naming.provider.url=localhost:1200
(previously just had the first line in there)
i remembered it being 1200 from looking up naming on the jmx console
so, back round to the original problem, my client is still hanging!
gettting lots of this;anonymous wrote :
| 2007-08-22 19:30:57,093 DEBUG [org.jboss.resource.connectionmanager.IdleRemover] run: IdleRemover notifying pools, interval: 450000
that i'm fairly sure will culminate with Caused by: java.io.EOFException
think i now need to adjust my timeouts else i'm going to be waiting another 5hours for the stack trace, will update and in the meanwhile, if anyone has any ideas, be very grateful
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4077009#4077009
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4077009
18Â years, 8Â months