[EJB 3.0] - EJB3 and jndi error.
by xubin
I have a project on JBoss AS 4.0.5.GA with EJB3, the jdk is sun jdk6. And there is a stateless session bean(slsb) in my project. Another servelt in tomcat access the slsb with jndi. The error is that I can not find the slbs by jndi.
Below is the code:
slsb:
package com.sacl.ibs.ejb3;
|
| import java.io.Serializable;
| import java.util.List;
|
| import javax.ejb.Stateless;
| import javax.persistence.EntityManager;
| import javax.persistence.PersistenceContext;
|
| import org.jboss.annotation.ejb.RemoteBinding;
| import org.jboss.annotation.ejb.RemoteBindings;
|
| @Stateless
| @RemoteBindings(@RemoteBinding(jndiBinding="com.sacl.ibs.ejb3.IBSManager"))
| public class IBSManagerBean implements IBSManager, Serializable {
| private static final long serialVersionUID = -2836261119947098786L;
| @PersistenceContext(unitName="ibs")
| EntityManager em;
|
| }
servlet:
package com.sacl.ibs.web;
|
| import java.io.IOException;
| import java.io.PrintWriter;
| import java.util.Properties;
|
| import javax.naming.Context;
| import javax.naming.InitialContext;
| import javax.naming.NamingException;
| import javax.servlet.ServletConfig;
| import javax.servlet.ServletException;
| import javax.servlet.http.HttpServlet;
| import javax.servlet.http.HttpServletRequest;
| import javax.servlet.http.HttpServletResponse;
|
| import com.sacl.ibs.ejb3.IBSManager;
|
| public class JNDIServlet extends HttpServlet{
|
| private static final long serialVersionUID = 3636864192783338015L;
| private static Context ctx;
| private static IBSManager manager;
|
| public void init(ServletConfig config) throws ServletException {
|
| }
|
|
|
| protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
| doPost(req, resp);
| }
|
| protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
| try {
| PrintWriter out = resp.getWriter();
|
| if(ctx == null){
| Properties env = new Properties();
| env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
| env.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interface");
| env.setProperty(Context.PROVIDER_URL, "jnp://localhost:1099");
|
| out.println("env ok!");
|
| try {
| ctx = new InitialContext(env);
| if(manager == null){
| //manager = (IBSManager)ctx.lookup(IBSManager.class.getName());
| manager = (IBSManager)ctx.lookup("java:"+IBSManager.class.getName());
| out.println("manager ok!");
|
| //ctx.lookup("java:comp/env/ejb/com/atsva/cmmts/ejb/DesignObjectManager");
|
| }
|
| } catch (NamingException e) {
| // TODO Auto-generated catch block
| e.printStackTrace();
| out.println(e);
| }
| }
|
|
|
|
| out.println(manager.hello("Kitty"));
|
| } catch (Exception e) {
| // TODO: handle exception
| }
|
|
| }
|
|
| }
When I run the servlet, it show "javax.naming.NameNotFoundException: com.sacl.ibs.ejb3.IBSManager not bound".
And in jboss as console, when jboss as start, it show:
anonymous wrote : 13:49:51,609 INFO [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured
| 13:49:51,609 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
| 13:49:51,843 INFO [EJBContainer] STARTED EJB: com.sacl.ibs.ejb3.IBSManagerBean ejbName: IBSManagerBean
| 13:49:51,906 INFO [EJB3Deployer] Deployed: file:/C:/jboss-4.0.5.GA/server/default/tmp/deploy/tmp33327IBS.ear-contents/IBS.par
| 13:49:51,953 INFO [EARDeployer] Started J2EE application: file:/C:/jboss-4.0.5.GA/server/default/deploy/IBS.ear
It don't say the session bean was been bound.
I'll appreciate any help with this.
Thanks
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4044583#4044583
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4044583
19 years, 1 month
[JBoss jBPM] - Validation of task form fields
by naseem.k
Hi...
I have created a process definition where I need to validate task form fields.
Initially I used default controller for the same task and I also created task variables with read, write and required checked. Now since required is checked so it should give error at the time of task form submission if entries are blank just like struts required validation-rule but still I can submit the form without entering task form fields.
Why there is no validation is this case when required is set to true? or is this required has some other meaning?
Secondly if the above approach is not the right way of validation, then can I do the same by writing a custom controller for the same and then validate form fields by java code in the custom controller.
Please suggest some solution.
Thanks & Regards
Naseem
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4044573#4044573
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4044573
19 years, 1 month