Debabrata,
The probable cause is which classloaders are being used to a) start jython and b) load the ojdbc.jar file. Basically they are probably not the same. See http://bugs.jython.org/issue1127

Cheers
Indra


On 9 May 2014 20:41, Richard Eckart de Castilho <richard.eckart@gmail.com> wrote:
Hi Debabrata,

consider the following example:

$ export CLASSPATH=path/to/my/ojdbc5.jar

$ jython
Jython 2.7b1 (default:ac42d59644e9, Feb 9 2013, 15:24:52)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0
Type "help", "copyright", "credits" or "license" for more information.
>>> from oracle.jdbc import OracleDriver
>>> _

$ jython
Jython 2.7b1 (default:ac42d59644e9, Feb 9 2013, 15:24:52)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0
Type "help", "copyright", "credits" or "license" for more information.
>>> from java.lang import Class
>>> Class.forName('oracle.jdbc.OracleDriver')
<type 'oracle.jdbc.OracleDriver'>
>>> _

Both appears to work for me (with 2.7b1).

-- Richard

On 09.05.2014, at 12:34, Debabrata Pani <debabrata.pani@gmail.com> wrote:

> Hi Richard,
>
> your example is correct. if I add the ojdbc5.jar to the sys.path as you say, it works. In fact that is the workaround we are planning to have.
>
> But my question is :
>
> a direct import oracle.jdbc.OracleDriver fails (pointing towards the fact that may be ojdbc5.jar is not in the classpath)
>
> but a
>
> Class.forName('oracle.jdbc.OracleDriver') goes through (as if the ojdbc5.jar IS in the classpath)
>
> From the point of view of Java and Jython, both Class.forName and "direct" import should have identical behavior.
> They should both succeed or both fail (due to ClassNotFoundException etc)
>
> Isn't it ?
>
> Regards,
> Debabrata Pani
>
>
> On Fri, May 9, 2014 at 3:25 PM, Richard Eckart de Castilho <richard.eckart@gmail.com> wrote:
> Hi Debabrata,
>
> I just tried this and it appears to work for me:
>
> Jython 2.7b1 (default:ac42d59644e9, Feb 9 2013, 15:24:52)
> [Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import sys
> >>> sys.path.append("/path/to/my/ojdbc5.jar")
> >>> from oracle.jdbc import OracleDriver
> >>> _
>
> Maybe a problem with the older Jython version?
>
> -- Richard
>
> On 09.05.2014, at 09:03, Debabrata Pani <debabrata.pani@gmail.com> wrote:
>
> > Hi Richard,
> >
> > Thanks for the quick suggestion. I tried the following
> >
> > wsadmin>from oracle.jdbc  import Oracle
> > WASX7015E: Exception running command: "from oracle.jdbc  import Oracle"; exception information:
> >  com.ibm.bsf.BSFException: exception from Jython:
> > Traceback (innermost last):
> >   File "<input>", line 1, in ?
> > ImportError: No module named jdbc
> >
> > wsadmin>
> >
> >
> > But the same error, I guess.
> >
> > Regards,
> > Debabrata Pani
> >
> >
> > On Fri, May 9, 2014 at 12:04 PM, Richard Eckart de Castilho <richard.eckart@gmail.com> wrote:
> > Hi,
> >
> > it should work if you say
> >
> > from oracle.jdbc import OracleDriver
> >
> > Cheers,
> >
> > -- Richard
> >
> > On 09.05.2014, at 08:00, Debabrata Pani <debabrata.pani@gmail.com> wrote:
> >
> > > Hi ,
> > >
> > > I have Websphere wsadmin setup which enables jython scripting.
> > >
> > > The jython version is :
> > >
> > > wsadmin>sys.version
> > > '2.1'
> > > wsadmin>
> > >
> > >
> > > In the wsadmin prompt, when I type the following :
> > >
> > > wsadmin> import oracle.jdbc.OracleDriver
> > >
> > > I get
> > >
> > > WASX7015E: Exception running command: "import oracle.jdbc.OracleDriver"; exception information:
> > >  com.ibm.bsf.BSFException: exception from Jython:
> > > Traceback (innermost last):
> > >   File "<input>", line 1, in ?
> > > ImportError: No module named jdbc
> > >
> > >
> > > But when i do the following :
> > >
> > > wsadmin>tt = java.lang.Class.forName('oracle.jdbc.OracleDriver')
> > >
> > > It goes through. Additionally,
> > >
> > > wsadmin>tt.getProtectionDomain()
> > > ProtectionDomain
> > > CodeSource=CodeSource, url=file:/some/path/work/middleware/wlserver_10.3/server/lib/ojdbc6.jar, <no certificates>
> > > ClassLoader=com.ibm.ws.bootstrap.ExtClassLoader@79ea79ea
> > > <no principals>
> > > Permissions:
> > >                 static: java.security.Permissions@25412541 (
> > >  (java.io.FilePermission /some/path/work/middleware/wlserver_10.3/server/lib/ojdbc6.jar read)
> > > )
> > >
> > >                 <no dynamic permissions>
> > >
> > > wsadmin>
> > >
> > >
> > > Can somebody explain what can be the possible reason for this discrepancy ? I tried understanding  the  jython "classpath" mechanism and how it depends upon sys.path and java.class.path . But I was unable to explain this particular behavior.
> > >
> > >
> > > Regards,
> > > Debabrata Pani


------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
&#149; 3 signs your SCM is hindering your productivity
&#149; Requirements for releasing software faster
&#149; Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
Jython-users mailing list
Jython-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users



--
Indra Talip