java-ee

How do i access EJB implementing remote interface in separate web application?

亡梦爱人 提交于 2020-01-02 12:04:09
问题 I am using Netbeans 6.8 and Glassfish v3.0. I created an ejb module and created entity classes from database and then created stateless session bean with remote interface. Say eg. @Remote public interface customerRemote{ public void add(String name, String address); public Customer find(Integer id); } @Stateless public class customerBean implements customerRemote{ //implementations of methods } Then i created a new web application. But now how do i access remote ejb's in my web application. I

writing test case for a DAO on a J2ee Application

随声附和 提交于 2020-01-02 10:08:35
问题 I am trying to write some test cases for my DAO classes in a J2EE applications. Methods in my DAO classes try to get connection to the Database based on a JDBC URL (which is on the app server). So from the front end if I click bunch of stuff and make the DAO trigger it runs fine. However, when I write tests cases for the DAO and the DAO object calls the method then it is not able to get the connection to the database. I think since the JDBC resource is on the App server that is why it is not

Hibernate to persist Dates as long

那年仲夏 提交于 2020-01-02 09:21:43
问题 Is there a way to tell Hibernate that java.util.Date should be persisted as long? I need this to get around the missing millisecond resolution in MySQL. Could you think of any drawbacks of this approach? 回答1: you can do it with a virtual attribute . So you map a long, and add a get/set for a Date object. The setter sets the long value and the getter creates a new Date with the long. And I can't see any drawbacks, only that probably you want to use a Date in your app (that's why I think the

Hibernate to persist Dates as long

ぃ、小莉子 提交于 2020-01-02 09:21:06
问题 Is there a way to tell Hibernate that java.util.Date should be persisted as long? I need this to get around the missing millisecond resolution in MySQL. Could you think of any drawbacks of this approach? 回答1: you can do it with a virtual attribute . So you map a long, and add a get/set for a Date object. The setter sets the long value and the getter creates a new Date with the long. And I can't see any drawbacks, only that probably you want to use a Date in your app (that's why I think the

Custom annotation injection with Jersey 1.x

筅森魡賤 提交于 2020-01-02 08:31:27
问题 I am using jersey 1.9.1. I have rest method like following where Authorization header contained encoded credentials such as username and password and it is parsed in a method and mapped local values. @PUT @Path(SystemConstants.REST_MESSAGE_SENDSMS) @Consumes(MediaType.APPLICATION_JSON) @Produces({MediaType.APPLICATION_JSON}) public Response sendSms(@HeaderParam("Authorization") String authorization, String param) { String[] credentials = ImosUtils.getUserCredentials(authorization); String

slf4j with glassfish is ignoring logback

爷,独闯天下 提交于 2020-01-02 08:28:27
问题 In a java-ee maven project I have I'm wanting to use slf4j with logback, however I believe inclusion of the 'glassfish-embedded-all' artifact from org.glassfish.extras is causing the JDK14LoggerAdapter to be used instead. Removing this artifact causes the logging to work as expected, however causes test failures due to java-ee api issues as described on this question - Testing against Java EE 6 API. The exact pom entry causing the problem, I believe, is: <dependency> <groupId>org.glassfish

EJB example for stateless and stateful beans difference [duplicate]

…衆ロ難τιáo~ 提交于 2020-01-02 08:16:52
问题 This question already has answers here : When to use Stateful session bean over Stateless session bean? (2 answers) Closed 5 years ago . I'm new to EJB, and I'm trying to understand the diference between Stateless and Stateful bean, so I made a simple example to test them. @Stateless public class Service { private int num; public Service(){ } public int getNum() { return num; } public void setNum() { this.num++; } } @WebServlet("/Controller1") public class Controller1 extends HttpServlet {

EJB example for stateless and stateful beans difference [duplicate]

蓝咒 提交于 2020-01-02 08:16:17
问题 This question already has answers here : When to use Stateful session bean over Stateless session bean? (2 answers) Closed 5 years ago . I'm new to EJB, and I'm trying to understand the diference between Stateless and Stateful bean, so I made a simple example to test them. @Stateless public class Service { private int num; public Service(){ } public int getNum() { return num; } public void setNum() { this.num++; } } @WebServlet("/Controller1") public class Controller1 extends HttpServlet {

Spring Auto Components Scanning with Constructor injection

一个人想着一个人 提交于 2020-01-02 07:53:23
问题 I know how to use Auto Components Scanning and Consctuctor Injection individually. http://www.mkyong.com/spring/spring-auto-scanning-components/ http://www.dzone.com/tutorials/java/spring/spring-bean-constructor-injection-1.html Is it possible to use AutoComponent Scanning with Constructor Injection? While using Auto Component Scanning spring framework scans all classes pointed "base-package" and creates an instance of each by invoking each Constructor with no parameter. Lets say how to

How to deal with aggregation and composition in RESTful web service

流过昼夜 提交于 2020-01-02 07:08:26
问题 I have created the following entities, Book , Chapter and Feedback . The Book have many Chapter entities, and it also have many Feedback entities. Since no Chapter entities could live by them self they are part of the Book composition. The same applies to the Feedback entitiy. My question is whether objects that are part of an composition should have their own URIs in a RESTful system? Such as: /books/1/chapters (With POST, DELETE, PUT operations) /books/1/feedback (With POST, DELETE, PUT