Catch(java.io.IOException ioe) help
Hi. I have used
static BufferedReader keyboardInput = new BufferedReader(new InputStreamReader(System.in)); and tried to read what the user will enter from an input box, im expecting interger, character, integer to be entered.
try{
int newOp1 = Integer.parseInt(keyboardInput.readLine());
char newOp = (char) keyboardInput.readLine().charAt(0);
int newOp2 = Integer.parseInt(keyboardInput.readLine());
}I can catch the error with
catch(java.io.IOException ioe){but i dont know how to go about hangling th errors, any ideas? thanks a lot :-)
but i dont know how to go about hangling th errors,
any ideas? thanks a lot :-)Well, you might print out the stack trace (ioe.printStackTrace()), then retry. Or print the stack trace and then just use default values, or wrap the exception in one more appropriate for that layer and throw the new exception, or just not catch IOE in the first place and declrae your method to throw it and let your method's caller decide how to handle it.
(The last two--wrap and rethrow, or just let it bubble up--are the most common.)
As for "fixing" it, that really depends on the nature of the exception and the semantics of your program. If you get an exception reading from the keyboard, there's probably not much you can do about it.
If you get an exception creating a file in GUI program, you might put up a dialog box telling the user the file couldn't be created, asking them if they want to try a different location or retry or cancel.
Similar Messages
-
What this error mean. Help! I dont understand. The program is running when I try to run it but when I try to deploy it using JNLP it wont work.
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.continueLaunch(Unknown Source)
at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)
at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: Cutout$1
at Cutout.<init>(Cutout.java:45)
at Cutout.main(Cutout.java:175)
... 11 more
It seems like the error is at line 45 of my code. My code starting from line 45 is this...
capture.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
try {
java.awt.Point pos = jFrame.getLocationOnScreen();
javax.imageio.ImageIO.write(shot.getSubimage(pos.x + 3, pos.y + 27, jFrame.getWidth() - 7, jFrame.getHeight() - 30), "jpg", new java.io.File("image.jpg"));
} catch(java.io.IOException ioe) {
ioe.printStackTrace();
popup.add(capture);
refresh = new javax.swing.JMenuItem("Refresh");
refresh.setMnemonic('R');
refresh.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
refresh();
popup.add(refresh);
exit = new javax.swing.JMenuItem("Exit");
exit.setMnemonic('x');
exit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jFrame.setVisible(false);
jFrame.dispose();
System.exit(0);
popup.add(exit);
addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
popup.show(evt.getComponent(), evt.getX(), evt.getY());
});Is there something wrong with this one?Hi,
I get the same error and i am not really sure what your explanation says... This problem below is the latest of a series of problems i started getting after i updated my BIRT version in Eclipse 3.3.1 and RAD 6.0... I troubleshooted and resolved most of them however i am not sure and it is not obvious to me what is required for this particular one below
In the problems tab there is nothing to give me a clue. The exception below appears in the Websphere console and also on the page when trying to access my jsp file normally. I am not sure what is causing it, but here it is:
JSP Processing Error
HTTP Error Code: 500
Error Message:JSPG0227E: Exception caught while translating /directory/init.jsp: java.lang.reflect.InvocationTargetException
Root Cause:com.ibm.ws.jsp.translator.JspTranslationException: JSPG0227E: Exception caught while translating /directory/init.jsp: java.lang.reflect.InvocationTargetException at com.ibm.ws.jsp.translator.JspTranslator.processVisitors(JspTranslator.java:133) at com.ibm.ws.jsp.translator.utils.JspTranslatorUtil.translateJsp(JspTranslatorUtil.java:168) at com.ibm.ws.jsp.translator.utils.JspTranslatorUtil.translateJspAndCompile(JspTranslatorUtil.java:81) at com.ibm.ws.jsp.webcontainerext.JSPExtensionServletWrapper.translateJsp(JSPExtensionServletWrapper.java:298) at com.ibm.ws.jsp.webcontainerext.JSPExtensionServletWrapper.checkForTranslation(JSPExtensionServletWrapper.java:265) at com.ibm.ws.jsp.webcontainerext.JSPExtensionServletWrapper.handleRequest(JSPExtensionServletWrapper.java:137) at com.ibm.ws.jsp.webcontainerext.JSPExtensionProcessor.handleRequest(JSPExtensionProcessor.java:230) at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:2837) at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:220) at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:204) at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1681) at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:77) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:421) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:367) at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:94) at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:548) at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java:601) at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:934) at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1021) at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1332)
One of the funny things here, is that this is happening only when i start websphere in debug mode!
Does anyone have any idea of what may be causing this or how we can find what's causing it or how to resolve it??
Thanks in advance
& Best Regards
Spiros P. -
Help at the earliset error in my code java.io.IOException :403 error code
my code is not working with the google and hot bot but working fine with other like yahoo and msn
pl rectify the problem ASAP
import java.net.URL;
import java.net.URLConnection;
import java.net.MalformedURLException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.StringTokenizer;
public class hbparsing
final static String DELIMITERS = ";-()\t\n\r\f.<>\"\'=/";
public static void main(String args[])
URL url = null;
String first = new String("10 of");
String sub = new String("of");
String line = new String();
String res = new String();
String buf = new String();
String temp = new String();
String searchURL="";
searchURL = args[0];
int i=0, j=0, k=0, val=0, total=0;
try
url = new URL("http://www.hotbot.com/default.asp?query="+searchURL+"&ps=&loc=searchbox&tab=web&provKey=Google&prov=Ask+Jeeves");
URLConnection connection = url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String contentType = connection.getContentType();
if (contentType == null || contentType.startsWith("text") == false)
throw new IOException("URL does not refer to a text file.");
System.out.println("Receiving Data......");
while ((line = in.readLine()) != null)
StringTokenizer tokenizer = new StringTokenizer(line, DELIMITERS);
while (tokenizer.hasMoreTokens())
String key = tokenizer.nextToken();
if (key != null && key.contains(first))
i = line.indexOf(first);
System.out.println("The search is " +first);
//" height="22" align="absmiddle"></strong> (Showing Results 1 - 10 of 1,441,000)</div><!-- RESULTS -->
StringTokenizer token1=new StringTokenizer(key," )<");
System.out.println("The fetched string using hb is "+key);
while(token1.hasMoreTokens())
buf = token1.nextToken();
if (buf != null && buf.contains(sub))
res = token1.nextToken();
j = line.indexOf(res);
System.out.println("The index of the searched string using hb is " +j);
temp = res.replaceAll("," , "");
val = Integer.parseInt(temp);
total = total + val;
System.out.println("The fetched substring using hb is "+res);
System.out.println("The Total values of the result searched using hb is "+total);
in.close();
else
continue;
if (j>0)
break;
else
continue;
catch (MalformedURLException e)
System.out.println("\nERROR! Improper syntax given for the URL to be loaded.");
catch (SecurityException e)
System.out.println("\nSECURITY ERROR! Can't access that URL.");
catch (IOException e)
System.out.println("\nINPUT ERROR! Problem reading data from that URL:\n" + e.toString());
}Hi Narasimhan
From what i understand from this post is that the application data is not getting downloaded to the client from the server and the data is in O-waiting in the middleware. One possibile reason for this is because of time out in the ABAP Sync Service. There is a parameter named <i><b>icm/keep_alive_timeout</b></i> which indicates the time between the last successful query and the termination of connection. The default value for his parameter is 60 seconds. Increasing this value to a higher value (preferably in minutes, depending on your landscape and amount of data) will definitely help. You can probably set the value of this parameter to around 10 mins.
Go to transaction RZ11 and enter the above parameter name to display the current setting. Inorder to change the default value, please refer to note 824554 which describes this in detail
Hope this helps
Best Regards
Sivakumar -
Help with a java.io.IOException
input : MemoryAccess - to load process into the disk
output : true if file opened, flase if fails
purpose : to open a file and read in the processes
code sourse: http://javaalmanac.com/egs/java.io/ReadLinesFromFile.html
public boolean openFile(MemoryAccess ma)
Process p;
String file, inputString;
char name = ' ';
int mem = 0, quantum = 0, numProc;
char[] charArray;
//Ask user for file name
System.out.print("Enter file name:");
BufferedReader stdin = new BufferedReader(new InputStreamReader( System.in ));
file = stdin.readLine();
//We are writing this code under the assumption that the memory column(in small.dat) is formated to 2 spa\
ces
//and all other columns are one space.
try {
BufferedReader in = new BufferedReader(new FileReader(file));
numProc = new Integer(in.readLine()).intValue();
while ((inputString = in.readLine()) != null)
charArray = inputString.toCharArray();
name = charArray[0];
if((charArray[2] != ' ') && (charArray[3] != ' '))
mem = ((int)(charArray[2] * 10) + (int)charArray[3]);
else if(charArray[2] != ' ')
mem = charArray[2];
else
mem = charArray[3];
quantum = (int)charArray[5];
System.out.print(name + " ");
System.out.print(mem + " ");
System.out.println(quantum);
in.close();
return true;
} catch (IOException e)
return false;
Pwnix.java:67: unreported exception java.io.IOException; must be caught or declared to be thrown
file = stdin.readLine();
^
1 error
That is my code and my error, I can't figure out what's wrong.>
Pwnix.java:67: unreported exception
java.io.IOException; must be caught or declared to be
thrown
file = stdin.readLine();
^
1 error
http://forum.java.sun.com/help.jspa?sec=formatting
http://forum.java.sun.com/help.jspa?sec=formatting
That is my code and my error, I can't figure out
what's wrong.http://forum.java.sun.com/help.jspa?sec=formatting
Please use the code tags around your code samples. It is much easier to read.
http://forum.java.sun.com/help.jspa?sec=formatting
The error message you see indicates that the readLine() method could throw an IOException. Therefore, you must either place that method call inside a try block, or declare to throw the IOException from your own method where the call to readLine is made. -
Help...java.io.IOException Problem
Hello,
I am having problems running Weblogic 4.5.1 as Windows NT Service but no
problems when running from command window.
The configuration is such:
Hardware:
Dual Processor PIII, 1GB memory, 2 NICs, mirrored internal RAID SCSI drive
on Compaq 1850R
OS:
Windows NT 4.0 SP5
Configuration:
JVM: JDK 1.2.2 (heap size 384M) from Sun
Weblogic 4.5.1 (Server version value=4.5.1 - 128 bit domestic version)
weblogic.system.executeThreadCount=40
weblogic.system.nativeIO.enable=true
weblogic.system.enableConsole=true
If I start the weblogic server from the command window and start throwing
https requests to it, the server works fine for as many number of messages
as I want and for as long as I want.
But when I start the server from the services window in the control panel,
after 98th message it starts giving error (found ofcourse in the log file
only). The snippet of the log file is shown below:
Error found in log file:
Thu Apr 27 05:57:34 PDT 2000:<I> <ListenThread> Listening on port: 80
Thu Apr 27 05:57:35 PDT 2000:<I> <SSLListenThread> Listening on port: 443
Thu Apr 27 05:57:35 PDT 2000:<I> <WebLogicServer> WebLogic Server started
Thu Apr 27 05:58:01 PDT 2000:<I> <ServletContext-Servlets>
com.mycompany.servlet.frontline.frontlineServlet: init
Thu Apr 27 05:59:01 PDT 2000:<E> <CliCon-#|myserver|11.956840209531>
FrontlineSessionBean.processMessage: error parsing message:
java.io.IOException: The handle is invalid
Thu Apr 27 05:59:01 PDT 2000:<E> <CliCon-#|myserver|11.956840209531>
FrontlineSessionBean.processMessage: error parsing message:
java.io.IOException: The handle is invalid
Your insights will be highly helpful.
thanks.
Alay DesaiHello all,
I'm having almost the same issue related to error message when I hit a button on my manufacturing software.
*"ScriptException: Error in exec: java.io.IOException: CreateProcess*
*exec(C:\\progra~1\\intern~1\\iexplore.exe http://cbweb4:81/barcode/CMbombyorder.asp\u003FR2=P&T2=12875424-P")*
This is when I hit a button that works for us to show this webpage I wrote previously. Last week we didnt have this issue, this just started this morning and I dont know what do to, it shows something about JAVA, that's why I'm asking to you guys, I dont know if you could please enlight me a little bit.
Thanks in advance. -
I use stand alone "XMLBeans survival kit" ( which I downloaded on 11/1/03 from
BEA site ). I use its xmlbean.jar and it works fine. I did not use its "scomp"
utility until today ( I used BEA's on-line compiler and it worked just great ).
When I tried to use the stand alone "scomp" , I've got into trouble. Here is the
trace of the error I receive for all schemas including the example schema ( I
have followed the instructions described in the attached README file for the environment
configuration) :
C:\WSAD_Workspaces\dc_xml_beans\xml_to_java\test>scomp -out myeasypo.jar C:\XMLBeanToolkit\xkit\schemas\easypo
Loading schema file C:\XMLBeanToolkit\xkit\schemas\easypo\easypo.xsd
Loading config file C:\XMLBeanToolkit\xkit\schemas\easypo\easypo.xsdconfig
Time to build schema type system: 1.297 seconds
java.io.IOException: CreateProcess: "C:\Program Files\Java\j2re1.4.1_05\..\bin\javac.exe"
-J-Xmx256M @C:\DOCUME~1\a337335\LOCALS~1\Temp\javac31952 error=3
null
java.io.IOException: CreateProcess: "C:\Program Files\Java\j2re1.4.1_05\..\bin\javac.exe"
-J-Xmx256M @C:\DOCUME~1\a337335\LOCALS~1\Temp\javac31952 error=3
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Win32Process.java:67)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:566)
at java.lang.Runtime.exec(Runtime.java:491)
at java.lang.Runtime.exec(Runtime.java:457)
at com.bea.xbean.tool.CodeGenUtil.externalCompile(CodeGenUtil.java:167)
at com.bea.xbean.tool.SchemaCodeGenerator.compileTypeSystem(SchemaCodeGenerator.java:178)
at com.bea.xbean.tool.SchemaCompiler.compileImpl(SchemaCompiler.java:547)
at com.bea.xbean.tool.SchemaCompiler.main(SchemaCompiler.java:141)
BUILD FAILED
Please, help me to find what is wrong here !!!
Thank you,
- Michael P.
[README.txt]Sorry, folks, the answer was quite simple: the default scomp script has pointed
to "wrong" location for java.exe. In particular, the scrip has specified compilation
command like this:
java -classpath %cp% com.bea.xbean.tool.SchemaCompiler %*
while it had to specify path to the java.exe based on JAVA_HOME env. variable
( I am saying "had" because README instructions state that the JAVA_HOME has to
be properly configured ). So, the solution looks like:
%JAVA_HOME%\bin\java -classpath %cp% com.bea.xbean.tool.SchemaCompiler %*
- Michael P.
"Michael P." <[email protected]> wrote:
>
>
>
I use stand alone "XMLBeans survival kit" ( which I downloaded on 11/1/03
from
BEA site ). I use its xmlbean.jar and it works fine. I did not use its
"scomp"
utility until today ( I used BEA's on-line compiler and it worked just
great ).
When I tried to use the stand alone "scomp" , I've got into trouble.
Here is the
trace of the error I receive for all schemas including the example schema
( I
have followed the instructions described in the attached README file
for the environment
configuration) :
C:\WSAD_Workspaces\dc_xml_beans\xml_to_java\test>scomp -out myeasypo.jar
C:\XMLBeanToolkit\xkit\schemas\easypo
Loading schema file C:\XMLBeanToolkit\xkit\schemas\easypo\easypo.xsd
Loading config file C:\XMLBeanToolkit\xkit\schemas\easypo\easypo.xsdconfig
Time to build schema type system: 1.297 seconds
java.io.IOException: CreateProcess: "C:\Program Files\Java\j2re1.4.1_05\..\bin\javac.exe"
-J-Xmx256M @C:\DOCUME~1\a337335\LOCALS~1\Temp\javac31952 error=3
null
java.io.IOException: CreateProcess: "C:\Program Files\Java\j2re1.4.1_05\..\bin\javac.exe"
-J-Xmx256M @C:\DOCUME~1\a337335\LOCALS~1\Temp\javac31952 error=3
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Win32Process.java:67)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:566)
at java.lang.Runtime.exec(Runtime.java:491)
at java.lang.Runtime.exec(Runtime.java:457)
at com.bea.xbean.tool.CodeGenUtil.externalCompile(CodeGenUtil.java:167)
at com.bea.xbean.tool.SchemaCodeGenerator.compileTypeSystem(SchemaCodeGenerator.java:178)
at com.bea.xbean.tool.SchemaCompiler.compileImpl(SchemaCompiler.java:547)
at com.bea.xbean.tool.SchemaCompiler.main(SchemaCompiler.java:141)
BUILD FAILED
Please, help me to find what is wrong here !!!
Thank you,
- Michael P. -
Help please! java.io.IOException: Stream closed
When I run my webapp under Tomcat5.5, it works fine, but I got the following Exception in Tomcat stdout.log:
2005.04.19. 15:54:47 org.apache.jasper.runtime.PageContextImpl release
WARNING: Internal error flushing the buffer in release()
2005.04.19. 15:54:47 org.apache.catalina.core.StandardWrapperValve invoke
WARNING: Servlet.service() for servlet jsp threw exception
java.io.IOException: Stream closed
at org.apache.jasper.runtime.JspWriterImpl.ensureOpen(JspWriterImpl.java:204)
at org.apache.jasper.runtime.JspWriterImpl.clearBuffer(JspWriterImpl.java:159)
at org.apache.jsp.pages.tree_jsp._jspService(org.apache.jsp.pages.tree_jsp:58)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
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.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:534)I dont have an idea why did my webapp throw this. I got it when I logged in the webapp. I cant find the root problem, because there is no a word from my package in the exception-list above. What happened?
Thanks in advance.SEVERE: Servlet.service() for servlet jsp threw exception
java.io.IOException: Stream closed
at org.apache.jasper.runtime.JspWriterImpl.ensureOpen(JspWriterImpl.java:204)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:115)
at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:186)
at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:118)
at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:77)
at org.apache.jsp.accSubAccount_jsp._jspService(accSubAccount_jsp.java:244)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)It is in JSP, I was just quoting that looking into error stack I opened genrated java file accSubAccount_jsp.java at line 244 and came to know that this file has only 196 lins.
At successfull submission I am opening a page through javascript window.location directive, probably it may be the reason? -
Help: java.io.IOException
I am running WL 6.1 SP1 with JDK 1.3.1. I get an IOException
each time I try to run a basic login jsp. The jsp worked fine,
then stopped working. Not sure if something was changed in the
weblogic or environmental conditions to cause this. Other jsp's
work fine. I've stopped, started, rebooted a number of times,
with no luck.
Anyone provide some insight? I am thinking something is screwed upwith my CLASSPATH
somewhere.
(I am new to this stuff, so take it easy on me if the problem is obvious!)
I have checked:
JAVA_HOME =C:\weblogic\jdk131
WL_HOME =C:\weblogic
PATH =%WL_HOME%\bin;%JAVA_HOME%\bin;%PATH%
CLASSPATH =%JAVA_HOME%\lib\tools.jar;%WL_HOME%\lib\weblogic_sp.jar;%WL_HOME%\lib\weblogic.jar;%CLASSPATH%
Compilation f 'C:\weblogic\config\mydomain\applications\DefaultWebApp\WEB-INF\_tmp_war_myserver_myserver_DefaultWebApp\jsp_servlet\_myjsps\__login.java'
failed:
C:\weblogic\config\mydomain\applications\DefaultWebApp\WEB-INF\_tmp_war_myserver_myserver_DefaultWebApp\jsp_servlet\_myjsps\__login.java
error=2
Full compiler error(s):
java.io.IOException: CreateProcess: javac -classpath
C:\weblogic\config\mydomain\applications\DefaultWebApp;C:\weblogic\config\mydomain\applications\DefaultWebApp\WEB-INF\_tmp_war_myserver_myserver_DefaultWebApp;C:\weblogic\jdk131\jre\lib\rt.jar;C:\weblogic\jdk131\jre\lib\i18n.jar;C:\weblogic\jdk131\jre\lib\sunrsasign.jar;C:\weblogic\jdk131\jre\classes;.;C:\weblogic\lib\weblogic_sp.jar;C:\weblogic\lib\weblogic.jar
-d C:\weblogic\config\mydomain\applications\DefaultWebApp\WEB-INF\_tmp_war_myserver_myserver_DefaultWebApp
C:\weblogic\config\mydomain\applications\DefaultWebApp\WEB-INF\_tmp_war_myserver_myserver_DefaultWebApp\jsp_servlet\_myjsps\__login.java
error=2
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Win32Process.java:66)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:551)
at java.lang.Runtime.exec(Runtime.java:477)
at java.lang.Runtime.exec(Runtime.java:443)
at weblogic.utils.Executable.exec(Executable.java:200)
at weblogic.utils.Executable.exec(Executable.java:125)
at weblogic.utils.compiler.CompilerInvoker.compileMaybeExit(CompilerInvoker.java:545)
at weblogic.utils.compiler.CompilerInvoker.compile(CompilerInvoker.java:354)
at weblogic.servlet.jsp.JspStub.compilePage(JspStub.java:382)
at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:189)
at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:154)
at weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:368)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:242)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2456)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2039)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
It's not a problem with your classpath.
I would guess that it can't find javac in your %PATH% - your PATH looks ok.
Mike
"Aubrey" <[email protected]> wrote:
>
>I am running WL 6.1 SP1 with JDK 1.3.1. I get an IOException
> each time I try to run a basic login jsp. The jsp worked fine,
>then stopped working. Not sure if something was changed in the
>weblogic or environmental conditions to cause this. Other jsp's
>work fine. I've stopped, started, rebooted a number of times,
>with no luck.
>Anyone provide some insight? I am thinking something is screwed upwith
>my CLASSPATH
>somewhere.
>(I am new to this stuff, so take it easy on me if the problem is obvious!)
>
>I have checked:
>
>JAVA_HOME =C:\weblogic\jdk131
>WL_HOME =C:\weblogic
>PATH =%WL_HOME%\bin;%JAVA_HOME%\bin;%PATH%
>CLASSPATH =%JAVA_HOME%\lib\tools.jar;%WL_HOME%\lib\weblogic_sp.jar;%WL_HOME%\lib\weblogic.jar;%CLASSPATH%
>
>
>Compilation f 'C:\weblogic\config\mydomain\applications\DefaultWebApp\WEB-INF\_tmp_war_myserver_myserver_DefaultWebApp\jsp_servlet\_myjsps\__login.java'
>failed:
>--------------------------------------------------------------------------------
> C:\weblogic\config\mydomain\applications\DefaultWebApp\WEB-INF\_tmp_war_myserver_myserver_DefaultWebApp\jsp_servlet\_myjsps\__login.java
>error=2
>--------------------------------------------------------------------------------
>Full compiler error(s):
>java.io.IOException: CreateProcess: javac -classpath
>C:\weblogic\config\mydomain\applications\DefaultWebApp;C:\weblogic\config\mydomain\applications\DefaultWebApp\WEB-INF\_tmp_war_myserver_myserver_DefaultWebApp;C:\weblogic\jdk131\jre\lib\rt.jar;C:\weblogic\jdk131\jre\lib\i18n.jar;C:\weblogic\jdk131\jre\lib\sunrsasign.jar;C:\weblogic\jdk131\jre\classes;.;C:\weblogic\lib\weblogic_sp.jar;C:\weblogic\lib\weblogic.jar
>-d C:\weblogic\config\mydomain\applications\DefaultWebApp\WEB-INF\_tmp_war_myserver_myserver_DefaultWebApp
>C:\weblogic\config\mydomain\applications\DefaultWebApp\WEB-INF\_tmp_war_myserver_myserver_DefaultWebApp\jsp_servlet\_myjsps\__login.java
>error=2
> at java.lang.Win32Process.create(Native Method)
> at java.lang.Win32Process.<init>(Win32Process.java:66)
> at java.lang.Runtime.execInternal(Native Method)
> at java.lang.Runtime.exec(Runtime.java:551)
> at java.lang.Runtime.exec(Runtime.java:477)
> at java.lang.Runtime.exec(Runtime.java:443)
> at weblogic.utils.Executable.exec(Executable.java:200)
> at weblogic.utils.Executable.exec(Executable.java:125)
> at weblogic.utils.compiler.CompilerInvoker.compileMaybeExit(CompilerInvoker.java:545)
> at weblogic.utils.compiler.CompilerInvoker.compile(CompilerInvoker.java:354)
> at weblogic.servlet.jsp.JspStub.compilePage(JspStub.java:382)
> at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:189)
> at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:154)
> at weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:368)
> at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:242)
> at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200)
> at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2456)
> at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2039)
> at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
> at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
-
How to solve java.io.IOException: Corrupt form data: premature ending
hei evryone!
Does anyone knows how to solve this bug?
java.io.IOException: Corrupt form data: premature ending
Im using Oreilly's cos.jar MultipartRequest
here is my form :
<FORM METHOD="POST" NAME="uploadform" action="mbbfile" ENCTYPE="multipart/form-data">
<TR>
<TD>Select a File:</TD>
<TD><INPUT TYPE="FILE" NAME="srcfile" style="width:400px"/></TD>
</TR>
<TR><TD><INPUT TYPE="SUBMIT" VALUE="Send"/></TD></TR>
</FORM>
HERE IS mbbfile which is a servlet :
package mbb.servlet;
import java.io.IOException;
import java.sql.Connection;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.oreilly.servlet.MultipartRequest;
import org.jconfig.Configuration;
import org.jconfig.ConfigurationManager;
public class MBBFileServlet extends HttpServlet{
private static final Configuration conf = ConfigurationManager.getConfiguration("ConfigFile");
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
String filePath = conf.getProperty("FilePath", "", "test");
try{
MultipartRequest multi = new MultipartRequest(req,filePath,5*1024*1024);
}catch(Exception e){
System.out.println("MBBFileServlet Exception ---> "+e.getMessage());
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
doGet(req,res);
Sometimes it works meaning the file is uploaded in the directory without any exception, sometimes the file is uploaded but with exception on the log saying "MBBFileServlet Exception ---> Corrupt form data: Premature Ending". and sometimes the files is not uploaded at all and when i check the error is : "MBBFileServlet Exception ---> Corrupt form data: Premature Ending". Can anyone please help me on this matter. Thx!
Your response would be deeply appreciated.
br,
TACHi all!
Since I've spent some days now trying to figure out what was wrong with my file upload in Struts 1.1, I would like to share my solution with the rest of you in order to spare you for the same amout of wasted time I've spent :-)
My platform is Resin 3.0.8 and Struts 1.1. My problem was that JPEG's got corrupted when arriviving at the server. After a few days searching on the net, I tried with a plain servlet and the O'Reilly package, and the app worked perfect.
Here is my servlet:
package no.yourcompany.yourapp.servlet;
import com.oreilly.servlet.multipart.MultipartParser;
import com.oreilly.servlet.multipart.Part;
import com.oreilly.servlet.multipart.FilePart;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.ServletException;
import javax.servlet.ServletContext;
import javax.servlet.RequestDispatcher;
import java.io.IOException;
import java.io.ByteArrayOutputStream;
public class ImageUpload extends HttpServlet {
private static final String PAGE_RECEIPT = "/popImageUploadReceipt.do";
private static final int MAX_FILE_SIZE_IN_BYTES = 10000000; // 10 M
* Extracts image from request and puts it into person form.
* @see HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// custom beans from my project, not defined here
PersonRegistrationForm personRegistrationForm = null;
PortraitImage portraitImage = null;
ByteArrayOutputStream outputStream = null;
Part currentPart = null;
FilePart currFilePart = null;
personRegistrationForm = (PersonRegistrationForm) request.getSession().getAttribute(DsnSessionKeyConstantsIF.KEY_PERSON_FORM);
portraitImage = personRegistrationForm.getPortraitImage();
try {
MultipartParser parser = new MultipartParser(request, MAX_FILE_SIZE_IN_BYTES);
while ((currentPart = parser.readNextPart()) != null) {
if (currentPart.isFile()) {
currFilePart = (FilePart) currentPart;
outputStream = new ByteArrayOutputStream();
currFilePart.writeTo(outputStream);
// portraitImage is just a bean for encapsulating image data, not defined in this posting
portraitImage.setContentType(currFilePart.getContentType());
portraitImage.setImageAsByteArray(outputStream.toByteArray());
portraitImage.setOriginalFileName(currFilePart.getFileName());
break;
} // if (currentPart.isFile())
} // while ((currentPart = parser.readNextPart()) != null)
} catch (IOException ioe) {
// noop
// redirect to receipt page
ServletContext servletContext = this.getServletContext();
RequestDispatcher requestDispatcher = servletContext.getRequestDispatcher(PAGE_RECEIPT);
requestDispatcher.forward(request, response);
} // doPost
} // ImageUpload
AND ADD THIS TO YOUR WEB.XML
<servlet>
<servlet-name>ImageUpload</servlet-name>
<servlet-class>no.yourcompany.yourapp.servlet.ImageUpload</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ImageUpload</servlet-name>
<url-pattern>imageUpload.do</url-pattern>
</servlet-mapping>
AND THE HTML-FORM IS HERE
<form action="/yourapp/imageUpload.do" method="post" enctype="multipart/form-data" accept="image/*">
<p>
<input type="file" name="portraitImage" />
</p>
<p>
<input type="image" src="/dsn/img/btn_last_bilde.gif" border="0">
</p>
</form> -
Hi,
I am using java.net.URLConnection to invoke servlet which uses oracle.xml.sql.dml.OracleXMLSave for dml operations.
I am facing below exception.
09/05/26 17:47:50 java.io.IOException: Server returned HTTP response code: 500 for URL: http://xxx.com/servlets/com.xxx.qu.XMLDocPostOracleInsert
09/05/26 17:47:50 at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpConnection.java:)
09/05/26 17:47:50 at com.xxx.util.http.HTTPRequester.makePostRequest(HTTPRequester.java:)
09/05/26 17:47:50 at com.xxx.qu.PostReceiver.doPost(PostReceiver.java:145)
09/05/26 17:47:50 at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
09/05/26 17:47:50 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
09/05/26 17:47:50 at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:810)
09/05/26 17:47:50 at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:322)
09/05/26 17:47:50 at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
09/05/26 17:47:50 at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:208)
09/05/26 17:47:50 at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:125)
09/05/26 17:47:50 at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
09/05/26 17:47:50 at java.lang.Thread.run(Thread.java:534)
The oraclexmlsave operations are with in try-catch block as shown below, but its not getting caught there(Donnno Whyy????).Instead its giving
exception at HttpURLConnection.getInputStream
try{
System.out.println("entered try :1");
String Query="SELECT * from global_name";
Statement CntStmt=con.createStatement();
ResultSet rsEmailAlertQuery=CntStmt.executeQuery(Query);
while(rsEmailAlertQuery.next()){
System.out.println(rsEmailAlertQuery.getString(1));
OracleXMLSave oxs = new OracleXMLSave(con,insertObject);
System.out.println("MI B: ");
oxs.setRowTag("row");
oxs.setIgnoreCase(true);
int rowsInserted = oxs.insertXML(xd);
System.out.println("MI C: ");
out.println("<success>TRUE</success>");
con.commit();
System.out.println("MI D: ");
catch(OracleXMLSQLException e){
System.out.println("OracleXMLSQLException");
e.printStackTrace();
catch(SQLException e){
System.out.println("SQLException");
e.printStackTrace();
catch(Exception e){
System.out.println("Exception");
e.printStackTrace();
Normal jdbc queries(rsEmailAlertQuery) are working properly.The problem is only with OracleXMLSave.
Any help would be greatfull.
Edited by: suryaraj on 29-May-2009 06:45Hi,
May be you can get the description of the error on the server log of the server running on ip:url
-Priyanka -
Hi,
I use ridc to check in file into Oracle Center Content server. There is no problem at the beginning. But after running for several days, there is following error.
I must restart my program to solve this issue.
Can anyone help me solve this problem?
Thanks,
Tony
2013-07-11 12:24:31,189 ERROR [BatchEventHandler] com.edocs.common.api.integration.contmgmt.ContentException: oracle.stellent.ridc.protocol.ProtocolEx
ception: java.io.IOException: Input terminated before being able to read line
at com.edocs.common.integration.contmgmt.UCMContentManager.saveContent(UCMContentManager.java:95)
at com.edocs.common.reporting.batch.BatchEventHandler.processBatchRequest(BatchEventHandler.java:284)
at com.edocs.common.reporting.batch.BatchEventHandler.service(BatchEventHandler.java:138)
at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask.executeInternal(BatchReportProcessorTask.java:156)
at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask.doProcessTask(BatchReportProcessorTask.java:68)
at com.edocs.pwc.tasks.CommonTask.processTask(CommonTask.java:166)
at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask_9qwgr6_EOImpl.__WL_invoke(Unknown Source)
at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:40)
at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask_9qwgr6_EOImpl.processTask(Unknown Source)
at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask_9qwgr6_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.activation.ActivatableServerRef.invoke(ActivatableServerRef.java:85)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:522)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:518)
at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
Caused by: oracle.stellent.ridc.protocol.ProtocolException: java.io.IOException: Input terminated before being able to read line
at oracle.stellent.ridc.protocol.ServiceResponse.getResponseAsBinder(ServiceResponse.java:149)
at oracle.stellent.ridc.protocol.ServiceResponse.getResponseAsBinder(ServiceResponse.java:108)
at com.edocs.common.integration.contmgmt.UCMContentManager.saveContent(UCMContentManager.java:81)
... 17 more
Caused by: java.io.IOException: Input terminated before being able to read line
at oracle.stellent.ridc.model.serialize.HdaBinderSerializer.readLine(HdaBinderSerializer.java:371)
at oracle.stellent.ridc.model.serialize.HdaBinderSerializer.readToEnd(HdaBinderSerializer.java:335)
at oracle.stellent.ridc.model.serialize.HdaBinderSerializer.parseBinder(HdaBinderSerializer.java:165)
at oracle.stellent.ridc.model.serialize.HdaBinderSerializer.parseBinder(HdaBinderSerializer.java:71)
at oracle.stellent.ridc.protocol.ServiceResponse.getResponseAsBinder(ServiceResponse.java:126)
... 19 more
2013-07-11 12:24:33,005 ERROR [BatchEventHandler] com.edocs.common.api.integration.contmgmt.ContentException: oracle.stellent.ridc.protocol.ProtocolEx
ception: java.io.IOException: Input terminated before being able to read line
at com.edocs.common.integration.contmgmt.UCMContentManager.saveContent(UCMContentManager.java:95)
at com.edocs.common.reporting.batch.BatchEventHandler.processBatchRequest(BatchEventHandler.java:284)
at com.edocs.common.reporting.batch.BatchEventHandler.service(BatchEventHandler.java:138)
at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask.executeInternal(BatchReportProcessorTask.java:156)
at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask.doProcessTask(BatchReportProcessorTask.java:68)
at com.edocs.pwc.tasks.CommonTask.processTask(CommonTask.java:166)
at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask_9qwgr6_EOImpl.__WL_invoke(Unknown Source)
at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:40)
at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask_9qwgr6_EOImpl.processTask(Unknown Source)
at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask_9qwgr6_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.activation.ActivatableServerRef.invoke(ActivatableServerRef.java:85)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:522)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:518)
at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
Caused by: oracle.stellent.ridc.protocol.ProtocolException: java.io.IOException: Input terminated before being able to read line
at oracle.stellent.ridc.protocol.ServiceResponse.getResponseAsBinder(ServiceResponse.java:149)
at oracle.stellent.ridc.protocol.ServiceResponse.getResponseAsBinder(ServiceResponse.java:108)
at com.edocs.common.integration.contmgmt.UCMContentManager.saveContent(UCMContentManager.java:81)
... 17 more
Caused by: java.io.IOException: Input terminated before being able to read line
at oracle.stellent.ridc.model.serialize.HdaBinderSerializer.readLine(HdaBinderSerializer.java:371)
at oracle.stellent.ridc.model.serialize.HdaBinderSerializer.readToEnd(HdaBinderSerializer.java:335)
at oracle.stellent.ridc.model.serialize.HdaBinderSerializer.parseBinder(HdaBinderSerializer.java:165)
at oracle.stellent.ridc.model.serialize.HdaBinderSerializer.parseBinder(HdaBinderSerializer.java:71)
at oracle.stellent.ridc.protocol.ServiceResponse.getResponseAsBinder(ServiceResponse.java:126)
... 19 more
2013-07-11 12:24:37,870 ERROR [BatchEventHandler] com.edocs.common.api.integration.contmgmt.ContentException: oracle.stellent.ridc.protocol.ProtocolEx
ception: java.io.IOException: Input terminated before being able to read line
at com.edocs.common.integration.contmgmt.UCMContentManager.saveContent(UCMContentManager.java:95)
at com.edocs.common.reporting.batch.BatchEventHandler.processBatchRequest(BatchEventHandler.java:284)
at com.edocs.common.reporting.batch.BatchEventHandler.service(BatchEventHandler.java:138)
at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask.executeInternal(BatchReportProcessorTask.java:156)
at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask.doProcessTask(BatchReportProcessorTask.java:68)
at com.edocs.pwc.tasks.CommonTask.processTask(CommonTask.java:166)
at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask_9qwgr6_EOImpl.__WL_invoke(Unknown Source)
at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:40)
at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask_9qwgr6_EOImpl.processTask(Unknown Source)
at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask_9qwgr6_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.activation.ActivatableServerRef.invoke(ActivatableServerRef.java:85)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:522)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:518)
at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
Caused by: oracle.stellent.ridc.protocol.ProtocolException: java.io.IOException: Input terminated before being able to read line
at oracle.stellent.ridc.protocol.ServiceResponse.getResponseAsBinder(ServiceResponse.java:149)
at oracle.stellent.ridc.protocol.ServiceResponse.getResponseAsBinder(ServiceResponse.java:108)
at com.edocs.common.integration.contmgmt.UCMContentManager.saveContent(UCMContentManager.java:81)
... 17 more
Caused by: java.io.IOException: Input terminated before being able to read line
at oracle.stellent.ridc.model.serialize.HdaBinderSerializer.readLine(HdaBinderSerializer.java:371)
at oracle.stellent.ridc.model.serialize.HdaBinderSerializer.readToEnd(HdaBinderSerializer.java:335)
at oracle.stellent.ridc.model.serialize.HdaBinderSerializer.parseBinder(HdaBinderSerializer.java:165)
at oracle.stellent.ridc.model.serialize.HdaBinderSerializer.parseBinder(HdaBinderSerializer.java:71)
at oracle.stellent.ridc.protocol.ServiceResponse.getResponseAsBinder(ServiceResponse.java:126)
... 19 more
2013-07-11 12:24:39,722 ERROR [BatchEventHandler] com.edocs.common.api.integration.contmgmt.ContentException: oracle.stellent.ridc.protocol.ProtocolEx
ception: java.io.IOException: Input terminated before being able to read line
at com.edocs.common.integration.contmgmt.UCMContentManager.saveContent(UCMContentManager.java:95)
at com.edocs.common.reporting.batch.BatchEventHandler.processBatchRequest(BatchEventHandler.java:284)
at com.edocs.common.reporting.batch.BatchEventHandler.service(BatchEventHandler.java:138)
at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask.executeInternal(BatchReportProcessorTask.java:156)
at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask.doProcessTask(BatchReportProcessorTask.java:68)
at com.edocs.pwc.tasks.CommonTask.processTask(CommonTask.java:166)
at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask_9qwgr6_EOImpl.__WL_invoke(Unknown Source)
at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:40)
at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask_9qwgr6_EOImpl.processTask(Unknown Source)
at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask_9qwgr6_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.activation.ActivatableServerRef.invoke(ActivatableServerRef.java:85)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:522)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:518)
at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
Caused by: oracle.stellent.ridc.protocol.ProtocolException: java.io.IOException: Input terminated before being able to read line
at oracle.stellent.ridc.protocol.ServiceResponse.getResponseAsBinder(ServiceResponse.java:149)
at oracle.stellent.ridc.protocol.ServiceResponse.getResponseAsBinder(ServiceResponse.java:108)
at com.edocs.common.integration.contmgmt.UCMContentManager.saveContent(UCMContentManager.java:81)
... 17 more
Caused by: java.io.IOException: Input terminated before being able to read line
at oracle.stellent.ridc.model.serialize.HdaBinderSerializer.readLine(HdaBinderSerializer.java:371)
at oracle.stellent.ridc.model.serialize.HdaBinderSerializer.readToEnd(HdaBinderSerializer.java:335)
at oracle.stellent.ridc.model.serialize.HdaBinderSerializer.parseBinder(HdaBinderSerializer.java:165)
at oracle.stellent.ridc.model.serialize.HdaBinderSerializer.parseBinder(HdaBinderSerializer.java:71)
at oracle.stellent.ridc.protocol.ServiceResponse.getResponseAsBinder(ServiceResponse.java:126)
... 19 moreThe following is my testing code.
package ebilling;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.SecureRandom;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import oracle.stellent.ridc.IdcClient;
import oracle.stellent.ridc.IdcClientManager;
import oracle.stellent.ridc.IdcContext;
import oracle.stellent.ridc.model.DataBinder;
import oracle.stellent.ridc.model.DataObject;
import oracle.stellent.ridc.model.DataResultSet;
import oracle.stellent.ridc.model.TransferFile;
import oracle.stellent.ridc.protocol.ServiceResponse;
import org.apache.commons.lang.StringUtils;
public class UCMContentManager {
* Check in a file into a Oracle WebCenter Content Server and return content id of uploaded content item in Oracle WebCenter Content Server.
* @param properties The Oracle WebCenter Content Server connection properties.
* @param contentFile This file will be checked in a Oracle WebCenter Content Server.
* @param path The location path of checked in file in Oracle WebCenter Content Server. This path includes the file name.<br>
* For example, "/folder1/folder2/file1.txt". The "file1.txt" is the file name part. <br>
* The file name will be used as dDocName in Oracle WebCenter Server. It must be unique.<br>
* @throws ContentException The exception when uploading file into Oracle WebCenter Content Server.
* @return The content id of uploaded content item in Oracle WebCenter Content Server.
public String saveContent(Properties properties, File contentFile, String path) throws ContentException{
if(path.endsWith(SLASH)) {
throw new ContentException("Require file name in Content Management Server");
if(!path.startsWith(SLASH)) {
throw new ContentException("The file store path in Content Management Server should be absolute.");
if (path.indexOf("//") != -1) {
path = path.replace("//", SLASH);
String[] paths = path.split(SLASH);
String[] parents = new String[paths.length - 1];
String itemName = paths[paths.length-1];
System.arraycopy(paths, 0, parents, 0, paths.length-1);
ServiceResponse response = null;
try {
IdcClientManager manager = new IdcClientManager();
IdcClient client = manager.createClient(properties.getProperty(URL_PROPERTY));
client.getConfig().setProperty ("http.library", "apache4");
String user = properties.getProperty(USERNAME_PROPERTY);
String pwd = properties.getProperty(PASSWORD_PROPERTY);
IdcContext connectionContext = new IdcContext(user, pwd);
pwd = null;
//create the parent folders if they don't exist
String folderGUID = makeFolders(properties, parents);
//check in the file
DataBinder requestData = client.createBinder();
requestData.putLocal("IdcService", "CHECKIN_UNIVERSAL");
requestData.putLocal("IsJava", "1");
requestData.putLocal("dDocName", itemName);
requestData.putLocal("dDocTitle", itemName);
requestData.putLocal("dDocType", "Binary");
requestData.putLocal("dSecurityGroup", "Public");
requestData.addFile("primaryFile", new TransferFile(contentFile));
response = client.sendRequest(connectionContext, requestData);
DataBinder responseData = response.getResponseAsBinder();
//String did = responseData.getLocal("dID");
String dDocname = responseData.getLocal("dDocName");
closeResponse(response);
//link the file in a folder
requestData = client.createBinder();
requestData.putLocal("IdcService", "FLD_CREATE_FILE");
requestData.putLocal("fParentGUID", folderGUID);
String fileType = "owner";
requestData.putLocal("fFileType", fileType);
requestData.putLocal("dDocName", dDocname);
response = client.sendRequest(connectionContext, requestData);
return dDocname;
} catch (Throwable e) {
throw new ContentException(e);
} finally{
closeResponse(response);
public void deleteContent(Properties properties, String contentId) throws ContentException{
List<String> didList = getDIds(properties, contentId);
contentId = contentId.toUpperCase();
ServiceResponse response = null;
try {
IdcClientManager manager = new IdcClientManager();
IdcClient client = manager.createClient(properties.getProperty(URL_PROPERTY));
client.getConfig().setProperty ("http.library", "apache4");
String user = properties.getProperty(USERNAME_PROPERTY);
String pwd = properties.getProperty(PASSWORD_PROPERTY);
IdcContext connectionContext = new IdcContext(user, pwd);
pwd = null;
DataBinder requestData = null;
for(int i=0; i<didList.size(); i++) {
String did = didList.get(i);
requestData = client.createBinder();
requestData.putLocal("IdcService", "DELETE_DOC");
requestData.putLocal("dDocName", contentId);
requestData.putLocal("dID", did);
response = client.sendRequest(connectionContext, requestData);
closeResponse(response);
//delete parent folder
// try {
// requestData = client.createBinder();
// requestData.putLocal("IdcService", "FLD_DELETE");
// requestData.putLocal("item1", "path:" + parentPath);
// requestData.putLocal("constructDialog", "1");
// response = client.sendRequest(connectionContext, requestData);
// } catch (Exception e) {
// // TODO: handle exception
} catch (Exception e) {
throw new ContentException(e);
} finally {
closeResponse(response);
public int getFileCountInFolder(Properties properties, String path) throws ContentException{
ServiceResponse response = null;
try {
IdcClientManager manager = new IdcClientManager();
IdcClient client = manager.createClient(properties.getProperty(URL_PROPERTY));
client.getConfig().setProperty ("http.library", "apache4");
String user = properties.getProperty(USERNAME_PROPERTY);
String pwd = properties.getProperty(PASSWORD_PROPERTY);
IdcContext connectionContext = new IdcContext(user, pwd);
pwd = null;
DataBinder binder = client.createBinder();
binder.putLocal("IdcService", "FLD_BROWSE");
binder.putLocal("path", path);
response = client.sendRequest(connectionContext, binder);
DataBinder result = response.getResponseAsBinder();
String num = result.getLocal("numFiles");
return Integer.parseInt(num);
catch (Exception e) {
throw new ContentException(e);
} finally {
closeResponse(response);
private String getFolderGUID(Properties properties, String path) throws ContentException {
ServiceResponse response = null;
String tmpFolderGUID = null;
try {
IdcClientManager manager = new IdcClientManager();
IdcClient client = manager.createClient(properties.getProperty(URL_PROPERTY));
client.getConfig().setProperty ("http.library", "apache4");
String user = properties.getProperty(USERNAME_PROPERTY);
String pwd = properties.getProperty(PASSWORD_PROPERTY);
IdcContext connectionContext = new IdcContext(user, pwd);
pwd = null;
DataBinder requestData = client.createBinder();
requestData.putLocal("IdcService", "FLD_INFO");
requestData.putLocal("path", path);
response = client.sendRequest(connectionContext,
requestData);
DataResultSet result = response.getResponseAsBinder().getResultSet("FolderInfo");
tmpFolderGUID = result.getRows().get(0).get("fFolderGUID")
.toString();
if(StringUtils.isBlank(tmpFolderGUID))
tmpFolderGUID = null;
} catch (Exception e) {
} finally {
closeResponse(response);
return tmpFolderGUID;
public boolean deleteFolder(Properties properties, String path) throws ContentException {
if(getFolderGUID(properties, path)==null)
return false;
int fileCount = getFileCountInFolder(properties, path);
ServiceResponse response = null;
if(fileCount==0) {
try {
IdcClientManager manager = new IdcClientManager();
IdcClient client = manager.createClient(properties.getProperty(URL_PROPERTY));
client.getConfig().setProperty ("http.library", "apache4");
String user = properties.getProperty(USERNAME_PROPERTY);
String pwd = properties.getProperty(PASSWORD_PROPERTY);
IdcContext connectionContext = new IdcContext(user, pwd);
pwd = null;
DataBinder binder = client.createBinder();
binder.putLocal("IdcService", "FLD_DELETE");
binder.putLocal("item1", "path:" + path);
binder.putLocal("constructDialog", "1");
response = client.sendRequest(connectionContext, binder);
return true;
catch (Exception e) {
throw new ContentException(e);
} finally {
closeResponse(response);
} else {
return false;
private String buildPath(String[] arr, int i) {
StringBuilder buf = new StringBuilder();
for(int j=0; j<=i; j++) {
buf.append(arr[j]);
buf.append(SLASH);
return buf.toString();
private String makeFolders(Properties properties, String[] paths) throws ContentException{
String folderGUID = "";
ServiceResponse response = null;
try {
IdcClientManager manager = new IdcClientManager();
IdcClient client = manager.createClient(properties.getProperty(URL_PROPERTY));
client.getConfig().setProperty ("http.library", "apache4");
String user = properties.getProperty(USERNAME_PROPERTY);
String pwd = properties.getProperty(PASSWORD_PROPERTY);
IdcContext connectionContext = new IdcContext(user, pwd);
pwd = null;
String parentFolderGUID = null;
for(int i=0; i<paths.length; i++) {
String fullPath = buildPath(paths, i);
DataBinder requestData = null;
parentFolderGUID = folderGUID;
folderGUID = getFolderGUID(properties, fullPath);
boolean exists = folderGUID!=null;
DataResultSet result = null;
if(!exists) {
//create new folder
try {
requestData = client.createBinder();
requestData.putLocal("IdcService", "FLD_CREATE_FOLDER");
requestData.putLocal("fParentGUID", parentFolderGUID);
requestData.putLocal("fFolderName", paths[i]);
response = client.sendRequest(connectionContext, requestData);
} finally {
closeResponse(response);
//retrieve folderGUID of new folder
folderGUID = getFolderGUID(properties, fullPath);
} catch (Throwable e) {
throw new ContentException(e);
} finally{
closeResponse(response);
return folderGUID;
public List<String> getDIds(Properties properties, String contentId) throws ContentException{
contentId = contentId.toUpperCase();
List<String> didList = new ArrayList<String>();
ServiceResponse response = null;
try {
IdcClientManager manager = new IdcClientManager();
IdcClient client = manager.createClient(properties.getProperty(URL_PROPERTY));
client.getConfig().setProperty ("http.library", "apache4");
String user = properties.getProperty(USERNAME_PROPERTY);
String pwd = properties.getProperty(PASSWORD_PROPERTY);
IdcContext connectionContext = new IdcContext(user, pwd);
pwd = null;
DataBinder requestData = null;
requestData = client.createBinder();
requestData.putLocal("IdcService", "GET_SEARCH_RESULTS");
requestData.putLocal("SortField", "dInDate");
requestData.putLocal("SortType", "DESC");
requestData.putLocal("QueryText", "dDocName <matches> `" + contentId +"`");
response = client.sendRequest(connectionContext, requestData);
DataBinder result = response.getResponseAsBinder();
DataResultSet resultSet = result.getResultSet("SearchResults");
for (DataObject dataObject : resultSet.getRows()) {
// System.out.println("ID : " + dataObject.get("dID")+" dDocName : "
// + dataObject.get("dDocName") + " Title : " + dataObject.get("dDocTitle")
// + " Author : " + dataObject.get("dDocAuthor") + " Security Group : "
// + dataObject.get("dSecurityGroup"));
String did = dataObject.get("dID");
didList.add(did);
//break;
} catch (Exception e) {
throw new ContentException(e);
} finally{
closeResponse(response);
return didList;
* Get the file content represented by contentId from a Oracle WebCenter Content Server.
* The return value is the input stream of retrieved file content.
* @param properties The Oracle WebCenter Content Server connection properties.
* @param contentId The Content ID for the content item in Oracle WebCenter Content Server.
* @throws ContentException The exception when retrieving content from Oracle WebCenter Content Server.
* @return The input stream of retrieved file content.
public InputStream retrieveContent(Properties properties, String contentId) throws ContentException{
try {
return new FileInputStream(retrieveContentFile(properties, contentId));
} catch (Throwable e) {
throw new ContentException(e);
public File retrieveContentFile(Properties properties, String contentId) throws ContentException {
contentId = contentId.toUpperCase();
ServiceResponse response = null;
try {
IdcClientManager manager = new IdcClientManager();
IdcClient client = manager.createClient(properties.getProperty(URL_PROPERTY));
client.getConfig().setProperty ("http.library", "apache4");
String user = properties.getProperty(USERNAME_PROPERTY);
String pwd = properties.getProperty(PASSWORD_PROPERTY);
IdcContext connectionContext = new IdcContext(user, pwd);
pwd = null;
DataBinder binder = client.createBinder();
binder.putLocal("IdcService", "GET_FILE");
//binder.putLocal("dID", dID);
binder.putLocal("dDocName", contentId);
binder.putLocal("RevisionSelectionMethod", "Latest");
response = client.sendRequest(connectionContext, binder);
InputStream in = null;
OutputStream out = null;
String edxhome = System.getProperty("edx.home");
File tmpParent = new File(edxhome);
tmpParent = new File(tmpParent, "Output");
tmpParent = new File(tmpParent, "tmp");
tmpParent.mkdirs();
File tmpFile = File.createTempFile("down_", "_ucm", tmpParent);
tmpFile.deleteOnExit();
try {
in = response.getResponseStream();
out = new FileOutputStream(tmpFile);
byte[] buf = new byte[1024];
int read = -1;
while((read = in.read(buf))!=-1) {
out.write(buf, 0, read);
} finally{
try {
if(in!=null)
in.close();
} catch (Exception e2) {
try {
if(out!=null)
out.close();
} catch (Exception e2) {
return tmpFile;
} catch (Throwable e) {
throw new ContentException(e);
} finally{
closeResponse(response);
private void closeResponse(ServiceResponse response) {
if(response!=null) {
try {
response.close();
} catch (Exception e) {
private static final String SLASH = "/";
private static final String URL_PROPERTY = "contentServerURL";
private static final String USERNAME_PROPERTY = "contentServerUser";
private static final String PASSWORD_PROPERTY = "contentServerPassword";
static volatile boolean flag = false;
static class UploadTask implements Runnable{
public void run() {
try {
while(!flag) {
UCMContentManager manager = new UCMContentManager();
Properties properties = new Properties();
properties.put(URL_PROPERTY, "https://slc402124:16201/cs/idcplg");
properties.put(USERNAME_PROPERTY, "weblogic");
properties.put(PASSWORD_PROPERTY, "weblogic1");
File contentFile = new File("C:/toding/mypro/UCM/test.txt");
String parentPath = "/new/test/multiThreadUpload/";
String location = makePath(parentPath);
manager.saveContent(properties, contentFile, location);
System.out.println(location);
Thread.sleep(5000);
} catch (Exception e) {
e.printStackTrace();
flag = true;
public static void main(String[] args) throws Exception{
ThreadPoolExecutor executor = new ThreadPoolExecutor(10, 10, 60, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>());
for(int i=0; i<10; i++) {
UploadTask uploadTask = new UploadTask();
executor.execute(uploadTask);
while(!flag) {
Thread.sleep(5000);
executor.shutdown();
public static String makePath(String parentPath) {
StringBuilder buf = new StringBuilder();
buf.append(parentPath);
if(!parentPath.endsWith("/")) {
buf.append("/");
Calendar rightNow = Calendar.getInstance();
String pattern = "yyyyMMdd";
SimpleDateFormat simDateForm = new SimpleDateFormat(pattern);
String dateStr = simDateForm.format((rightNow).getTime());
pattern = "HHmmssSSS";
simDateForm = new SimpleDateFormat(pattern);
String timeStr = simDateForm.format((rightNow).getTime());
buf.append(dateStr);
buf.append("/");
buf.append(timeStr);
buf.append("_");
buf.append(random.nextInt(10000));
String finalLocation = buf.toString();
return finalLocation;
private static SecureRandom random = new SecureRandom(); -
How to slove follwoing error "Unreported exception java.io.IOException;"
Currently I'm using following:
XP Professional
J2sdk1.4.2_01
Xerces-2_5_0
Xalan-j_2_5_1
Jakarta-tomcat-4.1.27
Jdom-b9
Current Classpath setting
User variables
PATH = c:\bmrt2.5\bin; c:\j2sdk\bin;%PATH%;%JAVA_HOME%\bin;
CLASSPATH=.;c:\xerces\xmlParserAPIs.jar;c:\xerces\xercesImpl.jar;
c:\xerces\xercesSamples.jar;c:\xalan\xercesImpl.jar;c:\xalan\xmlapis.jar;c:\xalan\xalan.jar;c:\tomcat\lib\webserver.jar;c:\tomcat\lib\jasper.jar;c:\tomcat\lib\xml.jar;c:\tomcat\common\lib\serlet.jar;c:\tomcat\lib\tools.jar; c:\tomcat\lib\tools.jar;c:\jdom\build\jdom.jar;
CATALINA_HOME= c:\tomcat
JAVA_HOME= c:\j2sdk
System variables
PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;
c:\j2sdk\bin;%Path%;%JAVA_HOME%\bin;
CLASSPATH=.;c:\xerces\xmlParserAPIs.jar;c:\xerces\xercesImpl.jar;
c:\xerces\xercesSamples.jar;c:\xalan\xercesImpl.jar;c:\xalan\xmlapis.jar;c:\xalan\xalan.jar;c:\tomcat\lib\webserver.jar;c:\tomcat\lib\jasper.jar;c:\tomcat\lib\xml.jar;c:\tomcat\common\lib\serlet.jar;c:\tomcat\lib\tools.jar; c:\tomcat\lib\tools.jar;
CATALINA_HOME= c:\tomcat
JAVA_HOME= c:\j2sdk
Program
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.jdom.*;
import org.jdom.Element;
import org.jdom.Document;
import org.jdom.output.XMLOutputter;
import org.jdom.input.SAXBuilder;
import org.jdom.Attribute;
import java.util.List;
public class AddToList extends HttpServlet
public Document getDocument(File sourceFile, PrintWriter errorsOut)
try
SAXBuilder builder = new SAXBuilder();
Document document = builder.build(sourceFile);
return document;
catch(JDOMException e)
errorsOut.print("there was a problem building the document: " e. getMessage()"<br/>"+ "Returning blank document.");
return new Document(new Element("blank"));
public void saveDocument(Document saveDoc, File saveFile, PrintWriter errorsOut)
try
FileOutputStream outStream= new FileOutputStream(saveFile);
XMLOutputter outToFile= new XMLOutputter(" ",true);
outToFile.output(saveDoc, outStream);
outStream.flush();
outStream.close();
catch (IOException e)
errorsOut.print("Can't save order.xml: " + e.getMessage()+"<br />");
public void addItem(Element orderElement, String product_id, String quant)
Element newItem =new Element("item");
newItem.setAttribute("product_id", product_id);
Element quantity =new Element("quantity");
quantity.addContent(quant);
newItem.addContent(quantity);
orderElement.addContent(newItem);
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
String thisProduct_id=request.getParameter("addProduct_id");
String thisQuantity=request.getParameter("addQuantity");
response.setContentType("text/html");
PrintWriter out= response.getWriter();
out.print("Adding "+ thisQuantity + "of item to chart "+ thisProduct_id +" ... ");
File orderFile = new File ("file:///c:/jdk1.3/orders.xml");
if(!orderFile.exists())
out.print("Creating ordersrocks....<br />");
Element root= new Element("orders");
root.addContent(" ");
Document document = new Document(root);
saveDocument (document, orderFile, out);
else
out.print("Orders File Exists.");
Document document =getDocument(orderFile, out);
HttpSession session =request.getSession(true);
String session_id= session.getId();
Element root =document.getRootElement();
List orders =root.getChildren();
int num_orders =orders.size();
boolean orderExists =false;
int orderIndex =0;
for(int i=0; i<num_orders; i++)
Element iOrder=(Element)orders.get(i);
String iOrder_id=iOrder.getAttributeValue("order_id");
if (iOrder_id.equals(session_id))
orderExists=true;
orderIndex=i;
break;
if(!orderExists)
Element order =new Element("order");
order.setAttribute("order_id", session_id);
Element status =new Element("order_status");
status.setText("open");
order.addContent(status);
addItem(order, thisProduct_id, thisQuantity);
root.addContent(order);
else
Element thisOrder=(Element)orders.get(orderIndex);
boolean itemExists=false;
int itemIndex =0;
List items =thisOrder.getChildren("item");
int num_items =items.size();
for(int i=0; i<num_items; i++)
Element iItem=(Element)items.get(i);
String iProduct_id =iItem.getAttribute("product_id").getValue();
if(iProduct_id.equals(thisProduct_id))
itemExists =true;
itemIndex =i;
break;
if(itemExists)
Element thisItem=(Element)items.get(itemIndex);
String currentQuantity= thisItem.getChildText("quantity");
int newQuantity = Integer.parseInt(currentQuantity)+ Integer.parseInt(thisQuantity);
String strQuantity= new String().valueOf(newQuantity)+1;
thisItem.getChild("quantity").setText(strQuantity);
else
addItem(thisOrder, thisProduct_id, thisQuantity);
saveDocument (document, orderFile, out);
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
doGet(request, response);
When I compile above program, it gives me following error.
Error
C:\tomcat\webapps\book\WEB-INF\classes>javac AddToList.java
AddToList.java:19: unreported exception java.io.IOException; must be caught
or declared to be thrown
Document document = builder.build(sourceFile);
^
1 error
Any help regarding this will be appreciated
Thank you
RocksObadare
Thank for your help, my program compile successfully. But now I�m facing different kind of error on Tomcat; why it gives me following error and how do I solve it
http://localhost:8080/rock/servlet/AddToList
Following Error generate by Tomcat:
Http Status 500-
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Cannot allocate servlet instance for path /rock/servlet/AddToList
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:435)
at org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:180)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:247)
root cause
java.lang.NoClassDefFoundError: org/jdom/JDOMException
at java.lang.Class.newInstance0(Native Method)
at java.lang.Class.newInstance(Class.java:237)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:903)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:668)
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:416)
at org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:180)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:247)
The following is my configuration
Classpath= .;c:\xalan\bin\xalan.jar;c:\xalan\bin\xml-apis.jar;c:\xerces\xmlParserAPIs.jar;c:\xerces\xercesImpl.jar;c:\tomcat\common\lib\servlet.jar;c:\jdom\build\jdom.jar;
Java_Home=c:\jdk1.3
Catalina_Home=c:\tomcat
Server.xml
<Engine name="Standalone" defaultHost="localhost" debug="0">
<Host name="localhost" debug="0" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context path="/rock" docBase="rock" debug="0"
reloadable="true" crossContext="true">
P.S When I try to build javadoc it give me following error:
C:\jdom>build javadoc
JDOM Build System
Building with classpath c:\jdk1.3\lib\tools.jar;.\lib\ant.jar;.\lib\xml-apis.jar
;.\lib\xerces.jar;
Starting Ant...
Buildfile: build.xml
[javadoc] Constructing Javadoc information...
[javadoc] Building tree for all the packages and classes...
[javadoc] Building index for all the packages and classes...
[javadoc] javadoc: warning - Tag @link: Class or Package not found: javax.xml.
transform.TransformerFactory#getFeature
[javadoc] javadoc: warning - Tag @link: Class or Package not found: javax.xml.
transform.TransformerFactory#getFeature
[javadoc] Building index for all classes...
[javadoc] javadoc: warning - Tag @link: Class or Package not found: javax.xml.
transform.TransformerFactory#getFeature
[javadoc] javadoc: warning - Tag @link: Class or Package not found: javax.xml.
transform.TransformerFactory#getFeature
[javadoc] javadoc: warning - Tag @link: Class or Package not found: javax.xml.
transform.Transformer
[javadoc] javadoc: warning - Tag @link: Class or Package not found: javax.xml.
transform.Transformer
[javadoc] javadoc: warning - Tag @link: Class or Package not found: javax.xml.
transform.Transformer JAXP TrAX Transformer
[javadoc] javadoc: warning - Tag @link: Class or Package not found: javax.xml.
transform.TransformerFactory#getFeature
[javadoc] javadoc: warning - Tag @link: Class or Package not found: javax.xml.
transform.TransformerFactory#getFeature
[javadoc] javadoc: warning - Tag @link: Class or Package not found: java.lang.
Double#NaN
[javadoc] Generating C:\jdom\build\apidocs\stylesheet.css...
[javadoc] 10 warnings
BUILD SUCCESSFUL
Total time: 12 seconds -
Java.io.IOException: The specified module could not be found
Hi.
I am using Runtime.exec() to run egrep on some files, and then trying to read its ouput in the following way:
String command2 = "egrep \"" + pattern +
"\" " + category + "egrep.txt";
Process p2 = Runtime.getRuntime().exec(command2);
double counterA = 0;
try {
BufferedReader fin3 = new BufferedReader(new InputStreamReader(p2.
getInputStream()));
String reader = "";
while ( (reader = fin3.readLine()) != null) {
counterA++;
if (counterA != 0)
//System.out.println(read + " ::: " + counterA);
fin3.close();
catch (Exception e) {
System.out.println("E");
And I get the following exception:
java.io.IOException: The specified module could not be found
at java.io.FileInputStream.readBytes(Native Method)
and this goes on to show exceptions in BufferedInputStream and then my code.
This does not happen all the time, so I cannot reproduce it easily. I have searched on google and in this forum looking for information but have not found out anything useful.
Help would be appreciated. Thanks.The only possible reason for this error occurring that I can think of is that it is somehow a side effect of the limited buffer size for stdin and stderr.
For an example of emptying both output streams simultaneously, see the StreamGobbler class in this article:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
(this applies to unix, the author just mixed it in with his discussion of windows issues, just remove the "cmd.exe" and other windows stuff)
Another thing to try if only for the sake of experimentation would be to throw in a "exitValue = p2.waitFor()" just in case there's some unpredictable resource conflict going on (although I can't imagine why for egrep, but it's something to experiment with).
Let me know if you can narrow down the conditions for reproducing the bug. -
Java.io.IOException: WEB8001: Write failed
I have written a servlet to download a tar file.
The Servlet takes the parameters and create a tar file based on the parameters and then opens the file for download for the user. I am able to download the tar file and the contents of the tar file is ok. But when I write the content to the OutputStream I getting an IOException
(1) Refer to the code snippt below. Here I am getting the following IOException: Cannot read and write data java.io.IOException: WEB8001: Write failed
private void sendDownloadFile(File downloadFile, HttpServletResponse response) {
try {
response.setContentType(contentType + "; name=\""
+ downloadFile.getName() + "\"");
Long length = new Long(downloadFile.length());
response.setContentLength(length.intValue());
response.setHeader("Content-Disposition", "attachment; filename=\""
+ downloadFile.getName() + "\"");
OutputStream outStream =
new BufferedOutputStream(response.getOutputStream());
InputStream streamIn = new BufferedInputStream(
new FileInputStream(downloadFile));
byte[] tarBytes = new byte[1024];
while (streamIn.read(tarBytes) != -1) {
outStream.write(tarBytes);
outStream.flush();
streamIn.close();
}catch (FileNotFoundException fnfex) {
logger.fatal("File is MISSING!!");
}catch (IOException ioex) {
logger.fatal("IOException: Cannot read and write data " + ioex);
catch (Exception e) {
logger.fatal("Download Exception: " + e);
}Any help would be appreciated.What are you using as your test client?The test client is WebStone 1.0. WebStone always downloads the whole response, and reports the size of the response in bytes. From this I can see that when the IO exception occurs, webstone is unable to read the whole response, as it reports a smaller size.
So, I do not think the problem is that the client has prematurely aborted its download. WebStone doesn't work that way. I think something has gone awry on the server side, and this worries me. -
Java.io.IOException: Permission denied
Hi All,
Having a bit of trouble out of a school project. I need to save information to an XML file and read from it and put those values into fields. Writing to the file is no big deal, however I get a Permission Denied error when I attempt to read the data back in. My code is attached:
private boolean readFile(String filename) throws IOException{
try {
XPathFactory factory=XPathFactory.newInstance();
XPath xPath=factory.newXPath();
//File xmlDocument = new File(filename);
System.out.println("Here");
FileInputStream in = new FileInputStream(filename);
System.out.println("Here2");
InputSource inputSource=new InputSource(in);
System.out.println("Here3");
String xmlShape = xPath.evaluate("/Volume_Calculator/Shape",inputSource);
String xmlLength = xPath.evaluate("/Volume_Calculator/Length",inputSource);
String xmlWidth = xPath.evaluate("/Volume_Calculator/Width",inputSource);
String xmlAvgDepth = xPath.evaluate("/Volume_Calculator/Average_Depth",inputSource);
String xmlVolume = xPath.evaluate("/Volume_Calculator/Volume",inputSource);
String xmlCustName = xPath.evaluate("/Volume_Calculator/Customer_Name",inputSource);
String xmlAddress1 = xPath.evaluate("/Volume_Calculator/Address1",inputSource);
String xmlAddress2 = xPath.evaluate("/Volume_Calculator/Address2",inputSource);
String xmlCity = xPath.evaluate("/Volume_Calculator/City",inputSource);
String xmlState = xPath.evaluate("/Volume_Calculator/State",inputSource);
String xmlZip = xPath.evaluate("/Volume_Calculator/Zip",inputSource);
String xmlPhone = xPath.evaluate("/Volume_Calculator/Phone",inputSource);
String xmlEmail = xPath.evaluate("/Volume_Calculator/Email",inputSource);
String xmlSalesPerson = xPath.evaluate("/Volume_Calculator/Sales_Person",inputSource);
String xmlOrderNo = xPath.evaluate("/Volume_Calculator/Order_No",inputSource);
String xmlDate = xPath.evaluate("/Volume_Calculator/Date",inputSource);
txtLength.setText(xmlLength);
txtWidth.setText(xmlWidth);
txtAvgDepth.setText(xmlAvgDepth);
txtVolume.setText(xmlVolume);
txtCustName.setText(xmlCustName);
txtAddress1.setText(xmlAddress1);
txtAddress2.setText(xmlAddress2);
txtCity.setText(xmlCity);
txtZip.setText(xmlZip);
txtPhone.setText(xmlPhone);
txtEmail.setText(xmlEmail);
txtSalesPerson.setText(xmlSalesPerson);
txtOrderno.setText(xmlOrderNo);
txtOrderDate.setText(xmlDate);
in.close();
catch (Throwable t) {
t.printStackTrace ();
return true;
My XML document is flat with no repeating nodes.
Any help is greatly appreciated, thank you.
- Jamesjava.io.IOException: Permission denied
at java.io.FileInputStream.read(Native Method)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager$RewindableInputStream.read(XMLEntityManager.java:2622)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager$RewindableInputStream.read(XMLEntityManager.java:2642)
at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:411)
at sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:453)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:183)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1740)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipString(XMLEntityScanner.java:1437)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:191)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:798)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:250)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292)
at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(XPathImpl.java:468)
at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(XPathImpl.java:515)
at volumecalculator.MainFrame.readFile(MainFrame.java:459)
at volumecalculator.MainFrame.btnOpen1ActionPerformed(MainFrame.java:565)
at volumecalculator.MainFrame.access$300(MainFrame.java:22)
at volumecalculator.MainFrame$4.actionPerformed(MainFrame.java:122)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:5517)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
at java.awt.Component.processEvent(Component.java:5282)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3984)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3819)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1791)
at java.awt.Component.dispatchEvent(Component.java:3819)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
--------------- linked to ------------------
javax.xml.xpath.XPathExpressionException
at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(XPathImpl.java:475)
at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(XPathImpl.java:515)
at volumecalculator.MainFrame.readFile(MainFrame.java:459)
at volumecalculator.MainFrame.btnOpen1ActionPerformed(MainFrame.java:565)
at volumecalculator.MainFrame.access$300(MainFrame.java:22)
at volumecalculator.MainFrame$4.actionPerformed(MainFrame.java:122)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:5517)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
at java.awt.Component.processEvent(Component.java:5282)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3984)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3819)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1791)
at java.awt.Component.dispatchEvent(Component.java:3819)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Caused by: java.io.IOException: Permission denied
at java.io.FileInputStream.read(Native Method)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager$RewindableInputStream.read(XMLEntityManager.java:2622)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager$RewindableInputStream.read(XMLEntityManager.java:2642)
at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:411)
at sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:453)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:183)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1740)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipString(XMLEntityScanner.java:1437)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:191)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:798)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:250)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292)
at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(XPathImpl.java:468)
... 29 more
Maybe you are looking for
-
I just got my X300 and put on Windows XP because the Vista took up too much space on an already small hard drive. (Also wanted to get rid of bloatware and didn't like comfirming every move I made on Vista). I then wanted to get rid of the Welcome scr
-
Why does photo taken on iPhone turn sideways when sent as an email attachment
why does photo taken on iPhone turn sideways when sent as an email attachment?
-
PLS-00306: wrong number or types of arguments in call to 'PROCESS_CDR'
hi i am trying to build a procedure which takes radius parameters as ip and than calculates some data and insert it back to the db this is my proc as NASIPADDRESS varchar2(50); USERNAME varchar2(50); ACCTSESSIONTIME number; CALLEDSTATIONID varchar2(5
-
Photoshop elements 5 - RUNTIME ERROR
I have photoshop elements 5. I downloaded a programme called Kies so i could upload photos from my Samsung phone. Ever since, my lap top hasn't worked properly and I haven't been able to open photoshop. i have uninstalled the kies programme and had
-
All, I am trying to Get COUNT of all DISTINCT (Accounts) in reports, Can any one shed some light on to as how this is done in Bex?