This may be a silly question, due to missing 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 our test server and a production server and each one should write to a different DB. How can I overcome this issue?
This is the error:
C:\projects\workspace\MLHRequester\MLHRequester-ejb\src\java\mlh\MLHRequesterBean.java:33: attribute value must be constant @PersistenceContext(unitName=sel) 1 error