Здравствуйте. Есть бин, у него есть несколько инстанс-полей и метод ejbLoad():
| Код | public void ejbLoad() throws RemoteException { Properties properties = new Properties(); properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); properties.put(Context.PROVIDER_URL, "localhost:1099"); try { Context initialContext = new InitialContext(properties);
Connection connection = ((DataSource) initialContext.lookup("java:jbdc/oracle/test")).getConnection(); try { PreparedStatement loadStatement = connection.prepareStatement("select car_name from cards where car_id = ?"); try { loadStatement.setInt(1, this.id); ResultSet carInfoResultSet = loadStatement.executeQuery(); try { if (!carInfoResultSet.next()) { throw new FinderException("Car not found"); }
this.name = carInfoResultSet.getString(1); } finally { carInfoResultSet.close(); } } finally { loadStatement.close(); } }
finally
{ connection.close(); }
} catch (Exception ex) { throw new RemoteException("Exception while removing entity", ex); }
}
|
Когда клиент вызывает remove() на home-интерфейсе, контейнер вызывает ejbLoad() и случается NullPointerException на строке 16, вызванная тем, что инстанс-поле с основным ключом есть null. В чем может быть причина этого? |