Tomcat 4.1 Oracle Blob problem using apache commons DBCP

Hi all,
We are using Tomcat 4.1.12, Java 1.4.x and trying to take advantage of the connection pooling that comes with Tomcat(the apache commons DBCP).
We are connecting to a oracle database.
Works fine for everything EXCEPT Blobs. We have a servlet that serves images from Oracle, that works fine when it doesn't use the connection pooling, but throws an exception when we call the
ERROR: Class:DisplayGraphic Method:processRequest(HttpServletRequest request, Ht
tpServletResponse response)
Exception: org.apache.commons.dbcp.DelegatingResultSet
DataSource ds = (DataSource)ctx.lookup("jdbc/db_connection");
Connection conn = ds.getConnection();
PreparedStatement pstmt = null;
ResultSet rs = null;
pstmt = conn.prepareStatement("SELECT graphic FROM graphics WHERE graphic_id = 1");
rs = pstmt.executeQuery();
if(rs.next())
    oracle.sql.BLOB oBlob = ((OracleResultSet) oRS).getBLOB("GRAPHIC");
    InputStream oIS =  oBlob.getBinaryStream();
    ... etc etc...
}Any ideas?
Cheers,
Alex.

solved the problem.. i was using getBLOB instead of
getBlob
doh..Hi Alex,
your problem is very interesting for me because I have a similar problem and your identical configuration...
the instruction
oracle.slq.BLOB aBlob = ((OracleResultSet)super.mRs).getBLOB("BLOBBONE")
causes this:
java.lang.ClassCastException: org.apache.commons.dbcp.DelegatingResultSet
To resolve this, I changed, in server.xml , the factory
<parameter>
                    <name>factory</name>
                    <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
               </parameter>
with:
<parameter>
<name>factory</name>
<value>oracle.jdbc.pool.OracleDataSourceFactory</value>
</parameter>          
and magically all works fine...
But the question is... Why doesn't it work with the standard factory???
There is a problem in the CLASSPATH that I don't see?
Any suggestions is welcome!
Thanks in advance!
Giselda

