loading mapscript in java error

Dan Barron dbarron at DSWLLC.COM
Tue Nov 9 08:48:39 PST 2004


At 12:26 AM 11/9/2004, Umberto Nicoletti wrote:
>On Tue, 2004-11-09 at 03:00, dbarron wrote:
> > Got the mapscript library to load - but now I have yet another error.  Got
> > library to load by doing the following:
> >
> > - commented out the following entry in the
> <src-root>/mapscript/swiginc/map.i
> > file - any ideas why the map.i file contains this entry?  maybe it needs to
> > be modified?
> >
>
>I think Sean is more informed than me but this has probably to do with
>compile flags.
>The same happened to me once when I built mapscript without OWS support.

Sean has sent an email referring to a bug - I will try his suggestion for this.

> >   int saveQueryAsGML(char *filename) {
> >     return msGMLWriteQuery(self, filename);
> >   }
> >
> > - rebuilt the java source files using swig command
> >
> >   swig -java -v -package mapscript mapscript.i
> >
>
>I think you can use 'make interface' instead

Yes - I discovered after I sent this email of the dumb error I made in
running swig and not naming the package correctly - and therefore getting
the naming exception.  I also dug deeper into the Makefiles and discovered
that I should just use the 'make interface' as well.  I was blinded to the
obvious by looking to much for the inobvious.

> > - rebuilt the mapscript.jar and libmapscript.so files
> > - copied the mapscript.jar file to the /usr/local/jdk1.5.0/jre/lib/ext/
> > directory
>
>It is probably not a good idea to copy the jar file over there.
>Keep it in a local directory and set CLASSPATH accordingly, at least
>until we don't get these issues sorted out.

I agree and I do have the jar in a local directory and the CLASSPATH is set
to have this local directory but when I added a -verbose flag to the java
command it showed it was looking in this directory for the jar.  It has to
be something in my setup that I am overlooking.


> > Now when I try to run the following little java app to test:
> >
> >  import java.io.*;
> >  import edu.umn.gis.mapscript.*;
> >
> >  public class MapScriptTest {
> >
> >    public static void main(String[] args) throws IOException {
> >       System.out.println("loading mapscript library...");
> >       System.loadLibrary("mapscript");
> >       System.out.println("mapscript library LOADED...");
> >       mapObj  map;
> >       imageObj image;
> >
> >       map=new mapObj("/home/dbarron/mapserver-test/china.map");
> >       System.out.println("Created new mapObj()...");
> >       image=map.draw();
> >       image.save("china.png",map);
> >
> >    }
> >  }
> >
> > I get the following output and exception:
> >
> > loading mapscript library...
> > mapscript library LOADED...
> > Exception in thread "main" java.lang.NoClassDefFoundError:
> > edu/umn/gis/mapscript/mapObj (wrong name: mapscript/mapObj)
> >         at java.lang.ClassLoader.defineClass1(Native Method)
> >         at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
> >         at
> > java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
> >         at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
> >         at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
> >         at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
> >         at java.security.AccessController.doPrivileged(Native Method)
> >         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> >         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
> >         at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
> >         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
> >         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
> >         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
> >         at MapScriptTest.main(MapScriptTest.java:14)
> >
> > I will continue to work through it - but wanted to see if either of you had
> > any ideas on this?
> >
>
>java simply cannot find the mapObj. But the 'wrong name' error looks
>strange.

My error there - fixed that already - and now I have another error.

>Have you run the tests that come with mapscript ('make test')?

No, I will do that today as well as include Sean's suggestion.

>Then what about telling us what platform you running on?

FC2 w/ JDK 1.5.0

Thanks!

Dan


>Please forward your previous email to the list for others to benefit.
>
>HTH,
>Umberto
>
> > Thanks,
> >
> > Dan
> >
> >
> > On Monday 08 November 2004 10:30, dbarron wrote:
> > > Umberto,
> > >
> > > Thanks for the suggestions!
> > >
> > > The error in full is below.  The test app does see the library and
> tries to
> > > load it - it just has an error within the library itself.  I used the
> > > straight beta2 release as Sean suggested.  It seems like the
> > > java/libmapscript.so compile is not loading in the source that holds the
> > > GML functionality - that's my guess anyway.  I do see the mapgml.c
> file get
> > > compiled into mapserv.exe - that defines the msGMLWriteQuery method - but
> > > why the java/libmapscript.so compile does not get it too, I do not
> know at
> > > this point.  I'll see if I can get it to work today.
> > >
> > > loading mapscript library...
> > > Exception in thread "main"
> > > java.lang.UnsatisfiedLinkError: /usr/local/lib/special/libmapscript.so:
> > > /usr/local/lib/special/libmapscript.so: undefined symbol: msGMLWriteQuery
> > >         at java.lang.ClassLoader$NativeLibrary.load(Native Method)
> > >         at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
> > >         at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1676)
> > >         at java.lang.Runtime.loadLibrary0(Runtime.java:822)
> > >         at java.lang.System.loadLibrary(System.java:992)
> > >         at MapScriptTest.main(MapScriptTest.java:8)
> > >
> > > Dan



More information about the MapServer-users mailing list