java-ee

How do I use Glass fish server with eclipse luna for Java EE?

蹲街弑〆低调 提交于 2019-12-19 22:00:43
问题 I thought that Glass Fish server came with Eclipse when you install the Glass fish tools for Java EE. However, after trying to install the Glass fish tools, it said there was nothing to update. Ok, so when I try to start the server, it asks for the server root. Does the glass fish server come with Eclipse? If so, how would I locate it? Or if I need to install it on my computer, which I did, why does it not recognize the folder where I installed Glass fish server as a valid installation of

JPA: Weird error when I try to persist an object

早过忘川 提交于 2019-12-19 20:44:08
问题 I got a OneToMany relation between User and Group Group.java @Entity public class Group { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String groupid; @ManyToOne @JoinColumn(name="USER_FK") private User user; ... } User.java @Entity public class User { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String userId; private String password; private String fname; private String lname; @OneToMany(mappedBy="user", cascade=CascadeType.ALL

Why is “public” not allowed for properties in JPA entities?

有些话、适合烂在心里 提交于 2019-12-19 18:24:49
问题 The JPA 2.0 specification says on page 22: The instance variables of a class must be private, protected, or package visibility independent of whether field access or property access is used. When property access is used, the property accessor methods must be public or protected. Why isn't public access allowed? 回答1: With public fields, there would be no way for proxying to work reliably -- if someone accesses a field directly, then there is no simple way for the persistence framework to

How to access JNDI data source defined in weblogic 10.3.6

自作多情 提交于 2019-12-19 16:18:11
问题 I have created a JNDI data-source using my weblogic console but I am not able to access the object from my web application. Below are the details In weblogic 10.3.6, I have given the JNDI name for datasource as : jdbc/mydb To get DB connection from my web application I have written this code in my web application: Context initContext = new InitialContext(); DataSource ds = (DataSource)initContext.lookup("java:/comp/env/jdbc/mydb"); jndiConnection = ds.getConnection(); Earlier I was using

How to print a Struts2 ActionMessage in a JavaScript alert box

旧巷老猫 提交于 2019-12-19 11:54:15
问题 I have one Action class which is sending an action message using addActionMessage(); . I want to display that message in my JSP using a JavaScript alert box. I've tried with alert ('<s:actionmessage/>'); but it is showing unterminated string literal . 回答1: The <s:actionmessage/> tag generates an HTML like the following: <ul class="actionMessage"> <li> <span> Your Message 1 </span> </li> <li> <span> Your Message 2, and so on... </span> </li> </ul> This will break your javascript function with

I want to add a header to Http Response, based on the Http Status code in Spring MVC

爱⌒轻易说出口 提交于 2019-12-19 11:53:39
问题 I have to add Cache-Control headers to a rest API designed in Spring MVC, based on the Http Response code. If response code is 200, add the header else dont add. I dont want the client to cache the response, in case it is not 200. It's not possible in filters/interceptors, as the response is already committed from controller, so can't change response state. Is there any other way to add header after controller? 回答1: You can extend org.springframework.web.filter.OncePerRequestFilter to add

no read permission on 'MSysObjects'

可紊 提交于 2019-12-19 11:05:52
问题 I want to use MS Access in my project. I try to integrate with this code. rs = st.executeQuery("SELECT name FROM MSysObjects where database <> ''"); By using this I try to get all the table names from MSysObjects . But I get an error: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Record(s) cannot be read; no read permission on 'MSysObjects'. Please help me resolve this error. 回答1: Give the Admin user read ( SELECT ) permission on MSysObjects . In an Access session, open the

Determining which test cases covered a method

若如初见. 提交于 2019-12-19 10:43:10
问题 The current project I'm working on requires me to write a tool which runs functional tests on a web application, and outputs method coverage data, recording which test case traversed which method. Details: The web application under test will be a Java EE application running in a servlet container (eg. Tomcat). The functional tests will be written in Selenium using JUnit. Some methods will be annotated so that they will be instrumented prior to deployement into the test enviornment. Once the

How to access file in the static resources(WEB-INF) folder from the referencing java project?

久未见 提交于 2019-12-19 10:19:27
问题 I have a web application, that contains a configuration xml file for one of my application services that is exposed as spring bean. Also I have a standalone java application(which references my web app project from its pom.xml) in the same workspace, that runs tests using Spring TestContext framework and one of the tests checks the configuration of that XML file. However I have a problem with accessing this xml file from the standalone app: Before setting-up the test, in my previous

javax.naming.NameNotFoundException: jms

醉酒当歌 提交于 2019-12-19 10:16:44
问题 I have this really simple code (Glassfish 3.1.2) : Context ic = new InitialContext(); ConnectionFactory connectionFactory = (ConnectionFactory) ic.lookup("jms/ConnectionFactory"); But the second line throws an Exception : SEVERE: javax.naming.NamingException: Lookup failed for 'jms/ConnectionFactory' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl,