Hontvári József wrote: > > BTW , Is META-INF/beans.xml defined in the JavaEE spec ? What's the > relation with beans.xml and resin-web.xml ? > > yes, beans.xml is part of JSR-299. > resin-web.xml has the same role as web.xml, it is processed by Resin > after web.xml. You can place resin specific / non-standard > configuration into resin-web.xml. beans.xml is also an important marker because it tells Resin which jars to scan for CanDI beans. So even if it's empty, it's an important file.
-- Scott > > > smallufo írta: >> I am new to CanDI , I want to migrate my spring app to JavaEE6 , but >> having a lot of troubles in Resin (4.0.5) CanDI : >> >> There is no working sample in the resin site , most are outdated ... >> >> Here is my very basic sample , just JPA 2 and a Servlet : >> >> public interface PersonDao { >> public Person get(long id); >> } >> >> public class PersonDaoImpl implements PersonDao , Serializable { >> @PersistenceContext(unitName = "mining", type = >> PersistenceContextType.EXTENDED) >> EntityManager em; >> >> @Override >> public Person get(long id) { >> return em.find(Person.class , id); >> } >> } >> >> public class HelloServlet extends HttpServlet { >> @javax.inject.Inject >> private PersonDao personDao; >> >> @Override >> protected void doGet(HttpServletRequest hreq, HttpServletResponse >> hres) throws ServletException, IOException { >> PrintWriter out = hres.getWriter(); >> System.out.println("personDao = " + personDao); // outputs Null >> Person p = personDao.get(1L); //NPE , personDao is not injected >> out.println("Hello, world! , person = " + p); >> out.close(); >> } >> } >> >> persistence.xml >> <?xml version="1.0" encoding="UTF-8"?> >> <persistence xmlns="http://java.sun.com/xml/ns/persistence" >> version="1.0"> >> >> <persistence-unit name="mining" transaction-type="RESOURCE_LOCAL"> >> <provider>org.hibernate.ejb.HibernatePersistence</provider> >> <class>foo.Person</class> >> <properties> >> <property name="hibernate.dialect" >> value="org.hibernate.dialect.MySQLDialect" /> >> <property name="hibernate.cache.provider_class" >> value="org.hibernate.cache.EhCacheProvider" /> >> <property name="hibernate.show_sql" value="true" /> >> <property name="hibernate.format_sql" value="true" /> >> >> <property name="javax.persistence.jdbc.driver" >> value="com.mysql.jdbc.Driver" /> >> <property name="javax.persistence.jdbc.user" value="adm" /> >> <property name="javax.persistence.jdbc.password" value="pwd" /> >> <property name="javax.persistence.jdbc.url" >> value="jdbc:mysql://db/mining?useUnicode=true&characterEncoding=UTF8" >> /> >> </properties> >> </persistence-unit> >> </persistence> >> >> META-INF/beans.xml >> <beans xmlns="http://java.sun.com/xml/ns/javaee"> >> </beans> >> >> >> my environment : >> >> <dependency> >> <groupId>org.hibernate</groupId> >> <artifactId>hibernate-core</artifactId> >> <version>3.5.0-CR-2</version> >> </dependency> >> <dependency> >> <groupId>org.hibernate.javax.persistence</groupId> >> <artifactId>hibernate-jpa-2.0-api</artifactId> >> <version>1.0.0-CR-1</version> >> <scope>provided</scope> >> </dependency> >> >> >> This is a very basic Dao + JPA pattern , but I cannot find how to >> inject the PersonDaoImpl to the Dao in the Servlet , >> Can somebody give me a hint ? Thanks in advenced ! >> >> BTW , Is META-INF/beans.xml defined in the JavaEE spec ? What's the >> relation with beans.xml and resin-web.xml ? >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> resin-interest mailing list >> resin-interest@caucho.com >> http://maillist.caucho.com/mailman/listinfo/resin-interest >> > > ------------------------------------------------------------------------ > > _______________________________________________ > resin-interest mailing list > resin-interest@caucho.com > http://maillist.caucho.com/mailman/listinfo/resin-interest > _______________________________________________ resin-interest mailing list resin-interest@caucho.com http://maillist.caucho.com/mailman/listinfo/resin-interest