Check out org.wicketstuff:javaee-inject:
https://github.com/wicketstuff/core/wiki/Java-EE-Inject
Regards,
Harald
Am 20.12.2012 18:05, schrieb Romain Manni-Bucau:
The webpage is not a javaee component (not a servlet, listener...). You
would need to update wicket application impl to manage injections in pages
to support it. Not sure it exists out of the box.
Le 20 déc. 2012 17:45, "Lucio Crusca" <lu...@sulweb.org> a écrit :
Hello *,
this document
http://docs.oracle.com/javaee/5/tutorial/doc/bnbrm.html
states that "resource injection using annotations can only be used with
classes that are managed by a Java EE compliant container [...] One
exception
is a request-scoped JavaServer Faces managed bean".
Then it specifies that "You can still use resource injection in a web
application that is not a JavaServer Faces application if you can do it in
an
object that is managed by the container. These objects include servlets and
ServletContextListener objects"
My application is a Wicket app, not JSF, but I'm deploying in Tomee+. As I
understand it, my container should be J2EE compliant, right? However, in:
@Stateless
public class MyPage extends org.apache.wicket.markup.html.WebPage
{
@PersistenceUnit
private EntityManagerFactory emf;
...
emf is always null.
Here is my persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="mercatino-unit">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>mercatinoDatabase</jta-data-source>
<non-jta-data-source>mercatinoDatabaseUnmanaged</non-jta-data-source>
<properties>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.archive.autodetection" value="class, hbm"
/>
<property name="hibernate.show_sql" value="true" />
<property
name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property
name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property
name="hibernate.connection.url">jdbc:mysql://localhost:3306/mydb?zeroDateTimeBehavior=convertToNull&autoReconnect=true</property>
<property name="hibernate.connection.username">myuser</property>
<property name="hibernate.connection.password">secret</property>
<property name="hibernate.c3p0.min_size" value="5" />
<property name="hibernate.c3p0.max_size" value="20" />
<property name="hibernate.c3p0.timeout" value="300" />
<property name="hibernate.c3p0.max_statements" value="50" />
<property name="hibernate.c3p0.idle_test_period" value="3000" />
</properties>
</persistence-unit>
</persistence>
What am I doing wrong?