Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2009
    Location
    Taiwan
    Posts
    4
    Rep Power
    0

    Unhappy Access Remote Session Bean from an separate web app

    Hello Everyone!

    I'm new here, and this is my first post, hope i get some help ..

    I build a Remote EJB Session Bean :

    @Stateless
    public class MyEJB implements MyEJBRemote
    {
    public void sayHello(){ //implement ...
    System.out.println("HELLO");
    }
    }

    I deploy it on GlassFish 2 and want to access it from a servlet in an separate web application on another server.


    the servlet looks like this...:
    public class MyServlet extends HttpServlet
    {
    @EJB
    MyEJBRemote bean;

    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException
    {
    bean.sayHello();
    }
    }

    and I deploy on tomcat server.

    then I access the servlet, but the exception has thrown:

    嚴重的: Allocate exception for servlet CallRemoteEJB
    java.lang.IllegalAccessException: Class org.apache.catalina.core.StandardWrapper can not access a member of class com.kiyo.ejb.web.servlet.MyServlet with modifiers ""
    at sun.reflect.Reflection.ensureMemberAccess(Reflecti on.java:65)
    at java.lang.Class.newInstance0(Class.java:349)
    at java.lang.Class.newInstance(Class.java:308)
    at org.apache.catalina.core.StandardWrapper.loadServl et(StandardWrapper.java:1104)
    at org.apache.catalina.core.StandardWrapper.allocate( StandardWrapper.java:806)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:129)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:104)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:261)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:581)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)


    It seems that there need some properties to specify the address of the server where the Session Bean is on, and I searched and found nothing but using InitialContext.lookup.

    Can I access the remote Session Bean just using Annotation @EJB ?

    Thanks very much

  2. #2
    Join Date
    Jan 2009
    Location
    Taiwan
    Posts
    4
    Rep Power
    0

    Default

    Problem Resolved.

  3. #3
    Join Date
    Jan 2009
    Location
    Taiwan
    Posts
    4
    Rep Power
    0

    Default

    add
    %GLASSFISH_HOME%/lib/appsrv-rt.jar
    %GLASSFISH_HOME%/lib/appsrv-deployment-client.jar
    %GLASSFISH_HOME%/lib/appsrv-ext.jar
    %GLASSFISH_HOME%/lib/appsrv-admin.jar
    %GLASSFISH_HOME%/lib/appsrv-launch.jar
    In /WEB-INF/lib and copy
    %GLASSFISH_HOME%/lib/javaee.jar
    into /TOMCAT_HOME/lib

    then call the servlet again, it works!

  4. #4
    Join Date
    Jan 2009
    Location
    Taiwan
    Posts
    4
    Rep Power
    0

    Default

    But instead of using Dependency Injection, I tried and success using InitialContext

  5. #5
    Caio Isikawa is offline Member
    Join Date
    Apr 2009
    Posts
    1
    Rep Power
    0

    Default

    Hi kiyoharatakuya, I'm trying to do the same thing you did. Could you post your code using InitialContext ?

    Thanks.

Similar Threads

  1. remote access
    By Omarero in forum NetBeans
    Replies: 1
    Last Post: 11-03-2008, 07:36 AM
  2. Replies: 1
    Last Post: 10-24-2008, 04:00 AM
  3. UREGENT-accessing session bean ok but entity bean
    By parimal in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 08-28-2008, 01:34 PM
  4. remote file access problem
    By kib_tse in forum New To Java
    Replies: 2
    Last Post: 08-14-2008, 06:04 PM
  5. Remote interface for entity bean
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-28-2007, 10:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •