I have been trying to inject/use my EJB from within an applet without success. I have created a new Java EE Enterprise application. I am using glassfish 3 & netbeans 7.1
The main problem has been instantiating InitialContext
.
Here are the declarations of my beans.
@Stateless
public class UserFacade implements UserFacadeLocal {
@PersistenceContext(unitName = "MetroEntitiesPU")
private EntityManager em;
@Remote
public interface UserFacadeLocal {
I have been able to create a stand alone Java client by including the gf-client.jar
class-path and using the following code.
try {
UserFacadeLocal ufl = (UserFacadeLocal) new InitialContext()
.lookup("bidd.data.ejb.UserFacadeLocal");
System.out.println("FROM EJB COUNT: " + String.valueOf(ufl.count()));
} catch (NamingException ex) {
Logger.getLogger(JavaApplication3.class.getName())
.log(Level.SEVERE, null, ex);
}
The problem is when i am trying to do the same in the applet. The applet is compiled in a jar file and then loaded from a jsp website which is part of my enterprise application in netbeans.
This is the line in the init method that gives the error that follows.
UserFacadeLocal ufl = (UserFacadeLocal) new InitialContext()
.lookup("bidd.data.ejb.UserFacadeLocal");
Need to specify class name in environment or system property,
or as an applet parameter,
or in an application resource file: java.naming.factory.initial
How to solve this error?
Need to specify class name in environment or system property,
or as an applet parameter,
or in an application resource file: java.naming.factory.initial
environment or system property
as an applet parameter
<applet ..><param name='the.name' value='bidd.data.ejb.UserFacadeLocal'> </applet>
in an application resource file
param
to identify the file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.