aspose file tools*
The moose likes JForum and the fly likes Attachments problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » JForum
Bookmark "Attachments problem" Watch "Attachments problem" New topic
Author

Attachments problem

Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
I have jForum 2.1.7 installed and am getting an error with attachments over 100k. I searched this forum and found reference that this was fixed but I am still having the problem.

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.NullPointerException
net.jforum.JForum.handleException(JForum.java:282)
net.jforum.JForum.service(JForum.java:208)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
net.jforum.util.legacy.clickstream.ClickstreamFilter.doFilter(ClickstreamFilter.java:59)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0 logs.


--------------------------------------------------------------------------------

Apache Tomcat/5.0
[originally posted on jforum.net by rroske@crinet.com]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
I think this may be caused by not having a temp directory for large files. Can't remember the exact directory so try creating these directories:

Under the webapp root (generally what /jforum points to that has the templates directory in it), create a directory named tmp.

Under the WEB-INF directory (under the webapp root), create a directory named temp.
[originally posted on jforum.net by monroe]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Nope! Tried that with no difference. Still can't upload large files.
[originally posted on jforum.net by rroske@crinet.com]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
"The full stack trace of the root cause is available in the Apache Tomcat/5.0 logs."

Then please look at the TC logs for the real error and post it here.

[originally posted on jforum.net by monroe]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
It looks like this bug has been fixed in 2.1.8. We are in the process of upgrading to that version now to see if it is rectified.

Thanks for your help.
[originally posted on jforum.net by rroske@crinet.com]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Ok, we installed a fresh copy of 2.1.8 and are still having the problem with attachments over 100k. In the fix list it said this problem was taken care of. Am I missing something?

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.NullPointerException
net.jforum.JForum.handleException(JForum.java:280)
net.jforum.JForum.service(JForum.java:205)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
net.jforum.util.legacy.clickstream.ClickstreamFilter.doFilter(ClickstreamFilter.java:59)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0 logs.


--------------------------------------------------------------------------------

Apache Tomcat/5.0
[originally posted on jforum.net by rroske@crinet.com]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Ok, we have gone back and checked everything and have done some tweaking and still no luck uploading attachments larger than 100k.

Anyone who has had this problem and got it fixed please give us a clue where to fix it.
We are running an Apache server on Suse Linux
PHP 5.1.2
MySQL 5.0.27
JForum 2.1.8 new install

Thanks!
[originally posted on jforum.net by rroske@crinet.com]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
monroe wrote:
"The full stack trace of the root cause is available in the Apache Tomcat/5.0 logs."

Then please look at the TC logs for the real error and post it here.


Full error info would be much more helpful with this than the generic error information you posted.
[originally posted on jforum.net by monroe]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Here is the full error text from the TC log.

Here is the complete error message. It appears that 'encoding' is not
being set on the call to JForum.handleException:


> java.lang.NullPointerException
> at net.jforum.JForum.handleException(JForum.java:280)
> at net.jforum.JForum.service(JForum.java:205)
> at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
> at
> net.jforum.util.legacy.clickstream.ClickstreamFilter.doFilter(ClickstreamFilter.java:59)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
> at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
> at
> org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
> at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
> at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
> at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
> at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
> at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
> at
> org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:162)
> at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
> at org.apache.coyote.http11.Http11Protocol
> $Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
> at
> org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
> at org.apache.tomcat.util.threads.ThreadPool
> $ControlRunnable.run(ThreadPool.java:684)
> at java.lang.Thread.run(Thread.java:534)

[originally posted on jforum.net by rroske@crinet.com]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
I am running a fresh install of 2.1.8 but I am still having the problem with attachments.


[originally posted on jforum.net by rroske@crinet.com]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Please upgrade to 2.1.8, where this bug is fixed.

Rafael
[originally posted on jforum.net by Rafael Steil]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Yes there is a tmp directory at the jforum root. It contains one readme.txt file.

Mode is set to 755
Owner is Tomcat and group is Tomcat.

[originally posted on jforum.net by rroske@crinet.com]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
The exact same problem? Odd. It was caused by a missing writable "tmp" directory in JForum's root, and the source code was changed to detect that and use java.io.tmpdir if possible.

Do you have the "tmp" directory in your app?

