?
Solved

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

Posted on 2003-03-11
16
Medium Priority
?
1,511 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month8 days, 20 hours left to enroll

764 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