cancel
Showing results for 
Search instead for 
Did you mean: 

JAVA Function Error

Former Member
0 Kudos

I get the following error when I run JAVA function:

=============================================

The following error occurred while fetching results:

Procedure 'hello' terminated with unhandled exception

'java.lang.Security Exception: File I/O not allowed'

SQLCODE=-91, ODBC 3 State='HY000"

=============================================

[OS Environment]

*  Linux testsvr 2.6.9-89.EL #1 Mon Apr 20 10:22:29 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux

*  Java -version : java version "1.4.2_11"

*  Sybase Server Version : 12.7.0/ESD 12

[Java Source Code]

import java.io.FileInputStream;

public class Dummy {

        public static String hello(String str) throws Exception {

               FileInputStream fis = null;

               try {

                       fis = new FileInputStream("/app/sybase/Test/test.txt");

                       fis.read();

                       return str;

               } catch (Exception e) {

                       throw e;

               } finally {

                       if (fis != null) {

                              try {

                                      fis.close();

                              } catch (Exception e) {}

                       }

               }

        }

}

Function SQL

[SQL Statements]

Install java new from file '/app/sybase/Test/Dummy.class';

Create function testdummy(in name varchar(249)) returns varchar(255) external name 'Dummy.hello(Ljava/lang/String;)Ljava/lang/String;' language JAVA;

Select testdummy('abc');

Permission was granted permission from the top 777.

Any help would be really appreciated.

Thank you.

Accepted Solutions (0)

Answers (1)

Answers (1)

tayeb_hadjou
Advisor
Advisor
0 Kudos

Hi Lee,

Does the function fail when called by its owner?

If it fails only when called with different user then try recreate it with option "SQL SECURITY INVOKER"

http://infocenter.sybase.com/help/topic/com.sybase.infocenter.dc00801.1604/doc/html/jcu1304529694510...

Former Member
0 Kudos

Hi HADJOU,

Yes, the function fail when called by its owner.

c_baker
Employee
Employee
0 Kudos

Try a function that does not use IO.

Can you also try this on a current IQ?  12.7 is very old and you are using a JVM that is deprecated.  There used to be restrictions in ASE and IQ Java that prevented IO to console and elsewhere so the JVM could run 'headless' without getting hung waiting for user input and resolution.

Perhaps you are hitting that restriction, even though the documentation may state otherwise and file IO is allowed.  Running on a current IQ version will help to narrow this down.

Chris

tayeb_hadjou
Advisor
Advisor
0 Kudos

Looking in google with "java.lang.Security Exception", this looks like a security restriction on JVM !

Do you get same problem when executing the Dummy.class outside IQ database?

By the way, your test case works fine in my IQ 16 Linux. I cannot test it in IQ12.7 because my Jdk compiler is not compatible with this old IQ version.

Regards,

Tayeb.

Former Member
0 Kudos

In IQ15.4 it operates normally. What is the solution of IQ12.7?

tayeb_hadjou
Advisor
Advisor
0 Kudos

Which jdk version you compiled with?

Please upload your class file, so I can test it with my IQ12.7.