3

I want to upload a file to my glassfish v3.0, but when i use richfaces and prime faces, i get problems. Is there any compatibility issue with file uploading in glassfishV3.0? Can files be uploaded to glassfish from a JSF page?

How can is do a very simple file upload to my server from a JSF? What tools should i use? What is the most common and easy approach to file uploading ussing JSF?

Update

Here is the problem i have with rich faces:

What i do first is add the info found at http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/GettingStarted.html#SimpleJSFapplicationwithRichFaces to mi web.xml(Also the richfaces jars inside the classpath in lib folder)

When i start the glassfish server from eclipse i get this message in the console:

WARNING: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory

I have no idea what that means

javing
  • 12,307
  • 35
  • 138
  • 211
  • @sfrk I don't think your problem is glassfish, so what are the problems you get? What does your code look like? This will all help you get answers. Also checkout this (albeit) different, but similar question http://stackoverflow.com/questions/1605758/file-upload-using-richfaces. – Jacob Schoen Mar 24 '11 at 15:16

2 Answers2

1

java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory

It just means that the mentioned class is missing in the classpath. As the package name hints, that class is part of Apache Commons Logging and that its homepage is at http://commons.apache.org/logging where you can download the JAR. Drop it in /WEB-INF/lib folder (which is part of webapp's default classpath) and this exception should disappear.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • The jars are in the /WEB-INF/lib already. What is wrong with the web.xml what i should modify? – javing Mar 24 '11 at 16:05
  • The exception tells it is not. Either it's the wrong JAR or it's not been deployed. – BalusC Mar 24 '11 at 16:06
  • Maybe the jars are broken? At the moment i drop them in the lib folder it says: SEVERE: Exception while loading the app java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory – javing Mar 24 '11 at 16:13
  • You have for sure `commons-logging-1.1.1.jar` file in the `/WEB-INF/lib` folder? You did rebuild/redeploy/republish the webapp and restart the server after adding it? – BalusC Mar 24 '11 at 16:17
  • The reason why is not working, is because the web.xml is ussing – javing Mar 24 '11 at 16:33
  • You don't need to change web.xml. Just set to highest whatever the server supports. The exception message is just telling that commons logging is missing in classpath. Click the download link in my answer, extract the zip file and copy the JAR file into `/WEB-INF/lib`. – BalusC Mar 24 '11 at 16:40
  • My .jars in WEB-INF/lib: commons-logging-1.1.1 commons-logging-1.1.1-javadoc commons-logging-1.1.1-sources commons-logging-api-1.1.1 commons-logging-adapters-1.1.1 commons-logging-tests richfaces-api-3.3.3.Final richfaces-impl-3.3.3.Final richfaces-impl-jsf2-3.3.3.Final richfaces-ui-3.3.3.Final I did restart. When the server starts this is what the console says: SEVERE: Exception while loading the app java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! – javing Mar 24 '11 at 16:42
  • I currently have all the .jars i mentioned in the previous comment. I see the CONFIGURATION FAILED message when i try to build. Should i remove any of them? wich ones will i need to be able to use the rich faces upload gadget? – javing Mar 24 '11 at 16:47
  • So you don't get a `NoClassDefFoundError` anymore? Then your concrete problem is solved. As to the new problem, sorry I don't do RichFaces, so I can't tell whether it's correct. At least the `com.sun.faces.config.ConfigurationException` usually means that there's a version conflict in JSF libraries, the `jsf-api` and `jsf-impl`. Further detail is unclear to me. Post a new question about the `ConfigrationException`. – BalusC Mar 24 '11 at 17:05
  • I dont use richfaces either. I just want to upload pdf files to my web app. Do you know what is the easiest way to do it? I keep getting errors and warnings. I rode the article at your place http://balusc.blogspot.com/2008/02/uploading-files-with-jsf.html but i dont realy understand it, is there any other way easier to upload a file to my glassfish server? – javing Mar 24 '11 at 18:27
  • That old article is for JSF 1.2. To do the same for JSF 2.0, you need Tomahawk for JSF 2.0 and read their instructions (filter is not needed anymore, etc). If you aren't using RichFaces or PrimeFaces for other purposes than uploading, then they are indeed too heavy-weight. Just use Tomahawk for JSF 2.0, it comes with to-the-point components without any UI fanciness. You could also create a custom component yourself, as outlined in this article http://balusc.blogspot.com/2009/12/uploading-files-with-jsf-20-and-servlet.html Try to read the text and not only copypaste code :) – BalusC Mar 24 '11 at 18:31
  • Thanks for the advice, it was really useful. Now i was just reading from a pdf called JSF2.0 Cookbook(Anghel Leonard) and it mentions what you said about Tomahawk. I will read all carefully(not just copy paste :) )and start all over again. I dont want the app to be heavy so thats what i will do. – javing Mar 24 '11 at 18:40
0

This post might be little too late but have you tried adding the following dependency to your project.

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>jcl-over-slf4j</artifactId>
    <version>1.7.2</version>
</dependency>

You can read more about the dependency here: http://www.slf4j.org/legacy.html

user422930
  • 259
  • 1
  • 5
  • 15