[jboss-user] [Beginners Corner] - EJB-Injection from JSF in JBoss 4.2.2

NSchweig do-not-reply at jboss.com
Fri Jun 27 04:03:49 EDT 2008


Hello,

I useJBoss AS 4.2.2 GA. 
I have got a simple EJB3-project that works. A Testclient simply does an output at the console.
I get the SessionBeans via the InitialContext:
Testclient.java

  | public static void main(String[] args) {
  | 		Context context;
  | 		try
  | 		{
  | 			context = new InitialContext();
  | 			//Zugriff auf die Session Beans 
  | ShopWebSite shopWebSiteBean= (ShopWebSite) context.lookup(ShopWebSiteBean.RemoteJNDIName);
  | 			
  | ...
  | 
Now I have a JSF-application, which should get access to the same sessionbeans from the project above.
I read that @EJB() is not available in this JBossversion so I thought that the ejb injection should work in the same way as in the project above. So I have following code in the JSF-managed-bean "ShopBean" in the constructor:

  | private ShopBean (){
  | 		
  | 		context = new InitialContext();
  | 		 try
  | 	      {
  | 			 ShopWebSite site = (ShopWebSite)context.lookup(ShopWebSiteBean.RemoteJNDIName); 
  | 	      }
  | 	      catch (NamingException e)
  | 	      {
  | 	         throw new RuntimeException(e);
  | 	      }
  | 	}
  | 
But in eclipse there is shown ...type cannot be resolved.
I have got separate projects in eclipse. One dynamic web project for JSF and an EJB-project. Should I connect them and when yes how to connect them?
Do there exist any best practises for getting access to the Session Beans? I do not think that it is the best solution to put it into the construktor from the JSF-managedbeans?
Thank you for your answers.
NSchweig

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

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



More information about the jboss-user mailing list