Я использу JBoss v 4.0.4 Есть EntityBean - PointsBean (Points - локальный интерфайс). Есть SessionBean - HaritonBean, с методом getPoints():
| Код | public Collection getPoints() { PointsHome pointsHome = null;
Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); props.put(Context.PROVIDER_URL, "localhost:1099");
Collection col = null;
try { Context ctx = new InitialContext(props); Object obj = ctx.lookup("Points");
pointsHome = (PointsHome) PortableRemoteObject.narrow( obj, PointsHome.class);
col = pointsHome.findAllPoints(); } catch (Exception e) { System.out.println(e.toString()); } return col; }
|
Есть JSP, использующая HaritonBean
| Код | <html> <head> <title> with JBoss </title> </head> <%@ page import="firstejb.*" %> <%@ page import="javax.naming.*" %> <%@ page import="java.util.*" %> <%@ page import="javax.rmi.*" %>
<body> <h1> <% Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); props.put(Context.PROVIDER_URL, "localhost:1099"); try { Context ctx = new InitialContext(props); Object obj = ctx.lookup("HaritonBean"); HaritonHome rhome = (HaritonHome) PortableRemoteObject.narrow(obj, HaritonHome.class); Hariton rhello = rhome.create(); Iterator iter = rhello.getPoints().iterator(); while (iter.hasNext()) { Points point = (Points)iter.next(); out.println(point.getName()); } rhello.remove(); } catch(Exception e) { out.println(e.toString()); } %> </h1> </body> </html>
|
При отображении JSP вылезает ошибка:
| Код | EJBException in method: public abstract java.lang.String firstejb.Points.getName(): javax.ejb.EJBException: Invalid invocation, check your deployment packaging, method=public abstract java.lang.String firstejb.Points.getName() at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1167) at org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:87) at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:284) at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:158) ...
|
Что делать - не знаю. Протестировал удаленным клиентом - все работает |