java-ee

Why does getRealPath() return null when deployed with a .war file? [duplicate]

廉价感情. 提交于 2019-12-17 04:33:07
问题 This question already has answers here : What does servletcontext.getRealPath(“/”) mean and when should I use it (4 answers) Closed last year . getRealPath() is returning the actual path in the local system, but returns null when deployed with a .war file. <%@ page import="java.io.*" %> <%@ page contentType="text/html;charset=ISO-8859-1" %> <% int iLf = 10; char cLf = (char)iLf; String a= application.getResource("/"); //String myfile = application.getRealPath("/")+ "generate.xml"; //String

Could not serialize object cause of HibernateProxy

巧了我就是萌 提交于 2019-12-17 03:55:50
问题 I am getting the following error response from the server. HTTP Status 500 - type Exception report message descriptionThe server encountered an internal error () that prevented it from fulfilling this request. exception javax.servlet.ServletException: java.lang.UnsupportedOperationException: Attempted to serialize java.lang.Class: org.hibernate.proxy.HibernateProxy. Forgot to register a type adapter? root cause java.lang.UnsupportedOperationException: Attempted to serialize java.lang.Class:

EJB 3.1 @LocalBean vs no annotation

穿精又带淫゛_ 提交于 2019-12-17 03:23:11
问题 I understand the difference between local view, remote view and no-interface view. I just don't understand what is the difference between "no view" (no annotation) and no-interface view. And also why should I annotate my interface with @Local ? What if I don't annotate the interface in at all, is there a difference? 回答1: The rules are (from memory): Bean has a @LocalBean annotation -> bean has a no-interface view Bean has a @Local annotation -> bean has a local view Bean has a @Remote

Making Distinctions Between Different Kinds of JSF Managed-Beans

我是研究僧i 提交于 2019-12-17 02:54:11
问题 I recently read this article from Neil Griffin Making Distinctions Between Different Kinds of JSF Managed-Beans and it got me thinking about the distinction between different beans in my own application. To quickly summarise the gist: Model Managed-Bean: This type of managed-bean participates in the "Model" concern of the MVC design pattern. When you see the word "model" -- think DATA. A JSF model-bean should be a POJO that follows the JavaBean design pattern with getters/setters

Should I use @EJB or @Inject

a 夏天 提交于 2019-12-17 02:52:20
问题 I have found this question: What is the difference between @Inject and @EJB but I did not get any wiser. I have not done Java EE before nor do I have experience with dependency injection so I do not understand what I should use? Is @EJB an old way of injecting? Is the injection done by the EJB container when using this annotation while using @Inject use the new CDI framework? Is that the difference and should I be using @Inject instead of @EJB if this is the case? 回答1: The @EJB is used to

How to read request.getInputStream() multiple times

我是研究僧i 提交于 2019-12-17 02:31:25
问题 I have this code: @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { logger.info("Filter start..."); HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletResponse httpResponse = (HttpServletResponse) response; String ba = getBaId(getBody(httpRequest)); if (ba == null) { logger.error("Wrong XML"); httpResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST); } else { if (!clients

How to read request.getInputStream() multiple times

吃可爱长大的小学妹 提交于 2019-12-17 02:30:35
问题 I have this code: @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { logger.info("Filter start..."); HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletResponse httpResponse = (HttpServletResponse) response; String ba = getBaId(getBody(httpRequest)); if (ba == null) { logger.error("Wrong XML"); httpResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST); } else { if (!clients

Choosing a Java Web Framework now? [closed]

核能气质少年 提交于 2019-12-17 02:26:18
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 8 years ago . we are in the planning stage of migrating a large website which is built on a custom developed mvc framework to a java based web

Maven2: Best practice for Enterprise Project (EAR file)

一个人想着一个人 提交于 2019-12-17 02:17:15
问题 I am just switching from Ant to Maven and am trying to figure out the best practice to set up a EAR file based Enterprise project? Let's say I want to create a pretty standard project with a jar file for the EJBs, a WAR file for the Web tier and the encapsulating EAR file, with the corresponding deployment descriptors. How would I go about it? Create the project with archetypeArtifactId=maven-archetype-webapp as with a war file, and extend from there? What is the best project structure (and

JSF request scoped bean keeps recreating new Stateful session beans on every request?

断了今生、忘了曾经 提交于 2019-12-16 20:13:58
问题 I'm building my first Java EE application using JSF, PrimeFaces, Glassfish and Netbeans. Because I'm new, it's possible I'm approaching the core problem wrong. Core problem: I want to maintain user's information securely. There seems to be conflicting ideas on whether it should be maintained in a JSF session bean or a stateful session EJB. I'm trying to use a stateful session EJB because it is more secure that way. The problem is that my application seems to be creating multiple instances of