java-ee-6

Transaction and Rollback in Spring with JPA

醉酒当歌 提交于 2019-12-08 04:58:42
问题 Hi friends of StackOverflow, I do not understand how to roll back I read the documentation of Spring, but I still do not understand. Basically I'm going to persist an object in the db (with primary key manually) all the way here all right, the object is inserted into the db. But when you persist the object again with the same primary key I have caused an exception, and rightly so, a violation of restriction of uniqueness. In this case I would get a Transaction rollback and warn you that there

Java EE 6 WebService and CDI injection

假装没事ソ 提交于 2019-12-08 03:38:12
问题 This is a clarification question I've got from a Java EE 5 migration. I'm currently developing a Java EE 6 web service packed in a WAR file, and I would like to know if it's possible to use CDI on it. I've seen some examples using the @Stateless annotation, which it's not possible to do in a WAR (as far as I know). Current implementation: @WebService public class MyService{ @Inject HelloTeller teller: @WebMethod public String sayHello(){ teller.sayHello(); } } Note: The other approach would

Execute some arbitrary sql in the current transaction in JPA 2.0

情到浓时终转凉″ 提交于 2019-12-08 03:31:12
问题 I am new to JPA 2.0/EclipseLink/Glassfish/JEE6, and have kind of a basic question. I have a DAO in which most of the entities are mapped directly to columns using JPA annotations, so I use the EntityManager, and it works great with no issues. However there are some tables in which I am constructing the SQL statements myself b/c they use oracle-specific functions (spatial), and I want very fine-grained control of the SQL. So I am building it with string concatenation. I would like to be able

Deploy Java web application to root context for glassfish in eclipse?

試著忘記壹切 提交于 2019-12-08 02:58:14
问题 I have an application that I only ever intend to deploy to the the root ('/') context using glassfish. Unlike with tomcat in eclipse, there are no application specific settings when I double-click the server in the server browser. I can go to http://localhost:4848 and accomplish this, but when I redeploy after making a change, eclipse deploys the application to '/myapp'. How can I do this? 回答1: For WAR-only deployments you must do this with a vendor specific configuration file. For Glassfish

Log back not able to find the configuration file (logback.xml)

会有一股神秘感。 提交于 2019-12-08 02:04:09
问题 I'm trying to use logback as the logging framework for my new project. I placed the logback.xml in main\resources\logback.xml . These are the contents of logback.xml file <configuration debug="true"> <appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>D:/logbacklog.log</file> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern> </layout> </appender> <logger name="com.myproject" level="ALL"/> <root

Am I using EJBs properly?

时光毁灭记忆、已成空白 提交于 2019-12-08 02:03:29
问题 I am using a JEE6 stack including JPA 2.0, JSF 2.0, EJB 3.1 etc. The way my architecture is setup is the following: I have JPA annotated DAOs using hibernate as my JPA provider. I have JSF Managed beans which correspond to my facelet/xhtml pages. I have EJBs that handle all of my database requests. My XHTML pages have JSF EL which make calls to my Managed beans. My managed beans contain references to my DAO entities which are managed by EJBs. For example, I have a user entity which is mapped

Weld and Java SE

心已入冬 提交于 2019-12-07 22:01:16
问题 I'm new to Weld and have been trying to get my head around it's concepts. I have a little experience with Spring and nothing with Guice, so I'm pretty much a novice with the DI frameworks. Here's a tutorial that introduce CDI, but in the context of web apps. I'm interested to see how this works in Java SE alone. I have created the following classes, but have no idea how to test the ItemProcessor's execute method with the DefaultItemDao class (or any other alternative) in a Java SE app. Here

How to invoke an EJB 3.1 non-zero-arguments constructor from a servlet?

这一生的挚爱 提交于 2019-12-07 18:41:02
问题 I have a login.java servlet and, as its name says, it provides login facilities to my web application. I'm a newbie and I'm using EJB 3.1 and EE 6. In my LoginBean.java EBJ I have a no-arguments constructor and another one that has some parameters (email, password, etc). At certain point in the servlet code I have the calling to instantiate my EJB: @EJB LoginBean loginBean; I'd like to know if it's possible (and how) to call the other constructor instead of the zero-arguments one. Thanks a

Using HTTP Request.login with JBoss/JAAS

☆樱花仙子☆ 提交于 2019-12-07 18:26:55
问题 I have successfully setup a JBoss security domain, and can authenticate using BASIC authentication (as defined in web.xml). This all works well. I cannot however figure out how to use the http request.login method. The following security domain (from jboss-web.xml) works for BASIC authentication: <jboss-web> <context-root>/myapp</context-root> <security-domain>java:/jaas/myapp-realm</security-domain> </jboss-web> But when I use request.login as follows: public void login() { FacesContext

How can I send http request to another servlet

折月煮酒 提交于 2019-12-07 17:57:29
In my project folder,We have 2 java files under ContextPath/WEB-INF/Classes/*.class names are App1.class and App2.class If I want to Run App1.class ,Just i need to trigger URL in browser. http://localhost:8080/Mapping/App1 in the same way,if you want to trigger App2.class ,use the following link http://localhost:8080/Mapping/App2 I want to trigger App2 from App1 ,means If you trigger App1 with corresponding URL in browser,It will be trigger App2 . I don't want to any response also. How can I do this. can anyone help me. Thanks. I want to trigger App2 from App1,means If you trigger App1 with