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 =
  EntityManager em;

  public Person get(long id)  {
    return em.find(Person.class , id);

public class HelloServlet extends HttpServlet {
  private PersonDao personDao;

  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);

<?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">
      <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&amp;characterEncoding=UTF8" />

<beans xmlns="http://java.sun.com/xml/ns/javaee";>

my environment :


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

Reply via email to