java-ee-7

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

how to get JSON representation of Java Objects in JAX-RS layer in java EE 7?

杀马特。学长 韩版系。学妹 提交于 2019-12-13 02:23:22
问题 We are currently using Java EE 5 and we do something like the following for turning POJO into JSON before sending the response. @GET @Path("/books") @Produces(MediaType.APPLICATION_JSON) public Response getBooks() { List<Book> listOfBooks = getMiscService().getbooks(); String response = "{\"books\":" + gson.toJson(listOfBooks) + "}"; return Response.status(Response.Status.OK).entity(response).build(); } we are using gson API of google. Now that we are restructuring the code to Java EE 7 API

The NetBeans IDE issues unusual compiler errors on “Clean and Build” or external changes.The IDE becomes unaware of the JPA generated static metamodel

限于喜欢 提交于 2019-12-12 12:40:25
问题 I'm completely tired of using the NetBeans IDE 8.x (currently using 8.0.1) for months - it just looks like a hell (seriously). When some external changes are made to the project (especially a Java EE web application - containing hundredth of Java classes in different packages) or an attempt is made to Clean and Build to project (especially to the enterprise module), Background Scanning of Projects is initiated which unusually propagates compile-time errors in almost all classes in which

How to make Concurrency utilities (JSR 236) work in plain non-EE Tomcat 8?

守給你的承諾、 提交于 2019-12-12 12:13:25
问题 My technical stack includes Tomcat 8.5.47 (plain, not EE) Weld 2.4.8.Final (as a reference implementation of CDI 1.2) To be able to use ManagedExecutorService and manage threads more wisely and in a safer manner, I would like to include this dependency org.glassfis:javax.enterprise.concurrent (as a reference implementation of JSR 236 [Concurrency Utilities]) I tried to inject the bean in different ways and into differently-scoped beans (view-, session-, application-based). @Inject private

How to list all JNDI entries in “java:global” namespace

时光总嘲笑我的痴心妄想 提交于 2019-12-12 10:42:57
问题 Goal is to list all the JNDI entries programmatically. new InitialContext().list("java:global") doesn't work. EJB 3.1, Wildfly or Glassfish 4 回答1: I think that the safer way to navigate in JNDI namespace is first to lookup its root and then list its content. I've tried this way in WildFly 8.1.0 and it worked : Context root = (Context) new InitialContext().lookup("java:global"); NamingEnumeration<NameClassPair> names = root.list(""); 来源: https://stackoverflow.com/questions/26463970/how-to-list

Stateless Session Beans Identity with @EJB and @Inject

做~自己de王妃 提交于 2019-12-12 09:07:05
问题 I have been looking into section 3.4.7.2 of the EJB3.2 specifications lately und done some tests. The specifications: @EJB Cart cart 1 ; @EJB Cart cart 2 ; … if (cart1.equals(cart1)) { // this test must return true ...} … if (cart 1 .equals(cart 2 )) { // this test must also return true ...} The equals method always returns true when used to compare references to the same business interface type of the same stateless session bean. The specifications cite explicitly the @EJB Annotation so I

Disable @Alternative classes

a 夏天 提交于 2019-12-12 04:23:11
问题 In my Java EE 7 program, I want to use @Alternative to inject different implementation depending on the context, production or test for example. What I did is to declare my class annotated with @Alternative in my beans.xml file. It works great and my alternative class is injected wherever I want instead of the default one. But I don't know if there is a way to skip this behavior and inject the default class other than removing the declaration in the beans.xml file. Which is not possible

ClassCastException: Lucene40PostingsFormat on Hibernate Search

余生长醉 提交于 2019-12-12 04:20:55
问题 I am trying using Hibernate-Search for add full text search capabilities but when i try deploy the ear proyect on glashfish application server i get the Lucene40PostingsFormat classCastException. here it is the complete server log: Información: HHH000412: Hibernate Core {[WORKING]} Información: HHH000206: hibernate.properties not found Información: HHH000021: Bytecode provider name : javassist Información: HCANN000001: Hibernate Commons Annotations {5.0.1.Final} Información: HHH000400: Using

Extracting the annotation value using java reflection?

邮差的信 提交于 2019-12-11 22:06:37
问题 I have below classes. I autowired someDao in service class as @Autowired SomeDao someDao . I call the logic in service as someDao.getName(2); SomeServiceImpl.java public class SomeServiceImpl{ @Autowired SomeDao someDao //call dao methods using someDao } SomeDao.java public interface SomeDao{ String getName(Int id); } SomeDaoImpl.java public class SomeDaoImpl implements SomeDao{ @CustomAnnotation("somevalue") public String getName(int id){ //logic } } SomeAspect.java @Around("execution(public

Running Java EE 7 on Tomcat 7 in Netbeans

青春壹個敷衍的年華 提交于 2019-12-11 21:36:27
问题 I'm not able to run a Java EE 7 webapp on tomcat 7 while in Eclipse using the same tomcat server it works. I can find my tomcat 7 server if I change the following in my pom.xml: <dependency> <groupId>javax</groupId> <artifactId>javaee-web-api</artifactId> <version>7.0</version> <scope>provided</scope> </dependency> If i change it to 6.0 it works fine in Netbeans but the problem is I'm using Jersey for my Rest API and at client side I use: new Gson().fromJson(resp.readEntity(String.class),