java-ee

Hibernate mapping multiple classes to one table using hbm.xml

最后都变了- 提交于 2019-12-23 12:34:06
问题 I am fairly new to Hibernate and need some help with hibernate-mapping. I have 4 different classes which I want to map into one table, of which the primary key consists of attributes from 2 different classes. At the same time, I want to map only selected attributes from each class into a local database. I wish to avoid JPA annotations and define the mapping style in a hbm.xml file instead. How do I do that? Take the following example: public class Tenant implements Serializable { private

org.jboss.weld.exceptions.IllegalArgumentException: WELD-001456: Argument resolvedBean must not be null

懵懂的女人 提交于 2019-12-23 12:29:10
问题 Injecting EJBs into entity listeners is available, since JPA 2.1. WildFly 9.0.2 final however, fails with the following exception. 15:41:12,125 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 149) MSC000001: Failed to start service jboss.persistenceunit."Test.ear/Test-ejb.jar#Test-ejbPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."Test.ear/Test-ejb.jar#Test-ejbPU": javax.persistence.PersistenceException: [PersistenceUnit: Test-ejbPU] Unable to

Unsupported major.minor version 52.0 Error [duplicate]

时间秒杀一切 提交于 2019-12-23 12:23:07
问题 This question already has answers here : Unsupported major.minor version 52.0 [duplicate] (26 answers) Closed 4 years ago . I have codes compiled on JDK 1.8. I created war file and deployed it on Tomcat8 in an Ubuntu server running JRE 1.8. I have this error when opening the main page: java.lang.UnsupportedClassVersionError: com/dash/io/web/bind/HomeCtrl : Unsupported major.minor version 52.0 $ java -versionjava version "1.8.0_45" Java(TM) SE Runtime Environment (build 1.8.0_45-b14) Java

Is it legal to inject a @Stateful into an MDB?

大憨熊 提交于 2019-12-23 12:19:50
问题 Is it legal to inject a @Stateful into an MDB? @Stateful public class InteruptBean implements Interrupt { .... } @MessageDriven(...) public class EchoTrigger implements MessageListener { @EJB Interrupt interrupt; .... } Or better phrased: Can I use a stateful EJB to pass state around in an asynchronous Event Driven Architecture? 回答1: Yes, it's "legal", but it's nonsensical. MDBs instances are pooled like SLSBs. The MDB will become non-functional after the SFSB times out. It might work to

Java EE/JPA way to add new tables/entities to database

别等时光非礼了梦想. 提交于 2019-12-23 12:16:56
问题 I have a mysql database that I want to add the functionality of adding a new table to the database. I could probably easily find the example of the JPQL for this but how would I then automatically generate the entity for this new table so that I could reference it in the rest of my JPA code for updating and deleting from the table I usually reference the entity not the actual table itself. The Entities I have now I've used eclipe to generate from the tables I created. But after deployment we

How to use java ee 6 @Resource annotation

ぐ巨炮叔叔 提交于 2019-12-23 12:09:40
问题 The java ee 6 api has an annotation @Resource with an attribute 'lookup', however, so does the java se 6 api (here). However, since java ee 6 is dependent on java se 6, it seems you can not get at the ee version of the annotation and the 'lookup' attribute. Is this a bug or is there some other way to use this annotation that I am missing. TIA 回答1: Your JDK (and mine) doesn't have the latest version of the javax.annotation.Resource from the JSR-250. To use the latest version during compilation

Serving static content with Jetty/Jersey/Guice

亡梦爱人 提交于 2019-12-23 12:06:43
问题 Similar to another question (cf. Filtering static content Jersey) I want to serve static content from Jetty. There are several similar questions scattered all around the vast Internet, but most of them do not involve Guice, and those that do are completely out of date. I have an existing service that uses Jersey (1.12) and Guice (3) with the following web.xml : <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema

Best way to expose business logic to restful services via @Inject

馋奶兔 提交于 2019-12-23 12:02:19
问题 I read a lot on this topic on SO and the web but there seem to be problems when dealing with older posts... I want to expose my EJB business logic to a rest api / inject an ejb into a jersey resource. Using @EJB works fine but there are people out there suggesting not to use @EJB for local beans. There are different methods to inject beans in services with @Inject. The easiest (to me) seems to be the following: @RequestScoped // This line is important! @Path("service") public class Rest {

Best way to specify fields returned by a Service

偶尔善良 提交于 2019-12-23 11:57:35
问题 We're using Java EE 7 with WildFly 9 to develop the custom backend for a mobile/web application. The backend is a classic 3-tier system, with communication logic (JAX-RS), business logic (Session EJBs) and persistence layer (Hibernate). The business logic layer is composed by a set of services, each defined by an interface and an EJB implementation. Let's suppose public interface IPostService { List<PostDTO> getAllPosts(); } and @Stateless public class PostService implements IPostService {

CDI injection in a JSP

馋奶兔 提交于 2019-12-23 11:46:09
问题 Within a JSP it is possible to use CDI managed beans using EL expressions such as ${myBean.myAttribute}. No problem here. I would like to use "regular injection" (i.e. without using EL expressions) with @Inject in JSP files, for example : <%! @Inject MyBean myBean; %> then later <%= myBean.getMyAttribute() %>. Even if that example can be achieved using EL expressions, some other use cases cannot. This does not seem to be completely supported by app servers: - JBoss 6.0.0, JBoss 6.1.0, Resin 4