java-ee

Overriding application server behaviour for loading jsp-api and servlet-api jars in a packaged web application

半世苍凉 提交于 2019-12-13 14:57:10
问题 I have a project built and packaged with a specific version of jsp-apiand servlet-api jar files. Now I want these jars to be loaded when deploying the web project on any application server for example tomcat, WAS, Weblogic etc. The behaviour I have seen on tomcat is that it gives messages that the packaged version of these apis are not loaded along with an offending class. Is there any way I could override these server settings or behaviour? My concern is that letting the default behaviour of

How to set up @Id field properly when database table is already populated JPA

Deadly 提交于 2019-12-13 14:34:21
问题 I am having a single table in my database and I have added the @Id attribute over the field. As strategy I use GenerationType.IDENTITY . This works fine WHEN the database table is not already populated by rows from a SQL script. How can I manage to get it to work when the table already has some rows in it? Because it doesn't work when I am trying to insert entities from my application when it is pre-populated. I am using Derby database for this and eclipselink as implementation. 回答1: Use

CDI injection not resolved inside a Jackson Serializer

最后都变了- 提交于 2019-12-13 14:19:27
问题 I'm trying to inject a @RequestScoped object class in a Jackson's JsonSerializer<> : public class DigitalInputSerializer extends JsonSerializer<DigitalInput> { @Inject private UserRequestResources user; @Override public void serialize(DigitalInput value, JsonGenerator gen, SerializerProvider serializers) throws IOException, JsonProcessingException { gen.writeStartObject(); gen.writeStringField("user", this.user.getMe().getUser()); On the last line, this.user is null . @RequestScoped public

How can I get real system file path from within a WebSocket Endpoint

瘦欲@ 提交于 2019-12-13 13:51:12
问题 While I am within a Servlet Context I can easily get the real system file path by calling on request.getServletContext().getRealPath(UPLOAD_PATH). Please friends how can I do the equivalent from within a WebSocket Endpoint in Java EE 7. Thanks in advance. 回答1: You can get path information from the ServerEndpointConfig#getPath(). The only difference between the results of this method and ServletContext#getRealPath() is that this gives the relateive path; you could just prefix the results of

Session Management in Tomcat

Deadly 提交于 2019-12-13 13:44:25
问题 I have developed a simple web-app with 2 servlets A and B. I have a few doubts related to session management for the web-app by Tomcat. NOTE - I have disabled cookies in my web-browser (Chrome) while accessing the web-app. 1.) When the web-app is first hit, Servlet A gets invoked. Servlet A accesses the session from the request and does a simple sysout of the session hashcode. It then does a sendRedirect to servlet B. [According to my understanding, since this is the first request, Tomcat

ArquillianProxyException instead of ConstrainViolationException in JUnit @Test(expected)

百般思念 提交于 2019-12-13 13:13:37
问题 When using Arquillian to test my (JPA) entities as part of an integration test, everything seems seems to work, except testing for ConstraintViolation s. For example it should not be possible to persist an entity instance which had null values in fields annotated with Bean Validation's @NotNull. Instead of a ConstrainViolationException I get ArquillianProxyException : Unexpected exception, expected<javax.validation.ConstraintViolationException> but was<org.jboss.arquillian.test.spi

javax.el.PropertyNotFoundException: /demo.xhtml @24,55 value=“#{UserBean.favYear3}”: Target Unreachable, identifier 'UserBean' resolved to null [duplicate]

余生长醉 提交于 2019-12-13 12:40:20
问题 This question already has answers here : Identifying and solving javax.el.PropertyNotFoundException: Target Unreachable (14 answers) Closed 3 years ago . I want to have a list box in JSF. I have written a simple code but it does not work. In demo page I see an empty box with out list and in user page I have error. UserBean.java @ManagedBean @SessionScoped public class UserBean implements Serializable{ public String favYear3;//list box public String getFavYear3() { return favYear3; } public

Eclipse deployment descriptor not found

纵然是瞬间 提交于 2019-12-13 12:33:08
问题 I have a dynamic web project created in eclipse. I moved the location of the WebContent folder (to be located within the /src folder). However, the project still thinks that the directory is under /projectName/WEB-INF/ (I know this because when I try to open an element in the deployment descriptor it tells me that that path does not exist (it doesn't exist, but I need to have it point to the new location). How can I point the build to the new location of the WebContent folder (and WEB-INF etc

MyBatis not working with Boolean mapping

给你一囗甜甜゛ 提交于 2019-12-13 12:30:01
问题 I am just trying to map a boolean value with Mybatis, but I am having a problem. Firstly, I'll show you the parts involved: XML File: <resultMap id="destinationTypeMap" type="DestinationTypeDTO"> <result property="destinationTypeId" column="education_destination_type_id" javaType="java.lang.Long" jdbcType="NUMERIC"/> <result property="description" column="description" javaType="java.lang.String" jdbcType="VARCHAR"/> <result property="available" column="is_available" javaType="boolean"

Understanding Persistence.xml in JPA

时光怂恿深爱的人放手 提交于 2019-12-13 12:27:49
问题 I am trying to understand the following things: When I make an EJB project and deploys it to Glassfish do I set up JDBC resources/connection pools at the administrator center of Glassfish or do I add all the different properites for username, password etc in the persistence.xml? I don't understand one bit of that. I do not understand why we have both JDBC resource and JDBC Connection pool either. What is it and what is the difference between them? Could somebody explain me these things or/and