Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Struts - A MVC web framework
Tomcat - JSP/Servlet container
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
JSP - A mailing list about Java Server Pages specification and reference
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
Websphere datasource giving security error from simple java a pp

Websphere datasource giving security error from simple java a pp

2004-03-10       - By Onganer, Cag

 Back
Reply:     1     2  

Hi,

It seems that you aren't putting in the security constraints onto the
context.
You need to add them to your Context

                       System.setProperty("java.naming.security.principal",
username);


System.setProperty("java.naming.security.credentials", password);


run your program with these switches:

-Djava.naming.security.principal=(username)
-Djava.naming.security.credentials=(password)

Cag Onganer

-- --Original Message-- --
From: A mailing list for Java(tm) 2 Platform, Enterprise Edition
[mailto:J2EE-INTEREST@(protected)] On Behalf Of Ashutosh Bhardwaj
Sent: 10 March 2004 14:39
To: J2EE-INTEREST@(protected)
Subject: Websphere datasource giving security error from simple java app



The code follows :

import java.util.Hashtable Source code of java.util.Hashtable;

import javax.naming.Context Source code of javax.naming.Context;
import javax.naming.InitialContext Source code of javax.naming.InitialContext;
import javax.sql.DataSource Source code of javax.sql.DataSource;

public class DSTest {

       public static void main(String[] args) {
               try {
//
//                              Hashtable jndiProperties = new Hashtable();
//                       jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");

                       System.setProperty("java.naming.factory.initial",
"com.ibm.websphere.naming.WsnInitialContextFactory");

                       System.setProperty("java.naming.provider.url",
"IIOP://localhost:2809/");

//                      jndiProperties.put(Context.PROVIDER_URL,
"iiop://localhost:2809");
                       Context initialContext = new InitialContext();

                       Hashtable ht = initialContext.getEnvironment();
                       System.out.println(ht.toString());
                       Context context = new InitialContext();

System.out.println(context.lookup("jdbc/owd_ds_tx"));
                       DataSource ds = (DataSource)
context.lookup("jdbc/ds_tx");


               } catch (Exception e) {
                       e.printStackTrace();
               }

       }

}

And then the error :


{com.ibm.websphere.naming.hostname.normalizer=com.ibm.ws.naming.util.Default
HostnameNormalizer,
java.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactor
y, com.ibm.websphere.naming.name.syntax=jndi,
com.ibm.websphere.naming.namespace.connection=lazy,
com.ibm.ws.naming.ldap.ldapinitctxfactory=com.sun.jndi.ldap.LdapCtxFactory,
com.ibm.websphere.naming.jndicache.cacheobject=populated,
com.ibm.websphere.naming.namespaceroot=defaultroot,
com.ibm.ws.naming.implementation=WsnIpCos,
com.ibm.ws.naming.provider.url=corbaname:iiop:1.0@(protected):2809/NameServ
ice#,
com.ibm.ws.naming.wsn.factory.initial=com.ibm.ws.naming.util.WsnInitCtxFacto
ry, com.ibm.websphere.naming.jndicache.maxcachelife=0,
com.ibm.websphere.naming.jndicache.maxentrylife=0,
com.ibm.websphere.naming.jndicache.cachename=providerURL,
java.naming.provider.url=IIOP://localhost:2809/,
java.naming.factory.url.pkgs=com.ibm.ws.naming}

com.ibm.websphere.naming.CannotInstantiateObjectException: Exception
occurred while the JNDI NamingManager was processing a
javax.naming.Reference Source code of javax.naming.Reference object.  Root exception is java.lang.Exception Source code of java.lang.Exception:
Failed security check.  Client is not permitted to create connection factory
jdbc/ds_tx

       at
com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.createMCFandPM(ConnectionFactor
yBuilderImpl.java:1566)
       at
com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.getObjectInstance(ConnectionFac
toryBuilderImpl.java:1188)
       at
javax.naming.spi.NamingManager Source code of javax.naming.spi.NamingManager(NamingManager.java:313)
       at
com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookup(Helpers.java
:884)
       at
com.ibm.ws.naming.jndicos.CNContextImpl.processResolveResults(CNContextImpl.
java:1762)
       at
com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1615)
       at
com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1525)
       at
com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1225)
       at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:132)
       at javax.naming.InitialContext Source code of javax.naming.InitialContext(InitialContext.java:359)
       at OWDDSTest.main(OWDDSTest.java:36)


Here are the jars :

