-
1. JBossAS 6 Final + Weld + WAR
jaikiran Mar 26, 2011 1:38 AM (in response to hosier.david)1 of 1 people found this helpfulSomeone with more Weld experience might be able to help. Could you post this question in the Weld forum here http://seamframework.org/Community/WeldUsersForum?
-
2. JBossAS 6 Final + Weld + WAR
nickarls Mar 26, 2011 2:04 AM (in response to hosier.david)1 of 1 people found this helpfulShow the signature of the class, the interface and the injection point + all qualifiers (and make sure you use the CDI scope qualifier)
-
3. Re: JBossAS 6 Final + Weld + WAR
hosier.david Mar 26, 2011 2:51 AM (in response to nickarls)Thanks for the response. I tried to do a little more researching of the documentation in light of some of the wording in your response, and nothing jumped out at me. This is how the code stands right now, simplified for brevity's sake.
In a jar named alert-cache-core.jar, I have the interface:
{code}
public interface AlertCache {
public void put(Alert alert);
public void putAll(Collection<Alert> alerts);
public Alert delete(long id);
public Alert find(long id);
public Alert find(String amo, String alert);
public Set<Alert> find(String amo);
public Set<Alert> findAll();
public int size();
public void clear();
}
{code}
Then in a jar named alert-cache-infinispan.jar, I have an Infinispan-based implementation of this interface.
{code}
@Singleton
public class InfinispanAlertCache implements AlertCache {
public InfinispanAlertCache() {
// initialize some stuff
}
}
{code}
And finally, I have the class into which I want to inject the above in a jar named alert-service.jar.
{code}
public class NxApiAlertService implements AlertService,NxConnectionListener,NxServiceListener {
private @Inject AlertCache alertCache;
public NxApiAlertService() {
log.info("!!!Creating NxApiAlertService");
}
}
{code}
I have confirmed that each of these jar files has a beans.xml. I also have a beans.xml in my WAR file's WEB-INF directory, although it's unclear to me whether or not I really need that based on the reading I've done. This NxApiAlertService class gets instantiated during server startup, and I want the cache implementation to be loosely coupled and injected at startup. I'm familiar with the older -jboss-beans.xml style of doing beans in JBoss, but I was hoping to go this route instead to try out something new. I feel like I'm following all the rules necessary to make something a managed bean as specified in the Weld documentation. One thought was that server just hadn't deployed my alert-cache* classes yet, and so it's potentially just a lifecycle thing. I read up on the Observers thinking that may be the solution, but I wasn't so sure after reading. My reading of the documentation seems to indicate that I don't need any qualifiers or scope because it will choose some defaults, so I was uncertain what you meant by "use the CDI scope qualifier". I researched more on scope and thought adding the Singleton to my cache impl would help, but it did not.
Do you need anything else from me? Shall I move this to the Seam forum as was previoiusly suggested? Thanks again for your response.
-
4. Re: JBossAS 6 Final + Weld + WAR
nickarls Mar 26, 2011 3:36 AM (in response to hosier.david)I don't see anything immediately wrong. Tried raising log levels so you see which beans are regged? Try sticking them all temporarily in the war classes to see if packaging has anything to do with it?
-
5. Re: JBossAS 6 Final + Weld + WAR
hosier.david Mar 26, 2011 5:47 AM (in response to nickarls)Ok, thank you. I'm being dumb and did not turn up the logging. Welcome to JBoss 101. I guess I will assume it does so for good reason, but it appears Weld just happily ignores errors while deploying beans. When I turned org.jboss up to DEBUG, I could then see a ClassNotFoundException coming from the attempt to deploy my InfinispanAlertCache implementation. Do you happen to know why Weld would only log such an error at DEBUG level? That seems pretty major. Perhaps it's just an oversight. I will fix my dependency problems, and when it's working I'll come back and accept your answer. Thanks again.
-
6. Re: JBossAS 6 Final + Weld + WAR
hosier.david Mar 26, 2011 6:31 AM (in response to nickarls)So I'm just at the point of struggling to get the infinispan query stuff working in JBoss 6. Now that I've deployed those jars to the server, I get other errors preventing my bean from deploying. I'll just jump over to that forum if I get stuck. Thanks for steering me in the right direction.
-
7. Re: JBossAS 6 Final + Weld + WAR
nickarls Mar 27, 2011 3:27 PM (in response to hosier.david)CNFE sounds a bit strange, yes. If the class had no no-args constructor on a normal scoped bean, it might be considered a non-CDI-bean and just ignored with a debug level info but how can it not find some class?
-
8. Re: JBossAS 6 Final + Weld + WAR
hosier.david Mar 27, 2011 3:40 PM (in response to nickarls)My beans are all fine. The CNFE was coming from the fact that I am setting up a Lucene index on my Infinispan cache in my bean's constructor, and I forgot to deploy all the necessary jars. I can see from the logging that the server was definitely attempting to deploy my bean, it just fails because of the missing jars. But I guess I would have expected some kind of error from Weld to have been noisily propagated to the log file and not buried in a DEBUG message. Because the *real* error was hidden in a DEBUG message, I was sent on a wild goose chase trying to figure out if I was doing something wrong, when I should have been shown the CNFE and would have realized I was missing jars right from the very first failure. Now I'm just stuck trying to get the Infinispan query module and it's depednent jars to play nicely in JBoss, but that's for another thread.
-
9. Re: JBossAS 6 Final + Weld + WAR
nickarls Mar 27, 2011 3:42 PM (in response to hosier.david)Please file a WELD JIRA if you can isolate an reasonably small example so others don't have to share your pain ;-)
-
10. Re: JBossAS 6 Final + Weld + WAR
hosier.david Mar 29, 2011 11:54 AM (in response to nickarls)It should be very straight-forward to create an example. I'll try to do this as soon as I get a chance.