Similar Messages

  • Using Apache Commons HTTPClient to create a custom socket for Java mail

    Does anyone know how to use Apache Commons HTTPClient to create a custom socket for Java mail. This is necessary for me to use NTLM authentication

    JavaMail doesn't use HTTP.
    If you want to add support for NTLM authentication to one of the standard protocols,
    your best bet is to create a SASL provider, although note that only JavaMail's IMAP
    provider uses SASL currently. The other protocols should add SASL support, but that
    hasn't been done yet.

  • Apache Commons DBCP issue

    Hi,
    I am using commons-dbcp.1.2.jar file in my web application. but whenever I start the soa suite, I get the following exception.
    java.lang.NoSuchMethodError: org.apache.commons.dbcp.BasicDataSource.setInitialSize(I)V
    After researching some, I saw two different versions of dbcp jar files in soa suite installation and orabpel.jar also contains all the classes from commons dbcp.
    Can some body tell me which version of dbcp it uses because it does not contain the above method.
    I tried changing the shared libraries in the server.xml and include the new jar file but I guess it is loading the orabpel.jar before any thing else.
    How do I use newer version of dbcp?
    Thanks

    I would strictly isolate your web appplication classes from other classes. Put your commons-dbcp.1.2.jar into WEB-INF/lib and set prefer-web-inf-classes element to true in weblogic.xml. prefer-web-inf-classes will ensure that your application libraries precede system libraries (orabpel.jar in this case) while SOA Suite should not see your commons-dbcp.1.2.jar and should start properly.
    http://download-llnw.oracle.com/docs/cd/E13222_01/wls/docs100/webapp/weblogic_xml.html#wp1059286

  • File upload using apache Commons FileUpload problem

    Hi All,
    I have used Commons FileUpload for uploading files from windows to unix machine. I'm able to upload files but I have a problem about the contents of file copied in unix. When i upload files few files containing special characters are not copied correctly in unix instead ascii codes are getting copied/written. Seems to be a problem with character encoding.
    For example symbol "�" is not getting copied correctly in unix. So as new line character to. If anyone has faced such issues kindly provide few pointers on this. Appreciate your guidance.
    Thanks,
    -Aj

    Thanks for the reply.
    I'm using the Commons FileUpload class "FileItem" which holds the filestream data and using function
    code snippet of file upload
    ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());
    List fileItemsList = servletFileUpload.parseRequest(request);
    Iterator it = fileItemsList.iterator();
    while (it.hasNext())
         FileItem fileItemTemp = (FileItem)it.next();
         File saveToFile = new File("newFile");
          fileItem.write(saveToFile ); // write fileItem data to saveToFile.
    } FileItem object takes care of writing data to disk.No idea,how it does internally.
    Thanks,
    -Aj.

  • I am trying to use apache commons fileupload and get this error

    I am using tomcat 5.5 as application server and JDK 1.6,
    does anybody have idea how to resolve this error ?
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    java.security.AccessControlException: access denied (java.util.PropertyPermission java.io.tmpdir read)
         java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
         java.security.AccessController.checkPermission(AccessController.java:546)
         java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
         java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1285)
         java.lang.System.getProperty(System.java:652)
         org.apache.commons.fileupload.disk.DiskFileItem.getTempFile(DiskFileItem.java:611)
         org.apache.commons.fileupload.disk.DiskFileItem.getOutputStream(DiskFileItem.java:556)
         org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:362)
         org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:126)
         project.UploadFiles.processRequest(UploadFiles.java:48)
         project.UploadFiles.doPost(UploadFiles.java:107)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         java.lang.reflect.Method.invoke(Method.java:597)
         org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:244)
         java.security.AccessController.doPrivileged(Native Method)
         javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
         org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:276)
         org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:162)

    Make sure that the servlet has permissions to write to that directory. I've hit that snag before, and on linux I set the permissions to nobody nobody 775.
    Good luck,
    Krista

  • Problems with Apache Commons Validator

    Hello there,
    I got a quiet big problem using the a.m. validation framework. When defining a validation rule for a property like this:
    <formset>
    <form name="testForm">
    <field property="firstName" depends="isEmail">
    <arg0 key="testForm.firstname"/>
    </field>
    </form>
    </formset>
    and instanciating my validator as follows:
    Validator validator = new Validator(resources, "testForm");
    validator.setParameter(Validator.BEAN_PARAM, name);
    everything works fine! I get a correct ValidatorResult object with a correct validation value.
    But as soons as I define a second Validation on the same property like this:
    <formset>
    <form name="testForm">
    <field property="firstName" depends="isEmail,isBlankOrNull">
    <arg0 key="testForm.firstname"/>
    </field>
    </form>
    </formset>
    Nothing works anymore. When iterating over the ValidatorResults object I only get one ValidatorResult object for "isEmail" with a wrong validation value. There should be two working ValidatorResult objects for "isEmail" and "isBlankOrNull"?!?!
    Are two validation method in the depends-Attribute not allowed (although it is defined in the standard)?
    You can assume, that the used validator class is conform to the given org.apache.commons.TestValidator!
    For any help, thx in advance!
    Greets
    CN

    Hey Aaron,
    Could you post your code for your <field>...</field>?
    Here is an example from: http://www.jsn-server3.com/struts-documentation/userGuide/dev_validator.html
    <field
        property="firstName" indexedListProperty="dependents"
        depends="requiredif">
      <arg0 key="dependentlistForm.firstName.label"/>
      <var>
        <var-name>field[0]</var-name>
        <var-value>lastName</var-value>
      </var>
      <var>
        <var-name>field-indexed[0]</var-name>
        <var-value>true</var-value>
      </var>
      <var>
        <var-name>field-test[0]</var-name>
        <var-value>NOTNULL</var-value>
      </var>
    </field>
    <field
        property="dob"
        indexedListProperty="dependents"
        depends="requiredif,date">
      <arg0 key="dependentlistForm.dob.label"/>
      <var>
        <var-name>field[0]</var-name>
        <var-value>lastName</var-value>
      </var>
      <var>
        <var-name>field-indexed[0]</var-name>
        <var-value>true</var-value>
      </var>
      <var>
        <var-name>field-test[0]</var-name>
        <var-value>NOTNULL</var-value>
      </var>
    </field>
    <field
        property="coverageType"
        indexedListProperty="dependents"
        depends="requiredif">
      <arg0 key="dependentlistForm.coverageType.label"/>
      <var>
        <var-name>field[0]</var-name>
        <var-value>lastName</var-value>
      </var>
      <var>
        <var-name>field-indexed[0]</var-name>
        <var-value>true</var-value>
      </var>
      <var>
        <var-name>field-test[0]</var-name>
        <var-value>NOTNULL</var-value>
      </var>
      <var>
        <var-name>field[1]</var-name>
        <var-value>insureDependents</var-value>
      </var>
      <var>
        <var-name>field-test[1]</var-name>
        <var-value>EQUAL</var-value>
      </var>
      <var>
        <var-name>field-value[1]</var-name>
        <var-value>true</var-value>
      </var>
      <var>
        <var-name>field-join</var-name>
        <var-value>AND</var-value>
      </var>
    </field>
    </form>" Which is read as follows: The firstName field is only required if the lastName field is non-null. Since field-indexed is true, it means that lastName must be a property of the same indexed field as firstName. Same thing for dob, except that we validate for date if not blank.
    The coverageType is only required if the lastName for the same indexed bean is not null, and also if the non-indexed field insureDependents is true.
    You can have an arbitrary number of fields by using the [n] syntax, the only restriction is that they must all be AND or OR, you can't mix. "
    Hope that helps,
    Nate

  • Problems with Apache Commons FileUpload

    I'm completely stymied here. I've been trying to get the Apache Commons FileUpload working with a JBoss 4.2 server, and having no luck whatsoever. The servlet is listed out here:
    package com.areteinc.servlets;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.Iterator;
    import java.util.List;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.commons.fileupload.FileItem;
    import org.apache.commons.fileupload.FileItemFactory;
    import org.apache.commons.fileupload.FileUploadException;
    import org.apache.commons.fileupload.disk.DiskFileItemFactory;
    import org.apache.commons.fileupload.servlet.ServletFileUpload;
    import org.apache.log4j.Level;
    import org.apache.log4j.Logger;
    public class Filer extends HttpServlet {
         private Logger logger = Logger.getLogger(Filer.class);
         public Filer() {
              logger.setLevel(Level.DEBUG);
         protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
              logger.debug("Serving up a GET page...");
              PrintWriter writer = resp.getWriter();
              StringBuffer response = new StringBuffer();
              response.append("<HTML><HEAD><TITLE>JENA File Uploader</TITLE></HEAD><BODY>");
              response.append("<FORM action=\"Filer\" method=\"POST\" enctype=\"multipart/form-data\">");
              response.append("Upload file: <input type=\"file\" name=\"file1\"/><br>");
              response.append("Upload file: <input type=\"file\" name=\"file2\"/><br>");
              response.append("<input type=submit value=\"Start upload\">");
              response.append("</BODY>");
              writer.println(response);
         protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
              // First see if someone is uploading more than one file at a time...
              boolean isMultipart = ServletFileUpload.isMultipartContent(req);
              logger.debug("Received a POST request.  Multipart is flagged as " + isMultipart);
              // Create a factory for disk-based file items
              FileItemFactory factory = new DiskFileItemFactory();
              // Create a new file upload handler
              ServletFileUpload upload = new ServletFileUpload(factory);
              // Parse the request
              try {
                   List<FileItem> items = upload.parseRequest(req);
                   Iterator itr = items.iterator();
                   logger.debug("Size of upload is " + items.size() + " items.");
                   while(itr.hasNext()) {
                        FileItem item = (FileItem) itr.next();
                        logger.debug("Filename is " + item.getName());
              } catch (FileUploadException e) {
                   e.printStackTrace();
    }When run, I hit it with a get operation, and get the form. When I put in 2 forms (in reality, all i want to do is use one, but I'm tinkering), I see nothing in items list...
    Run, with 2 files selected to upload:
    13:50:15,421 DEBUG [Filer] Received a POST request. Multipart is flagged as true
    13:50:15,421 DEBUG [Filer] Size of upload is 0 items.
    I've tried variation after variation after variation, and it jst doesn't work. I'm using commons-fileupload-1.2.1.
    Help! :)

    On the client side, the client's browser must support form-based upload. Most modern browsers do, but there's no guarantee. For your case,
    The servlet can use the GET method parameters to decide what to do with the upload while the POST body of the request contains the file data to parse.
    When the user clicks the "Upload" button, the client browser locates the local file and sends it using HTTP POST, encoded using the MIME-type multipart/form-data. When it reaches your servlet, your servlet must process the POST data in order to extract the encoded file. You can learn all about this format in RFC 1867.
    Unfortunately, there is no method in the Servlet API to do this. Fortunately, there are a number of libraries available that do. Some of these assume that you will be writing the file to disk; others return the data as an InputStream.
    Jason Hunter's MultipartRequest (available from [http://www.servlets.com/])
    Apache Jakarta Commons Upload (package org.apache.commons.upload) "makes it easy to add robust, high-performance, file upload capability to your servlets and web applications"
    *CParseRFC1867 (available from [http://www.servletcentral.com/]).
    *HttpMultiPartParser by Anil Hemrajani, at the isavvix Code Exchange
    *There is a multipart/form parser availailable from Anders Kristensen ([http://www-uk.hpl.hp.com/people/ak/java/] at [http://www-uk.hpl.hp.com/people/ak/java/#utils].
    *JavaMail also has MIME-parsing routines (see the Purple Servlet References).
    *Jun Inamori has written a class called org.apache.tomcat.request.ParseMime which is available in the Tomcat CVS tree.
    *JSPSmart has a free set of JSP for doing file upload and download.
    *UploadBean by JavaZoom claims to handle most of the hassle of uploading for you, including writing to disk or memory.
    There's an Upload Tag in dotJ
    Once you process the form-data stream into the uploaded file, you can then either write it to disk, write it to a database, or process it as an InputStream, depending on your needs. See How can I access or create a file or folder in the current directory from inside a servlet? and other questions in the Servlets:Files Topic for information on writing files from a Servlet.
    Please note: that you can't access a file on the client system directly from a servlet; that would be a huge security hole. You have to ask the user for permission, and currently form-based upload is the only way to do that.
    I still have doubt if all the moentioned resources are alive or not

  • Oracle BLOB problem...pls help if possible

    I have been having trouble with my JSP code using the Tomcat server. I've finally gotten the compiler to recognize my result set as an Oracle Result set without it giving me casting errors. Here is part of my code:
    %@ page import="oracle.sql.*"%>
    <%@ page import="oracle.sql.BLOB"%>
    <%@ page import="oracle.jdbc.driver.*"%>
    <%@ page import="oracle.jdbc.driver.OracleResultSet"%>
    <%@ page import="java.lang.Object.*"%>
    <%@ page import="java.sql.*"%>
    <%@ page import="java.io.*"%>
    <body bgcolor="navajowhite">
    <%
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:Andy","system","pass");
    //con.setAutoCommit(false);
    Statement myStatement = null;
    String sourceDirectory = "D:\\Tomcat\\jakarta-tomcat-4.0.3\\webapps\\Root\\Mproject\\";
    String fileName = sourceDirectory + "Test.doc";
    String SS = "222-22-2222";
    myStatement.executeUpdate("INSERT INTO LI.TEST (ID, FILE_NAME, BLOB_COLUMN)" +
    "VALUES(SS,'" + fileName + "',EMPTY_BLOB())");
    oracle.jdbc.driver.OracleResultSet blobResultSet =
    (oracle.jdbc.driver.OracleResultSet)myStatement.executeQuery(
                   "select BLOB_COLUMN " +
                   "from LI.TEST "+
                   "where FILE_NAME = '" + fileName + "' " +
                   "FOR UPDATE" );
    blobResultSet.next();
    oracle.sql.BLOB myBlob;
    myBlob = ((oracle.jdbc.driver.OracleResultSet)blobResultSet).getBLOB("BLOB_COLUMN");
         int chunkSize = myBlob.getChunkSize();
         byte[] byteBuffer = new byte[chunkSize];
         File myFile = new File(fileName);
         FileInputStream myFileInputStream = new FileInputStream(myFile);
         long position = 1;
         int bytesRead;
         while ((bytesRead = myFileInputStream.read(byteBuffer)) != -1)
              myBlob.putBytes(position, byteBuffer);
              position += bytesRead;
         myFileInputStream.close();
    however now, it is still giving me wierd errors. It says that
    org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
    D:\Tomcat\jakarta-tomcat-4.0.3\work\localhost\_\Mproject\blobtest5$jsp.java:0: The method oracle.jdbc2.Clob getClob(int) declared in interface oracle.jdbc.OracleResultSet cannot override the method of the same signature declared in interface java.sql.ResultSet. They must have the same return type.     
    package org.apache.jsp;
    ^
    D:\Tomcat\jakarta-tomcat-4.0.3\work\localhost\_\Mproject\blobtest5$jsp.java:0: The method oracle.jdbc2.Clob getClob(java.lang.String) declared in interface oracle.jdbc.OracleResultSet cannot override the method of the same signature declared in interface java.sql.ResultSet. They must have the same return type.     
    package org.apache.jsp;
    ^
    D:\Tomcat\jakarta-tomcat-4.0.3\work\localhost\_\Mproject\blobtest5$jsp.java:0: The method oracle.jdbc2.Ref getRef(int) declared in interface oracle.jdbc.OracleResultSet cannot override the method of the same signature declared in interface java.sql.ResultSet. They must have the same return type.     
    package org.apache.jsp;
    ^
    D:\Tomcat\jakarta-tomcat-4.0.3\work\localhost\_\Mproject\blobtest5$jsp.java:0: The method oracle.jdbc2.Ref getRef(java.lang.String) declared in interface oracle.jdbc.OracleResultSet cannot override the method of the same signature declared in interface java.sql.ResultSet. They must have the same return type.     
    package org.apache.jsp;
    ^
    D:\Tomcat\jakarta-tomcat-4.0.3\work\localhost\_\Mproject\blobtest5$jsp.java:0: The method oracle.jdbc2.Blob getBlob(int) declared in interface oracle.jdbc.OracleResultSet cannot override the method of the same signature declared in interface java.sql.ResultSet. They must have the same return type.     
    package org.apache.jsp;
    ^
    D:\Tomcat\jakarta-tomcat-4.0.3\work\localhost\_\Mproject\blobtest5$jsp.java:0: The method oracle.jdbc2.Blob getBlob(java.lang.String) declared in interface oracle.jdbc.OracleResultSet cannot override the method of the same signature declared in interface java.sql.ResultSet. They must have the same return type.     
    package org.apache.jsp;
    ^
    D:\Tomcat\jakarta-tomcat-4.0.3\work\localhost\_\Mproject\blobtest5$jsp.java:0: The method oracle.jdbc2.Array getArray(int) declared in interface oracle.jdbc.OracleResultSet cannot override the method of the same signature declared in interface java.sql.ResultSet. They must have the same return type.     
    package org.apache.jsp;
    ^
    D:\Tomcat\jakarta-tomcat-4.0.3\work\localhost\_\Mproject\blobtest5$jsp.java:0: The method oracle.jdbc2.Array getArray(java.lang.String) declared in interface oracle.jdbc.OracleResultSet cannot override the method of the same signature declared in interface java.sql.ResultSet. They must have the same return type.     
    package org.apache.jsp;
    ^
    8 errors, 1 warning
    can anybody tell me what i'm doing wrong? This is the last hurdle in my project and I would sincerly apprecaite any help. Many thanks
    Andrew

    OK, I'm confused. You declare a statement, set it to null, then try to execute a query with it? Your statement will still be null, you'll get a NullPointerException.
    And the OracleResultSet? This object will ONLY be created by using either Oracle's thin driver or OCI driver. The JDBC-ODBC bridge has no idea what an OracleResultSet is. The OracleResultSet IS a ResultSet object so there is no marked error on the cast, but the fit just isn't there. Had this compiled you could expect a ClassCastException at runtime.
    If you have to use ODBC, you will not be able to use Oracle-specific database objects. If you have an Oracle database available, then the ODBC driver is going to give you poor performance anyway, use Oracle's thin driver and you'll have access to the objects you're attempting to manipulate.
    And, as always, have fun!

  • Memory Leak when TOMCAT connects to Oracle 10g RAC using JDBC Thin driver.

    We had experienced Memory leak when a Oracle 10g (10.2.0.3) RAC node was evicted. TOMCAT app server is connecting to the Oracle 10g RAC database instances using JDBC 10.2.0.3 thin driver.
    Anyone had similar experience?
    Any ideas? Any bugs reported/fixed?
    Thanks,
    Raj

    If you're doing XA, we absolutely do not support
    driver-level load-balancing OR failover. Use neither.
    For non-XA, you can use driver-level failover. For
    non-XA, you could set load-balancing, but it won't
    help because we get connections from the driver,
    and keep them indefinitely, so the driver never gets
    the chance to affect which connections the pool
    uses after that.

  • How to do a file upload & download using Apache Commons FileUpload?

    Hi, I have read through the user guide but I don't understand what are the steps as to implementing the functions...
    http://commons.apache.org/fileupload/using.html
    How do I Create a servlet to read the contents(filename) of te dir where the files are, then create a collection (ArrayList for instance) with the files path and send this collection back to a jsp page.In jsp page, iterate through the collection and build the links (with scriptlets or c tags)
    Can help? Thanks for the guidance!

    This is my single_upload_page.jsp
    <%@ page import="java.io.*" %>
    <%
         //to get the content type information from JSP Request Header
         String contentType = request.getContentType();
         //here we are checking the content type is not equal to Null and
    //as well as the passed data from mulitpart/form-data is greater than or
    //equal to 0
         if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0)) {
              DataInputStream in = new DataInputStream(request.getInputStream());
              //we are taking the length of Content type data
              int formDataLength = request.getContentLength();
              byte dataBytes[] = new byte[formDataLength];
              int byteRead = 0;
              int totalBytesRead = 0;
              //this loop converting the uploaded file into byte code
              while (totalBytesRead < formDataLength) {
                   byteRead = in.read(dataBytes, totalBytesRead, formDataLength);
                   totalBytesRead += byteRead;
              String file = new String(dataBytes);
              //for saving the file name
              String saveFile = file.substring(file.indexOf("filename=\"") + 10);
              saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
              saveFile = saveFile.substring(saveFile.lastIndexOf("\\")+ 1,saveFile.indexOf("\""));
              int lastIndex = contentType.lastIndexOf("=");
              String boundary = contentType.substring(lastIndex + 1,contentType.length());
              int pos;
              //extracting the index of file
              pos = file.indexOf("filename=\"");
              pos = file.indexOf("\n", pos) + 1;
              pos = file.indexOf("\n", pos) + 1;
              pos = file.indexOf("\n", pos) + 1;
              int boundaryLocation = file.indexOf(boundary, pos) - 4;
              int startPos = ((file.substring(0, pos)).getBytes()).length;
              int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
              // creating a new file with the same name and writing the content in new file
              String folder = "C:/Program Files/Apache Software Foundation/Tomcat 5.5/webapps/ROOT/test/x/";     
              FileOutputStream fileOut = new FileOutputStream(folder + saveFile);     
                             //out.print("Saved here: " + saveFile);     
                             //fileOut.write(dataBytes);     
              fileOut.write(dataBytes, startPos, (endPos - startPos));
              fileOut.flush();
              fileOut.close();
              %><Br><table border="2"><tr><td><b>You have successfully upload the file by the name of:</b>
              <% out.println(saveFile); %></td></tr></table> <%
    %>

  • BLOB insertion in Oracle 10g database using ojdbc14 (10g drivers)

    Hello!
    I have a situation where I am trying to insert a blob data into oracle 10g database using oracle thin
    10g drivers, <b>ojdbc14.jar</b> in <b>weblogic 8.1 sp2</b>. I have the following error happening very intermittently.
    <u><b>java.sql.SQLException: OALL8 is in an inconsistent state.</b></u>
    And this is leading to the <u><b>"No more data to read from socket"</b></u> error when I am trying to
    insert the BLOB into the database. I have gone through the bug list of SP2 and have realised there is the
    following issue fixed in SP3.
    <b>CR124933</b>
    <b>An Oracle BLOB sometimes used a pooled connection after the connection pool determined that
    the connection was available for reassignment.
    Code was added to ensure the BLOB is completely processed before closing the pool connection or
    ending the transaction.</b>
    I believe the problem arises when we try to insert BLOB into database using a refreshed connection
    from the pool.We have upgraded weblogic 8.1 from SP2 to SP4 service pack inorder to come over the above problem.
    But this still continues to behave intermittently.
    We put ojdbc14.jar in our classpath and Weblogic startup classpath looks like the following :-
    WLS_CLASSPATH=${WLS_DOMAIN_DIR}/appslib/server.jar:$PRE_CLASSPATH:${WLS_WEBLOGIC_HOME}/server/lib/weblogic.jar:
    ${WLS_WEBLOGIC_HOME}/server/lib/ojdbc14.jar:${WLS_WEBLOGIC_HOME}/server/lib:${WLS_JAVA_HOME}/lib/tools.jar:
    ${WLS_JAVA_HOME}/jre/lib/rt.jar:${WLS_WEBLOGIC_HOME}/server/lib/webservices.jar:${WLS_CONFIG_DIR}:
    ${WLS_CUSTLIB_DIR}:${WLS_BIN_DIR}:$POST_CLASSPATH
    export WLS_CLASSPATH
    CLASSPATH=${WLS_CLASSPATH}:${APP_CLASSPATH}
    export CLASSPATH
    After upgrade to SP4, there are new ojdbc14_g.jar(debug jar) and orai18n.jar jars in the ${WLS_WEBLOGIC_HOME}/server/ext/jdbc/oracle/10g directory added.
    Please let me know if I need to update classpath with the new 10g jars in the ext/lib directory or any suggestions
    to insert BLOB using the ojdbc14 10G drivers, Weblogic 8.1 environment would be appreciated.
    Following is the stack trace of the errors that I recieve:
    <Oct 6, 2005 1:29:36 PM EDT> <Error> <JDBC> <BEA-001112> <Test "select count(*) from DUAL" set up for pool
    "MHUBPoolStage" failed with exception: "java.sql.SQLException: OALL8 is in an inconsistent state".>
    <Oct 6, 2005 1:29:36 PM EDT> <Info> <JDBC> <BEA-001128> <Connection for pool "MHUBPoolStage" closed.>
    <Oct 6, 2005 1:29:36 PM EDT> <Info> <JDBC> <BEA-001067> <Connection for pool "MHUBPoolStage" refreshed.>
    <Oct 6, 2005 1:29:36 PM EDT> <Info> <EJB> <BEA-010051>
    java.rmi.RemoteException: TransactionRequestManager.requestTransaction():
    Caught PersistnceException com.mortgagehub.busobj.PersistenceException: -5258: No more data to read from socket
    Please let me know if there is anything that I am missing.
    Thanks
    Pradeep G

    pradeep g wrote:
    Hello!
    I have a situation where I am trying to insert a blob data into oracle 10g database using oracle thin
    10g drivers, <b>ojdbc14.jar</b> in <b>weblogic 8.1 sp2</b>. I have the following error happening very intermittently.
    > <u><b>java.sql.SQLException: OALL8 is in an inconsistent state.</b></u>
    And this is leading to the <u><b>"No more data to read from socket"</b></u> error when I am trying to
    insert the BLOB into the database. I have gone through the bug list of SP2 and have realised there is the
    following issue fixed in SP3.
    > <b>CR124933</b>
    <b>An Oracle BLOB sometimes used a pooled connection after the connection pool determined that
    the connection was available for reassignment.
    Code was added to ensure the BLOB is completely processed before closing the pool connection or
    ending the transaction.</b>
    > I believe the problem arises when we try to insert BLOB into database using a refreshed connection
    from the pool.We have upgraded weblogic 8.1 from SP2 to SP4 service pack inorder to come over the above problem.
    But this still continues to behave intermittently.
    We put ojdbc14.jar in our classpath and Weblogic startup classpath looks like the following :-
    > WLS_CLASSPATH=${WLS_DOMAIN_DIR}/appslib/server.jar:$PRE_CLASSPATH:${WLS_WEBLOGIC_HOME}/server/lib/weblogic.jar:
    ${WLS_WEBLOGIC_HOME}/server/lib/ojdbc14.jar:${WLS_WEBLOGIC_HOME}/server/lib:${WLS_JAVA_HOME}/lib/tools.jar:
    ${WLS_JAVA_HOME}/jre/lib/rt.jar:${WLS_WEBLOGIC_HOME}/server/lib/webservices.jar:${WLS_CONFIG_DIR}:
    ${WLS_CUSTLIB_DIR}:${WLS_BIN_DIR}:$POST_CLASSPATH
    export WLS_CLASSPATH
    CLASSPATH=${WLS_CLASSPATH}:${APP_CLASSPATH}
    export CLASSPATH
    > After upgrade to SP4, there are new ojdbc14_g.jar(debug jar) and orai18n.jar jars in the ${WLS_WEBLOGIC_HOME}/server/ext/jdbc/oracle/10g directory added.
    > Please let me know if I need to update classpath with the new 10g jars in the ext/lib directory or any suggestions
    to insert BLOB using the ojdbc14 10G drivers, Weblogic 8.1 environment would be appreciated.
    > Following is the stack trace of the errors that I recieve:
    > <Oct 6, 2005 1:29:36 PM EDT> <Error> <JDBC> <BEA-001112> <Test "select count(*) from DUAL" set up for pool
    "MHUBPoolStage" failed with exception: "java.sql.SQLException: OALL8 is in an inconsistent state".>
    <Oct 6, 2005 1:29:36 PM EDT> <Info> <JDBC> <BEA-001128> <Connection for pool "MHUBPoolStage" closed.>
    <Oct 6, 2005 1:29:36 PM EDT> <Info> <JDBC> <BEA-001067> <Connection for pool "MHUBPoolStage" refreshed.>
    <Oct 6, 2005 1:29:36 PM EDT> <Info> <EJB> <BEA-010051>
    java.rmi.RemoteException: TransactionRequestManager.requestTransaction():
    Caught PersistnceException com.mortgagehub.busobj.PersistenceException: -5258: No more data to read from socket
    Please let me know if there is anything that I am missing.
    > Thanks
    > Pradeep GHi. This is something we'd like to diagnose. How is your application
    getting using and closing pool connections? The initial symptom
    seems to be an internal oracle problem... Are you using standard
    JDBC or oracle-specific calls?
    Joe

  • FTPS using JDK 1.4, Apache Commons, JScape, JSh

    I want to write a stand-alone Java program (not web based, it is Java main class), I want to do FTPS (FTP over SSL) to a remote box outside the firewall. Following are my questions:
    1. Does JDK 1.4 support it?
    2. Does JDK 1.5 support it?
    3. Does Apache Commons commons-net-1.4.1.jar support it in JDK 1.4?
    If not, I may look into using JScape or JSh.
    Any recommendation on how to write FTPS using JDK package 1.4?
    I was thinking of using JDK 1.4 as follows, however do not know if it will support FTPS. However, JDK support is rudimentary.
    URL url = new URL("ftp://user01:[email protected]/README.txt;type=i");
    URLConnection urlc = url.openConnection();
    InputStream is = urlc.getInputStream(); // To download
    OutputStream os = urlc.getOutputStream(); // To upload
    I have used Apache commons for FTP in the past, but it was not FTPS. I do not think that Apache commons supports FTPS. Please let me know, if Apache commons can also support FTPS.
    As far as I know, JScape supports FTPS.
    Any recommendation, or suggestion will be helpful.

    Hi, i'm with the issue. If you take a look at [http://commons.apache.org/net] you'll see that in version 2.0 ftps is supported. But, up to now i couldn't connect to the server, XFB Gateway in my case, it's difficult to find examples and documentation about it.
    Did you you figure out how to do it? If so, please post some help.

  • Apache commons fileUpload parseRequest finds no form fields-portalComponent

    Hello All,
    What am I trying?
    Developing a portal component (no JSP, no HTMLB).
    Have used Apache commons fileUpload libraries.
    What is the problem?
    parseRequest method works fine when I right click and preview from PCD.
    parseRequest method returns 0 html form elements when the portal component is tested under the TLN (via role -> workset -> iview)
    What else did I try?
    1.
    I looked in to Apache documentation - there are two different APIs for two different scenarios, Servlets and Portlets.
    My understanding is that I can not use portlets scenario in SAP Portal.
    Servlets scenario was what worked while doing a preview from PCD.
    2. I have looked into other solutions like using web dynpro and HTMLB to do file upload - not really a fan of either for various reasons.
    Can any one help?
    I am trying to understand why the HTTPServletRequest when parsed returns 0 form elements in the SAP Portal scenario.
    Thanks!

    Hello Ankur,
    You said:
    The reason for this is, unlike the request parameters, the multipart formdata is 'read-once-only' (because once
    the data is read off the ServletInputStream, it is gone! It cannot be read again). When you call a full portal request it goes through lot of gets before reaching your component.
    The above concept is not fully clear to me. I got a hint to something like this happening from this link that explains the need for portlets API scenario compared to a servlets scenario - Link: http://commons.apache.org/fileupload/using.html
    (Search for Servlets and Portlets within that link)
    I initially thought something like what you had replied would have happened. However, when I do a getContentLength on HTTPServletRequest in the SAP Portal mode (role -> workset -> iview), the size still includes that of the uploaded document. So like you said "it is gone! It cannot be read again" may not be accurate.
    My question still remains open.
    Edited by: Mohammed on Aug 24, 2009 6:29 PM

  • Apache commons logging

    I am trying to use apache commons logging in wls 9.2 as described in the documentation, ref
    http://edocs.bea.com/wls/docs92/logging/config_logs.html#wp1015132
    However, I get the following stacktrace
    org.apache.commons.logging.LogConfigurationException: The chosen LogFactory implementation does not extend LogFactory. Please check your configuration. (Caused
    by java.lang.ClassCastException: weblogic.logging.commons.LogFactoryImpl)
    Does anybody know the reason of this unexpected behavior?
    /Peter

    One small problem - Commons-Logging isn't listed under the available libraries. I looked through the entire list for anything that mightly remotely similar but found nothing. I thought that the commons-logging library was available as part of the struts library. Do I need to set it up as a user defined library?
    Thanks for your input.
    Chris

  • Apache Commons Net - Retrieve File - Extension, Compare , Move - FTP Server

    Dear All,
    I am using Apache Commons net FTP Library for FTP Operations. I had a few doubts
    1) I like to retrieve ftp files only with some extensions like *.txt or *.jpg etc. How can we retrieve files with specifying file extension?
    2) I need to compare the FTP Files with the local files before downloading from the FTP Server?
    3) I need to move files from the ftp server to local directory. Is there is anyway to move the files rather than first retrieve files from the FTP Server and then deleting the file in the FTP Server using FTP delete()
    Thanks,
    J.Kathiresan

    1) I like to retrieve ftp files only with some
    extensions like *.txt or *.jpg etc. How can we
    retrieve files with specifying file extension?
    List the files and then filter the list to those that you want to process.
    2) I need to compare the FTP Files with the local
    files before downloading from the FTP Server?Think about this one! To compare two files you nead to read both. If you do this on the client then you will have to copy the file from the server first!
    >
    3) I need to move files from the ftp server to local
    directory. Is there is anyway to move the files
    rather than first retrieve files from the FTP Server
    and then deleting the file in the FTP Server using
    FTP delete()What is wrong with copy then delete?

Maybe you are looking for

  • Getting ABAP runtime error while doing MIGO-GR against PO.

    Hi, Getting ABAP runtime error message while doing GR against PO. 47 ENHANCEMENT-POINT MB_POST_GOODS_MOVEMENTS_01 SPOTS ES_SAPLMBWL STATIC. 48 49 ENHANCEMENT-POINT MB_POST_GOODS_MOVEMENTS_02 SPOTS ES_SAPLMBWL. 50    CALL FUNCTION 'MB_CREATE_MATERIAL_

  • How can I save my finder arrange/sort options once and for all?

    I'm opening the Finder View Options panel and resetting the arrange and sort options several times a day and it's driving me nuts. The Finder ignores my desperate pleas to apply these options system-wide and seems to purposely forget the options I ch

  • Problem in connecting to the site

    I want to post user id and password to enter into the Home page of a site using java. The problem is that I receive the same login page after the HttpURLConnection to the site posting with user id and password.my code doesn't work. First, i authentic

  • Import still pics from video camera into iphoto with firewire?

    I have a new panasonic pv-gs250. Although it is PC based, I was able to bypass their software and use imovie by attaching a 4 to 6 firewire to the dv port. It imported the movieclips with no problem. When I changed the mode on the camera from replay

  • SOAP Header modification.

    Hello All, Please help me. I am trying to use the following scenario RFC to XI and SOAP to post the message. I am getting all the info I need in RFC, but the problem is I have to modify the Header fields. The SOAP system is expecting custom parameter