I've downloaded hibernate3 beta 4 and hibernate annotations 3 alpha 2, and am trying to compile a very simple "hello world" example. With jdk 1.5 installed, i'm trying to compile a pojo:
package hello;
import javax.ejb.*;
@Stateless
@Remote
public class HelloWorldBean {
public String sayHello() {
return "Hello World!!!";
}
}
and a hibernate utility class:
package hello;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
AnnotationConfiguration configuration = new AnnotationConfiguration();
configuration.addPackage("hello");
configuration.addAnnotatedClass(HelloWorldBean.class);
sessionFactory = configuration.buildSessionFactory();
} catch (Throwable ex) {
// Log exception!
throw new ExceptionInInitializerError(ex);
}
}
public static Session getSession() throws HibernateException {
return sessionFactory.openSession();
}
}
I use the following command:
C:\temp\ejb3>c:\bin\dev\java\jdk_1.5\bin\apt -classpath lib\hibernate3.jar;lib\ejb-3.0-edr1.jar;lib\hibernate-annotations.jar;lib\jboss-j2ee.jar -sourcepath src src\hello\HibernateUtil.java src\hello\HelloWorldBean.java
and get the following results:
src\hello\HelloWorldBean.java:9: cannot find symbol
symbol: class Stateless
@Stateless
^
src\hello\HelloWorldBean.java:10: cannot find symbol
symbol: class Remote
@Remote
^
warning: No annotation processors found but annotations present.
1 warning
src\hello\HelloWorldBean.java:9: cannot find symbol
symbol: class Stateless
@Stateless
^
src\hello\HelloWorldBean.java:10: cannot find symbol
symbol: class Remote
@Remote
^
Note: src\hello\HibernateUtil.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
I read through the documentation on apt, and it seems that I need to specify an instance of AnnotationProcessorFactory. I grepped the hibernate and hibernate-annotations source trees, but found no references; is this a class I need to implement myself, or am I jumping the gun - that such an implementation will be included with hibernate, just not yet? I sincerely appreciate any help or feedback. Thanks,
-erath
|