java-ee

JPA: check whether an entity object has been persisted or not

馋奶兔 提交于 2019-12-22 03:40:33
问题 Is there a general method that can if(entity is persisted before){ entity = entity.merge(); }else{ entity.persist(); } So the method contain above logic is safe everywhere? 回答1: If you need to know is object already in persistence context you should use contains method of EntityManager . Only EntityManager can tell you is entity persisted or not, entity does not have such information. Here you can check javadoc for contains method. if (!em.contains(entity)) { em.persist(entity); } else { em

AspectJ Maven Plugin cannot compile my project

半世苍凉 提交于 2019-12-22 02:47:08
问题 I try to use aspectj maven plugin for compile project with aspectj compiler and then I try to package classes into "war" file. Unfortunately, it doesn't work with following configuration (pom.xml): <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.17</version> <configuration> <skipTests>true</skipTests> </configuration> </plugin> <plugin> <groupId>com.liferay.maven.plugins</groupId> <artifactId>liferay-maven-plugin

How do I access EJB bean when inside a custom Converter [duplicate]

旧街凉风 提交于 2019-12-22 01:31:38
问题 This question already has answers here : How to inject @EJB, @PersistenceContext, @Inject, @Autowired, etc in @FacesConverter? (5 answers) Closed 5 years ago . This converter is called from my JSF. I already register it inside faces-config.xml public class ProjectConverter implements Converter{ @EJB DocumentSBean sBean; @ManagedProperty(value="#{logging}") private Logging log; public ProjectConverter(){ } public Object getAsObject(FacesContext context, UIComponent component, String value) {

How to create an installer for a Java EE Web application in a single installer?

我怕爱的太早我们不能终老 提交于 2019-12-21 23:26:14
问题 Is there a way to create an installer that contains a whole Java EE Web app, and where the final user only has to execute a single installer without the need to install a whole production environment? What I'm trying to do is to save them the installation of JDK + Tomcat, if you have a better solution, please provide it. 回答1: The more simplest way would be to create a compressed file with all files that you need (Tomcat and JDK). Upon unzipping the file, this could run a command to start

Transaction options over Web Service calls

╄→гoц情女王★ 提交于 2019-12-21 22:47:53
问题 Does anyone have any insight into transaction options available over web-service calls? 1.) There are two applications that we have that need transactional communication between them. 2.) App1 calls a web service on app 2 and then makes some changes to its own db. the call on app2 and the changes to it's own db need to be co-ordinated. How can we do this? what are the possible options ? 回答1: You make the webservice call and if its successful do change in your own DB. If changing your own DB

How to handle memory leaks in Java EE?

两盒软妹~` 提交于 2019-12-21 22:36:23
问题 As I've found somewhere on web, following items can lead to memory leaks. For example: ResultSets and Statement objects DataLists Collections Static variables and classes Singletons HttpSession and HttpRequest Managed beans in my JSF application are mostly @ViewScoped , so I thought that after leaving the view, GC has enough informations to release datalists, objects, and so on. But it hasn't or not completelly: I'm just closing hibernate sessions manually (using finally), but that's all. The

Is DB connection pooling all that important?

别说谁变了你拦得住时间么 提交于 2019-12-21 22:04:24
问题 In the Java world it is pretty standard for app servers to pool "expensive" resources, like DB connections. On the other hand in dynamic languages, most stacks have little to do with pooled resources and especially DB connections. E.g. for the popular PHP+MySQL combo, I've rarely seen it used with persistent connection, which can be considered poor-mans pooled connections. If the concept of pooling DB connections is not that widely implemented, does this mean that the performance/scalability

Thread creation in JavaEE EJB/Web containers

痴心易碎 提交于 2019-12-21 22:01:49
问题 I read in Adam Bien's JavaEE night hacks book that while thread creation is prohibited on EJB containers, this is not the case for web containers. He actually creates a thread pool executor in his x-ray probe which runs on Tomcat. I'm a little confused now. While I faced situations in which I had to do manual thread-pool management in an EE app, I can somehow understand why it would be a bad idea to manually create threads in a JavaEE container. However, I don't understand the difference

Thread creation in JavaEE EJB/Web containers

故事扮演 提交于 2019-12-21 21:51:03
问题 I read in Adam Bien's JavaEE night hacks book that while thread creation is prohibited on EJB containers, this is not the case for web containers. He actually creates a thread pool executor in his x-ray probe which runs on Tomcat. I'm a little confused now. While I faced situations in which I had to do manual thread-pool management in an EE app, I can somehow understand why it would be a bad idea to manually create threads in a JavaEE container. However, I don't understand the difference

How conditionally show the content of a div rather than another div in a JSP page?

我们两清 提交于 2019-12-21 21:42:27
问题 I am very new in JSP development and I have the following doubt. If into a JSP page I have 2 div like this: <div id="succes"> <p>SUCCESS</p> </div> <div id="failure"> <p>FAILURE</p> </div> and I have to show only one of these div according to the value of a status variable putted into the Http Session that can have only 2 value: OK and KO . Can I do something like this: <% if(request.getSession(false).getAttribute("status")=="OK"> { %> <div id="succes"> <p>SUCCESS</p> </div> <% } %> <% else {