java-ee-6

Transaction and Rollback in Spring with JPA

混江龙づ霸主 提交于 2019-12-07 02:24:28
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 was the problem and continue running the program This is my class: public class ServiceDaoImpl{

Glassfish: Unable to map datasource JNDI name to portable name using glassfish-web.xml

北城余情 提交于 2019-12-07 02:11:57
问题 I'm going slightly insane trying to make a Java EE 6 webapp portable between Glassfish AS 3.x and JBoss AS 6 (and 7 when released). Because each server maps JNDI names for datasources differently, I need to specify an application-private internal name for the datasource in persistence.xml then use glassfish-web.xml or jboss-web.xml (as appropriate) to map that to a real datasource name in the server. The theory is simple (well, for EE): Use internal name in persistence.xml, eg "my-datasource"

Cannot run arquillian tests

耗尽温柔 提交于 2019-12-06 20:58:19
问题 I'm trying to use Arquillian for some unit tests, however I can't find why they fail when deployed using Maven. This is the class test: package com.ndeveloper.spec.test; import javax.inject.Inject; import junit.framework.Assert; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.ArchivePaths; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.ByteArrayAsset; import org.jboss

Could not open JPA EntityManager for transaction; org.hibernate.exception.GenericJDBCException: Could not open connection

我的梦境 提交于 2019-12-06 16:39:52
I am working on spring hibernate with jpa specification when my web application try to connect to database it gives the above exception Caused by: java.sql.SQLException: Access denied for user 'sandip'@'localhost' (using password: YES) , sandip is my linux user. data source set is like....... @Bean public DataSource getDataSource() { DriverManagerDataSource ds = new DriverManagerDataSource( env.getProperty("url")); ds.setDriverClassName(env.getProperty("driver")); ds.setUsername(env.getProperty("user")); ds.setPassword(env.getProperty("pass")); // Set up JPA and transactionManager @Bean public

Faces Navigation not really working in JSF2

送分小仙女□ 提交于 2019-12-06 15:46:19
I'm using JSF 2.0 this is my faces-config.xml <?xml version="1.0" encoding="UTF-8"?> <!-- This file is not required if you don't need any extra configuration. --> <faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"> <navigation-rule> <from-view-id>/pages/test/test.html</from-view-id> <navigation-case> <from-outcome>write</from-outcome> <to-view-id>/pages/test/test-write.html</to-view-id> </navigation-case> <

Am I using EJBs properly?

ぐ巨炮叔叔 提交于 2019-12-06 15:09:50
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 to a db table. I have a user EJB which handles all CRUD operations that return Users. I have a page

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

旧街凉风 提交于 2019-12-06 14:28:18
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 lot. Cheers. You don't want to do that. The one and same servlet is shared among all users, so the EJB is

Execute some arbitrary sql in the current transaction in JPA 2.0

隐身守侯 提交于 2019-12-06 14:06:19
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 to enroll my SQL executions in the current transaction, if there is one already underway. So naturally I

Resteasy and fileupload: get no content-disposition error

本秂侑毒 提交于 2019-12-06 13:50:08
问题 I have a rest resource to which files can be uploaded. @Path("/rest/input") public class InputResourceBean { @POST @Path("{directory: .*}") @Consumes("multipart/form-data") public void post(final String directory, final MultipartFormDataInput input) { } I've used SOAPUI, curl and a HTML form to test this code and for all of them I get the same error: Could find no Content-Disposition header within part 12:55:19,739 WARN [org.jboss.resteasy.core.SynchronousDispatcher] Failed executing POST

javax:javaee-api-6.0 contains non-abstract classes with no method body

纵饮孤独 提交于 2019-12-06 13:01:05
问题 I am fairly new to Java EE and when I look into the compiled code (I could not find the source code for javax:javaee-api-6.0), I notice this class. package javax.servlet; import java.util.EventObject; public class ServletContextEvent extends EventObject { public ServletContextEvent(ServletContext paramServletContext); public ServletContext getServletContext(); } However, the same class in javax:javaee-api-7.0 is this. package javax.servlet; import java.util.EventObject; public class