I have the following java program which can run as an application or can be deployed
as a servlet. The program invokes the findByPrimaryKey methos on a home interface
to obtain the remote interface.

On the both the modes(servlet vs application) the program fails with the exception
listed below. Everything works fine if I remove the line System.setSecurityManager(new
RMISecurityManager()); in the java code. But in the production scenario the same
application also acts as an RMI client so this statement is required. Can someone
help me fix these errors(atleast as a servlet).
Thanks in advance,
DW

SOURCE
=======
package support;

import javax.naming.Context;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Hashtable;
import java.lang.reflect.Method;
import java.rmi.RMISecurityManager;
import java.io.PrintWriter;
import java.io.IOException;

public class EJBClient extends HttpServlet {
public static void main(String[] args) {
System.out.println("Started Exceution ....");
try {
System.setSecurityManager(new RMISecurityManager());
System.out.println("Security Manger is: "+System.getSecurityManager());
Hashtable env = new Hashtable(11);
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL, "t3://localhost");
DirContext ctx = new InitialDirContext(env);
Object oHomeInterface = ctx.lookup("bookstore.book");
Class[] paramClasses = new Class[] {String.class};
Method oFindByPk = oHomeInterface.getClass().getMethod(
"findByPrimaryKey", paramClasses);
String[] paramValues = {"1001"};
Object oRemoteInterface = oFindByPk.invoke(oHomeInterface , paramValues);
System.out.println("oRemoteInterface: "+oRemoteInterface);
} catch(Exception exce) {
System.out.println("ERR_MAIN: ");
exce.printStackTrace();
}
System.out.println("Exceution over.");
}

public void doGet(HttpServletRequest req, HttpServletResponse resp) throws
IOException {
main(null);
PrintWriter pw = resp.getWriter();
pw.println("

Success

");
}
}

ERROR WHILE RUNNING AS A SERVLET
===========================
java.lang.reflect.InvocationTargetException: java.rmi.UnmarshalException: cannot
unmarshaling return; nested exception is:
java.rmi.UnexpectedException: Failed to parse descriptor file; nested exception
is:
org.xml.sax.SAXException: ResourceEntityResolver: did not resolve entity for
publicId = -//BEA Systems, Inc.//RMI Runtime DTD 1.0//EN with resource name rmi.dtd
java.rmi.UnexpectedException: Failed to parse descriptor file; nested exception
is:
org.xml.sax.SAXException: ResourceEntityResolver: did not resolve entity for
publicId = -//BEA Systems, Inc.//RMI Runtime DTD 1.0//EN with resource name rmi.dtd
org.xml.sax.SAXException: ResourceEntityResolver: did not resolve entity for publicId
= -//BEA Systems, Inc.//RMI Runtime DTD 1.0//EN with resource name rmi.dtd
at weblogic.xml.dom.ResourceEntityResolver.resolveEnt ity(ResourceEntityResolver.java:99)
at weblogic.rmi.internal.RMIEntityResolver.resolveEnt ity(RMIEntityResolver.java:43)
at weblogic.xml.jaxp.ChainingEntityResolver.resolveEn tity(ChainingEntityResolver.java:85)
at weblogic.apache.xerces.readers.DefaultEntityHandle r.startReadingFromExternalEntity(DefaultEntityHand ler.java:768)
at weblogic.apache.xerces.readers.DefaultEntityHandle r.startReadingFromExternalSubset(DefaultEntityHand ler.java:583)
at weblogic.apache.xerces.framework.XMLDTDScanner.sca nDoctypeDecl(XMLDTDScanner.java:1161)
at weblogic.apache.xerces.framework.XMLDocumentScanne r.scanDoctypeDecl(XMLDocumentScanner.java:2189)
at weblogic.apache.xerces.framework.XMLDocumentScanne r.access$0(XMLDocumentScanner.java:2143)
at weblogic.apache.xerces.framework.XMLDocumentScanne r$PrologDispatcher.dispatch(XMLDocumentScanner.jav a:856)
at weblogic.apache.xerces.framework.XMLDocumentScanne r.parseSome(XMLDocumentScanner.java:399)
at weblogic.apache.xerces.framework.XMLParser.parse(X MLParser.java:1147)
at org.xml.sax.helpers.XMLReaderAdapter.parse(XMLRead erAdapter.java:223)
at weblogic.xml.jaxp.WebLogicParser.parse(WebLogicPar ser.java:67)
at weblogic.rmi.internal.DescriptorManager.getDescrip torParser(DescriptorManager.java:100)
at weblogic.rmi.internal.DescriptorManager.getBasicRu ntimeDescriptor(DescriptorManager.java:63)
at weblogic.rmi.internal.DescriptorManager.getDescrip tor(DescriptorManager.java:48)
at weblogic.rmi.internal.DescriptorManager.getDescrip tor(DescriptorManager.java:37)
at weblogic.rmi.internal.OIDManager.makeActivatableSe rverReference(OIDManager.java:204)
at weblogic.rmi.internal.OIDManager.getReplacement(OI DManager.java:138)
at weblogic.common.internal.RemoteObjectReplacer.getR eplacement(RemoteObjectReplacer.java:288)
at weblogic.common.internal.RemoteObjectReplacer.repl aceObject(RemoteObjectReplacer.java:107)
at weblogic.common.internal.WLObjectOutputStreamBase2 .replaceObject(WLObjectOutputStreamBase2.java:44)
at java.io.ObjectOutputStream.writeObject(ObjectOutpu tStream.java:318)
at weblogic.rmi.internal.CBVOutputStream.writeObject( CBVOutputStream.java:78)
at weblogic.rmi.internal.ServerRequest.unmarshalRetur n(ServerRequest.java:87)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke( ReplicaAwareRemoteRef.java:264)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke( ReplicaAwareRemoteRef.java:230)
at ejbcategory.samples.store.BookBean_y7odp5_HomeImpl _WLStub.findByPrimaryKey(Unknown
Source)
at java.lang.reflect.Method.invoke(Native Method)
at support.EJBClient.main(EJBClient.java:46)
at support.EJBClient.doGet(EJBClient.java:56)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletI nvocationAction.run(ServletStubImpl.java:1075)
at weblogic.servlet.internal.ServletStubImpl.invokeSe rvlet(ServletStubImpl.java:418)
at weblogic.servlet.internal.ServletStubImpl.invokeSe rvlet(ServletStubImpl.java:306)
at weblogic.servlet.internal.WebAppServletContext$Ser vletInvocationAction.run(WebAppServletContext.java :5517)
at weblogic.security.service.SecurityServiceManager.r unAs(SecurityServiceManager.java:685)
at weblogic.servlet.internal.WebAppServletContext.inv okeServlet(WebAppServletContext.java:3156)
at weblogic.servlet.internal.ServletRequestImpl.execu te(ServletRequestImpl.java:2506)
at weblogic.kernel.ExecuteThread.execute(ExecuteThrea d.java:234)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.ja va:210)

