I think the problem is the following: Through the new JEE7/CDI1.1 specifications used in Glassfish 4, CDI automatically scans ALL classes, if there is something to inject.
And thats the point: So CDI tries to inject something, where we want guice to inject it, and CDI fails.
So this error would come up with every application server, that implements JEE7/CDI1.1 - not only Glassfish 4.
The solution for me was, to add a file beans.xml to the META-INF directory for my EJB-project and to the META-INF directory in the gwtp-dispatch-server-guice-1.0.3.jar with the following content:
<?xml version="1.0" encoding="UTF-8"?>
bean-discovery-mode="none">
</beans>
This disables the auto-scanning. But with this JAR there could be problems with application servers that uses JEE6/CDI1.0 ...
To add this file I created a directory META-INF with the beans.xml in the directory where the JAR is and than used the following command:
jar uvf .\gwtp-dispatch-server-guice-1.0.3.jar .\META-INF
(I also added my JAR to this post, so you could easily use this)
Interesting links for this problem:
@Christian Goudreau: Could you (or someone else from the GWTP-team) take a deeper look at this problem and find a suitable solution for GWTP? Maybe this problem would be solved, if GWTP doesnt use javax.inject.* classes.. that would probably the best solution. Alternatively you have to add this
beans.xml and than provide two GWTP-packages.. one for CDI1.0 and one for CDI1.1, because application server with CDI1.0 doesnt work with this
beans.xml ... :( (see
here)