-
1. Re: AS6 Final ear deploy problem
jaikiran Jan 4, 2011 9:40 AM (in response to brackxm)Michael Brackx wrote:
The war has a listener doing a jndi lookup of an ejb.
The stacktrace shows:
Caused by: javax.naming.NameNotFoundException: DocumentResourceBean not bound at org.jnp.server.NamingServer.getBinding(NamingServer.java:771) [:5.0.5.Final] at org.jnp.server.NamingServer.getBinding(NamingServer.java:779) [:5.0.5.Final] at org.jnp.server.NamingServer.getObject(NamingServer.java:785) [:5.0.5.Final] at org.jnp.server.NamingServer.lookup(NamingServer.java:396) [:5.0.5.Final] at org.jnp.server.NamingServer.lookup(NamingServer.java:399) [:5.0.5.Final] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:728) [:5.0.5.Final] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688) [:5.0.5.Final] at javax.naming.InitialContext.lookup(InitialContext.java:392) [:1.6.0_21] at org.jboss.resteasy.plugins.server.resourcefactory.JndiResourceFactory.getScannableClass(JndiResourceFactory.java:57) [:6.0.0.Final] ... 97 more
I'm not quite sure how RestEasy sets up the dependencies. Can you post some code related to where the DocumentResourceBean is being injected?
-
2. Re: AS6 Final ear deploy problem
brackxm Jan 4, 2011 9:49 AM (in response to brackxm)<context-param><param-name>resteasy.jndi.resources</param-name><param-value>alexandria-ear-${project.version}/DocumentAdminResourceBean/local,alexandria-ear-${project.version}/DocumentResourceBean/local,alexandria-ear-${project.version}/MimeTypeResourceBean/local,alexandria-ear-${project.version}/OwnerResourceBean/local,alexandria-ear-${project.version}/PropertyResourceBean/local,alexandria-ear-${project.version}/SLAResourceBean/local,alexandria-ear-${project.version}/StoreResourceBean/local,alexandria-ear-${project.version}/UserResourceBean/local</param-value></context-param>just configuration in web.xml
<context-param>
<param-name>resteasy.jndi.resources</param-name>
<param-value>
...
alexandria-ear-${project.version}/DocumentResourceBean/local,
...
</param-value>
</context-param>
<listener>
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
-
3. Re: AS6 Final ear deploy problem
jaikiran Jan 4, 2011 9:53 AM (in response to brackxm)Hmm, this is unlike Java EE resource references and appears to be a RestEasy specific way of referencing Java EE resources. I'll have to check with someone who has the RestEasy implementation knowledge to see how this can be handled.
-
4. Re: AS6 Final ear deploy problem
brackxm Jan 4, 2011 9:56 AM (in response to jaikiran)resteasy does a normal lookup
from org.jboss.resteasy.plugins.server.resourcefactory.JndiResourceFactory
public JndiResourceFactory(String jndiName){this.jndiName = jndiName;try{this.ctx = new InitialContext();}catch (NamingException e){throw new RuntimeException(e);}}public void registered(InjectorFactory factory){}public Object createResource(HttpRequest request, HttpResponse response, InjectorFactory factory){try{return ctx.lookup(jndiName);}catch (NamingException e){throw new RuntimeException(e);}}public JndiResourceFactory(String jndiName)
{
this.jndiName = jndiName;
try
{
this.ctx = new InitialContext();
}
catch (NamingException e)
{
throw new RuntimeException(e);
}
}
public Object createResource(HttpRequest request, HttpResponse response, InjectorFactory factory)
{
try
{
return ctx.lookup(jndiName);
}
catch (NamingException e)
{
throw new RuntimeException(e);
}
}
-
5. Re: AS6 Final ear deploy problem
jaikiran Jan 4, 2011 9:59 AM (in response to brackxm)Yep, I checked that code. The lookup is normal, but it doesn't really setup the dependency on the jndi name being available, from what I see. Typically, a Java EE reference to an EJB (or other resource) will create the necessary dependencies so that the lookup doesn't happen until the binding is available.
-
6. Re: AS6 Final ear deploy problem
brackxm Jan 4, 2011 11:06 AM (in response to jaikiran)So what if user code does a lookup in a servlet context listener? Then also no dependency will be set up.
-
7. Re: AS6 Final ear deploy problem
jaikiran Jan 4, 2011 11:13 AM (in response to brackxm)Michael Brackx wrote:
So what if user code does a lookup in a servlet context listener? Then also no dependency will be set up.
If there is no explicit "reference" (via the Java EE provided mechanisms) or some other explicit dependency config, then there's no way the server can guarantee that some random jndi lookup will work in the context listener during deployment.
-
8. Re: AS6 Final ear deploy problem
dunks80 Jan 7, 2011 1:57 PM (in response to jaikiran)Try adding a <depends/> element in your jboss-web.xml something like
<depends>jboss.j2ee:ear=your.ear,jar=yourejb.jar,name=yourejbname,service=EJB3</depends> -
9. Re: AS6 Final ear deploy problem
brackxm Jan 10, 2011 1:10 PM (in response to dunks80)Thanks, that works.