users@glassfish.java.net

Re: JAX-RS on Glassfish 3.1: _at_EJB injection?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 16 Jun 2010 14:43:31 +0200

On Jun 16, 2010, at 2:15 PM, glassfish_at_javadesktop.org wrote:

> Thanks, Paul, for the quick response.
>
> I apologize for the configuration; I thought I had proofed the thing
> better than that. I've been through so many configurations that a
> bad one slipped through the cracks.
>
> I found some other issues as well.
>
> It turns out that looking for resources in the .ear does NOT work.
> That is, once I cleared up the skinny .war problem (there was indeed
> a jar file in the war; there shouldn't have been) then the
> application did not deploy.
>
> I'm attaching another copy which I regard as the copy that I should
> have attached in the first place; again I'm sorry for having put one
> out there that wasn't proofed accurately.
>

But in any case it did show up another issue with CDI where your
previous example did work on 3.0 but not on 3.0.1 and 3.1 b04.

When i deploy the new example you provide i get the following
deployment error:

SEVERE: Exception while loading the app
org.glassfish.deployment.common.DeploymentException: WELD-001201 Error
loading beans.xml java.io.IOException: Cannot open a foreign URL;
this.url=jar:file:/Users/paulsandoz/Downloads/glassfish-bugs%25202/
frobnicator/ear/target/gfdeploy/ljnelson_frobnicator-ear_ear_1.0-
SNAPSHOT/lib/frobnicator-jaxrs-1.0-SNAPSHOT.jar!/META-INF/beans.xml;
foreign.url=jar:file:/Users/paulsandoz/Downloads/glassfish-bugs%25202/
frobnicator/ear/target/gfdeploy/ljnelson_frobnicator-ear_ear_1.0-
SNAPSHOT/lib/frobnicator-jaxrs-1.0-SNAPSHOT.jar!/META-INF/beans.xml
         at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:167)
         at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:
125)
         at
org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:
237)
         at
com
.sun
.enterprise
.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:355)
         at
com
.sun
.enterprise
.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:199)
         at
org
.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:
286)


If i remove the beans.xml then i can deploy and then i get the
following in the logs when i access the URL:

   http://localhost:8080/frobnicator-war/frobnication/frobnicator

INFO: WEB0671: Loading application [ljnelson_frobnicator-ear_ear_1.0-
SNAPSHOT#frobnicator-war-1.0-SNAPSHOT.war] at [/frobnicator-war]
INFO: ljnelson_frobnicator-ear_ear_1.0-SNAPSHOT was successfully
deployed in 2,800 milliseconds.
INFO: Updating configuration from org.apache.felix.fileinstall-
autodeploy-bundles.cfg
INFO: Installed /Users/paulsandoz/Applications/GlassFish/3.1/b04/
glassfishv3/glassfish/modules/autostart/org.apache.felix.fileinstall-
autodeploy-bundles.cfg
INFO: {felix.fileinstall.poll (ms) = 5000, felix.fileinstall.dir = /
Users/paulsandoz/Applications/GlassFish/3.1/b04/glassfishv3/glassfish/
domains/domain1/autodeploy/bundles, felix.fileinstall.debug = -1,
felix.fileinstall.bundles.new.start = true, felix.fileinstall.tmpdir
= /var/folders/vd/vdTgcMYGEb0tkynCTcnFH++++TI/-Tmp-/
fileinstall--6530420101675025480, felix.fileinstall.filter = null}
INFO: GlobalStatsProvider registered
INFO: Initiating Jersey application, version 'Jersey: 1.1.5 01/20/2010
04:04 PM'
INFO: Adding the following classes declared in META-INF/services/
jersey-server-components to the resource configuration:
   class com.sun.jersey.multipart.impl.FormDataMultiPartDispatchProvider
   class com.sun.jersey.multipart.impl.MultiPartConfigProvider
   class com.sun.jersey.multipart.impl.MultiPartReader
   class com.sun.jersey.multipart.impl.MultiPartWriter
INFO: Instantiating the Application class, named
ljnelson.frobnicator.war.Application. The following root resource and
provider classes are registered: [class
ljnelson.frobnicator.jaxrs.FrobnicatorResource]
INFO: Binding the Managed bean class
ljnelson.frobnicator.jaxrs.FrobnicatorResource to
ManagedBeanComponentProvider
SEVERE: The RuntimeException could not be mapped to a response, re-
throwing to the HTTP container
java.lang.IllegalStateException: Dependency injection of junk failed
         at
ljnelson
.frobnicator
.jaxrs.FrobnicatorResource.doFrobnication(FrobnicatorResource.java:54)



The reason being is i do not think @ManagedBean supports 330 injection
rules when CDI is not enabled. So if you modify the resource method to
do:

   @GET
   @Produces("text/plain")
   public String doFrobnication() {
// if (this.junk == null) {
// throw new IllegalStateException("Dependency injection of junk
failed");
// }
     if (this.frobnicator == null) {
       throw new IllegalStateException("Dependency injection of
frobnicator failed");
     }
     return frobnicator.frobnicate();
   }

it works for me.

Paul.


> Thanks again for looking into this.
>
> Best,
> Laird
> [Message sent by forum member 'ljnelson']
>
> http://forums.java.net/jive/thread.jspa?messageID=474474
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>