From: Edward P. <epo...@te...> - 2002-03-22 23:01:00
|
Hello All, I've look in the archives, but only see questions, and no answers relating to this. I have a folder hierarchy impi/core/ and a .class file impi/core/Impi.class when I 'from impi.core import *' from another module, I get 'java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: impi/core/impi (wrong name: impi/core/Impi)' Is there a quick fix for this? Thanks -Ed |
From: Kevin B. <kb...@ca...> - 2002-03-22 23:41:53
|
Hmm. I'm not quite sure how you managed it, but I imagine at some point you had Impi in a file named impi.java? You may also not be using Jython 2.1? Windows' case-insensitive filesystem is unfriendly to Java's case-sensitive class names & one-class-one-file philosophy. I'd suggest doing a clean build of all your Java code related to Impi. This will probably identify some class that is using 'impi' instead of 'Impi'. 'grep' may also do it. kb Edward Povazan wrote: >Hello All, > >I've look in the archives, but only see questions, and no answers relating >to this. >I have a folder hierarchy impi/core/ and a .class file impi/core/Impi.class > >when I 'from impi.core import *' from another module, I get >'java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: >impi/core/impi (wrong name: impi/core/Impi)' > >Is there a quick fix for this? > >Thanks >-Ed > > >_______________________________________________ >Jython-users mailing list >Jyt...@li... >https://lists.sourceforge.net/lists/listinfo/jython-users > |
From: Edward P. <epo...@te...> - 2002-03-23 00:40:19
|
> I'm not quite sure how you managed it, but I imagine at some point > you had Impi in a file named impi.java? You may also not be using Jython > 2.1? That was my first thought ... I checked for rogue impi.java classes. Still doesn't work. I did see similar questions in the archives, I think it is something windows specific. -Ed |
From: Samuele P. <pe...@in...> - 2002-03-22 23:43:27
|
> Hello All, > > I've look in the archives, but only see questions, and no answers relating > to this. > I have a folder hierarchy impi/core/ and a .class file impi/core/Impi.class > > when I 'from impi.core import *' from another module, I get > 'java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: > impi/core/impi (wrong name: impi/core/Impi)' > > Is there a quick fix for this? > Under which OS? What does: import impi.core dir(impi.core) display? Impli or impli Samuele. |
From: Edward P. <epo...@te...> - 2002-03-23 00:15:35
|
I am using Jython 2.1 under XP Pro. > import impi.core > dir(impi.core) ['__doc__', '__file__', '__name__', '__path__'] Hmm, this is strange, but I can acually: import impi.core.Impi dir(impi.core.Impi) Which works as expected, showing all the static methods of the Impi class. Impi is a class containing static methods only. Do I have something set up wrong. My classpath is set to the root of my project. Is there anything else? Thanks -Ed |
From: Samuele P. <pe...@in...> - 2002-03-23 00:42:49
|
From: Edward Povazan <epo...@te...> > I am using Jython 2.1 under XP Pro. > > > import impi.core > > dir(impi.core) > ['__doc__', '__file__', '__name__', '__path__'] > > Hmm, this is strange, but I can acually: That means that impi.core is a Python package, you have a __init__.py both in impi and impi/core? That's OK. But so your from impi.core import * will never get you the Java class. Anyway why the error? The thing you haven't said to us is that you are doing the from impi.core import * from a module inside impi.core, is that true? Samuele. |
From: Samuele P. <pe...@in...> - 2002-03-23 01:17:07
|
From: Edward Povazan <epo...@te...> > Ok, > I have __init__.py in the proper places. > I have this hierarchy > /impi > /impi/core > /impi/core/Impi.class # java class with static methods, ie "looks like a > module" > /impi/core/editors.py # a bunch of basic gui's used by the app. > > In a jython console, I can do this: > from impi.core import * # works ok but does it get you Impi? it shouldn't. > from impi.core.editors import * # I get the exception here > > editors.py contains: > from impi.core import * > > > But so your from impi.core import * will never > > get you the Java class. Anyway why the error? > In the console > from impi.core import * works fine, and I can call the static methods in > class Impi. Just when import is from another file, I get the problem. > > > The thing you haven't said to us > > is that you are doing the > > from impi.core import * > > from a module inside impi.core, is that true? > Yes, from editors.py A-ah, you get the error because Python import are interpreted first as relative to the package of the current module: that means that inside import.core.editors from impi.core import * tries from impi.core.impi.core import * before from impi.core import * # top-level impi now the first should fallback to the second because Impi.class is not impi something, So it seems we have still a case-sensitivity problem we shouldn't have anymore. That one is a bug :(!. OTOH from py.pkg import * never gets to the possible Java classes inside py.pkg, the single import yes or if you have already imported them otherwise. from java.pkg import * works OTOH. Now for a workaround, it really depends on what do you want to get with from impi.core import *? regards. PS: as a style note it is better to avoid import * in production code. |
From: Edward P. <epo...@te...> - 2002-03-23 02:56:32
|
> A-ah, :) thanks for your trouble at least now it is not me. Looks like I need to reread about python import. > PS: as a style note it is better to avoid import * > in production code. Yes, I normally do, except that impi.core has most of the 'brains' of my app, and it is used often. I have tried to import the specific files I need. Seems that Impi.class still causes problems. from impi.core import Whatever still causes problems. I will write some test code separate from my app, and see if I can figure it out. Thanks -Ed |
From: Samuele P. <pe...@in...> - 2002-03-23 04:14:17
|
From: Edward Povazan <epo...@te...> > Ok, I have recreated the error in a separate test. > Do you know where I can start looking in the source, where the import > actually occurs. > Or is there someone who 'maintains' the import code that would be interested > to see this? Maybe you refer to me <wink>. I'm guilty for much of the import logic impl. Sorry for the duplicated work but when I asked: [me] >The thing you haven't said to us >is that you are doing the > from impi.core import * >from a module inside impi.core, is that true? I had already code that duplicated the bug, I was exploring whether my work hypothesis matched your world(-view). > > No matter if I use * or a specific method/object, the error still occurs. > I never said the contrary, inside impi.core.editors all from impi.core import * from impi.core import Impi import impi.core import impi will fail. The situation is more involved that it already seems <wink>. [*] At some point we [the devels] decided that NoClassDefFoundError should be treated differently than ClassNotFoundException, and not transformed in import errors, but just propagated up to the user. Because it can contain valuable debug info. So the naive fix that we can apply - leaving [*] as it is - would fix the problem as long as sys.path is disjunct from classpath... So the point is that maybe we should rethink about [*]. For your case, I don't know if this is acceptable for you, but I would move the java classes in impi.core.jclasses, jclasses being a java package (a dir without __init__.py), and putting the right package statements in the java sources. Then you can put a from jclasses import * or from impi.core.import * inside impi.core.__init__ and murphy-willing things should work, unless other subtlilities block this approach too. regards. |