J2ee.jar,j2cimpl.jar,namingclient.jar,namingserver.jar,naming.jar,ecutils.ja
r,implfactory.jar.



Any solutions .

Regards,
ashutosh

===========================================================================
To unsubscribe, send email to listserv@(protected) and include in the body
of the message "signoff J2EE-INTEREST". For general help, send email to
listserv@(protected) and include in the body of the message "help".




===========================================================================
To unsubscribe, send email to listserv@(protected) and include in the body
of the message "signoff J2EE-INTEREST".  For general help, send email to
listserv@(protected) and include in the body of the message "help".


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<TITLE>Message</TITLE>

<META content="MSHTML 6.00.2800.1400" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=766325314-10032004><FONT face=Arial color=#0000ff
size=2>Hi,</FONT></SPAN></DIV>
<DIV><SPAN class=766325314-10032004></SPAN>&nbsp;</DIV>
<DIV><SPAN class=766325314-10032004><FONT face=Arial color=#0000ff size=2>It
seems that you aren't putting in the security constraints onto the
context.</FONT></SPAN></DIV>
<DIV><SPAN class=766325314-10032004><FONT face=Arial color=#0000ff size=2>You
need to add them to your Context&nbsp;</FONT></SPAN></DIV>
<DIV><SPAN class=766325314-10032004><FONT face=Arial color=#0000ff
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=766325314-10032004>
<P><FONT color=#0000ff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT
size=2>System.setProperty("<FONT
face=Arial>java.naming.security.principal</FONT>",&nbsp;<SPAN
class=766325314-10032004>username</SPAN>);</FONT></FONT></P>
<P><FONT color=#0000ff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT
size=2>System.setProperty("<FONT
face=Arial>java.naming.security.credentials</FONT>",&nbsp;<SPAN
class=766325314-10032004>password</SPAN>);</FONT></FONT></P></SPAN></DIV>
<DIV><SPAN class=766325314-10032004><FONT face=Arial color=#0000ff
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=766325314-10032004><FONT face=Arial color=#0000ff size=2>run
your program with these switches:</FONT></SPAN></DIV>
<DIV><SPAN class=766325314-10032004></SPAN><SPAN class=766325314-10032004><FONT
face=Arial color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=766325314-10032004><FONT face=Arial color=#0000ff
size=2>-Djava.naming.security.principal=(username)
-Djava.naming.security.credentials=(password)</FONT></SPAN></DIV>
<DIV><SPAN class=766325314-10032004><FONT face=Arial color=#0000ff
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=766325314-10032004><FONT face=Arial color=#0000ff size=2>Cag
Onganer</FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
 <DIV></DIV>
 <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT
 face=Tahoma size=2>-- --Original Message-- --<BR><B>From:</B> A mailing list
 for Java(tm) 2 Platform, Enterprise Edition
 [mailto:J2EE-INTEREST@(protected)] <B>On Behalf Of </B>Ashutosh
 Bhardwaj<BR><B>Sent:</B> 10 March 2004 14:39<BR><B>To:</B>
 J2EE-INTEREST@(protected)<BR><B>Subject:</B> Websphere datasource giving
 security error from simple java app<BR><BR></FONT></DIV>
 <P><FONT size=2>The code follows :</FONT> </P>
 <P><FONT size=2>import java.util.Hashtable Source code of java.util.Hashtable;</FONT> </P>
 <P><FONT size=2>import javax.naming.Context Source code of javax.naming.Context;</FONT> <BR><FONT size=2>import
 javax.naming.InitialContext Source code of javax.naming.InitialContext;</FONT> <BR><FONT size=2>import
 javax.sql.DataSource Source code of javax.sql.DataSource;</FONT> </P>
 <P><FONT size=2>public class DSTest {</FONT> </P>
 <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=2>public static void
 main(String[] args) {</FONT> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=2>try {</FONT> <BR><FONT
 size=2>//</FONT> <BR><FONT size=2>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Hashtable jndiProperties = new
 Hashtable();</FONT> <BR><FONT size=2>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY,
 "com.ibm.websphere.naming.WsnInitialContextFactory");</FONT></P>
 <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT
 size=2>System.setProperty("java.naming.factory.initial",
 "com.ibm.websphere.naming.WsnInitialContextFactory");</FONT></P>
 <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT
 size=2>System.setProperty("java.naming.provider.url",
 "IIOP://localhost:2809/");</FONT> </P>
 <P><FONT size=2>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 jndiProperties.put(Context.PROVIDER_URL, "iiop://localhost:2809");</FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=2>Context initialContext
 = new InitialContext();</FONT> </P>
 <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=2>Hashtable ht =
 initialContext.getEnvironment();</FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT
 size=2>System.out.println(ht.toString());</FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=2>Context context = new
 InitialContext();</FONT> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT
 size=2>System.out.println(context.lookup("jdbc/owd_ds_tx"));</FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=2>DataSource ds =
 (DataSource) context.lookup("jdbc/ds_tx");</FONT> </P>
 <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=2>} catch (Exception e)
 {</FONT> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT
 size=2>e.printStackTrace();</FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=2>}</FONT> </P>
 <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=2>}</FONT> </P>
 <P><FONT size=2>}</FONT> </P>
 <P><FONT size=2>And then the error :</FONT> </P><BR>
 <P><FONT
 size=2>{com.ibm.websphere.naming.hostname.normalizer=com.ibm.ws.naming.util
.DefaultHostnameNormalizer,
 java.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory,
 com.ibm.websphere.naming.name.syntax=jndi,
 com.ibm.websphere.naming.namespace.connection=lazy,
 com.ibm.ws.naming.ldap.ldapinitctxfactory=com.sun.jndi.ldap.LdapCtxFactory,
 com.ibm.websphere.naming.jndicache.cacheobject=populated,
 com.ibm.websphere.naming.namespaceroot=defaultroot,
 com.ibm.ws.naming.implementation=WsnIpCos,
 com.ibm.ws.naming.provider.url=corbaname:iiop:1.0@(protected):2809
/NameService#,
 com.ibm.ws.naming.wsn.factory.initial=com.ibm.ws.naming.util
.WsnInitCtxFactory,
 com.ibm.websphere.naming.jndicache.maxcachelife=0,
 com.ibm.websphere.naming.jndicache.maxentrylife=0,
 com.ibm.websphere.naming.jndicache.cachename=providerURL,
 java.naming.provider.url=IIOP://localhost:2809/,
 java.naming.factory.url.pkgs=com.ibm.ws.naming}</FONT></P>
 <P><FONT size=2>com.ibm.websphere.naming.CannotInstantiateObjectException:
 Exception occurred while the JNDI NamingManager was processing a
 javax.naming.Reference Source code of javax.naming.Reference object.&nbsp; Root exception is java.lang.Exception Source code of java.lang.Exception:
 Failed security check.&nbsp; Client is not permitted to create connection
 factory jdbc/ds_tx</FONT></P>
 <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=2>at
 com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.createMCFandPM
