Java OutOfMemoryError on File Upload in ADF
Hi All,
I am using JDeveloper 11.1.1.5.0.
I am uploading a file in ADF. i should be able to upload files upto 10MB. below is the method I am calling when user puts the filename.
public void setUploadedFile(ValueChangeEvent valueChangeEvent) {
UploadedFile file = (UploadedFile)valueChangeEvent.getNewValue();
if (file != null && file.getLength() > 0l) {
filename = file.getFilename();
filetype = file.getContentType();
try {
InputStream is = file.getInputStream();
long length = file.getLength();
if (length > Integer.MAX_VALUE) {
// File is too large
byte[] bytes = new byte[(int)length];
int offset = 0;
int numRead = 0;
while (offset < bytes.length &&
(numRead = is.read(bytes, offset,
bytes.length - offset)) >= 0) {
offset += numRead;
if (offset < bytes.length) {
try {
throw new IOException("Could not read complete file");
} catch (IOException e) {
e.printStackTrace();
is.close();
byte[] encoded = Base64.encode(bytes);
filecontents = new String(encoded); //getting java.lang.OutOfMemoryError: Java heap space error here
} catch (IOException e) {
e.printStackTrace();
}else{
}I am getting a java.lang.OutOfMemoryError: Java heap space error at the mentioned point. This is happening for files larger than 5MB.
My web.xml have below entries.
<context-param>
<param-name>org.apache.myfaces.trinidad.UPLOAD_MAX_DISK_SPACE</param-name>
<param-value>512000000</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.trinidad.UPLOAD_MAX_MEMORY</param-name>
<param-value>51200000</param-value>
</context-param>
<context-param>
<!-- directory to store temporary files -->
<param-name>oracle.adf.view.faces.UPLOAD_TEMP_DIR</param-name>
<!-- Use an ADFUploads subdirectory of /tmp -->
<param-value>/tmp/ADFUploads/</param-value>
</context-param>how can i resolve this issue?
regards,
Rajan
byte[] bytes = new byte[(int)length];means that you try to load the whole file into memory (regardless of the parameters in web.xml). And after the file is loaded you need the same amount on memory for
filecontents = new String(encoded); You should upload the data from the stream into a file and then process the file when you need to do it. For this you can use http://projects.apache.org/projects/commons_io.html
Timo
Similar Messages
-
I tried to use af:inputFile component to upload files, but i can't upload file bigger than 2K, for example i received:
Successfully uploaded file 1.txt (4337 bytes) - file.getLength() returns
but:
Available to upload : 2048 - file.getInputStream().available() returns
I try to set in web.xml params:
<context-param>
<!-- Maximum disk space per request (in bytes) -->
<param-name>oracle.adf.view.faces.UPLOAD_MAX_DISK_SPACE</param-name>
<!-- Use 5,000K -->
<param-value>5120000</param-value>
</context-param>
<context-param>
<!-- Maximum memory per request (in bytes) -->
<param-name>oracle.adf.view.faces.UPLOAD_MAX_MEMORY</param-name>
<!-- Use 500K -->
<param-value>512000</param-value>
</context-param>
<context-param>
<!-- directory to store temporary files -->
<param-name>oracle.adf.view.faces.UPLOAD_TEMP_DIR</param-name>
<!-- Use an ADFUploads subdirectory of /tmp -->
<param-value>D:\tmp</param-value>
</context-param>
but nothing changed. How can i upload file bigger than 2K ?
JDeveloper 10.1.3
Application Server: OC4JHi,
set the following context parameter in web.xml
<context-param>
<!-- Maximum memory per request (in bytes) -->
<param-name>oracle.adf.view.faces.UPLOAD_MAX_MEMORY</param-name>
<!-- Use 5000K -->
<param-value>5120000</param-value>
</context-param>
Frank -
Java Exception after File Upload while retreiving using Filepath
Hello everyone,
I am performing the following steps:-
1) I am uploading a file from my local File system (D:/ a.XML) using FileUpload UI Element in Web Dynpro.
2) In the OnActionMethod of the View, I am trying to get the content of the file using the Filepath (D:/ a.XML).
But I am getting a Java Exception "No Such File or Directory" after deploying the archive and run on to the remote server.
The Exception is not a Web Dynpro Runtime Exception. But I am able to catch it in the try, catch block of the Java code.
Do I need the file to be present in the server as well. What is the Solution? Please advise me about, where is the content of the uploaded XML file stored and how can it be retrieved.
How can I retrieve the content of the file using a valid file path, because my method which will open the uploaded file requires argument as a filepath. Please suggest about this problem. I would be very thankful for your help.
Kind Regards,
Phani.
Edited by: Armin Reichert on Apr 18, 2008 2:43 PMHi Ayyaparaj,
Please have a look at the code that I am using for my application. I am getting the exception method after the load method i.e after this line of code "msgMgr.reportSuccess("\n\nInit0\n\n");". The exception that I am getting is "Invalid Stream Header".
public void onActionMaximalJoin(
com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent)
// @@begin onActionMaximalJoin(ServerEvent)
MessageManager msgMgr = (MessageManager) wdThis.wdGetAPI().getComponent()
.getMessageManager();
InputStream text = null;
int temp = 0;
try
File file = new File(wdContext.currentContextElement().getUploadXML()
.getResourceName().toString());
FileOutputStream op = new FileOutputStream(file);
if (wdContext.currentContextElement().getUploadXML() != null)
text = wdContext.currentContextElement().getUploadXML().read(false);
while ((temp = text.read()) != -1)
op.write(temp);
op.flush();
op.close();
String path = file.getAbsolutePath();
wdComponentAPI.getMessageManager().reportSuccess(path);
Ontology ontology = new Ontology();
msgMgr.reportSuccess("\n\nInit0\n\n");
ontology = Ontology.load(path);
Lexicon mainLexicon = ontology.getMainLexicon();
msgMgr.reportSuccess("\n\nInit1\n\n");
text = null;
temp = 0;
File file1 = new File(wdContext.currentContextElement().getUploadGraph1()
.getResourceName().toString());
FileOutputStream op1 = new FileOutputStream(file1);
if (wdContext.currentContextElement().getUploadGraph1() != null)
text = wdContext.currentContextElement().getUploadGraph1().read(false);
while ((temp = text.read()) != -1)
op1.write(temp);
op1.flush();
op1.close();
String path1 = file1.getAbsolutePath();
wdComponentAPI.getMessageManager().reportSuccess(path1);
CG cg1 = new CG();
msgMgr.reportSuccess("\n\nInit2\n\n");
cg1 = CG.load(path1);
text = null;
temp = 0;
File file2 = new File(wdContext.currentContextElement().getUploadGraph2()
.getResourceName().toString());
FileOutputStream op2 = new FileOutputStream(file2);
if (wdContext.currentContextElement().getUploadGraph2() != null)
text = wdContext.currentContextElement().getUploadGraph2().read(false);
while ((temp = text.read()) != -1)
op2.write(temp);
op2.flush();
op2.close();
String path2 = file1.getAbsolutePath();
wdComponentAPI.getMessageManager().reportSuccess(path2);
CG cg2 = new CG();
msgMgr.reportSuccess("\n\nInit3\n\n");
cg2 = CG.load(path2);
CG maximalJoinResult = (CG) cg1.maximalJoin(cg2);
StringBuffer output = new StringBuffer();
output.append(maximalJoinResult.toString(mainLexicon));
msgMgr.reportSuccess("\n\nInit4\n\n");
System.out.println(output.toString());
msgMgr.reportSuccess("\n\nInit5\n\n");
msgMgr.reportSuccess(output.toString());
msgMgr.reportSuccess("\n\nInit6\n\n");
catch (Exception e)
msgMgr.reportSuccess(e.getMessage());
// @@end
Please advise me if you find any mistake.
Edited by: Armin Reichert on Apr 9, 2008 1:27 PM -
XML file Upload in ADF UI page
Hi,
I have following requirement:
a) There will be an upload button on the ADF UI page.
b) The ADF UI will allow user to browse and select the XML file
c) Once XML file is selected there will be a Load button.
Note: I am fine till step c)....
d) Upon the Load, UI Screen should be populated with the XML content.
e.g. UI screen will have Book Title and Author text boxes and the data for Title and Author should be loaded from XML file.
e) Once data is loaded in ADF UI page (from XML) , it should allow user to modify Title and Author in UI screen.
f) After modifying the data, user should be allowed to save modified content either in XML file or Database.
Note: On the OTN forum I posted similar question and I found the partial solution of using the URLConnection Data control, however this data control does not allow you to modify the content on the ADF UI page.
ThanksHi,
Note: On the OTN forum I posted similar question and I found the partial solution of using the URLConnection Data control, however this data control does not allow you to modify the content on the ADF UI page.
Not quite true what you say. The data control shows the data as read only. However, setting the updateable property on the metadata will allow you to create an input form, which is editable. For this, in the Data Control for the URL data control, select the collection and choose "Edit Definition" from the context menu. Select Attributes and if this doesn't show the attributes, follow the link in the Attributes field. Then select each attribute and set the updateable property using the PI
The question then is how you perform the update, which is what the URL data control doesn't do for you. For this you need to expose methods in a POJO that you then expose as a POJO data control. With your knowledge about the location and name of the XML file, you can then use JAXB to upload the XML, or a database bound collection (EJB, ADF BC or JDBC) to write changes to the database. Note that JAXB could also be used read from teh XML file and show the data in the UI using the JavaBean Data Control.
To access the object to use for updating the XML file or the database, you use ((DCIteratorBinding)bindings.get("IteratorNameInPageDef")).getCurrentRow().getDataProvider()
Frank -
How to solve Fusion ADF file upload and download?
Now we are building web application with Fusion ADF (JDeveloper 11.1.2.0.0). We want to downloading and uploading from tables.Is there any special tool in Fusion ADF or should I going with traditional java coding. Thanks
Actually ADF Provide Components for file upload and download
Download :
<af:fileDownloadActionListener/>
See tagDoc: http://jdevadf.oracle.com/adf-richclient-demo/docs/tagdoc/af_fileDownloadActionListener.html
Upload
<af:inputFile/>
See tagDoc: http://jdevadf.oracle.com/adf-richclient-demo/docs/tagdoc/af_inputFile.html
Edited by: -CHS on Jul 6, 2011 9:52 AM -
Hi All,
We are on Netweaver 7.01 SP14. (well I understand we are way behind patch levels, but a simple file upload should be working ?/)
We are trying to upload (HTML &/ Image) a file in one of the KM's public folder.
As and when we select folder and click on upload we get the below message:
Below is the error trace details:
Full Message Text
com.sapportals.wdf.WdfException
at com.sapportals.wcm.control.edit.ResourceUploadControl.render(ResourceUploadControl.java:688)
at com.sapportals.wdf.layout.HorizontalLayout.renderControls(HorizontalLayout.java:42)
at com.sapportals.wdf.stack.Pane.render(Pane.java:155)
at com.sapportals.wdf.stack.PaneStack.render(PaneStack.java:73)
at com.sapportals.wdf.layout.HorizontalLayout.renderPanes(HorizontalLayout.java:73)
at com.sapportals.wdf.stack.Pane.render(Pane.java:158)
at com.sapportals.wdf.stack.PaneStack.render(PaneStack.java:73)
at com.sapportals.wdf.layout.HorizontalLayout.renderPanes(HorizontalLayout.java:73)
at com.sapportals.wdf.stack.Pane.render(Pane.java:158)
at com.sapportals.wdf.stack.PaneStack.render(PaneStack.java:73)
at com.sapportals.wdf.layout.HorizontalLayout.renderPanes(HorizontalLayout.java:73)
at com.sapportals.wdf.stack.Pane.render(Pane.java:158)
at com.sapportals.wdf.stack.PaneStack.render(PaneStack.java:73)
at com.sapportals.wdf.WdfCompositeController.internalRender(WdfCompositeController.java:709)
at com.sapportals.wdf.WdfCompositeController.buildComposition(WdfCompositeController.java:674)
at com.sapportals.htmlb.AbstractCompositeComponent.preRender(AbstractCompositeComponent.java:33)
at com.sapportals.htmlb.Container.preRender(Container.java:120)
at com.sapportals.htmlb.Container.preRender(Container.java:120)
at com.sapportals.htmlb.Container.preRender(Container.java:120)
at com.sapportals.portal.htmlb.PrtContext.render(PrtContext.java:408)
at com.sapportals.htmlb.page.DynPage.doOutput(DynPage.java:238)
at com.sapportals.wcm.portal.component.base.KMControllerDynPage.doOutput(KMControllerDynPage.java:134)
at com.sapportals.htmlb.page.PageProcessor.handleRequest(PageProcessor.java:133)
at com.sapportals.portal.htmlb.page.PageProcessorComponent.doContent(PageProcessorComponent.java:134)
at com.sapportals.wcm.portal.component.base.ControllerComponent.doContent(ControllerComponent.java:88)
at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209)
at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:215)
at com.sapportals.portal.prt.pom.PortalNode.service(PortalNode.java:645)
at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:753)
at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:249)
at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:557)
at java.security.AccessController.doPrivileged(Native Method)
at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:430)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:386)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:364)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:1064)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:265)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:104)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:176)
--- Nested WDF Exception -----------------------
java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key xtlt_Required
at java.util.ResourceBundle.getObject(ResourceBundle.java:327)
at java.util.ResourceBundle.getObject(ResourceBundle.java:324)
at java.util.ResourceBundle.getString(ResourceBundle.java:287)
at com.sapportals.wcm.util.resource.ResourceBundles.getString(ResourceBundles.java:55)
at com.sapportals.wcm.control.base.WcmBaseControl.getBaseBundleString(WcmBaseControl.java:150)
at com.sapportals.wcm.control.base.WcmBaseControl.getBaseBundleString(WcmBaseControl.java:176)
at com.sapportals.wcm.control.edit.ResourceUploadControl.renderUploadFileContent(ResourceUploadControl.java:773)
at com.sapportals.wcm.control.edit.ResourceUploadControl.render(ResourceUploadControl.java:655)
at com.sapportals.wdf.layout.HorizontalLayout.renderControls(HorizontalLayout.java:42)
at com.sapportals.wdf.stack.Pane.render(Pane.java:155)
at com.sapportals.wdf.stack.PaneStack.render(PaneStack.java:73)
at com.sapportals.wdf.layout.HorizontalLayout.renderPanes(HorizontalLayout.java:73)
at com.sapportals.wdf.stack.Pane.render(Pane.java:158)
at com.sapportals.wdf.stack.PaneStack.render(PaneStack.java:73)
at com.sapportals.wdf.layout.HorizontalLayout.renderPanes(HorizontalLayout.java:73)
at com.sapportals.wdf.stack.Pane.render(Pane.java:158)
at com.sapportals.wdf.stack.PaneStack.render(PaneStack.java:73)
at com.sapportals.wdf.layout.HorizontalLayout.renderPanes(HorizontalLayout.java:73)
at com.sapportals.wdf.stack.Pane.render(Pane.java:158)
at com.sapportals.wdf.stack.PaneStack.render(PaneStack.java:73)
at com.sapportals.wdf.WdfCompositeController.internalRender(WdfCompositeController.java:709)
at com.sapportals.wdf.WdfCompositeController.buildComposition(WdfCompositeController.java:674)
at com.sapportals.htmlb.AbstractCompositeComponent.preRender(AbstractCompositeComponent.java:33)
at com.sapportals.htmlb.Container.preRender(Container.java:120)
at com.sapportals.htmlb.Container.preRender(Container.java:120)
at com.sapportals.htmlb.Container.preRender(Container.java:120)
at com.sapportals.portal.htmlb.PrtContext.render(PrtContext.java:408)
at com.sapportals.htmlb.page.DynPage.doOutput(DynPage.java:238)
at com.sapportals.wcm.portal.component.base.KMControllerDynPage.doOutput(KMControllerDynPage.java:134)
at com.sapportals.htmlb.page.PageProcessor.handleRequest(PageProcessor.java:133)
at com.sapportals.portal.htmlb.page.PageProcessorComponent.doContent(PageProcessorComponent.java:134)
at com.sapportals.wcm.portal.component.base.ControllerComponent.doContent(ControllerComponent.java:88)
at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209)
at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:215)
at com.sapportals.portal.prt.pom.PortalNode.service(PortalNode.java:645)
at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:753)
at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:249)
at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:557)
at java.security.AccessController.doPrivileged(Native Method)
at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:430)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:386)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:364)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:1064)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:265)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:104)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:176)Hi Vijay,
Thanks for the quick reply.
I have gone through the notes 1535201 & now on 1606563 after your advise.
Both the notes says the fix is available on 7.01 after SP 07 and we are on SP 14 already.
Also just in case I did checked with our basis and they confirmed we are a head and we have the above notes in our release already.
Unfortunately the notes are not the solution to the investigation till date.
Thanks,
Sai -
File upload java errors...HEEELPPP!
All was working fine for months, now getting java errors in my ADDT. Mostly related to file uploads, or image uploads. I found that I don't get these errors in older sites that I've worked with, but I've created a new site and started from scratch and I'm still getting them.
Here are the errors and what I'm doing:
*I go insert record form wizard (in ADDT)
*One field is a date, others are text, one is an integer, one is a file field
That works ok up to here.
*Then I choose ADDT > File upload. I get the following error immediately: "While executing canApplyserverBehavior in kb_FileUpload.htm, a javascript error occured."
*I click ok, the wizard box attempts to load and it give me the error: "While executing onLoad in kb_FileUpload.htm, the following javascript errors occured:
At line 354 of the file "Macintosh HD:Applications:Adobe Dreamweaver CS3:Configuration:Shared:DeveloperToolbox:classes:triggerUtil.js":
TypeError: hash[transactionColumn[k]].push is not a fuction.
I'm totally tearing my hair out, not to mention not hitting deadlines with this... can anyone help. I've tried removing the fileCache, rebuilding the site cache, removing and rebuilding the includes folder, removing and reinstalling ADDT. HEEEEEELLLLLPPP.Hi
Please look into this about the destination
Pathname of directory in which to upload the file. If not an
absolute path (starting a with a drive letter and a colon, or a
forward or backward slash), it is relative to the ColdFusion
temporary directory, which is returned by the GetTempDirectory
function. -
File upload, download using ADF UIX and not JSP
I have examples for the file upload, download using JSP
But I want to use ADF UIX. Look and feel in this is impressing and I want to use this. Any one have example for this.
Users will select a file from their desktop
This will be stored into the database (Any document. Word, Excel)
When they query the records then the UIX column need to give a hyperlink. Clicking on the link should prompt to download the file to the local systemSure, I use the Apache Commons File Upload package, so that is what I will discuss here ( [Commons File Upload|http://commons.apache.org/fileupload/] ).
The Commons File Upload uses instances of ProgressListener to receive upload progress status. So first create a simple class that implements ProgressListener:
public class ProgressListenerImpl implements ProgressListener {
private int percent = 0;
public int getPercentComplete() {
return percent;
public void update(long pBytesRead, long pContentLength, int pItems) {
if (pContentLength > -1) { //content length is known;
percent = (new Long((pBytesRead / pContentLength) * 100)).intValue();
}So in your Servlet that handles file upload you will need to create an instance of this ProgressListenerImpl, register it as a listener and store it in the session:
ServletFileUpload upload = new ServletFileUpload();
ProgressListenerImpl listener = new ProgressListenerImpl();
upload.setProgressListener(listener);
request.getSession().setAttribute("ProgressListener", listener);
...Now create another servlet that will retrieve the ProgressListenerImpl, get the percent complete and write it back (how you actually write it back is up to you, could be text, an XML file, a JSON object, up to you):
ProgressListenerImpl listener = (ProgressListenerImpl) request.getSession().getAttribute("ProgressListener");
response.getWriter().println("" + listener.getPercentComplete());
...Then your XMLHttpRequest object will call this second servlet and read the string returned as the percent complete.
HTH -
IMP:ClassCastException while using File upload UI in Webdynpro for java
Hi All,
I have used a FileUpload UI element in my screen , which is working fine for only the first time we upload a file. If we try to upload any file with out refreshing the application , a ClassCastException is being thrown. Please help me in resolving the issue.
Thanks in advance.
SrikanthThank you!!
1. But when i use the File Upload UI and try to use the 'data' property to retrieve the bytes i am getting a null pointer exception meaning the data is not being picked up by the UI even though browsed file has data.
2. How I am I supposed to set the 'Resource' property while downloading a PDF which has UTF-16 text and picture??
Note: I have done the same scenario using WD04 java without any trouble.
reg
vln -
How to Upload/Attachment File in MYSQL ADF???
HEY Guys...
How to Upload/Attachment File in MYSQL ADF???
Regards Ninja,You need to provide more information.
Which jdev version do you use?
Which ui technology?
I see two question to be answered:
1) load the attatchments ADFrc af:inputFile (http://technology.amis.nl/blog/2297/adf-faces-file-uploading-it-is-really-that-simple)
2) store the loaded data in the DB -> mysql doc or google should have the needed information
Timo -
Upload and download file in jdev adf
hi,
i'm still looking for upload and downlaod files in jdev adf
any idea sir
TQHi spnolin,
Can u tell me how to download a file from server, so that the client can get the file. such as click on the link or button, and the pop up windows (save as) appear?
Please tell me in details. if possible provide the example code as well and some explanations.
Thx in advance
FELIX -
File upload and download through web Dynpro2.0.9. with Java
Hai All,
I am working in web Dynpro2.0.9 with Java.For file upload and download "IWDResource" is used.But this package is not available in web Dynpro2.0.9.How to download and upload files through using this version?
Anyone can help me?
Thanks in Advance,
Kindly Regards,
S.V.Selva Bala.Hai Noufal,
I successfully upload the files to the database.
For file download i create two views.
In the first view files are fetched from the database(datatype for the file is image in the database)and it is converted to byte from image.Afterthat the byte is converted to string by using the following code.
byte source[]=new byte[1024];
if(rs.next()){
source=rs.getBytes("cv_document_file");
String sourcestr=source.toString();
wdContext.currentContextElement().setDownloadfile(sourcestr);
Now i put the converted string into the second view.In the second view i try to convert the string value into bytes by using the following codes.
String sourcestr=wdContext.currentContextElement().getDownloadfile();
byte bs[]=new byte[1024];
bs=sourcestr.getBytes();
wdContext.currentDownloadElement().setDownloadfile(bs);
But it doesn't work and no error.
Now i am expecting the valuable suggestions from you.
Thanks in Advance,
Kind Regards,
S.V.Selva Bala. -
My file upload java application working fine in tomcat 7 but not working in weblogic 11
Hi All,
My file upload java application successfully run in tomcat 7 . But I could not run it in Weblogic 11. Getting following error message . Please help.
Please contact your administrator.org.springframework.beans.NullValueInNestedPathException: Invalid property 'fileData[0]' of bean class [com.techm.util.UploadItem]: Cannot access indexed value in property referenced in indexed property path 'fileData[0]': returned null
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:681)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:651)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:78)
at org.springframework.validation.DataBinder.applyPropertyValues(DataBinder.java:587)
at org.springframework.validation.DataBinder.doBind(DataBinder.java:489)
at org.springframework.web.bind.WebDataBinder.doBind(WebDataBinder.java:149)
at org.springframework.web.bind.ServletRequestDataBinder.bind(ServletRequestDataBinder.java:110)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodInvoker.doBind(AnnotationMethodHandlerAdapter.java:566)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:213)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:132)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:326)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:313)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:324)
at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:460)
at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:163)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)What version of spring are you using in tomcat?
What version of WLS are you using.
What JDK are you using in both environments?
Is the issue random? or can you reproduce it at will?
Thanks
Luz -
Struts file upload without interMedia under ADF
Can this be done ?
I have an existing table with the following columns:
Content BLOB
MimeType VARCHAR2
FileName VARCHAR2
and moreVery frustrated :(
Trying to find an answer to my question above.
If I Add a transient OrdDocDomain to the Entity/View Layer.
Map this into the UIModel (drag-drop onto JSP as struts file upload) so a FormFile object is available in the struts Action layer.
Override 'processUpdateModel' so I can obtain a reference to the FormFile object.
In the commit event of the Action class, take the referenced FormFile and set the BLOB like follows;
newRow.setAttribute("FileData",
new BlobDomain(uploadFile.getFileData())
Then call into the internal commit operation.
The following exception is raised;
04/11/19 07:32:18 java.lang.ArrayIndexOutOfBoundsException: 0
04/11/19 07:32:18 at oracle.jbo.client.remote.OrdClientPostListener.notifyClientPostAfter(OrdClientUtil.java:135)
04/11/19 07:32:18 at oracle.jbo.client.remote.ApplicationModuleImpl.postChanges(ApplicationModuleImpl.java:796)
The transient OrdDocDomain has registered a listener.
How can I remove this listener. The transient has a method 'removeListenerFromTransaction()' with the comment 'Internal: Applications should not use this method.' and no other references ?
Does anyone know how the listener can be removed or better still, not be registered with the transaction. -
How to Save a file uploaded in WebDynpro Java to Windows server
Hi Guys,
I need to save a file uploaded in WebDynpro Java to a location on one of my companys many internal Window servers but I cannot get it to work. I do not get any errors with the following code, but NOTHING happens... And when I check the folder it is still emply... Please advise. I am particularly not sure about specifying the Path syntax. Also, I do have permission to write to this server. Is it even possible to save to a Windows server from WebDynpro??
//uploaded document already in context...
byte[] file = element.getFileResource();
// get the size of the uploaded file
element.setFileSize(this.getFileSize(file));
wdContext.currentContextElement().setFSize(this.getFSize(file));
// get the extension of the uploaded file
element.setFileExtension(binaryType.getMimeType().getFileExtension());
String fName = wdContext.currentContextElement().getFName();
String fExt = wdContext.currentContextElement().getFileExtension();
String foName1 = "
server01.w9\Files\P
HRP_Attachments\" + fName + ".pdf";
File f1 = new File(foName1);
DataOutputStream dos1;
dos1 = new DataOutputStream(new FileOutputStream(f1));
dos1.write(file);
dos1.flush();
dos1.close();
Edited by: christiaanp on Sep 30, 2011 8:07 AMHi Christiaan,
When specifying the path, make sure you escape the slashes
So, when you would normally use something like
\\server\path\file.txt
in your code you must use it in the form:
String fileName = "\\\\server\\path\\file.txt";
Hope this helps!
Robin van het Hof
Maybe you are looking for
-
Scaling SWF in PDF (FlashVar)
I'm currently strucling with an exported SWF file from Indesign, which I want to import in an interactive pdf. The importing isn't the problem, but it appears the SWF file does not scale with the pdf, when for example putting the pdf in fullscreen (o
-
How to switch between views in iPhone SDK
I have been tasked to learn the iPhone SDK. I know Actionscript, Javascript and some Java, but I cannot understand the iPhone SDK at all. I cannot understand the syntax or how the multitude of files work together. Also, there are no tutorials for com
-
Downpayment ..... fi tickets
respected gurus, please help me on the below, 1. can it be possible to pay down payment to vendors through APP 2. can any one send me sample FI tickets for supporting project. can be sending by links. please reply me it would really helping me thanks
-
JMS Adapter Fail - Receiver channel. Details: Receive timed out
Its an IDOC to JMS scenario. IDOC gets processed through the pipeline in XI successfully, can see the checkered flag. However in Adapter monitoring, JMS adapter is in red. The error text against the Communication Channel is "Receiver channel. Details
-
see question...