EJB lookup returned stub from a different classloader.

I've written an EJB for doing authenitcation. This EJB is accessed by an security-mbean (BEA's login module).
- The EJB is deployed in an EAR.
- The EJB-stubs are extracted and is included as part of the MBEAN Jar.
When I hit a webapp causing the EJB lookup to occur, the stub object returned is created by the webapp's classloader. This cause a ClassCastException when trying to cast the returned home interface into the home interface of the MBEAN's classloader.
Note that all this is happening on the same BEA server running WLS8.1.
I don't want to put the EJB jar on the system classpath so I can redeploy the EJB, the Application's EAR and the MBEAN to a cluster.
-alex

Robert Greig <[email protected]> wrote:
Thanks for responding to my question, which newsgroup is more appropriate for
my line of question?
But before I move this thread, I would like to add:
I've already handled the recursion problem on top of the ejb-lookup before JNDI
becomes avaliable (while doing server startup) problem.
The advantage with the EJB model is this. By changing the host/port configuration,
I can switch between a local-authentication server or a remote provide authentication
server network configuration.
If I were to include the necessary classes in the mbean JAR from our application,
there maybe resources issues since I now have 2 classloaders loading my server-portion
of classes. Not sure how that will workout with resources and all. This model
has the disadvantage of any classes I have in the mbean JAR will require updates
outside my EAR. This wroks against the EAR deployment model.
-alex
Alex Cheung wrote:
I've written an EJB for doing authenitcation. This EJB is accessedby an security-mbean (BEA's login module).
- The EJB is deployed in an EAR.
- The EJB-stubs are extracted and is included as part of the MBEANJar.
This isn't a good approach. You are pretty much stuffed mainly for the
reasons you outline.
Also note that if you continue to go down this road you will have to
handle the potential recursion (i.e accessing an EJB will invoke a
security call to your provider!).
Why do you need to implement this as an EJB? The main advantages of EJBs
are security and container managed transactions neither of which is
relevant here surely?
Robert

