simple mapserver instrucctions don't work!!
Sean Gillies
sgillies at FRII.COM
Mon Nov 29 06:56:16 PST 2004
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("</Body></HTML>");
> out.println("<TABLE border=1>");
> rs.next();//I move to the first row
> out.println("<TR><TD COLSPAN=3>");
> out.println("</TD></TR>");
> out.println("<TR><TD>"+rs.getString("Name"));
> out.println("</TD><TD>"+rs.getString("Mobile"));
>
> out.println("</TD><TD>"+rs.getString("Telephone_Number"));
> out.println("</TD></TR>");
> while (rs.next()){
> out.println("<TR><TD>"+rs.getString("Name"));
> out.println("</TD><TD>"+rs.getString("Mobile"));
>
> out.println("</TD><TD>"+rs.getString("Telephone_Number"));
> out.println("</TD></TR>");
> }
> out.println("</TABLE>");
>
>
>
> }//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
More information about the MapServer-users
mailing list