Hi all,
I decided to use Tucana FileUploadSelector component for my application. I used the codes in the examples. It works fine without setting uploadcallback. But when i try to add a uploadcallback it throws error in runtime.
Here is my code:
final FileUploadSelector selector = new FileUploadSelector(); selector.setButtonMode( ButtonMode.image ); selector.setButtonDisplayMode( ButtonDisplay.right ); selector.setInputSize( 20 ); selector.setUploadSizeLimit( UploadSPI.NO_SIZE_LIMIT ); selector.setBackground( new Color( 0xa1a1a1 ) ); selector.setBorder( new Border( 1, Color.BLUE, Border.STYLE_GROOVE ) ); selector.setProgressBar( new ProgressBar() ); final Callback callback = new Callback( selector, new File( "C:/temp2" ) ); callback.setLevel( Level.INFO ); selector.setUploadCallback( callback );//without this line, it works
here is the callback class:
private static class Callback extends DefaultUploadCallback
{
private static final long serialVersionUID = 1l;
private final FileUploadSelector upload;
private Callback( final FileUploadSelector upload, final File file )
{
super( file );
this.upload = upload;
}
@Override
public void uploadSucceeded( final UploadFinishEvent event )
{
logger.info( "Running succeeded task" );
final ProgressBar bar = (ProgressBar) upload.getProgressBar();
bar.setText( "Finished upload!" );
upload.getParent().add( displayDownload( event ) );
super.uploadSucceeded( event );
}
@Override
public void uploadFailed( final UploadFailEvent event )
{
final ProgressBar bar = (ProgressBar) upload.getProgressBar();
bar.setText( "Upload failed!" );
displayError();
super.uploadFailed( event );
}
@Override
public void uploadDisallowed( final InvalidContentTypeEvent event )
{
final ProgressBar bar = (ProgressBar) upload.getProgressBar();
bar.setText( "Upload disallowed!" );
super.uploadDisallowed( event );
}
@Override
public void uploadCancelled( final UploadCancelEvent event )
{
final ProgressBar bar = (ProgressBar) upload.getProgressBar();
bar.setText( "Upload cancelled!" );
super.uploadCancelled( event );
}
private Component displayDownload( final UploadFinishEvent event )
{
final StringBuilder builder = new StringBuilder( 128 );
builder.append( "Upload of file: <b>" );
builder.append( event.getFileName() );
builder.append( "</b> succeeded. File size is: <i>");
builder.append( event.getFileSize() / 1000 );
builder.append( "</i> kilobytes." );
final Row row = new Row();
final File file = new File ( "/tmp/" + event.getFileName() );
final DownloadButton button = new DownloadButton( file );
( (DownloadCallbackAdapter) button.getDownloadCallback() ).setLevel( Level.INFO );
row.add( button );
row.add( new Strut() );
row.add( new DirectHtml( builder.toString() ) );
return row;
}
private void displayError()
{
final StringBuilder builder = new StringBuilder( 128 );
builder.append( "Upload " );
if ( getEvent() != null )
{
builder.append( " of file: <b>" );
builder.append( getEvent().getFileName() );
builder.append( "</b>" );
}
builder.append( " failed/cancelled." );
upload.getParent().add( new DirectHtml( builder.toString() ) );
}
}
and here is the error:
16:41:44,827 INFO [STDOUT] java.lang.NullPointerException 16:41:54,561 ERROR [STDERR] ---------------------------------------- Wed Jun 17 16:41:54 EEST 2009 16:41:54,561 ERROR [STDERR] Server Exception. ID: 136e94c_121ee73cb01_34 16:41:54,561 ERROR [STDERR] java.lang.NullPointerException 16:41:54,561 ERROR [STDERR] at org.apache.log4j.CategoryKey.<init>(CategoryKey.java:31) 16:41:54,561 ERROR [STDERR] at org.apache.log4j.Hierarchy.getLogger(Hierarchy.java:261) 16:41:54,561 ERROR [STDERR] at org.apache.log4j.Hierarchy.getLogger(Hierarchy.java:242) 16:41:54,561 ERROR [STDERR] at org.apache.log4j.LogManager.getLogger(LogManager.java:188) 16:41:54,561 ERROR [STDERR] at org.apache.log4j.Logger.getLogger(Logger.java:104) 16:41:54,562 ERROR [STDERR] at org.jboss.logbridge.LogBridgeHandler.publish(LogBridgeHandler.java:71) 16:41:54,562 ERROR [STDERR] at java.util.logging.Logger.log(Logger.java:458) 16:41:54,562 ERROR [STDERR] at java.util.logging.Logger.doLog(Logger.java:480) 16:41:54,562 ERROR [STDERR] at java.util.logging.Logger.log(Logger.java:569) 16:41:54,562 ERROR [STDERR] at echopoint.tucana.event.UploadCallbackAdapter.uploadFailed(UploadCallbackAdapter.java:160) 16:41:54,562 ERROR [STDERR] at ata.dys.main.window.DocumentWindow$Callback.uploadFailed(DocumentWindow.java:265) 16:41:54,562 ERROR [STDERR] at echopoint.tucana.FileUploadSelector.notifyCallback(FileUploadSelector.java:699) 16:41:54,562 ERROR [STDERR] at echopoint.tucana.UploadReceiverService$Fail.run(UploadReceiverService.java:179) 16:41:54,562 ERROR [STDERR] at nextapp.echo.app.ApplicationInstance.processQueuedTasks(ApplicationInstance.java:657) 16:41:54,562 ERROR [STDERR] at nextapp.echo.app.update.UpdateManager.processClientUpdates(UpdateManager.java:95) 16:41:54,562 ERROR [STDERR] at nextapp.echo.webcontainer.ComponentInputProcessor.process(ComponentInputProcessor.java:224) 16:41:54,562 ERROR [STDERR] at nextapp.echo.webcontainer.ClientMessage.process(ClientMessage.java:163) 16:41:54,562 ERROR [STDERR] at nextapp.echo.webcontainer.InputProcessor.process(InputProcessor.java:144) 16:41:54,562 ERROR [STDERR] at nextapp.echo.webcontainer.Synchronization.process(Synchronization.java:106) 16:41:54,562 ERROR [STDERR] at nextapp.echo.webcontainer.service.SynchronizeService.service(SynchronizeService.java:78) 16:41:54,562 ERROR [STDERR] at nextapp.echo.webcontainer.WebContainerServlet.process(WebContainerServlet.java:398) 16:41:54,562 ERROR [STDERR] at nextapp.echo.webcontainer.WebContainerServlet.doPost(WebContainerServlet.java:305) 16:41:54,562 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) 16:41:54,562 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 16:41:54,562 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 16:41:54,562 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 16:41:54,562 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) 16:41:54,562 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 16:41:54,562 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 16:41:54,562 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235) 16:41:54,562 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) 16:41:54,562 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190) 16:41:54,562 ERROR [STDERR] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525) 16:41:54,562 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92) 16:41:54,562 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126) 16:41:54,562 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70) 16:41:54,562 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 16:41:54,562 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 16:41:54,562 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) 16:41:54,562 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 16:41:54,562 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330) 16:41:54,562 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829) 16:41:54,562 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598) 16:41:54,562 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) 16:41:54,562 ERROR [STDERR] at java.lang.Thread.run(Thread.java:619)
Can you give me some
Can you give me some information on how you got the upload to fail? I need to test that scenario to find what the issue is. It looks like the problem could be that the event object was passed a null exception which I am not able to figure out how.
I attached two screenshots
I attached two screenshots of file uploading. I only use the component as in the example.
Can you try the following
Can you try the following and let me know what you get in your uploadFailed implementation?
Here is the output rakesh:
Here is the output rakesh: The first three lines are what you want i think
Can you also do a
Can you also do a event.getException().printStackTrace() so I can see the call stack on it?
Thank you rakesh for the
Thank you rakesh for the quick replies.
Here is the new output
This seems very strange and
This seems very strange and weird. Can you change the log level to FINEST (or some level that will not generate a log message) and see if you get the error. This is not a fix, but I want to see why your code that is taken directly off the test application code generates an error.
Another test would be deploy the EchoPoint test application on your JBoss instance and see if that has the same issue. It really should, since your call back is nearly identical to the one in the test application.
I changed the log level to
I changed the log level to FINEST as you mentioned but the same error(and the error messages) occures again. But i forgot to mention something. I didn't use the jar files of the Tucana component. I added all the source codes that this component needs as a seperate java project to my workspace. When i deploy the project, Tucana's project's jar is automatically added to classpath of the web project. Anyway the screenshots proves (in my opinion) that the component's jar is successfully created and added to the classpath of web project.
The library is obviously
The library is obviously getting loaded, so that should not be the issue. Can you post the lines from the source files from the stack trace so we can try and see where the problem originates?
Hi rakesh, I removed the
Hi rakesh,
I removed the project that i created for Tucana component from the workspace and added the jar echopoint-3.0.0b1.jar to my web project's classpath, but the same error occured.
I think you refered these lines.
Can you see if just
Can you see if just commenting out logging code avoids this problem (by getting the sources back into your workspace)? I am not familiar with log4j, but does it have any issues with generating a log message when one argument is null?
hi rakesh, i changed level
hi rakesh, i changed level to FINEST and changed loggings with system.out.println. Here is the new exception
I forgot to comment out some
I forgot to comment out some logging codes. When i changed them with System.out.println it gives red screen (i attached the screenshot). But it uploads the file coreectly. I think application couldn't process update for tucana component. As you can see from the output there is no error during upload process:
Any ideas?
Can you run the application
Can you run the application with Opera and then when you get the client error, look at the stack trace? Opera usually gives the best debug information with line number, script line etc. Please post them, maybe that will help track down the bug.
Hi rakesh, That was my
Hi rakesh,
That was my fault. I didnot add some peer classes to my project. The component now works fine for small size files. It uploads the files which has a size of under 5MB perfectly but when the file's size is bigger than 5MB it throws exception. I uploaded 4 files with sizes 86KB, 3.5MB, 5.2MB and 7.1MB respectively. As you can see in the log, I add printstacktrace and output some informations that would be helpful. Here is the exception:
I have tested it with >50Mb
I have tested it with >50Mb uploads. It looks like more of a client issue since the primary cause is "org.apache.commons.fileupload.MultipartStream$MalformedStreamException: Stream ended unexpectedly".
That usually indicates a client -> server communication error, rather than a server-side error. Just to clear any other issues, I assume you can upload larger files to other web applications?
I am using JBoss 5.1.0 AS.
I am using JBoss 5.1.0 AS. Do you mean i have to configure JBoss for file transferring.
You may have to. The error
You may have to. The error indicates that it is unlikely to be a component issue. Is the JBoss running on your local machine?
Yes it is runnig on my local
Yes it is running on my local machine. Does it make a difference?
No, it should eliminate any
No, it should eliminate any firewall/network setup type issues. I just wanted to clear up any such issue.
No, it should eliminate any
No, it should eliminate any firewall/network setup type issues. I just wanted to clear up any such issue.