java-ee

Can I use a single war file in multiple environments? Should I?

拥有回忆 提交于 2019-12-29 03:07:33
问题 I have a Java web application at my work and I'd like simplify how we deploy to our DEV, QA, and PROD environments. The application reads in a series of properties at startup, and the properties files are different for dev, qa, and prod. Whenever I want to deploy to a certain environment I drop the environment-specific properties file into my app folder, build the war, and then deploy it to one of the three tomcat 5.5 servers. What I would like to do is have to have a single .war that has the

JSF 2.0: use Enum values for selectOneMenu [duplicate]

南笙酒味 提交于 2019-12-29 02:48:14
问题 This question already has answers here : How to use enum values in f:selectItem(s) (4 answers) Closed 4 years ago . I'm using JSF 2.0 and want to fill a selectOneMenu with the values of my Enum. A simple example: // Sample Enum public enum Gender { MALE("Male"), FEMALE("Female"); private final String label; private Gender(String label) { this.label = label; } public String getLabel() { return this.label; } } Unfortunately, i can't use Seam for my current project, which had a nice <s

How to Save a file at client side using JavaScript?

雨燕双飞 提交于 2019-12-29 00:35:07
问题 I want to save a JSON object to a file at client to persist it for future usage, I have tried following line window.open("data:text/json;charset=utf-8," + escape(JSON.stringify(obj))); and it works!! Problem it asks user the location and name of the file for saving. What I want is I want the user completely unaware of the fact that something is being saved for future use or atleast keep it to minimum possible user clicks. How can I give the file name and location statically in window.open() ?

Filter do not initialize EntityManager

烈酒焚心 提交于 2019-12-28 18:44:07
问题 I trying to use the Open Session in View pattern, but everytime I try to catch the EntityManager in my ManagedBean the entityManager come NULL here is how I'm doing: package filters; // imports.. public class JPAFilter implements Filter { private EntityManagerFactory factory; @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { EntityManager entityManager = this.factory.createEntityManager(); request

How do I access a text file from within my war

有些话、适合烂在心里 提交于 2019-12-28 16:13:02
问题 How do I know what file reference to use to get a file from my WAR. The structure of the WAR is: WAR src - model - web build WebContent META-INF WEB-INF LIB The JSPs are under WebContent, I have put the config.txt file under the WebContent folder and tried to get to it with BufferedReader in = new BufferedReader(new FileReader("WebContent/config.txt")); But this doesn't work. Does anyone know what reference I need to pass or how I can figure it out. 回答1: Check out ServletContext

How do I access a text file from within my war

只愿长相守 提交于 2019-12-28 16:12:04
问题 How do I know what file reference to use to get a file from my WAR. The structure of the WAR is: WAR src - model - web build WebContent META-INF WEB-INF LIB The JSPs are under WebContent, I have put the config.txt file under the WebContent folder and tried to get to it with BufferedReader in = new BufferedReader(new FileReader("WebContent/config.txt")); But this doesn't work. Does anyone know what reference I need to pass or how I can figure it out. 回答1: Check out ServletContext

What will the the order in which filters will be called? [duplicate]

耗尽温柔 提交于 2019-12-28 14:35:12
问题 This question already has answers here : How to define servlet filter order of execution using annotations in WAR (3 answers) Closed 5 years ago . Suppose i have following in my web.xml <filter-mapping> <filter-name>F1</filter-name> <url-pattern>/XYZ/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>F2</filter-name> <url-pattern>/XYZ/abc.do</url-pattern> </filter-mapping> <filter-mapping> <filter-name>F3</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> What will be

Inject CDI managed bean in custom Shiro AuthorizingRealm

时光总嘲笑我的痴心妄想 提交于 2019-12-28 13:23:44
问题 In an app I'm building we're using straight Java 6 EE and JBoss (no Spring, etc), with JPA/Hibernate, JSF, CDI and EJBs. I haven't found many good general security solutions (recommendations are welcome), but the best bet I found is Apache Shiro. However this seems to have a number of shortcomings. Some of which you can read about at Balus C's site: http://balusc.blogspot.com/2013/01/apache-shiro-is-it-ready-for-java-ee-6.html But I've stumbled on another big problem which is already

Inject CDI managed bean in custom Shiro AuthorizingRealm

徘徊边缘 提交于 2019-12-28 13:23:35
问题 In an app I'm building we're using straight Java 6 EE and JBoss (no Spring, etc), with JPA/Hibernate, JSF, CDI and EJBs. I haven't found many good general security solutions (recommendations are welcome), but the best bet I found is Apache Shiro. However this seems to have a number of shortcomings. Some of which you can read about at Balus C's site: http://balusc.blogspot.com/2013/01/apache-shiro-is-it-ready-for-java-ee-6.html But I've stumbled on another big problem which is already

java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind (JBOSS)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-28 12:16:08
问题 I'm using JBoss 4.0.5 GA on Windows 7 with Java version 1.5 (I have to use older java version and a JBoss because I'm working with a legacy system). And when I'm starting the server I get the following error: java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind And I believe this causes many other exceptions: 11:09:26,925 WARN [ServiceController] Problem starting servicejboss.cache:service=TomcatClustering Cache java.lang.NullPointerException at org.jgroups.protocols.FD