ERROR WHILE RUNNING AS AN APPLICATION
===============================
weblogic.common.internal.VersioningError: No WebLogic packages defined in CLASSP
ATH
at weblogic.common.internal.VersionInfo.(VersionInfo.java:41)
at weblogic.common.internal.VersionInfo.initialize(Ve rsionInfo.java:86)
at weblogic.kernel.Kernel.initialize(Kernel.java:156)
at weblogic.kernel.Kernel.ensureInitialized(Kernel.ja va:133)
at weblogic.rmi.internal.ClientRuntimeDescriptor.(ClientRuntimeD
escriptor.java:54)
at weblogic.jndi.WLInitialContextFactoryDelegate.(WLInitialConte
xtFactoryDelegate.java:164)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:115)
at weblogic.jndi.WLInitialContextFactory.getInitialCo ntext(WLInitialCont
extFactory.java:145)
at javax.naming.spi.NamingManager.getInitialContext(N amingManager.java:6
60)
at javax.naming.InitialContext.getDefaultInitCtx(Init ialContext.java:241
)
at javax.naming.InitialContext.init(InitialContext.ja va:217)
at javax.naming.InitialContext.(InitialContext.java:193)
at javax.naming.directory.InitialDirContext.(InitialDirContext.jav
a:78)
at support.EJBClient.main(EJBClient.java:35)
Exception in thread "main" java.lang.InternalError: error initializing kernel
at weblogic.kernel.Kernel.ensureInitialized(Kernel.ja va:136)
at weblogic.rmi.internal.ClientRuntimeDescriptor.(ClientRuntimeD
escriptor.java:54)
at weblogic.jndi.WLInitialContextFactoryDelegate.(WLInitialConte
xtFactoryDelegate.java:164)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:115)
at weblogic.jndi.WLInitialContextFactory.getInitialCo ntext(WLInitialCont
extFactory.java:145)
at javax.naming.spi.NamingManager.getInitialContext(N amingManager.java:6
60)
at javax.naming.InitialContext.getDefaultInitCtx(Init ialContext.java:241
)
at javax.naming.InitialContext.init(InitialContext.ja va:217)
at javax.naming.InitialContext.(InitialContext.java:193)
at javax.naming.directory.InitialDirContext.(InitialDirContext.jav
a:78)
at support.EJBClient.main(EJBClient.java:35)