Hi all,
(it drives me crazy...)
i'm trying to access some ejbs from my webapp on another orion-server.
1) my application-client (with application-client.xml) works fine.
jndi_props.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.evermind.server.ApplicationClientInitialContextFactory");
...
initial = new InitialContext(jndi_props); => Ok.
rootctx = (Context)initial.lookup("java:comp/env");
System.out.println("rootctx: "+rootctx.toString()); ==> shows the contents of
application-client.xml (=Context), Ok.
2) same source but (servlet or jsp-page(attached))
jndi_props.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.evermind.server.rmi.RMIInitialContextFactory");
...
initial = new InitialContext(jndi_props); => Ok.
rootctx = (Context)initial.lookup("java:comp/env");
System.out.println("rootctx: "+rootctx.toString());
==> Exception: "java:comp/env not found"
Did i miss something????? - where to get the Context? - whats wrong?
3) same as 2) but calling
initial = new InitialContext(); => local access
rootctx = (Context)initial.lookup("java:comp/env");
System.out.println("rootctx: "+rootctx.toString()); ==> shows
webapp.war/web.xml (=Context), Ok.
tia
klaus
btw:
rmi.xml: <server host="196.129.237.124" port="23791" username="admin"
password="secure"/>
orion-application.xml: <ejb-module remote="true" path="ejb-jar.jar" />
works (for all ejbs) if _both_ servers are 1.5.2 or oc4j-1.0.2.2.1.
but then there are other bugs....
--
Klaus Thiele - Personal & Informatik AG
mailto:[EMAIL PROTECTED]
"Your mouse has moved.
Windows must be restarted for the change to take effect."
<%@ page language="java"%>
<%@ page import="java.util.Properties" %>
<%@ page import="java.util.Hashtable" %>
<%@ page import="javax.naming.Context" %>
<%@ page import="javax.naming.InitialContext" %>
<%@ page import="javax.rmi.PortableRemoteObject" %>
<%@ page import="javax.ejb.*" %>
<%@ page import="com.PIAG.ejb.entity.*" %>
<%@ page import="com.PIAG.ejb.session.*" %>
<%
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 1);
%>
<html>
<head>
<title>TestIt</title>
</head>
<body>
<%
Context initial = null;
Context rootctx = null;
SettingsHome setHome = null;
Settings set = null;
Hashtable jndi_props = new Hashtable();
jndi_props.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.evermind.server.rmi.RMIInitialContextFactory");
jndi_props.put(javax.naming.Context.SECURITY_PRINCIPAL,"admin");
jndi_props.put(javax.naming.Context.SECURITY_CREDENTIALS,"secure");
jndi_props.put(javax.naming.Context.PROVIDER_URL,"ormi://196.129.237.124:23791/testapp");
//jndi_props.put("dedicated.connection","true");
%>
<%= javax.naming.Context.INITIAL_CONTEXT_FACTORY%>: <%=
jndi_props.get(javax.naming.Context.INITIAL_CONTEXT_FACTORY)%><br>
<%= javax.naming.Context.PROVIDER_URL%>: <%=
jndi_props.get(javax.naming.Context.PROVIDER_URL)%><br><br>
<%
try {
//initial = new InitialContext();
initial = new InitialContext(jndi_props);
rootctx = (Context)initial.lookup("java:comp/env");
%>
<%=initial.toString()%><br>
<%=rootctx.toString()%><br>
<%
} catch (Exception e) {
%>
Oops1: <%=e.getMessage()%><br>
<%
}
try {
Object objref = rootctx.lookup("ejb/Settings");
//Object objref = initial.lookup("java:comp/env/ejb/Settings");
setHome = (SettingsHome)PortableRemoteObject.narrow(objref,
SettingsHome.class);
%>
<%=objref.toString()%><br>
<%
} catch (Exception e) {
%>
Oops2: <%=e.getMessage()%><br>
<%
}
Properties props = null;
try {
set = setHome.create("ZAPPA", Settings.LOGA);
%>
<%=set.toString()%><br>
<%
/* props = set.getProperties();
%>
props=<%=props.toString()%><br>
<% */
set.setValue("ak","NET");
set.setValue("pnr","1");
set.setValue("vertnr","1");
set.setValue("naname","Duck");
set.setValue("vorname","Donald");
props = set.getProperties();
%>
props=<%=props.toString()%><br>
<%
set.save();
set.remove();
} catch( Exception e ) {
%>
Oops3: <%=e.getMessage()%><br>
<%
}
%>
</body>
</html>