Similar Messages

  • EJB lookup on Remote Server or different domain fails

    Hi,
    I am having two different domain (domain1,domain2) respectvely. My ABC.ear j2eee application is deployed on domain2 and its iiop port is 33703.In domain1 i have xyz.war (web application) and it's IIOP port is 3700 .In xyz.war i am having CallEJB.jsp file.In this Jsp file i want to lookup an EJB Service called PaymentEJB(JNDI Name is ejb/PaymentEJB).
    The code is below
    InitialContext context=new InitialContext();
    Object objRef=context.lookup("corbaname:iiop:andaman:33703#ejb/PaymentEJB");
    I am getting the following error.
    [#|2005-12-14T16:42:03.422+0530|SEVERE|sun-appserver-pe8.1_02|javax.enterprise.resource.corba._DEFAULT_.rpc.transport|_ThreadID=11;|"IOP00410216: (COMM_FAILURE) Unable to create IIOP listener on the specified host/port: all interfaces/3700"
    org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 216 completed: No
    at com.sun.corba.ee.impl.logging.ORBUtilSystemException.createListenerFailed(ORBUtilSystemException.java:2661)
    My doubt is
    1.While starting domain1 and domain2 iiop listeners are started on the port 3700 and 33703.in that case why EJB lookup tries to create listener on one more time.
    2.I am looking the 33703 port only.but it tries to create port on 3700 why?
    3.It was working till JES2005Q1.Is there any patch i need to install? or i need to change anything in my code.
    I am frustrated with this error for past one week.I will be happy if some body will give me the peace of mind(thru some solution).

    Hi
    I found the solution for this issue.
    To lookup the EJB applications in web component,we should not set any thing in the Initial Context.i.e the lookup should be
    InitialContext initContext=new InitialContext();
    Object objref = initContext.lookup("java:comp/env/ejb/"+ejbName_);
    This will get you the Home object of the EJB you are looking.
    In your web.xml you should have the entry like below.(Just replace the ejbname which you are looking for)
    <ejb-ref>
    <ejb-ref-name>ejb/GetAssertionEJB</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <home>com.ssertion.GetAssertionHome</home>
    <remote>com.assertion.GetAssertionRemote</remote>
    </ejb-ref>
    In your sun-wb.xml,you should have the entry like below(Just replace the ejbname which you are looking for)
    <ejb-ref>
    <ejb-ref-name>ejb/GetAssertionEJB</ejb-ref-name>
    <jndi-name>corbaname:iiop:<hostname>:<iiopport>#ejb/GetAssertionEJB</jndi-name>
    </ejb-ref>
    Hope this works.

  • Are return codes from APIs different when upgrading DOT from 8.0.3 to 8.1.4/8.2.3 (7-mode only)

    Customer is looking to upgrade from DOT 8.0.3 to 8.1.4/8.2.3 (7-mode). There are no real API changes between these upgrades other than additional functionality being added. Howver, are the return codes from APIs any different when upgrading DOT from 8.0.3 to 8.1.4/8.2.3 (7-mode only)? Any help on this to help confirm would be greatly appreciated. Many Thanks in advance. Luke

    Thanks. I had the Portal 3.0.6/3.0.7/3.0.8 to Portal 3.0.9 upgrade scripts and instructions, but thought that was my last step. I hesitated on running the Portal Configuration Assistant. None of the instructions told me what to do at this point.
    Anyways, it looks that by running the Portal Configuration Assitant at the end of the 1.0.2.2 9iAS install, it created a new repository for Portal 3.0.9 in my database. Since I gave it a different schema name, I now have two portal repositories. The old Portal 3.0.6 repository (jvac_portal30) and the new Portal 3.0.9 repository (j_portal30).
    So, I assume I have to perform the upgrade scripts on the Portal 3.0.6 repository to get it to 3.0.9. Since we really did not have very much in the repository, we may just manually recreate everything in the new 3.0.9 repository. I have ssen several discussion threads about the upgrade and problems, so I am very leary to do it.
    In regards to our J Server propblem, we left for lunch. Came back and rebooted several more times, double checked all our configuration files (made no changes), stopped and restarted Apache several more times, and then by some miracle everything started working.
    null

  • Lookup returning stubs..

    hi All, I have a problem in that my jndi lookup keeps returning SessionBean stubs rather than my objects.
    I cannot find any logical explanation to this...
    This is what my descriptors looks like.. (the essential parts)
    web.xml
    <ejb-ref>
    <description>AdvisorProxy</description>
    <ejb-ref-name>ejb/AdvisorProxy</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <home>com.proxy.AdvisorProxyHome</home>
    <remote>com.proxy.AdvisorProxy</remote>
    </ejb-ref>
    sun-web.xml
    <ejb-ref>
    <ejb-ref-name>ejb/AdvisorProxy</ejb-ref-name>
    <jndi-name>ejb/AdvisorProxy</jndi-name>
    </ejb-ref>
    ejb-jar.xml
    <session>
    <description>Session Bean ( Stateless ) </description>
    <display-name>AdvisorProxy</display-name>
    <ejb-name>AdvisorProxy</ejb-name>
    <home>com.proxy.AdvisorProxyHome</home>
    <remote>com.proxy.AdvisorProxy</remote>
    <ejb-class>com.component.AdvisorProxyBean</ejb-class>
    <session-type>Stateless</session-type>
    <!-- Links and references -->
    </session>
    sun-ejb.xml
    <ejb>
         <ejb-name>AdvisorProxy</ejb-name>
         <jndi-name>ejb/AdvisorProxy</jndi-name>
         <is-read-only-bean>false</is-read-only-bean>
    <!-- linkr and references -->
    </ejb>
    My lookup in my ServiceLocator is the following:
    Object homeObj =ctx.lookup("java:comp/env/ejb/" + beanRmiName);
              EJBHome home = (EJBHome)PortableRemoteObject.narrow(homeObj, EJBHome.class);
    When I try to convert the EJBHome which should be teh proper implementation , but it is not. Instead i have a reference to an _AdvisorProxyHome_stub_ object. Which to me is quite useless...
    (Since the class cast fails rather immediately)
    I am absolutely clueless. The deployment and the code works perfectly on JBOSS and Oracle9i.
    So I am tempted to say that there is something I am not completely getting right in the sun***.xml files.
    Am I correct?
    What do I need to do?
    Any help, pointers, miracles welcome..
    /johan

    Hi Jeff,
    Thanks for your reply.
    Here's what the user guide (p. 204) says about LOOKUP.
    The LOOKUP function finds a match for a given search value in one range, then returns the value in the cell with the same relative position in a second range.
    Here's what is says (p.210) about VLOOKUP.
    The VLOOKUP function returns a value from a range of columns by using the left column of values to pick a row and a column number to pick a column in that row.
    close-match: An optional value that determines whether an exact match is required.
    Before posting this discussion, I tried using VLOOKUP. It returned an error in every record in the large table (even for the records that did have matching IDs)—the formula contains an invalid reference.
    Based upon the user guide's instruction to set the optional value to FALSE (0) for exact match, I used the following.
    =VLOOKUP($B2,'small table' :: $B$2:$B$230,'small table' :: $W$2:$W$230, FALSE)
    This returned the above error for all records.
    Any other suggestions?

  • Casting to an abstract class from a different classloader

    I have a class Special that extends an abstract class Base. In my code I use a URLClassLoader to load the class Special and I then want to cast Special to Base. If I do this I get a ClassCastException because the classes are loaded from different classloaders. I can't have the URLClassLoader and the class that performs the cast extend a parent ClassLoader that knows about the Base class. What I want to be able to do is something like this:
    URLClassLoader loader = new URLClassLoader(codebase, null);
    Class baseClass = loader.loadClass(className);
    Base baseObj = (Base)baseClass.newInstance();
    I have seen some post that suggest I can achieve this using Reflection but I am not sure how to go about this. Any help would be appreciated.
    Thanks
    Jim.

    Thanks for your help so far but I still can't do the casting, consider this example:
    //Base.java
    package classTest;
    public interface Base
         public abstract void execute();
    //ConcBase.java
    package classTest;
    public class ConcBase implements Base
         public void execute()
              System.out.println("execute in ConcBase called");
    I compile these files and jar them into work.jar
    I now have my application:
    //Test.java
    import java.net.*;
    import java.io.*;
    import classTest.*;
    public class Test
    public static void main(String[] args)
              Test t = new Test();
              t.test();
         public void test()
              try
                   File file = new File("D:/Projects/classloadTest/work.jar");
                   URL[] codebase = {file.toURL()};
                   ClassLoader ccl = getClass().getClassLoader();
                   ccl.loadClass("classTest.Base");
                   URLClassLoader ucl = new URLClassLoader(codebase,ccl);
                   Class conClass = ucl.loadClass("classTest.ConcBase");
                   classTest.Base b = (classTest.Base)conClass.newInstance();
                   b.execute();
              catch(Exception t)
                   System.out.println("thowable caught");
                   t.printStackTrace(System.out);
    I compile this and run it with this command:
    java -classpath D:\Projects\classloadTest\work.jar;. Test
    This runs as I would expect, however I have set the parent class loader of my custom URLClassLoader to the one that does the cast, this means that Base and ConcBase are both being picked up by the application class loader as my custom class loader delegates to its parent. This is the current behaviour I have in my proper application and it is causing problems, I don't want the class that implements Base to delegate to any class on the main applications classpath. If I change the line:
    URLClassLoader ucl = new URLClassLoader(codebase,ccl);
    In Test.java to:
    URLClassLoader ucl = new URLClassLoader(codebase,null);
    I get a ClassCastException, this is because the class that does the cast (Test) loads Base from it's classpath and ConcBase is loaded from the URLClassLoader. After spending more time looking at this problem I don't think there is anyway to resolve but if anyone thinks there is please tell me.
    Many thanks
    Jim.

  • EJB lookup from another EJB server

    Hi people,
    I have two application servers on two different computers. One
    of them contains an EJB, which I need to access from another EJB
    server. I know that I can achieve this using RMI, but will then
    security and transaction contexts be propagated to the called
    EJB?
    Sincerely,
    Sergei Batiuk.

    Here is the solution posted on another forum:
    [email protected] Dec 8, 6:03 am show options
    Newsgroups: ibm.software.websphere.studio
    From: [email protected]
    Date: 8 Dec 2004 06:03:04 -0800
    Local: Wed, Dec 8 2004 6:03 am
    Subject: Re: EJB lookup on from one server to another does not work
    Eric,
    I dealt with this same problem trying to run 2 local servers (websphere
    test servers), using 2 separate WSAD 5.1.2 workspaces. Running on 1
    server I have an application that contains an EJB, and running on the
    other server is an application that uses an access bean to make a
    remote call to my EJB, running on my other server. I too repeately
    received the "NameNotFoundException" when trying to lookup my EJB home
    reference.
    What you have to do to get around this is to modify the server
    configuration of the application that contains the EJB that you are
    attempting to call remotely. You must open the the server.wsi file for
    the server that is running the EJB and go to the "Configuration" tab.
    You must check the "Enable administrative console". Once this is
    complete, start your server. When it is started, right click on the
    server, and select "run administrative console". In the admin console,
    select
    servers -> application servers -> <your server> -> end points ->
    bootstrap address. For "host" you must change "localhost" to either
    your ip address or computer name (ive only tried my ip, but your
    computer name should work too). When building your properties to get
    the initial context, make sure you use
    "env.put(Context.PROVIDER_URL, "corbaloc:iiop:<the ip or computer name
    listed as the bootstrap host of server running ejb>:<the port listed as
    the bootstrap port of server running ejb, which is 2809 in your case>
    Restart your server and things should work.

  • RFC call to a different system returns data from local system,

    Hi:
    I defined a RFC function and execute against a different system, the data returned is from the local system. The rfc_destination in SM59 works fine. The function works fine in the target system. No errors appear, just the data is not from the remote system.
    Any input will be appreciated.
    Thanks.
    Kamaraj

    Hi,
    For now, it seems u haven't specified the destination properly. the call function statement must be suffixed with the 'destination' addition to make sure that the function call is an RFC and the particular function be executed at the desired destination.

  • EJBs accessing protected classes from java classloader

    Hello,
    We are facing a problem with classes isolation. I read from this newsgroup that
    to access a package level class from the base classloader from a bean, the supporting
    classes has to be from the same classloader as the bean. Well I think the only
    way we could do that is to have the *Bean.class in the base classloader, which
    is not what's recommended or move the support classes into the bean's classloader,
    which we cannot do.
    The purpose of this mail is to ask: is it a bug from weblogic server? Will it
    be fixed one day? If not, does it mean that it is impossible to isolate classes
    for local access from public classes?
    Thank you, Khiet.

    Thank you for your reply.
    Hope that one day we will not be obliged to have anything in the main classpath.
    :) Khiet.
    Rob Woollen <[email protected]> wrote:
    Tran T. Khiet wrote:
    Hello,
    We are facing a problem with classes isolation. I read from this newsgroupthat
    to access a package level class from the base classloader from a bean,the supporting
    classes has to be from the same classloader as the bean. Well I thinkthe only
    way we could do that is to have the *Bean.class in the base classloader,which
    is not what's recommended or move the support classes into the bean'sclassloader,
    which we cannot do.All correct.
    The purpose of this mail is to ask: is it a bug from weblogic server?No, it's how java classloaders work.
    Will it
    be fixed one day? If not, does it mean that it is impossible to isolateclasses
    for local access from public classes?You can expect that future versions of WLS will allow the user more
    control over classloaders, but for now you'll need public or protected
    access to cross classloaders.
    -- Rob
    Thank you, Khiet.

  • Calling an EJB deployed in OC4J from Java Stored Proc in Oracle

    Hello!
    Trying to make a call to an EJB deployed in OCJ4 from a oracle java stored proc. After loaded orion.jar and crimson.jar lib into SCOTT schema, I can't get the JNDI Context working because of this error:
    ============================================
    javax.naming.NoInitialContextException: Cannot instantiate class:
    com.evermind.server.ApplicationClientInitialContextFactory. Root exception is
    java.lang.ClassNotFoundException:
    com/evermind/server/ApplicationClientInitialContextFactory
    at java.lang.Class.forName0(Class.java)
    at java.lang.Class.forName(Class.java)
    at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:45)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java)
    at javax.naming.InitialContext.init(InitialContext.java)
    at javax.naming.InitialContext.<init>(InitialContext.java)
    ===============================
    I did load the java with "loadjava" with on time with the "resolve" option and time time no option and still no working.
    Here is the EJB client code:
    =======================================
    import java.sql.*;
    import java.util.*;
    import javax.naming.*;
    import com.evermind.server.ApplicationClientInitialContextFactory;
    class EmpRemoteCall {
    public static void main(String[] args) {
    System.out.println(getEmpName());
    public static String getEmpName() {
    String ejbUrl = "java:comp/env/ejb/Emp";
    String username = "admin";
    String password = "admin";
    Hashtable environment = new Hashtable();
    environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.ApplicationClientInitialContextFactory");
    environment.put(Context.PROVIDER_URL, "ormi://127.0.0.1/testemp");
    environment.put(Context.SECURITY_PRINCIPAL, username);
    environment.put(Context.SECURITY_CREDENTIALS, password);
    //environment.put(Context.SECURITY_AUTHENTICATION, ServiceCtx.NON_SSL_LOGIN);
    //environment.put(javax.naming.Context.URL_PKG_PREFIXES, "oracle.aurora.jndi");
    com.kboum.sertir.essais.EmpHome homeInterface = null;
    try {
    Class.forName("com.evermind.server.ApplicationClientInitialContextFactory", true, ClassLoader.getSystemClassLoader());
    System.out.println("Creating an initial context");
    Context ic = new InitialContext(environment);
    System.out.println("Looking for the EJB published as 'java:comp/env/ejb/Emp'");
    homeInterface = (com.kboum.sertir.essais.EmpHome) ic.lookup(ejbUrl);
    catch (CommunicationException e) {
    System.out.println("Unable to connect: " + ejbUrl);
    e.printStackTrace();
    //System.exit(1);
    catch (NamingException e) {
    System.out.println("Exception occurred!");
    System.out.println("Cause: This may be an unknown URL, or some" +
    " classes required by the EJB are missing from your classpath.");
    System.out.println("Suggestion: Check the components of the URL," +
    " and make sure your project includes a library containing the" +
    " EJB .jar files generated by the deployment utility.");
    e.printStackTrace();
    //System.exit(1);
    catch (ClassNotFoundException e) {
    System.out.println("Unable to connect: " + ejbUrl);
    e.printStackTrace();
    //System.exit(1);
    try {
    System.out.println("Creating a new EJB instance");
    com.kboum.sertir.essais.Emp remoteInterface = homeInterface.findByPrimaryKey(Integer.valueOf("7369"));
    System.out.println(remoteInterface.getENAME());
    System.out.println(remoteInterface.getSAL());
    remoteInterface.setSAL(2);
    System.out.println(remoteInterface.getSAL());
    return remoteInterface.getENAME();
    catch (Exception e) {
    System.out.println(e.getMessage());
    e.printStackTrace();
    return "error";
    null

    What I did to solve this problem was to
    create a simple RMI remote object that
    resides outside the database JVM and that
    serves as a proxy EJB client for your java
    stored procedure. The stored procedure can
    invoke a method on the remote RMI object
    which then looks up the EJBean's home
    interface and invokes the relevant method on
    the bean's remote interface, and relays any
    return values back to the java stored
    procedure.
    Hope this helps,
    Avi.
    null

  • EJB lookup works in embedded OC4J but not stand-alone

    I use JDeveloper 9.0.3.1 to develop a combined web & EJB application. The EJBs are deployed on a 9.0.3 iAS server on a different machine.
    The EJB lookup is in a helper class that's called by the servlet. For EJB lookup, I use the class "com.evermind.server.rmi.RMIInitialContextFactory" as described by the OC4J servlet guide (http://download-uk.oracle.com/docs/cd/A97688_10/generic.903/a97680/develop.htm#1003973). So my code looks like this:
    Hashtable map = new Hashtable();
    map.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
    map.put(Context.PROVIDER_URL, "ormi://server:port/app-business");
    map.put(Context.SECURITY_PRINCIPAL, "admin");
    map.put(Context.SECURITY_CREDENTIALS, "password");
    map.put("dedicated.rmicontext", "true");
    InitialContext context = new InitialContext(map);
    Object thing = context.lookup("MyEjb");
    EJBHome feedback = (EJBHome)PortableRemoteObject.narrow(thing, "com.company.ejb.MyEjbHome");
    The last insert into the map (map.put("dedicated.rmicontext", "true");) wasn't mentioned neither in the servlet guide nor the EJB one. But without it, I'd always get some "domain is null" error.
    Now this code above works flawlessly in the embedded OC4J of JDeveloper. But it always hangs in the "Object thing = context.lookup("MyEjb");" line when executed either in a stand-alone OC4J (the one from JDeveloper launched through the batch file in [JDeveloper directory]\jdev\bin\start_oc4j.bat) or in the OC4J in iAS.
    Does anybody know why this happens or how to fix it? I know that there are other ways of EJB lookup in servlets but since we also have plain Java classes for testing purposes that access EJBs, this seemed like the simplest thing to do for both Java classes and servlets.

    I was referring to the java client case where this optoin is not required. In general for web clients one doesn't use the rmi initial context to find the bean. This is because the bean and the webclient are both packaged in the same application. One defines the ejb-ref in the web.xml for the bean and then looks it using the default initial context. Something like
    Context ctx = new InitialCOntext();
    ctx.lookup("bean ejb-ref-name");
    However if you must use rmi for accessing the bean from the web client then the dedicated connection property is required.
    For java clients you would setup the rmi context environment.
    Since you are trying to use a common utility class for both java and webclient I would recommend that you look into packaging the java client as a j2ee application client. Basically in that case you would be able to define a ejb-ref in the aplication-client.xml and use the default initial context in code for both the cases.
    Hope that helps
    Dhiraj

  • Issues in looking up a ejb deployed on glassfish from tomcat.

    Hi all,
    I have followed the steps mentioned in the EJB FAQ in the glassfish site and was able to lookup a remote ejb deployed in glassfish from a standalone client.
    In case of standalone client, i set the appropriate jndi properties in the initial context as mentioned in the FAQ and added the 4 jars specified to the classpath of the application.
    It all worked perfectly well.
    But I attempted to do the same from a servlet running under tomcat.
    I set the appropriate jndi properties in the intial context and added 4 jars specified in the lib directory of the war file.
    But this did not turn out well and tomcat complained me with some servlet init errors.
    Then i searched through the web and found this posting from you:
    http://www.archivesat.com/GlassFish_Enterprise_JavaBeans_Developers/thread1399339.htm
    Then i created a folder called "shared/lib" under TOMCAT_HOME directory in my machine and ran the same example. Wow.....miraculously the application ran well.
    But i found that the "index.jsp" which i configured in the welcome file list does not appear now. But i was able to access the servlet without any problem. And the servlet was able to successfully lookup the ejb deployed in glassfish.
    Then i thought, let me try to access the ejb from a jsf application.
    Then i created a jsf application in netbeans 5.5.1 and tried to access the bean deployed in glassfish.
    (Note: the jsf application runs in tomcat 5.5.17 which is bundled with netbeans)
    OOPSS....
    Tomcat now complains me that it cannot compile the jsp page..
    This is the error i got...
    org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    C:\Documents and Settings\james\.netbeans\5.5.1\apache-tomcat-5.5.17_base\work\Catalina\localhost\CityExplorer-WebClient1\org\apache\jsp\index_jsp.java:7: org.apache.jsp.index_jsp is not abstract and does not override abstract method getDependants() in org.apache.jasper.runtime.JspSourceDependent
    public final class index_jsp extends org.apache.jasper.runtime.HttpJspBase
    ^
    Generated servlet error:
    C:\Documents and Settings\james\.netbeans\5.5.1\apache-tomcat-5.5.17_base\work\Catalina\localhost\CityExplorer-WebClient1\org\apache\jsp\index_jsp.java:12: getDependants() in org.apache.jsp.index_jsp cannot implement getDependants() in org.apache.jasper.runtime.JspSourceDependent; attempting to use incompatible return type
    found : java.lang.Object
    required: java.util.List
    public Object getDependants() {
    ^
    2 errors
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    Any ideas...
    Can you please help me.
    I've noticed that you were eagerly answering questions related to ejb lookup in many places.
    I feel there is some potential compatability issue between tomcat and glassfish...
    I request you to investigate on this and clarify the community with your response.
    Thanks in advance,
    James Selvakumar

    Thank you guys!
    I've found the answer myself.

  • Loading an object using a different classloader

    I have 2 web-apps which share a common object. I want to store that
    common object in a common cache accessible to both web-apps. The problem
    is the 2 web-apps have a different classloader, so how do I return an
    object that was stored by web-app1 to be used with web-app2 without getting a ClassCastException
    -

    First question is whether the Web-Apps are on the same JVM - if you're using Tomcat, it is likely that they are. The next question is whether the Web-Apps' classloaders descend from a common parent classloader - again in Tomcat this is the case. If they do, then you should use the common parent classloader to instantiate the classes that need to be shared.
    To do this, you need to add the common classes to either the system classpath or to the classpath configured for your servlet/jsp engine. If the Web-Apps' classloaders are standard they will defer any requests initially to their parent classloader which will provide them with the same class definition and make it so that these classes can be shared between the Web-Apps.
    Now comes the nitty-gritty of implementation. The best way to share a common object is via a static instance in one of the classes loaded by the parent classloader, using the singleton pattern or the like.
    A trivial example would be if you wanted to hold a map of common (thread-safe) objects:public class Shared{
        private static java.util.HashMap sharedMap;
        static{
            // Thread safe, assuming all shared objects are initialised
            // in this static block.
            // If objects are to be created and placed in the
            // sharedMap later, use the synchronized map wrapping
            // methods from the Collections utility class.
            sharedMap = new java.util.HashMap();
            ... //instantiate and store the shared objecs here.
        public static Object getCommonObject(String key){
            return sharedMap.get(key);
    }As long as the Shared class comes from an ancestral classloader, both Web-Apps will see the same map of the same objects.
    Hope this helps,
    Bob B.

  • EJB in Glassfish V2 from a Servlet in SJSWS

    HI, I'm trying to use a EJB deployed in Glassfish from a servlet in the web server. I followed the steps in EJB_Faq of Glassfish site and they work
    perfectly in Tomcat, but when I try it on Sun Web Server 7.0u1 it fails. On the web server log there is an exception when trying to create InitialContext, but I think
    it is because of a warning that the server shows before the error. It doesn't load the javaee.jar file because is "Offending a class", the Servlet class.
    Anyone has tried this, call an EJB in Glassfish from Sun Web Server? It works in Tomcat but the Web Server doesn't load the javaee.jar file and I think this is the reason that the call fails.

    This is the code for the EJB:
    package jpm.business;
    import java.util.List;
    import javax.ejb.Stateless;
    @Stateless(mappedName="ejb/soloEJB")
    public class JavaPlatformManagerBean implements jpm.business.JavaPlatformManagerRemote, jpm.business.JavaPlatformManagerLocal {
    public String getNombre(){
    return "Minchez";
    public String toString(){
    return "Minchez ";
    And this is the part of the servlet that looks for the EJB:
    try{
    java.util.Properties props = new java.util.Properties();
    props.setProperty("java.naming.factory.initial",
    "com.sun.enterprise.naming.SerialInitContextFactory");
    props.setProperty("java.naming.factory.url.pkgs",
    "com.sun.enterprise.naming");
    props.setProperty("java.naming.factory.state",
    "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
    props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
    props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
    out.print("1");
    InitialContext ic = new InitialContext(props);
    out.print("2");
    JavaPlatformManagerRemote jpmr = (JavaPlatformManagerRemote)ic.lookup("ejb/soloEJB");
    out.print("-" + jpmr.getNombre());
    out.print("3");
    } catch(Exception e){ out.println(e.toString()); }
    (I just deleted some comments, but if there is an error, just complete the declarations)
    The EJB's .jar is deployed on Glassfish and the Servlet's .war is deployed on SJSWS or Tomcat. As the FAQs says on Glassfish forum, you have to add some jars to the web server classpath. Copy this jars to a folder named shared/lib on tomcat installation: javaee.jar, appserv-rt.jar, appserv-ext.jar, appserv-deployment-client.jar and jmxremote_optional.jar the last one I don't know if its necessary but I copied also, they are on Glassfish lib directory.
    If you try in tomcat it works fine, the servlet receives the String form the EJB method. But when you try it in SJSWS the javaee.jar file its not loaded, fails on "validateJar(....)" and I think this is the reason the servlet doesn't find de EJB.
    I'm using:
    Glassfish V2
    SJS Web Server 7.0u1
    Tomcat 5.5.17

  • How to return Collection from from entity bean to servlet?

    hi
    is it possible to return Collection from entity bean (Which is returns form CMR field ) to servlet ?
    thanks

    SERVLET
    public class test extends HttpServlet {
       @EJB
       private LocalBean lookupBean;
        protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            response.setContentType("text/html;charset=UTF-8");
            PrintWriter out = response.getWriter();
      for(Item i : lookupBean.getMyCollection() )
              out.println(i.getItemName());
            out.close();
    }BEAN INTERFACE
    public interface BeanLocal {
        Collection<Item> getMyCollection();  
    }BEAN IMPLEMENTATION
    @Stateless()
    public class Bean implements BeanLocal {
        @PersistenceContext()  
        private EntityManager em;      
         public Collection<Item> getMyCollection() {
            return em.createQuery("SELECT i from ITEM i").getResultList();
        }    and if you create an instance of your servlet you'll have to reinitialize LocalBean
    @EJB(name="myejbref", beanInterface=BeanLocal.class)
    private BeanLocal lookupBean;
    private BeanLocal getLookupBean() {
    if(lookupBean == null) {
    try {
    InitialContext ic = new InitialContext();
    lookupBean = (BeanLocal) ic.lookup("java:comp/env/myejbref");
    catch(Exception e){
    System.out.println(e.getMessage());
    return lookupBean;
    }

  • About different ClassLoader in Applet

    I have made an application which can reload updated class dynamically..
    for reloading class dynamically from file system, I can't help using URLClassLoader which is different from original ClassLoader.
    When the application works in local JVM, the diffrenent class loaders didn't make any problem .. but, when the application works as Applet in web, class loaders make some problems....
    for example,
    Class A {
    protected String name;
    public String getName(Class B) { return name; }
    Class B {
    URLClassLoader classLoader;
    public void showName(){
    A aClass = classLoader.loadClass("A");
    Method method = aClass.getClass().getMethod("getName", this.getClass()); ----> 1
    String name = (String)Method.invoke(aClass, this);
    the part of 1 generates error :: NoMethodError.
    that is the reasion that Class A is loaded from default system class loader,
    and Class B is loaded dynamically from URLClassLoader.
    but, above code works well in local JVM, but when I execute as Applet in Web,
    it generates NoMethodError...
    Is there any persion telling me the answer?

    This is just a guess, but maybe it's a security issue in the browser ?
    Try changing the settings in IE: tools, internetoptions, security, custom level, java permissions: custom
    Then, enable 'run unsigned content' and enable 'access to all networkaddresses'

Maybe you are looking for

  • How can I transfer my itunes library edits to my computer music

    I got my PC music that I transfer to my itunes library, and I do a lot of editing of my itunes music and I would like it to automaticly edit my PC music so that when I lose my itunes music I could go back to my PC and download it again without having

  • Find out which is the calling method at runtime

    Hello. I have to write a very simple, custom logger. Don't tell me to use logging API, since I can not, unfortunately :-( In order to log informations I use a class calles FileLogger, which has some methods, like warn(String message), info(String mes

  • Not Recognizing External HD.

    I have three external hard drives connected to usb hub and all of a sudden IMAC does not show them in finder but it shows message "Disk not ejected properly ,"eject ( Drive) before disconnecting or turning off." Thye have always worked and I leave on

  • LaCie 500GB d2 Quadra (Final Cut & DV Cam)

    Got a MacBook Pro (2008) only one firewire and i will be capturing my movies from my DV Camcorder and also will be setup up as m default storage for Final Cut. I see in the description of LaCie 500GB d2 Quadra: You can also daisy-chain via FireWire o

  • AES-256 Security Provider ??

    Hi, Our company is using a tool called AdvenetNet WebNMS to create a network management system. However, there is one particular section in the developer guide that refers to working with "providers" to support privacy in SNMPv3. Our software group w