ejb-3.0

Consuming local EJB, in the same Container but different ears

一曲冷凌霜 提交于 2019-12-04 05:55:30
I'm triying to consume a Local EJB in the same Glassfish, but different ears. But Glassfish can't found the local EJB or can't consume I read this: According to the JavaEE tutorial, the client of a @Local bean "must run in the same JVM as the enterprise bean it accesses." In the first ear , I have the local Interface inside a jar @Local public interface MyLocalBean { int getNumber(int num3); } In another jar, I have the implementation @Stateless @LocalBean public class MyLocalBeanImpl implements MyLocalBean,Serializable{ public MyLocalBeanImpl() {} public int getNumber(int num3){...... In the

Migrating Hibernate to JPA without annotations

喜夏-厌秋 提交于 2019-12-04 05:11:44
I have a large non-Java EE, JSF-based web app project. Our system is layered (in the source code sense): there's a data model package, building on that is the DAO package. We are using Hibernate's XML configuration mapping exclusively in the DAO package. We really don't want to muddle the data model with annotations, but aren't wedded to Hibernate specifically (except that the mapping is quite complex). I'm strongly considering making a move towards Java EE and building our DAO objects as EJBs. But as we're unwilling to discard Hibernate's XML, this leads me to several questions: Is it

How to get the invoker name in EJB interceptor's lifecycle event method

谁说胖子不能爱 提交于 2019-12-04 04:54:25
I use Java EE 5. I wrote an interceptor for all EJBs with three methods for logging: public class DefaultInterceptor { public static final String PREFIX = "!!!!!!!!!Interceptor:"; @PostConstruct public void postConstruct(InvocationContext ctx) { try { System.out.println(PREFIX + " postConstruct"); } catch (Exception ex) { throw new RuntimeException(ex); } } @PreDestroy public void preDestroy(InvocationContext ctx) { try { System.out.println(PREFIX + " predestroy"); System.out.println(PREFIX + "ctx.preceed=" + ctx.proceed()); } catch (Exception ex) { throw new RuntimeException(ex); } }

Java EE: Proxy cannot be cast to Local Interface, maybe classloading issue?

ε祈祈猫儿з 提交于 2019-12-04 04:00:52
问题 I'm currently "rearranging" my Java EE application, which consists of three components: MyAppInterface: mostly JPA- and JAXB-annotated POJOs, also some EJB Local Interfaces MyAppServer: JPA Facades, EJBs, Jersey resources MyAppWeb: GWT frontend, communicates with MyAppServer via HTTP/REST via loadbalancer Both MyAppServer and MyAppWeb use the classes defined in MyAppInterface; MyAppServer "exports" some of its EJBs via local interfaces in MyAppInterface. MyAppInterface is kind of the API, it

Can a stateless session bean have protected final method?

天涯浪子 提交于 2019-12-04 03:57:55
问题 I have defined a session bean base class. This class is abstract and contains protected final methods. A session implementation class extends the abstract class and defines additional methods. During deployment, Glassfish 3.1.2 server generates an exception stating that method is overridden. abstract class AbstractSessionBean { @PersistenceContext(unitName="primary") private EntityManager em; protected final EntityManager getEntityManager() { return em; } } @Startup @Stateless class

Configurable values to MDB annotations

南笙酒味 提交于 2019-12-04 03:50:48
I'm trying to use this method for receiving mail in our EJB3 app. In short, that means creating an MDB with the following annotations: @MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "mailServer", propertyValue = "imap.company.com"), @ActivationConfigProperty(propertyName = "mailFolder", propertyValue = "INBOX"), @ActivationConfigProperty(propertyName = "storeProtocol", propertyValue = "imap"), @ActivationConfigProperty(propertyName = "debug", propertyValue = "false"), @ActivationConfigProperty(propertyName = "userName", propertyValue = "username"),

call method on server startup [duplicate]

青春壹個敷衍的年華 提交于 2019-12-04 03:03:19
This question already has answers here : Closed 2 years ago . Is there a way to run a method/class only on Tomcat/Wildfly/Glassfish startup? (3 answers) I am trying to call a method when my webapplication starts. The purpose is to kick-off a timer that does some work at defined intervals. how do i call a function helloworld when my jboss 7.1 web application starts up? jagra Other then ContextListeners, you can also have a servlet in web.xml loading on startup: <servlet> <servlet-name>mytask</servlet-name> <servlet-class>servlets.MyTaskServlet</servlet-class> ... <load-on-startup>1</load-on

Long Polling with Java and JBoss

此生再无相见时 提交于 2019-12-04 01:41:52
问题 I'm looking for an example, how to implement a longpoling mechanism in java. I would love to use a stateless EJB. I know that something like that would work: @WebService(serviceName="mywebservice") @Stateless public class MyWebService { @WebMethod public String longPoll() { short ct = 0; while(someCondition == false && ct < 60) { sleep(1000); // 1 sec ct++; } if (someCondition) return "got value"; else return ""; } } Unfortunately i know that this does'nt scale. Can i return in the webmethod

Better Exception Handling in JPA

夙愿已清 提交于 2019-12-03 23:15:21
I used EJB3/JPA when persisting my entities and I am happy on how it is able to manage my DB related task. My only concern is on the exception handling. My sample code when saving entity always comes in this flavor. Most of the tutorials that I read on the net comes in this flavor also with no regards to exception handling. @Stateless public class StudentFacade{ @PersistenceContext(unitName = "MyDBPU") private EntityManager em; public void save(Student student) { em.persist(student); } } But I dont know whats the best way of exception handling in an EJB app? What should be the best way when

Unsatisfied dependencies for type […] with qualifiers [@Default] at injection point (using @Stateful EJB with CDI)

时间秒杀一切 提交于 2019-12-03 23:14:16
I have the following code to manage two kinds of repositories. Both repository classes inherit an interface to allow reinitialization of their resources. public interface CachingRepository { public void invalidateCache(); } Global, application-scoped repo: @Named("globalRepo") @ApplicationScoped public class GlobalRepository implements CachingRepository { private List<Category> categories; ... @Override public void invalidateCache() { categories = null; } ... } Per user, session-scoped repo: @Named("userRepo") @SessionScoped //@Stateful // <- NOTE HERE public class UserRepository implements