-
1. Re: EJB 3.0 and env-entry injection
onekludov Sep 8, 2005 11:50 AM (in response to czertik)I have same problem to...
-
2. Re: EJB 3.0 and env-entry injection
viennec Oct 10, 2005 8:52 AM (in response to czertik)I also already tried out plenty of things (explicit adding name property to annotation, prefixing in the ebj-jar.xml the env-entry-name value with the package and Bean name, ...) and none seems to work.
-
3. Re: EJB 3.0 and env-entry injection
bill.burke Oct 12, 2005 1:53 PM (in response to czertik)Ok, revamped this stuff in RC3 release...
You do need to read Java EE 5 specification on injection. According to specification, your above code would not work...It needs to be:package org.acme; public class MyClass { @Resource(name="providerURL") String field; <env-entry> <env-entry-name>providerURL</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>ldap://localhost:389/</env-entry-value> </env-entry>
ORpackage org.acme; public class MyClass { @Resource String field; <env-entry> <env-entry-name>org.acme.MyClass/field</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>ldap://localhost:389/</env-entry-value> </env-entry>
ORpackage org.acme; public class MyClass { String field; <env-entry> <env-entry-name>providerUrl</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>ldap://localhost:389/</env-entry-value> <injection-target> <injection-target-class>org.acme.MyClass</injection-target> <injection-target-name>field</injection-target-name> </injection-target> </env-entry>
All this should work in RC3 now... -
4. Re: EJB 3.0 and env-entry injection
viennec Oct 13, 2005 7:30 AM (in response to czertik)I'm sorry but after upgrading my JBoss 4.0.3 AS with the EJB 3.0 RC3 release, i have the impression only the last case works (using the injection-target tag) while the other 2 possibilities mentioned still don't work (a bit pitty since i find these in fact the nicest ways to inject)
Anyway, at least now there's a way to inject an environment entry, so thanks!
christophe -
5. Re: EJB 3.0 and env-entry injection
bill.burke Oct 17, 2005 12:55 PM (in response to czertik)I thought I had the appropriate junit tests... I do have a test for #2 and #3 above, but not #1. Can you post how #2 does not work?
-
6. Re: EJB 3.0 and env-entry injection
czertik Nov 10, 2005 3:42 PM (in response to czertik)I can confirm, that from the examples above only the third is working in my environment as well - installed JBoss 4.0.3 + EJB 3.0 RC3.
The first example seems to bind the entries to the NamingContext, but there's no interceptor created for the injection. The second is unable to find the field for injection - no wonder, when it really uses the whole string in the tag.
As soon as I find some spare time, I'll try to debug it some more and hopefully provide more insight or even patch if possible... but I'm just too deep in other stuff right now :-( -
7. Re: EJB 3.0 and env-entry injection
jagthedrummer Dec 7, 2005 1:59 PM (in response to czertik)Can someone please post a full example of the ejb-jar.xml file where this is working? I've spent hours trying to get it to work, and no matter what I do I can't seem to get an env-entry passed into one of my classes. I assume that it's supposed to go inside the entry for a particular bean, but it's just not working for me at all. I'm attempting to do option #3 as mentioned above since it's the version that people have gotten to work.
Thanks,
Jeremy -
8. Re: EJB 3.0 and env-entry injection
bill.burke Dec 7, 2005 7:01 PM (in response to czertik)Jag/Jeremy,
You need to publish examples of what exactly is going wrong. -
9. Re: EJB 3.0 and env-entry injection
jagthedrummer Dec 7, 2005 7:41 PM (in response to czertik)What's going wrong is that none of the examples given above seem to work, and I'm wondering where exactly all that information needs to go. Having the java code mixed in with the deployment descriptor doesn't really give me an idea where in the deployment descriptor the env-entry stuff should go.
I have a class that looks like this:package com.webeprint.node.ejb; @Service public class NodeManagerBean implements NodeManager { String testParam = "origTestParam"; }
Then I'm setting up ejb-jar.xml to look like this:<ejb-jar> <enterprise-beans> <session> <ejb-name>com.webeprint.node.ejb.NodeManager</ejb-name> <ejb-class>com.webeprint.node.ejb.NodeManagerBean</ejb-class> <env-entry> <env-entry-name>testParam</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>newTestValue</env-entry-value> <injection-target> <injection-target-class>com.webeprint.node.ejb.NodeManagerBean</injection-target-class> <injection-target-name>testParam</injection-target-name> </injection-target> </env-entry> </session> </enterprise-beans> </ejb-jar>
I've tried this too:<ejb-jar> <enterprise-beans> <session> <ejb-name>com.webeprint.node.ejb.NodeManagerBean</ejb-name> <ejb-class>com.webeprint.node.ejb.NodeManagerBean</ejb-class> <env-entry> <env-entry-name>testParam</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>newTestValue</env-entry-value> <injection-target> <injection-target-class>com.webeprint.node.ejb.NodeManagerBean</injection-target-class> <injection-target-name>testParam</injection-target-name> </injection-target> </env-entry> </session> </enterprise-beans> </ejb-jar>
I've even tried this (which I didn't really expect to work, but I'll try anything at this point):<ejb-jar> <enterprise-beans> <env-entry> <env-entry-name>testParam</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>newTestValue</env-entry-value> <injection-target> <injection-target-class>com.webeprint.node.ejb.NodeManagerBean</injection-target-class> <injection-target-name>testParam</injection-target-name> </injection-target> </env-entry> </enterprise-beans> </ejb-jar>
I also tried many variations of examples #1 and #2, and none of them can get the job done. What I need is:testParam.equals("newTestValue") == true;
All I ever end up with is :testParam.equals("origTestParam") == true;
I even tried leaving testParam unintialized in my class, but I just get a NullPointerException when trying to test the value of it.
So, I'm hoping that someone can post the full code for a simple class and ejb-jar.xml file that actually gets this to work.
Thanks,
Jeremy -
10. Re: EJB 3.0 and env-entry injection
sandello Dec 7, 2005 11:19 PM (in response to czertik)IMHO, you forget annotation "@Resource" before
String testParam = "origTestParam";
It exist in example 1 and 2 -
11. Re: EJB 3.0 and env-entry injection
jagthedrummer Dec 8, 2005 1:01 AM (in response to czertik)"sandello" wrote:
IMHO, you forget annotation "@Resource" beforeString testParam = "origTestParam";
It exist in example 1 and 2
Yeah, I got the impression that you didn't need it when you're using the injection-target method (#3). But I'm pretty sure that I tried it that way anyway. I'll give it another shot and see what I can come up with.
Jeremy -
12. Re: EJB 3.0 and env-entry injection
jagthedrummer Dec 8, 2005 2:34 AM (in response to czertik)"sandello" wrote:
IMHO, you forget annotation "@Resource" beforeString testParam = "origTestParam";
It exist in example 1 and 2
I just tested it again, and if I use the @Resource I get an exception thrown about testParam not being bound.
Jeremy -
13. Re: EJB 3.0 and env-entry injection
bill.burke Dec 8, 2005 12:18 PM (in response to czertik)1) You should not need the @Resource annotation
2) Can you please post stack traces. "I get an exception" does not help us very much in debugging your problem. -
14. Re: EJB 3.0 and env-entry injection
jagthedrummer Dec 8, 2005 1:04 PM (in response to czertik)"bill.burke@jboss.com" wrote:
1) You should not need the @Resource annotation
2) Can you please post stack traces. "I get an exception" does not help us very much in debugging your problem.
But I only get the exception when I include the @Resource (which you siad I don't need). When I leave that out there is no exception. No nothing. It just flat out doesn't work, doesn't complain, doesn't even act like it's trying to work. I do get a line like this:[org.jboss.ejb3.Ejb3DescriptorHandler] found ejb-jar.xml jar:file:/usr/local/jboss-4.0.3RC2/server/default/tmp/deploy/tmp57478testclient-webeprint.ejb3!/META-INF/ejb-jar.xml
But that doesn't seem like it's going to tell anyone anything.
I wish there was more information I could give you but I simply don't have it. So again, if someone could please post a FULL example of a simple class and ejb-jar.xml file that actually does work, maybe I can use that to figure out what's going on.
Thanks,
Jeremy