-
1. Re: EJB archive never gets deployed in glassfish embedded
aslak Mar 14, 2010 3:41 PM (in response to meetoblivion)This is actually a combination of how Arquillian currently packages the deployment(Not supported by the EE spec) and a bug in GlassFish..
https://glassfish.dev.java.net/issues/show_bug.cgi?id=11497
Next release will hopefully have a fix for this.
-
2. Re: EJB archive never gets deployed in glassfish embedded
meetoblivion Mar 14, 2010 7:34 PM (in response to aslak)well actually it has nothing to do with CDI.
Let's say I create a very simple EJB module w/ just one singleton EJB in it.
{code}@Singleton
@Startup
public class SingletonEJBTest {
@PostConstruct
public void init() {
System.out.println("Initializing a new instance of SingletonEJBTest");
}
public String sayHiTo(String name) {
return String.format("Hey there %s",name);}
}{code}And then I write a test case for it:
{code}@RunWith(Arquillian.class)
public class SingletonEJBTestCase extends TestCase {
@Deployment
public static JavaArchive createDeployment() {
return Archives.create("test.jar", JavaArchive.class)
.addClass(SingletonEJBTest.class);
}
@EJB SingletonEJBTest testCase;
@Test
public void testSayHi() {
if(testCase == null) {
System.out.println("Injected instance of SingletonEJBTest is null.");
}
Assert.assertEquals("Hey there bob",testCase.sayHiTo("bob"));
}
}{code}The injection never seems to happen; in fact the testCase == null block is triggered.
-
3. Re: EJB archive never gets deployed in glassfish embedded
aslak Mar 15, 2010 4:56 AM (in response to meetoblivion)Currently the EJB injector does not support EJB 3.1 no-interface injection, only a very limited bean naming convention:
[Reference Doc - Injection into test case|http://docs.jboss.org/arquillian/reference/1.0.0.Alpha1/en-US/html_single/#d0e755]
This will be fixed in the next versions: https://jira.jboss.org/jira/browse/ARQ-77
But the [EJB injector|http://anonsvn.jboss.org/repos/common/arquillian/trunk/testenrichers/ejb/src/main/java/org/jboss/arquillian/testenricher/ejb/EJBInjectionEnricher.java]
should throw Exception if it can't locate the injection point. This makes me suspect it's not running at all..
Could you attach a complete test case /w maven poms etc.. ?
-
4. Re: EJB archive never gets deployed in glassfish embedded
meetoblivion Mar 15, 2010 8:35 PM (in response to aslak)So first, back to my original issue.
I still believe there's an issue w/ deploying in glassfish. I rewrote my bean using EJB3.0 Stateless.
I then changed my deployment to look like this:
{code} @Deployment
public static JavaArchive createDeployment() {
return Archives.create("test.jar", JavaArchive.class)
.addClass(SingletonEJBTest.class)
.addClass(SingletonEJBTestBean.class);
}
@EJB SingletonEJBTestBean testCase;
@Test
public void testSayHi() {
if(testCase == null) {
System.out.println("Injected instance of SingletonEJBTest is null.");
}
Assert.assertEquals("Hey there bob",testCase.sayHiTo("bob"));
}{code}
And yet, testCase is still null.
I'll poke around and see if I see which enricher is responsible for injecting EJBs into the test case, however i'm inclined to say it's a bad idea/unnecessary. So you either have a coding bug (attempting to inject an EJB in to a non EJB) or an issue with arquillian itself (injecting a singleton/no interface EJB). so i'm not sure if it's a good idea to throw an exception here, other than the NPE that happens when the injection point is null.
-
5. Re: EJB archive never gets deployed in glassfish embedded
aslak Mar 16, 2010 4:37 AM (in response to meetoblivion)Does the GlassFish Embedded 3.0 Examples work for you?
mvn test -P glassfish-embedded-30 -f examples/junit/pom.xml
meetoblivion wrote:
@Deployment public static JavaArchive createDeployment() { return Archives.create("test.jar", JavaArchive.class) .addClass(SingletonEJBTest.class) .addClass(SingletonEJBTestBean.class); } @EJB SingletonEJBTestBean testCase; @Test public void testSayHi() { if(testCase == null) { System.out.println("Injected instance of SingletonEJBTest is null."); } Assert.assertEquals("Hey there bob",testCase.sayHiTo("bob")); }
And yet, testCase is still null.
Your trying to injecting the Bean, not the interface. Try @EJB SingletonEJBTest testCase;meetoblivion wrote:
I'll poke around and see if I see which enricher is responsible for injecting EJBs into the test case, however i'm inclined to say it's a bad idea/unnecessary.
What's a bad idea/unnecesary? Throwing exception or you poking around in the code?meetoblivion wrote:
so i'm not sure if it's a good idea to throw an exception here, other than the NPE that happens when the injection point is null.
The EJB container will throw an exception if you try to inject a non existing EJB ref into a EJB.Since EJB injection points are not optional it's an exception case when, for what ever reason the injection can not be fulfilled. -
6. Re: EJB archive never gets deployed in glassfish embedded
aslak Mar 16, 2010 4:40 AM (in response to meetoblivion)meetoblivion wrote:
or an issue with arquillian itself (injecting a singleton/no interface EJB).
EJB 3.1 injection is not supported in Alpha-1.
-
7. Re: EJB archive never gets deployed in glassfish embedded
meetoblivion Mar 20, 2010 11:02 AM (in response to aslak)I realize that.
I think you missed the part in my post where I stated that the same thing happens in GFV3 using a regular EJB 3.0 Stateless Local EJB w/ Local interface, attempting to inject against the interface fails.
I did just run
mvn test -P glassfish-embedded-30 -f examples/junit/pom.xml
the only thing I can get from it is that tests are skipped, seems to have something to do w/ ARQ-60.
I am in fact injecting the EJB as @EJB Interface someName; not @EJB Implementation someName;
-
8. Re: EJB archive never gets deployed in glassfish embedded
aslak Mar 24, 2010 7:07 AM (in response to meetoblivion)The junit/testng example test cases are skipped from the main build, but the appropriate tests for each container are activated by the defined profiles.
This is my output:
{code}
aslak@lappy:~/arquillian-alpha1$ mvn test -P glassfish-embedded-30 -o -f examples/junit/pom.xml[INFO] Scanning for projects...[INFO] ------------------------------------------------------------------------[INFO] Building Arquillian Example JUnit[INFO] task-segment: [test][INFO] ------------------------------------------------------------------------[INFO] [enforcer:enforce {execution: enforce-maven-environment}][INFO] [resources:resources {execution: default-resources}][INFO] Using default encoding to copy filtered resources.[INFO] [compiler:compile {execution: default-compile}][INFO] Nothing to compile - all classes are up to date[INFO] [resources:testResources {execution: default-testResources}][INFO] Using default encoding to copy filtered resources.[INFO] [compiler:testCompile {execution: default-testCompile}][INFO] Nothing to compile - all classes are up to date[INFO] [surefire:test {execution: default-test}][INFO] Surefire report directory: /mnt/build-server/home/aslak/workspace/opensource/jboss-test/arquillian-alpha1/examples/junit/target/surefire-reports-------------------------------------------------------T E S T S-------------------------------------------------------Running com.acme.ejb.TemperatureConverterTestCaseTests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 9.291 secRunning com.acme.ejb.InjectionTestCaseTests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.7 secResults :Tests run: 4, Failures: 0, Errors: 0, Skipped: 0[INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESSFUL[INFO] ------------------------------------------------------------------------[INFO] Total time: 19 seconds[INFO] Finished at: Wed Mar 24 11:57:33 CET 2010[INFO] Final Memory: 17M/120M[INFO] ------------------------------------------------------------------------aslak@lappy:~/arquillian-alpha1${code}
-
9. Re: EJB archive never gets deployed in glassfish embedded
meetoblivion Apr 3, 2010 11:21 PM (in response to aslak)after digging around a bit, it appears that Arquillian didn't like two things about my test case
1. it extended TestCase
2. it was named "SomethingSomethingTestCase"
Removing the extends and change the name to SomethingSomethingTestTest makes it deploy.
-
10. Re: EJB archive never gets deployed in glassfish embedded
meetoblivion Apr 4, 2010 12:17 AM (in response to meetoblivion)alright, so there's something to be said about naming conventions. i'm not sure if it falls under maven or arquillian with this.
Originally, my classes were named (mostly because I was just playing around with it)
SingletonEJBTest (Local interface)
SingletonEJBTestBean (EJB Impl)
SomethingSomethingTestTest (Test case)
wouldn't run. couldn't process injection point
I then renamed everything to be more consistent with real naming conventions
StatelessGreeter (Local interface)
StatelessGreeterBean (EJB Impl)
StatelessGreeterTest (Test case)
then it worked perfectly.