Results 1 to 2 of 2
- 08-06-2011, 04:53 PM #1
Member
- Join Date
- Jun 2011
- Posts
- 3
- Rep Power
- 0
java.rmi.UnmarshalException; on client side
The DuplicatedAddressException works on the client side (in a try and catch it catches when a duplicate entry is made) but it gives me the errorsJava Code://implementation of the remote interface import java.rmi.*; import java.rmi.server.*; import java.sql.*; import java.util.ArrayList; import java.net.*; import java.io.*; import java.applet.*; import java.io.Serializable; class DuplicatedAddressException extends RemoteException implements Serializable { DuplicatedAddressException() { } DuplicatedAddressException(String s) { super(s); } } public class DataAccessImpl extends UnicastRemoteObject implements DataAccess { private String name; static final String driverName = "com.mysql.jdbc.Driver"; static final String sysName = "zenit.senecac.on.ca"; static final String dbName = "--"; static final String userId = "--"; static final String password = "--"; private ArrayList alAddress = new ArrayList(); private ArrayList alX = new ArrayList(); private ArrayList alY = new ArrayList(); private Connection conn; public DataAccessImpl(String s) throws java.rmi.RemoteException { name = s; try { Class.forName(driverName); } catch(ClassNotFoundException ec) { ec.printStackTrace(); System.out.println("MySQL JDBC driver not found!"); System.exit(1); } System.out.println("JDBC class found"); } public boolean connectToDatabase() throws java.rmi.RemoteException { System.out.println("Connection to the MYSQL server: " + sysName + "..."); try { conn = DriverManager.getConnection("jdbc:mysql:" + "//" + sysName + "/" + dbName, userId, password); Statement stat = conn.createStatement(); ResultSet rs = stat.executeQuery("SELECT * FROM locations"); System.out.println("**Query Result**"); while(rs.next()) { alAddress.add(rs.getString(1)); alX.add(rs.getDouble(2)); alY.add(rs.getDouble(3)); } for(int i = 0; i < alAddress.size(); i++) { System.out.println(alAddress.get(i) + " " + alX.get(i) + " " + alY.get(i)); } rs.close(); stat.close(); } catch(SQLException exc) { System.out.println("connection failed with: " + exc.getMessage()); return false; } System.out.println("database connection-OK"); GetClientIP getIp = new GetClientIP(); return true; } public boolean disconnectToDatabase() throws java.rmi.RemoteException { System.out.println("Close the database connection...."); try { if(conn != null) conn.close(); } catch(SQLException se) {se.printStackTrace(); return false;} System.out.println("disconnected from database...."); alAddress = new ArrayList(); alX = new ArrayList(); alY = new ArrayList(); return true; } public boolean add(Location l) throws java.rmi.RemoteException, DuplicatedAddressException { //boolean flag = true; for(int checkDup = 0; checkDup < alAddress.size();checkDup++) { if(l.getAddress().equals(alAddress.get(checkDup).toString())) { throw new DuplicatedAddressException( "The address you entered is already inserted" ); //flag = false; } } alAddress.add(l.getAddress()); alX.add(l.getX()); alY.add(l.getY()); /*for(int i = 0; i < alAddress.size(); i++) { System.out.println(alAddress.get(i) + " " + alX.get(i) + " " + alY.get(i)); }*/ try { int getSize = alAddress.size(); Statement stat = conn.createStatement(); stat.executeUpdate("INSERT INTO locations ( address, coorx, coory )" + " VALUES ('" + alAddress.get(getSize-1).toString() + "', '" + Double.parseDouble(alX.get(getSize-1).toString()) + "', '" + Double.parseDouble(alY.get(getSize-1).toString()) + "')"); alAddress = new ArrayList(); alX = new ArrayList(); alY = new ArrayList(); ResultSet rs = stat.executeQuery("SELECT * FROM locations"); System.out.println("**Query Result**"); while(rs.next()) { alAddress.add(rs.getString(1)); alX.add(rs.getDouble(2)); alY.add(rs.getDouble(3)); } for(int i = 0; i < alAddress.size(); i++) { System.out.println(alAddress.get(i) + " " + alX.get(i) + " " + alY.get(i)); } rs.close(); stat.close(); } catch (SQLException exc) { System.out.println("query failed with: " + exc.getMessage()); return false; } return true; } public Location[] createReport() throws java.rmi.RemoteException { int locationSize = alAddress.size(); String tempAddress; double tempX; double tempY; Location[] retLocations = new Location[locationSize]; for(int i=0;i<locationSize;i++) { tempAddress = alAddress.get(i).toString(); tempX = Double.parseDouble(alX.get(i).toString()); tempY = Double.parseDouble(alY.get(i).toString()); retLocations[i] = new Location(tempAddress, tempX, tempY); //retLocations[i].set(tempAddress, tempX, tempY); //retLocations[i].display(); } //System.out.println(locationSize); return retLocations; } public class GetClientIP extends Applet { public GetClientIP() { try { InetAddress thisIp = InetAddress.getLocalHost(); System.out.println("Clients IP: " + thisIp.getHostAddress()); } catch(Exception e) { e.printStackTrace(); } } } }
java.rmi.UnmarshalException; error unmarshaling retun; nested exception is:
java.lang.ClassNotFoundException: DuplicatedAddressException <no security manager:
RMI class loader disabled>
- 08-07-2011, 10:38 AM #2
Use policy file in your application. On both sides i.e. at the server side and at client side.
To create a policy file use the command "policytool" provided with the jdk.
In your code use
after that start the program with the following switch:Java Code:if(System.getSecurityManager() == null){ System.setSecurityManager(new RMISecurityManage()); }
>java -Djava.security.policy=<PathToPolicyFile> <Your Class having Main method.>
Similar Threads
-
Need help in socket programming, client side.
By rushabh in forum NetworkingReplies: 0Last Post: 01-20-2011, 07:33 PM -
session management ON CLIENT SIDE.
By alfonz19 in forum Java ServletReplies: 1Last Post: 01-15-2011, 03:57 PM -
how to access Ms Access from client side to server side
By arunkumarinfo in forum JDBCReplies: 1Last Post: 03-20-2010, 07:03 PM -
Help you save printing configuration at client-side with Java reporting tool
By freezea in forum Reviews / AdvertisingReplies: 2Last Post: 05-07-2009, 04:06 AM -
How can i retain special characters in server side (java) after passing from client
By Malathi in forum Web FrameworksReplies: 1Last Post: 03-27-2009, 10:18 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks