This might be a dumb question due to a lack of some understanding of java, but I have this code:
@Stateless @WebService public class MLHRequesterBean implements MLHRequesterBeanRemote { private final static String sel = "MLHRequesterPU" + (isProduction()? " " : "-dev"); public static boolean isProduction(){ try { if (Inet4Address.getLocalHost().getHostName().equalsIgnoreCase("ironman")) { return true; } } catch (UnknownHostException ex) {} return false; } @PersistenceContext(unitName=sel) ...
Why is sel not considered a constant? We have a test server and a production server, and each of them should write to a different database. How can I solve this problem?
This is mistake:
C: \ projects \ workspace \ MLHRequester \ MLHRequester-ejb \ src \ java \ mlh \ MLHRequesterBean.java: 33: attribute value must be constant @PersistenceContext (UnitName = Selectivity) 1 error
source share