(ConnectionFactoryBuilderImpl.java:1566)</FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=2>at
 com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.getObjectInstance
(ConnectionFactoryBuilderImpl.java:1188)</FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=2>at
 javax.naming.spi.NamingManager Source code of javax.naming.spi.NamingManager(NamingManager.java:313)<
/FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=2>at
 com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookup(Helpers.java
:884)</FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=2>at
 com.ibm.ws.naming.jndicos.CNContextImpl.processResolveResults(CNContextImpl
.java:1762)</FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=2>at
 com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1615)<
/FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=2>at
 com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1525)<
/FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=2>at
 com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1225)</FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=2>at
 com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:132)</FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=2>at
 javax.naming.InitialContext Source code of javax.naming.InitialContext(InitialContext.java:359)</FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=2>at
 OWDDSTest.main(OWDDSTest.java:36)</FONT> </P><BR>
 <P><FONT size=2>Here are the jars :</FONT> </P>
 <P><FONT
 size=2>J2ee.jar,j2cimpl.jar,namingclient.jar,namingserver.jar,naming.jar
,ecutils.jar,implfactory.jar.</FONT>
 </P><BR><BR>
 <P><FONT size=2>Any solutions .</FONT> </P>
 <P><FONT size=2>Regards,</FONT> <BR><FONT size=2>ashutosh</FONT>
 </P>=========================================================================
==
 To unsubscribe, send email to listserv@(protected) and include in the body of
 the message "signoff J2EE-INTEREST". For general help, send email to
 listserv@(protected) and include in the body of the message "help".
 <P></P></BLOCKQUOTE></BODY></HTML>
===========================================================================
To unsubscribe, send email to listserv@(protected) and include in the body
of the message "signoff J2EE-INTEREST".  For general help, send email to
listserv@(protected) and include in the body of the message "help".
<p>

©2008 junlu.com - Jax Systems, LLC, U.S.A.