From: Chris G. <cg...@gc...> - 2001-10-05 16:08:26
|
Hi everyone, I'm seeing some strange behavior when running jython servlets from Tomcat 4. Not sure where the source of the error is but I'll try to explain. I have 2 classes and they both have the same name but our in different packages, ie., something like this: pkgA.Foo pkgB.Foo These two classes are different implementation-wise, but they both have the same name. The code I have very explicity refers to pkgA.Foo: from pkgA import Foo f = Foo() but for some reaon it is using pkgB.Foo. Now, since this is all loaded under the Tomcat virtual machine, it it possible that pkgA.Foo did get loaded into memory, so somehow maybe it overwrote the pkgB.Foo when it was loaded by another application? I noticed this behavior because I was getting all kinds of errors when the application was loading and executing the wrong Foo. Then when I restarted the Tomcat server everything worked fine. I'm wondering is it possible to explicitly use a class from a particular package like this: str = java.lang.String() This can be done in Java, can this be done in python? Hopefully this makes some sense to someone :) Chris -- __________________________________________________ /\ \ \_| Christopher D. Gokey, SSAI, NASA/GCMD | | 18 Martin Road, Shelburne Falls, MA 01370 | | Phone: Voice (413) 625-8129 / FAX 208-248-9055 | | cg...@gc... / http://gcmd.nasa.gov | | ICQ #52132386, AOL IM: chrisgokey | | _____________________________________________|_ \_/______________________________________________/ |
From: Chris G. <cg...@gc...> - 2001-10-05 16:17:56
|
Sorry, see a correction below: Chris Gokey wrote: > Hi everyone, > > I'm seeing some strange behavior when running jython servlets from > Tomcat 4. Not sure where the source of the error is but I'll try to > explain. > > I have 2 classes and they both have the same name but our in different > packages, ie., something like this: > > pkgA.Foo > pkgB.Foo > > These two classes are different implementation-wise, but they both have > the same name. > > The code I have very explicity refers to pkgA.Foo: > > from pkgA import Foo > f = Foo() > > but for some reaon it is using pkgB.Foo. > > Now, since this is all loaded under the Tomcat virtual machine, it it > possible that pkgA.Foo did get loaded into memory, so somehow maybe it > overwrote the pkgB.Foo when it was loaded by another application? > This should say: Now, since this is all loaded under the Tomcat virtual machine, it it possible that pkgA.Foo did get loaded into memory, so somehow maybe it was overwritten by pkgB.Foo when it was loaded by another application? > I noticed this behavior because I was getting all kinds of errors when > the application was loading and executing the wrong Foo. Then when I > restarted the Tomcat server everything worked fine > > I'm wondering is it possible to explicitly use a class from a particular > package like this: > > str = java.lang.String() > > This can be done in Java, can this be done in python? > > Hopefully this makes some sense to someone :) > > Chris > > > -- __________________________________________________ /\ \ \_| Christopher D. Gokey, SSAI, NASA/GCMD | | 18 Martin Road, Shelburne Falls, MA 01370 | | Phone: Voice (413) 625-8129 / FAX 208-248-9055 | | cg...@gc... / http://gcmd.nasa.gov | | ICQ #52132386, AOL IM: chrisgokey | | _____________________________________________|_ \_/______________________________________________/ |
From: Brian Z. <bri...@ya...> - 2001-10-08 19:44:19
|
How about try: import pkgA f = pkgA.Foo() -Brian ----- Original Message ----- From: "Chris Gokey" <cg...@gc...> To: <jyt...@li...> Cc: "Dave Kendig" <dk...@gc...> Sent: Friday, October 05, 2001 9:02 AM Subject: [Jython-users] class conflict > Hi everyone, > > I'm seeing some strange behavior when running jython servlets from > Tomcat 4. Not sure where the source of the error is but I'll try to > explain. > > I have 2 classes and they both have the same name but our in different > packages, ie., something like this: > > pkgA.Foo > pkgB.Foo > > These two classes are different implementation-wise, but they both have > the same name. > > The code I have very explicity refers to pkgA.Foo: > > from pkgA import Foo > f = Foo() > > but for some reaon it is using pkgB.Foo. > > Now, since this is all loaded under the Tomcat virtual machine, it it > possible that pkgA.Foo did get loaded into memory, so somehow maybe it > overwrote the pkgB.Foo when it was loaded by another application? > > I noticed this behavior because I was getting all kinds of errors when > the application was loading and executing the wrong Foo. Then when I > restarted the Tomcat server everything worked fine. > > I'm wondering is it possible to explicitly use a class from a particular > package like this: > > str = java.lang.String() > > This can be done in Java, can this be done in python? > > Hopefully this makes some sense to someone :) > > Chris > > > > -- > __________________________________________________ > /\ > > \ > \_| Christopher D. Gokey, SSAI, NASA/GCMD | > | 18 Martin Road, Shelburne Falls, MA 01370 | > | Phone: Voice (413) 625-8129 / FAX 208-248-9055 | > | cg...@gc... / http://gcmd.nasa.gov | > | ICQ #52132386, AOL IM: chrisgokey | > | _____________________________________________|_ > \_/______________________________________________/ > > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > |
From: Brian Z. <bri...@ya...> - 2001-10-08 20:35:45
|
Hi Chris, I can reliably reproduce the problem. $ lynx -dump http://localhost:8080/ctx/helloA.py from pkgA import Foo; Foo() => pkgA.Foo() pkgA.Foo() => pkgA.Foo() $ lynx -dump http://localhost:8080/ctx/helloB.py from pkgB import Foo; Foo() => pkgB.Foo() pkgB.Foo() => pkgB.Foo() $ lynx -dump http://localhost:8080/ctx/helloA.py from pkgA import Foo; Foo() => pkgB.Foo() pkgA.Foo() => pkgA.Foo() The third request shows the problem, while pkgA.Foo() and pkgB.Foo() works fine. I guess different servlet URLs share the same PyServlet instance, thus the same PythonInterpreter instance. JSP does not have this problem because it does not have separate python name space. But even with the workaround, it still puzzles me, as the following is the expected result. Jython 2.1a3 on java1.4.0-beta2 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> from pkgA import Foo >>> Foo() pkgA.Foo() >>> from pkgB import Foo >>> Foo() pkgB.Foo() >>> from pkgA import Foo >>> Foo() pkgA.Foo() -Brian ----- Original Message ----- From: "Chris Gokey" <cg...@gc...> To: <jyt...@li...> Cc: "Dave Kendig" <dk...@gc...> Sent: Friday, October 05, 2001 9:02 AM Subject: [Jython-users] class conflict > Hi everyone, > > I'm seeing some strange behavior when running jython servlets from > Tomcat 4. Not sure where the source of the error is but I'll try to > explain. > > I have 2 classes and they both have the same name but our in different > packages, ie., something like this: > > pkgA.Foo > pkgB.Foo > > These two classes are different implementation-wise, but they both have > the same name. > > The code I have very explicity refers to pkgA.Foo: > > from pkgA import Foo > f = Foo() > > but for some reaon it is using pkgB.Foo. > > Now, since this is all loaded under the Tomcat virtual machine, it it > possible that pkgA.Foo did get loaded into memory, so somehow maybe it > overwrote the pkgB.Foo when it was loaded by another application? > > I noticed this behavior because I was getting all kinds of errors when > the application was loading and executing the wrong Foo. Then when I > restarted the Tomcat server everything worked fine. > > I'm wondering is it possible to explicitly use a class from a particular > package like this: > > str = java.lang.String() > > This can be done in Java, can this be done in python? > > Hopefully this makes some sense to someone :) > > Chris > > > > -- > __________________________________________________ > /\ > > \ > \_| Christopher D. Gokey, SSAI, NASA/GCMD | > | 18 Martin Road, Shelburne Falls, MA 01370 | > | Phone: Voice (413) 625-8129 / FAX 208-248-9055 | > | cg...@gc... / http://gcmd.nasa.gov | > | ICQ #52132386, AOL IM: chrisgokey | > | _____________________________________________|_ > \_/______________________________________________/ > > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > |
From: Chris G. <cg...@gc...> - 2001-10-20 02:03:21
|
Hi Brian, Thanks for your response. Yes, this is the exact behavior that I'm seeing... Your work-around that you provided in your previous message works great, but I'd also be interested in knowing why it does not produce the expected results. Chris Brian Zhou wrote: > Hi Chris, > > I can reliably reproduce the problem. > > $ lynx -dump http://localhost:8080/ctx/helloA.py > from pkgA import Foo; Foo() => pkgA.Foo() > pkgA.Foo() => pkgA.Foo() > $ lynx -dump http://localhost:8080/ctx/helloB.py > from pkgB import Foo; Foo() => pkgB.Foo() > pkgB.Foo() => pkgB.Foo() > $ lynx -dump http://localhost:8080/ctx/helloA.py > from pkgA import Foo; Foo() => pkgB.Foo() > pkgA.Foo() => pkgA.Foo() > > The third request shows the problem, while pkgA.Foo() and pkgB.Foo() works > fine. > > I guess different servlet URLs share the same PyServlet instance, thus the > same PythonInterpreter instance. JSP does not have this problem because it > does not have separate python name space. > > But even with the workaround, it still puzzles me, as the following is the > expected result. > > Jython 2.1a3 on java1.4.0-beta2 (JIT: null) > Type "copyright", "credits" or "license" for more information. > >>>>from pkgA import Foo >>>>Foo() >>>> > pkgA.Foo() > >>>>from pkgB import Foo >>>>Foo() >>>> > pkgB.Foo() > >>>>from pkgA import Foo >>>>Foo() >>>> > pkgA.Foo() > > -Brian > > ----- Original Message ----- > From: "Chris Gokey" <cg...@gc...> > To: <jyt...@li...> > Cc: "Dave Kendig" <dk...@gc...> > Sent: Friday, October 05, 2001 9:02 AM > Subject: [Jython-users] class conflict > > > >>Hi everyone, >> >>I'm seeing some strange behavior when running jython servlets from >>Tomcat 4. Not sure where the source of the error is but I'll try to >>explain. >> >>I have 2 classes and they both have the same name but our in different >>packages, ie., something like this: >> >>pkgA.Foo >>pkgB.Foo >> >>These two classes are different implementation-wise, but they both have >>the same name. >> >>The code I have very explicity refers to pkgA.Foo: >> >>from pkgA import Foo >>f = Foo() >> >>but for some reaon it is using pkgB.Foo. >> >>Now, since this is all loaded under the Tomcat virtual machine, it it >>possible that pkgA.Foo did get loaded into memory, so somehow maybe it >>overwrote the pkgB.Foo when it was loaded by another application? >> >>I noticed this behavior because I was getting all kinds of errors when >>the application was loading and executing the wrong Foo. Then when I >>restarted the Tomcat server everything worked fine. >> >>I'm wondering is it possible to explicitly use a class from a particular >>package like this: >> >>str = java.lang.String() >> >>This can be done in Java, can this be done in python? >> >>Hopefully this makes some sense to someone :) >> >>Chris >> >> >> >>-- >> __________________________________________________ >>/\ >> >> \ >>\_| Christopher D. Gokey, SSAI, NASA/GCMD | >> | 18 Martin Road, Shelburne Falls, MA 01370 | >> | Phone: Voice (413) 625-8129 / FAX 208-248-9055 | >> | cg...@gc... / http://gcmd.nasa.gov | >> | ICQ #52132386, AOL IM: chrisgokey | >> | _____________________________________________|_ >> \_/______________________________________________/ >> >> >>_______________________________________________ >>Jython-users mailing list >>Jyt...@li... >>https://lists.sourceforge.net/lists/listinfo/jython-users >> >> -- __________________________________________________ /\ \ \_| Christopher D. Gokey, SSAI, NASA/GCMD | | 18 Martin Road, Shelburne Falls, MA 01370 | | Phone: Voice (413) 625-8129 / FAX 208-248-9055 | | cg...@gc... / http://gcmd.nasa.gov | | ICQ #52132386, AOL IM: chrisgokey | | _____________________________________________|_ \_/______________________________________________/ |