java-ee

Intercept another web application requests

你。 提交于 2020-01-06 06:17:20
问题 I have 2 ear application (Primary and Proxy). The primary application is build using Servlet JSP MVC. Now, I want to create a Proxy application (ear app) to listen and log all the requests and response going and coming from the Primary application. I cannot modify the Primary application, have only control on the Proxy application that I am writing. Can I write a simple Servlet Filter to listen all the requests on my primary application. Note: Both the applications will run in WAS, may be

Create custom JPA query function

妖精的绣舞 提交于 2020-01-06 05:46:04
问题 I'm using EclipseLink. Is is possible to use custom query function like: Select u from User u where my_function(u.name) = my_function(:param) I would like to retrive entities based on custom created slug names rather than id (and remove any id's from url) 回答1: If you implement it as function in database then it is possible, otherwise not (because it translates to SQL in the end anyway calls to method implemented with Java are not possible). Keyword func is used to call database function:

How to enable assertion for a Java EE project in NetBeans?

前提是你 提交于 2020-01-06 05:30:14
问题 I'd like Java assertions to be enabled for Java EE code which is running on Payara 4.1.1.172 and is deployed from within NetBeans 8.2. I tried to specify exec.args=-ea in the NetBeans Action "Debug project", but that doesn't help. https://stackoverflow.com/a/14710564/1797006 suggests to configure the JVM options in the server settings, but those aren't available because of NetBeans 8.2 or the Glassfish server layout. 回答1: You need to modify the settings in the Payara Server configuration,

How can I use the J2EE Timer Service API in the Servlet startup code?

馋奶兔 提交于 2020-01-06 05:27:27
问题 For a background job which I would like to run in a J2EE container, I found the suggestion to create a startup servlet and use the Timer Service API to create a managed Timer (in the answers for What tools are there for timed batch processes in J2EE?). To create a timer, I need a context which implements the timer API. (Example) In the Servlet class, I override the init method, but it has only access to a ServletContext, but not to a SessionContext. A ServletContext does not have methods to

Verifying if request source comes from Internet or Intranet

扶醉桌前 提交于 2020-01-06 04:12:12
问题 I have application running on Internet which contains some admin module also. I don't want to let the user access my admin module on Internet. I want that request coming from intranet can access admin module. Is there any way to control this without developing a new application which serves admin component? 回答1: If you are using servlets, you could add a filter and analyze the client IP address (see this question). Be aware that there is no guarantee you will determine the correct address by

EJB3.1 Timer cancel issue

三世轮回 提交于 2020-01-06 03:58:25
问题 I have a problem with EJB3.1 Timer service. I find this issue quite strange! I have a stateless session bean like below deployed on JBoss7.1.1 application server. import javax.annotation.Resource; import javax.ejb.Local; import javax.ejb.Remote; import javax.ejb.Stateless; import javax.ejb.Timeout; import javax.ejb.Timer; import javax.ejb.TimerService; import javax.interceptor.Interceptors; @Stateless @Local(HelloUserLocal.class) @Remote(HelloUserRemote.class) public class HelloUserBean

java.sql.SQLException: error occurred during batching: batch must be either executed or cleared

拟墨画扇 提交于 2020-01-06 03:50:23
问题 I am getting java.sql.SQLException: error occurred during batching: batch must be either executed or cleared in the below code. I want to execute two queries. String sql_query="insert into m_status values(20,'test');select * from m_user"; String query1 = sql_query.toUpperCase(); String[] results = query1.split(";"); stmt = conn1.createStatement(); conn1.setAutoCommit(false); for (int i = 0; i < results.length; i++) { if(results[i].startsWith("SELECT")) { rs1 = stmt.executeQuery(results[i]); }

Hibernate Ant Tools

那年仲夏 提交于 2020-01-06 03:40:26
问题 I have used hibernate ant tool to generate hibernate pojo classes with annotations. What is the POJO class generation strategy from existing tables using ANT SCRIPT? I figured out the answer and I'm posting it. 回答1: If table column is having not null constraint, then a property related to that column in generated class will be of primitive type. If table column is not having not null constraint, then a property related to that column in generated class will be of java.lang.X type. (X == any

Why Hibernate Search takes so much time to build a Index?

时光怂恿深爱的人放手 提交于 2020-01-06 03:04:07
问题 I am trying to build a lucene index through hibernate search FullTextSession.createIndexer().startAndWait() but even for very little test data it won't end. Here is my code @Component("hibernateSearchMassIndexerService") public class HibernateSearchMassIndexerServiceImpl implements HibernateSearchMassIndexerService { public static final Logger log = LoggerFactory .getLogger(HibernateSearchMassIndexerServiceImpl.class); @Override @Transactional public void buildSearchIndex(Session session) {

Invalidate Session at all Cluster Weblogic

半世苍凉 提交于 2020-01-06 02:56:05
问题 i try to save user session in a hashmap on every cluster. and when i need to invalidate it, i will take specified session id. and invalidate it where the session created with normal way to invalidate session. public class SessionListener implements HttpSessionListener { public HashMap<String, HttpSession> sessionHolder = new HashMap<String, HttpSession>(); @Override public void sessionCreated(HttpSessionEvent se) { sessionHolder.put(se.getSession().getId(), se.getSession()); } public void