-
1. Re: Can't inject EJB from external project
syjmick Jan 5, 2011 4:10 PM (in response to syjmick)I tried on JBoss 5.1 - same issue - so is it some xml-configuration problem?
-
2. Re: Can't inject EJB from external project
syjmick Jan 7, 2011 1:55 PM (in response to syjmick)I have tried all tips from Seam documentation, posts found on this forum - with no luck.
Anyone has (could share) a working copy of example Seam 2.2 project that deploys and works on Weblogic 10.3? -
3. Re: Can't inject EJB from external project
isonisak Jan 7, 2011 2:22 PM (in response to syjmick)Check if the NPE comes from Logger or DAO.
if log is null, then app. class is not instantiated
by Seam. -
4. Re: Can't inject EJB from external project
mkiel Jan 7, 2011 4:34 PM (in response to syjmick)If the EAR includes the version, the JNDI pattern must include it, too. My main pom.xml includes something like this:
<properties> <app.jndi.pattern>${ear.name}/#{ejbName}/local</app.jndi.pattern> <ear.name>my-project-${project.version}</ear.name> ... </properties>
EAR pom.xml:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ear-plugin</artifactId> <configuration> <finalName>${ear.name}</finalName> ...
components.xml:
<core:init debug="${app.debug}" jndi-pattern="${app.jndi.pattern}" />
This allows to easily change the EAR name, e.g. to include a deployment ID enabling you to run multiple deployments in parallel.
But of course, the EJB has to be deployed correctly in any case. When using JBoss, you should see something like this at application startup:
19:46:25,355 INFO [SessionSpecContainer] Starting jboss.j2ee:ear=my-project-1.0.ear,jar=my-project-1.0-ejb.jar,name=UserDAOImpl,service=EJB3 19:46:25,355 INFO [EJBContainer] STARTED EJB: UserDAOImpl ejbName: UserDAOImpl 19:46:25,366 INFO [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI: my-project-1.0/UserDAOImpl/local - EJB3.x Default Local Business Interface my-project-1.0/UserDAOImpl/local- UserDAO - EJB3.x Local Business Interface
Oh and, just as a good habit, you should use parameters for logging - string concatenation is expensive, but would be executed even if you disable this log level:
log.info("#0 ..... init() method .....", HomeMB.class.getSimpleName());
-
5. Re: Can't inject EJB from external project
syjmick Jan 10, 2011 4:39 PM (in response to syjmick)Thanks for tips Marcel, however please correct me if I'm wrong:
in my scenario i MUST NOT have :
<ejb-local-ref> <ejb-ref-name>ejb/UsersDAOBean/local</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local>my.app.module.UsersDAO</local> </ejb-local-ref>
cause my jndi pattern dffers from version to version, right? Or should I put ${app.version} into ejb-ref-name?
Does Weblogic 10.3.3.0 really needs it in web.xml?
Unfortunately I still can't run my example, message on console:
Could not instantiate Seam component: homeMB ... Caused by: java.lang.NullPointerException at my.priject.module.HomeMB.init(HomeMB.java:30)
here is my EJB:
@Stateless @Name(UsersDAO.NAME) public class UsersDAOBean implements UsersDAO { private static final long serialVersionUID = 5855999111119720298L; @Logger Log log; @Create @Override public void init(){ log.info("#0 ..... Inside init() method .....", UsersDAOBean.class.getSimpleName()); } @Override public List getUsers() { log.info("# ..... listing users here .....", UsersDAOBean.class.getSimpleName()); for(int i = 0; i < 10; i++){ log.info("#0 #1", UsersDAOBean.class.getSimpleName(), i); } return null; } }
where @Name(UsersDAO.NAME) is defined in interface:
@Local public interface UsersDAO extends Serializable { public static final String NAME = "usersDAO"; public List getUsers(); public void init(); }
Hope You could push me with this further ;)
-
6. Re: Can't inject EJB from external project
mkiel Jan 10, 2011 4:50 PM (in response to syjmick)Well, I dont' know anything about WebLogic, but I assume you don't need <ejb-local-ref> at all if you use EJB3 annotations.
Did you have any luck testing the app in JBoss AS? Do the application startup log entries I mentioned show up there?
Another solution would of course be to set the EAR name to something static, not including the version. Just set the <finalName> in the pom.xml as described above.
-
7. Re: Can't inject EJB from external project
aareshchanka Jan 11, 2011 6:15 PM (in response to syjmick)First check your logs, you should see that Seam instantiated EJB's from your ejb module.
Second check if seam.properties file is located in ejb module, because of if not then Seam will ignore it. -
8. Re: Can't inject EJB from external project
syjmick Jan 17, 2011 5:02 AM (in response to syjmick)gosh.... you were absolutely right :( lame me ! seam.properties was mispelled! works now. I'll try to play with it (add JPA and stuff) and if it works I think I'll publish maven sources here for everyone to reuse.