Thursday, December 13, 2012

Some several years old log of my attempts to choose dependency injection framework, if I remember correctly. *Nostalgic

Guice + JSF problems:
1. Bean fields resolving
2. Mess up with order of initialization of Eager servlets, Eager beans, Context creation listeners.
3. Field injection doen't works with scala default constructors if injected fields are used immediately.
4. It should be used in conjuction with guice servlet module.
5. Note: Every servlet (or filter) is required to be a @Singleton. If you cannot annotate the class directly, you must bind it using bind(..).in(Singleton.class), separate to the filter() or servlet() rules. //
6. Guice servlet doesn't tolerate filters (at least) in web.xml. They should be moved to configServlets.
7. Guice configureServlets doesn't provide a whole replacement for web.xml
8. serve(...).with(classOf[javax.faces.webapp.FacesServlet]) - won't, because it requires HttpServlet.
9. There is no mention of JSF on Guice referense site. Guice development looks abandoned.
10. The implementation of EL variable resolver (GuiceResolver) is incomplete. It doesn't provide setters etc.

6,7,8 looks like a design flow, i.e. following this design we will have a lot of mess.

CDI troubles.
1. Seems bounded to WebSphere, IBM and proprietary marketing.
2. Problems with eager singletons. There is no alternative to JSF's @ManagedBean(eager=true)
3. To solve 2 I decided to use CODI cause here some guy promises it will help.
4. Got error while initializing of CODI.
"no org.apache.myfaces.extensions.cdi.core.api.provider.BeanManagerProvider in place! Please ensure that you configured the CDI implementation of your choice properly. If your setup is correct, please clear all caches and compiled artifacts. If there is still a problem, try one of the controlled bootstrapping add-ons for the CDI implementation you are using."
After poking for half an hour around found this
without any links of bootstrap addons. Another 15 minutes:
Copypasted one class.
Got some progress but with many exceptions. Seems maven failed to resolve dependencies:
java.lang.ClassNotFoundException: org.eclipse.jetty.servlet.ServletContextHandler$Decorator

It looks tha this class is missing starting from Jetty 7.2. See similar problems
The previous suggestion is wrong the true reason is:
Jetty-server 8.0.1... package resolved dependency to jetty-servlet 3.0.... instead of 8.0...
Jetty-server pom.xml doesn't specify version of jetty-servlet.
I've made maven exclusion. Although m2e seems failing maintain up to date project config. I mean pom.xml doesn't always correspond to runned instance.
java.lang.ClassNotFoundException: javax.validation.Validator
java.lang.ClassNotFoundException: javax.validation.MessageInterpolator

Added validation-api : 1.0.0.GA
java.lang.ClassNotFoundException: javax.persistence.EntityManager

Added javax.persistence from eclipse
Got exceptions that passivating beans must be serializable. Added 'implements Serializable' without analizyng if someone needs cusome serialization.

Got 10 validation exceptions about unsatisfyed injection dependensies.
1. WELD-001408 Unsatisfied dependencies for type ...
Fix: add @Produces methods to some beans.

2. WELD-001435 Normal scoped bean class alehro.{mysite}.background.BackgroundTasksSupervisor is not proxyable because it has no no-args constructor
Fix: add no-args constructors for the sake of internal features of Weld:
Trying Glassfish
Got error while trying to deploy {mySite}:
[#|2012-11-23T01:32:25.422+0300|FINE|glassfish3.1.2|javax.enterprise.resource.webcontainer.jsf.config|_ThreadID=20;_ThreadName=Thread-2;ClassName=com.sun.faces.config.WebConfiguration;MethodName=processJndiEntries;|javax.naming.NamingException: Lookup failed for 'java:comp/env/ClientStateSavingPassword' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory,, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: No object bound to name java:comp/env/ClientStateSavingPassword]|#]

Probably it's because I'm new to JNDI. Solution:
Recreate all from scratch Create project

Another big trouble while starting with Glassfish 3.1.2.
Averybody says that beans.xml can be empty. But it shouldn't. guessnumber oracle's example won't deploy with errors. But my code taken from tutorial
just silently doesn't work. #{helloWord.greetings} doesn't get calculated.
I made a mistake: beans.xml instead of bean.xml. IT WAS STUPID, STUPID - error killed another half a day. guessnumber helped.

The reeason of failed deploy: <listener-class>org.apacheExtras.myfaces.codi.addon.weld.startup.WeldAwareConfigurationListener</listener-class>
in web.xml
Cannot use arquillian with glassfish. Have exception durin deployment of tests:

[#|2012-11-28T23:23:37.468+0400|SEVERE|glassfish3.1.2||_ThreadID=103;_ThreadName=Thread-2;|Exception while loading the app : javax.ejb.CreateException: Initialization failed for Singleton StartUpSettings
javax.ejb.CreateException: Initialization failed for Singleton StartUpSettings
at com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(
Caused by: java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.hash(

No comments:

Post a Comment