Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

java.lang.SecurityException: Prohibited package name: java.sql

Posted on 2003-03-11
16
Medium Priority
?
1,538 Views
Last Modified: 2012-08-13
hi,

i am trying to push a java application onto a JRun 3.1 server connecting to a oracle 8 database. in my servlet initialization, i use a connection pool to gain a connection to the database.

Class.forName("oracle.jdbc.OracleDriver");
outConn = DriverManager.getConnection(outUrl, outUsername, outPassword);
//throws error at the above line

this will throw an error:
java.lang.SecurityException: Prohibited package name: java.sql

this error is most peculiar because it runs fine locally on my developers version of JRun 3.1. but when i push it to a licensed version on a different server it gives this error. any hints?
0
Comment
Question by:echuta86
  • 8
  • 6
  • 2
16 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 8114751
Does the other server have a policy file like this (in the java.security file in your ${JAVA_HOME}/jre/lib/security)

--------------------

#excerpted from java.security. Each property
#takes a comma delimited
#list of package prefixes. Security checks
#apply only to packages
#that begin with an exact string match
#of one of these prefixes.

package.access=java.sql

--------------------

If so, whatever genius set up the machine blocked all java.sql.* classes from being able to run
0
 

Author Comment

by:echuta86
ID: 8114851
another bit of info:

when i write a standalone script that has the same code, and i run it locally, it gives me the same error. i put nothing into the classpath except these files (plus the classes i developed):

@set CP=%CP%;%JAVA_HOME%\jre\lib\rt.jar
@set CP=%CP%;C:\projects\utils\lib\ojdbc14.jar

so Tim, it might not be the security file because i looked locally and the only line that prohibits package access is:

package.access=sun.

and i reiterate that it works locally on my JRun server but not on a different machine running JRun.
0
 
LVL 92

Expert Comment

by:objects
ID: 8114907
> C:\projects\utils\lib\ojdbc14.jar

Whats in this jar?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:echuta86
ID: 8115021
ojdbc14.jar is oracles jdbc connection classes.

i have a thought that maybe the problem is caused by the oracle driver's use of java.sql classes.
0
 
LVL 92

Expert Comment

by:objects
ID: 8115104
Try include the package in the 'ext' directory instead of in the classpath.

Also why are you adding rt.jar? I'd also remove that.
0
 

Author Comment

by:echuta86
ID: 8115210
i've tried to add the ext directory and i also removed rt.jar but i still get the error. the reason i had rt.jar was because the oracle driver apparently is implementing the java.sql.Savepoint interface which is making it's first appearance in JDK1 1.4. so i've added that specific class to the path instead of the whole jar file.
0
 
LVL 92

Expert Comment

by:objects
ID: 8115256
What JDK is it running? You can't just add rt.jar to include 1.4 support.
If the driver requires 1.4 then you need to install 1.4.

Sounds like this could be the cause of your problem.
0
 

Author Comment

by:echuta86
ID: 8115343
hmmm..... object, you might be leading me to the answer. in jrun, i've explicitly set the JDK to 1.4 in the server settings for my machine.

might i be incorrectly setting the JDK in my script?
this is my whole script:(project\... are my own class files)

@set JAVA_HOME=C:\j2sdk1.4.1_01

@set CP=%CP%;C:\projects\conventions\classes
@set CP=%CP%;C:\projects\utils\classes
@set CP=%CP%;C:\projects\utils\lib\ojdbc14.jar
@set CP=%CP%;C:\j2sdk1.4.1_01\jre\lib\

java -classpath %CP% tl.conventions.utils.ConventionSynchronizer

@pause

0
 

Author Comment

by:echuta86
ID: 8115348
btw, i only have 1.4.1_01 installed on my machine.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 8115368
you might need

@set CP=%CP%;C:\j2sdk1.4.1_01\jre\lib\ext

as well...
0
 
LVL 92

Expert Comment

by:objects
ID: 8115416
> @set CP=%CP%;C:\j2sdk1.4.1_01\jre\lib\

you shouldn't need this line.


0
 

Author Comment

by:echuta86
ID: 8115505
without that line, @set CP=%CP%;C:\j2sdk1.4.1_01\jre\lib\
my script will not run, and complains that there is no java.sql.Savepoint. this would leave me to believe that my system variables might not be set up correctly. but all i need is to set these correct?

JAVA_HOME=C:\j2sdk1.4.1_01
CLASSPATH=C:\j2sdk1.4.1_01
 
and add C:\j2sdk1.4.1_01\bin to the PATH sys var.
0
 
LVL 92

Accepted Solution

by:
objects earned 1000 total points
ID: 8115547
try:

@set JAVA_HOME=C:\j2sdk1.4.1_01

@set CP=%CP%;C:\projects\conventions\classes
@set CP=%CP%;C:\projects\utils\classes
@set CP=%CP%;C:\projects\utils\lib\ojdbc14.jar

%JAVA_HOME%\bin\java -classpath %CP% tl.conventions.utils.ConventionSynchronizer

@pause

0
 

Author Comment

by:echuta86
ID: 8115673
awesome. thanks tim & objects for the input. this should solve my other problem on the server because it's running 1.3.

for future developers:
note1: java.sql.Savepoint is a new interface in JDK1.4
note2: you cannot include any class that begins with java.* unless they are already part of the original JDK. in my case i tried to extract the java.sql.Savepoint class from 1.4 and include it in my classpath in a JDK1.3 env.

your a lifesaver objects.
0
 

Author Comment

by:echuta86
ID: 8115679
followed up questions very fast and efficiently.
0
 
LVL 92

Expert Comment

by:objects
ID: 8115713
happy to hear it's fixed :)

thanks for the points.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn different types of Android Layout and some basics of an Android App.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question