simple mapserver instrucctions don't work!!

Jose Luis Gonzalez joseluismapserver at YAHOO.ES
Tue Nov 30 09:13:24 EST 2004


I am using mapserver 4.2.4.
All I wanted to do is to do any simple mapserver instructions to see that everything works.
I have tried the demos that apear when you install mapserver, but I wanted to see it work with my own code and deploying my archives to the server.
For example it will be great if i could manage to just draw a .map file for instance as a response to the client.
Does anyone know how to do this, or what easy instructions I can use to see if it works?

Thank you

Jose Luis

<sgillies at FRII.COM> wrote:
On Nov 29, 2004, at 4:26 AM, Jose Luis Gonzalez wrote:

> --0-82611386-1101727598=:30831
> Content-Type: text/plain; charset=iso-8859-1
> Content-Transfer-Encoding: 8bit
>
> This is my code:
> First of all I have this file:
>
> package javamaps;
>
> public class MapserverLibLoad{
> public static void loadLibrary() throws UnsatisfiedLinkError{
> System.loadLibrary("mapscript");
> }
> }
>
> Then this is the principal program, as you see it is a servlet:
>
> import javamaps.*;
> import edu.umn.gis.mapscript.*;
> import javax.ejb.*;
> import javax.xml.parsers.*;
> import javax.xml.transform.*;
> import javax.xml.transform.dom.*;
> import org.w3c.dom.*;
> import java.sql.*;
> import javax.sql.*;
> import javax.naming.*;
>
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.io.*;
> public class test2 extends HttpServlet{
>
> InitialContext initialContext=null;
>
> static{
> try{
> MapserverLibLoad.loadLibrary();
> }catch(UnsatisfiedLinkError e){
> e.printStackTrace();
> System.out.println("CONTINUE");
> }
> }
>
>
> /
> /----------------------------------------------------------------------
> ------------------------------------------------------
>
> private Connection createDatabaseConnection()throws EJBException{
> DataSource dataSource;
> Connection connection;
> PreparedStatement stmt;
> try{
> dataSource = (DataSource) initialContext.lookup("jdbc/lbs");
> connection= dataSource.getConnection();
> //System.out.println("
> DATABSE:::::"+connection.getMetaData().getUserName());
> return connection;
> }catch (SQLException e){
> throw (new EJBException(e));
> }catch (NamingException e){
> throw (new EJBException(e));
> }
> }
>
>
>
> /
> /----------------------------------------------------------------------
> ------------------------------------------------------
> public void init (ServletConfig cfg){
> try{
> System.out.println("Try to init servlet");
> System.out.flush();
> initialContext= new InitialContext();
> }catch(Exception e){
> throw (new EJBException(e));
> }
>
> }//fin init
>
> public void service (HttpServletRequest req, HttpServletResponse res){
> Connection conexion=null;
> String imei=null;
> PrintWriter out=null;
> Statement orden=null;
> ResultSet rs=null;
> String SQL=null;
>
> try{ itemObj item = new itemObj();
> System.out.println(" BIG NAME
> :>>"+item.getName()+"<<");
>
> conexion=this.createDatabaseConnection();
> imei=req.getParameter("IMEI");
> out=res.getWriter();
> SQL="SELECT * FROM Client WHERE Name=";
> SQL=SQL+"'"+imei+"'";
> orden=conexion.createStatement();
> rs=orden.executeQuery(SQL);
> res.setContentType("text/html");
> out.println("");
> out.println(" ");
> rs.next();//I move to the first row
> out.println(" ");
> out.println("");
> out.println(" "+rs.getString("Name"));
> out.println(""+rs.getString("Mobile"));
>
> out.println(""+rs.getString("Telephone_Number"));
> out.println("");
> while (rs.next()){
> out.println(" "+rs.getString("Name"));
> out.println(""+rs.getString("Mobile"));
>
> out.println(""+rs.getString("Telephone_Number"));
> out.println("");
> }
> out.println("");
>
>
>
> }//fin try
> catch (Exception e){
> System.out.println(e);
> }catch (Throwable e){
> System.out.println("WRONGG POINT");
> e.printStackTrace();
> }finally{
> try{
> out.close();
> rs.close();
> conexion.close();
> orden.close();
> }catch(Exception e){
> throw (new EJBException(e));
> }
>
> }//fin service
>
> }
> }
>
> It seems as like he can't reach the mapserver librarys and I don't
> know why.It gives me this error:
>
> java.lang.UnsatisfiedLinkError: new_itemObj
>
> Can someone help me?
> Know what I'm doing wrong?
>
> Thank you
>
> Jose Luis
>

Jose Luis,

1) it is *very* important that you mention which version of MapServer
you use! The mapscript module has changed very much from 3.6 to 4.4.

2) do not try to use itemObj, it is not functional. We use SWIG to
generate the mapscript wrapper for Java, and it is very permissive,
with the result that non-functional classes can be accidently
added to mapscript. I'm going to shut itemObj out of the final 4.4
release.

cheers,
Sean



--
Sean Gillies
sgillies at frii dot com
http://users.frii.com/sgillies


---------------------------------




---------------------------------

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20041130/7a385c08/attachment.html


More information about the mapserver-users mailing list