I have an EJB deployed successfully in a JAR, which is in turn deployed in an EAR in 
JBoss. I can access the EJB's methods from an JSP deployed in a WAR file in the same 
EAR. However, when I try to use the same JNDI name to access the EJB from a standalone 
Java application (just a class with simple main() function) using this code:


/* class imports here...*/

public class EJBInvoker {
  public static void main(String[] args) {
                
  Category myCategory = null;    // remote interface
  CategoryHome myCategoryHome = null;    // home interface
                
  try {
    Context context = new InitialContext();
    myCategoryHome = 
(CategoryHome)PortableRemoteObject.narrow(Context.lookup("CategoryBean"), 
CategoryHome.class);
    Integer primaryKey = new Integer(8); // just an integer for primarykey
    myCategory = (Category)myCategoryHome.findByPrimaryKey(primaryKey);
    System.out.println(myCategory.getName());
  
  } catch (Exception ex) {
    System.out.println("Error: "+ ex.getMessage());
    ex.printStackTrace();
    }
}       
}

I get the following error:

Error: Can't find SerialContextProvider
javax.naming.CommunicationException: Can't find SerialContextProvider
        at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.jav
a:63)
        at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:120
)
        at javax.naming.InitialContext.lookup(InitialContext.java:347)
        at com.mtmalta.ejb.testing.EJBInvoker.main(EJBInvoker.java:22)

Can anyone turn the light switch on for me pls?! Thanks!

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3841563#3841563

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3841563


-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to