Rafael
[originally posted on jforum.net by Rafael Steil]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
I found the upload directory is missing from the jforum-2.1.8.zip. Check if you have this directory.
If not, create it yourself under JForum root and make it writable to tomcat.
[originally posted on jforum.net by andowson]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
I do have an upload directory.

Mode is 755
Owner is Tomcat and Group is Tomcat

So it should be ok to use.
[originally posted on jforum.net by rroske@crinet.com]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
I have same problem to upload files larger than 100KB.

I am using 2.1.8, and both upload and tmp folders are there. I can upload files less than 100KB, for files larger than 100KB, no error pop-up, just nothing show up. I don't know if anyone still have this attachment issue.
[originally posted on jforum.net by chows@gvmc.org]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Are there any error messages in your App server logs?

Are you using a web server front end to the App server? I know that the jk connectors for Tomcat can have limits set on file uploads.

Is that a proxy server involved? Some companies have upload/download limits set... (but generally larger than 100Kb...
[originally posted on jforum.net by monroe]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Thank you very much for your reply.
There is no error messages in logs.

I am using ServletExec with IIS, using Oracle. Everything works fine but just can not upload files large than 100KB. There is no proxy server involved.
I guess that it may be related to buffer size defined in the code. Currently, buffer size in the code is defined 2KB, I don't know if this is too small. There may be a timeout limit. When file exceeds a certain size, timeout trigger and then just ignore the uploading.

This shall be not issue with folder permission since small size files are successfully uploaded.
[originally posted on jforum.net by chows@gvmc.org]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
It's hard to say... wandering around the code I found that a key method to this is the WebRequestContext.handleMultipart method. This has a hard coded memory threshold of 100K.

This is also where the tmp directory gets defined from a combination of the ApplicationPath (set up via a request to get the "realpath" for "") and the value of the tmp.dir setting.

The code attempts to make this directory if it can. If that fails it tries to use the OS tmp directory. If ServletExec is reporting something odd for any of these, this might cause this.

Other than that, I'm not sure... especially since you're using a small usage base App Engine like ServletExec.. (I know all J2EE containers are supposed to be equal.. but some are more equal than others...)
[originally posted on jforum.net by monroe]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Thanks a lot for your reply. I will try to increase memory threshold first to test if things change.
[originally posted on jforum.net by chows@gvmc.org]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Monroe,

You are great. It is caused by hard coded memory threshold of WebRequestContext.handleMultipart. I have changed it to 1000K. Now I am able to upload files more than 100KB but less than 1000KB. If I increase it again, I can upload larger size file. So the hard coded threshold limits the file size that can be uploaded. Thanks for your help.



monroe wrote:It's hard to say... wandering around the code I found that a key method to this is the WebRequestContext.handleMultipart method. This has a hard coded memory threshold of 100K.

This is also where the tmp directory gets defined from a combination of the ApplicationPath (set up via a request to get the "realpath" for "") and the value of the tmp.dir setting.

The code attempts to make this directory if it can. If that fails it tries to use the OS tmp directory. If ServletExec is reporting something odd for any of these, this might cause this.

Other than that, I'm not sure... especially since you're using a small usage base App Engine like ServletExec.. (I know all J2EE containers are supposed to be equal.. but some are more equal than others...)

[originally posted on jforum.net by chows@gvmc.org]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
One thing to make clear... the "threshold" setting in this is the amount of real physical memory (e.g. RAM/paging space) that will be used while uploading a file. If a file is larger than this threshold, the file will not be stored in memory but in a temporary file on the disk.

So, you may "fix" your problem by storing things in memory, but then have major performance problems because multiple file uploads are using up your memory/paging space.

IMHO, it's better to figure out why the temporary file can't be created.
[originally posted on jforum.net by monroe]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Yes, it is better to figure out why the temporary file can't be created.
One more question for memory usage, is the physical memory released after file uploaded or session terminated? Thanks.
[originally posted on jforum.net by chows@gvmc.org]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
It should be released thru Java's normal "garbage" collection operations...

FWIW, it looks like the file upload code is based on the apache commons fileupload package.
[originally posted on jforum.net by monroe]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Attachments problem
 
Similar Threads
Another Problem about Attached Files
About NullPointerException with Oracle
Tomcat, Apache, ANT ENV Variable HELL
Tomcat starting problem
an eclipse problem