java-ee

Is it possible to define a servlet filter for a stateless ejb webservice, on GlassFish 3.1

你。 提交于 2019-12-20 02:39:18
问题 I want to export a Web-Service which was implemented as a stateless EJB. I know that these WebServices were hanled by the EJB Container, when they are annotated as @Stateless + @Webservice. Is it possible to route all incoming requests to this Webservice through a Servlet-Filter. The Servlet-Filter works when my Java-Class is annotated @Stateful and @Webservice, or just @Webservice. But not in conjunction with @Stateless. Anyway to register a Servlet Filter for an EJB Webservice? Many thanks!

MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 465; timeout -1

喜欢而已 提交于 2019-12-20 02:38:38
问题 I need to send an email from my application using Gmail as the SMTP server. This is my mail connector class and I have set values in a separate property file public class EmailConnector { public static Session sessionCreate() { final String fromEmail = ConfigurationManager.getInstance().getProperty(EmailConfig.SENDER_EMAIL.toString()); final String password = ConfigurationManager.getInstance().getProperty(EmailConfig.SENDER_PASSWORD.toString()); Properties props = new Properties(); props.put(

Java more than one DB connection in UserTransaction

£可爱£侵袭症+ 提交于 2019-12-20 02:34:22
问题 static void clean() throws Exception { final UserTransaction tx = InitialContext.doLookup("UserTransaction"); tx.begin(); try { final DataSource ds = InitialContext.doLookup(Databases.ADMIN); Connection connection1 = ds.getConnection(); Connection connection2 = ds.getConnection(); PreparedStatement st1 = connection1.prepareStatement("XXX delete records XXX"); // delete data PreparedStatement st2 = connection2.prepareStatement("XXX insert records XXX"); // insert new data that is same primary

Why request which start with “/WEB-INF” cannot be mapped to a servlet/filter

一个人想着一个人 提交于 2019-12-20 02:28:36
问题 [context] tomcat 7 - java 1.7 Hey everyone; I'm facing with stranges working. In my web.xml file, I mapped request like this : web.xml <web-app> <filter> <filter-name>filter</filter-name> <filter-class>demo.DemoFilter</filter-class> </filter> <filter-mapping> <filter-name>filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet> <servlet-name>Servlet</servlet-name> <servlet-class>demo.DemoServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>Servlet</servlet

JAXB Marshaller : StringWriter output has a truncated tag value

两盒软妹~` 提交于 2019-12-20 02:28:32
问题 I want to marshall a java object to xml string. Therefore I have been given a schema from which I generate the JAXB classes. There is a set method(corresponding to an element of type hexbinary in schema) where I have to set a string. The string size is about 2566. After setting data into the object via the setter methods, I call the marshaller passing stringWriter argument. But on printing stringWriter, I see that it is truncated. I don't see the entire 2566 characters. What is wrong? Any

Automatic EJB Timer on Glassfish Server not triggering

落爺英雄遲暮 提交于 2019-12-20 01:59:13
问题 So I'm running a Java EAR application on a Glassfish 3.1. I created a stateless session bean with a single annotated timer function in my EJB Module. I don't have the exact code but it looks something like this: @Stateless public class SessionTimerBean { public SessionTimerBean(){ System.out.println("Constructor Called"); } @Schedule(second="*/10", minute="*", hour="*") public void scheduleTimer(final Timer t) { System.out.println("Timer Called"); } } When I launch Glassfish the debug info

How to get file system path of the context root of any application

风格不统一 提交于 2019-12-20 01:58:30
问题 I am working on web application.I invoke on my jsp request.getContextPath() , but strangely I got address /streetshop . Then I am appending some path as request.getContextPath() + "abc" and create folder. Then its creating folder in D:// instead of my webapplication folder. Please, tell me, I want to upload an image in put it in my web-application root/images/images.gif . 回答1: You mix things up here. HttpServletRequest.getContextPath() returns your web application root path. In your example

javax.faces.FacesException: java.lang.ClassCastException: java.lang.String cannot be cast to javax.faces.component.UIComponent

筅森魡賤 提交于 2019-12-20 01:34:53
问题 My Java EE web application is working fine with Glassfish 2.1. Now I want to migrate to Glassfish 3.1.1 I have followed the modifications provided here my dependencies for richfaces are as follow:- <dependency> <groupId>org.richfaces.framework</groupId> <artifactId>richfaces-api</artifactId> <version>3.3.3.Final</version> </dependency> <dependency> <groupId>org.richfaces.framework</groupId> <artifactId>richfaces-impl-jsf2</artifactId> <version>3.3.3.Final</version> </dependency> <dependency>

Determine Which Application Server our application is deployed to?

假装没事ソ 提交于 2019-12-20 01:11:22
问题 Our J2EE Application is deployed to JBoss and sometimes to OC4J . Can I know which one is being used? I hope there is a method returning the container information on runtime. 回答1: Simplest thing I can think of is to look through the system properties at runtime, since both servers are almost certainly going to define their own. For example, JBoss 4 defines the jboss.server.dir system property. Check to see if that property exists, and if it does, then you can assume you're running under that

javax.el.ELException: The identifier [return] is not a valid Java identifier

。_饼干妹妹 提交于 2019-12-20 01:09:40
问题 I have a page url, which looks like: http://mydomain.com/nodes/32/article/new?return=view After installing tomcat 7, when trying to access it I got this exception: /nodes/${param.id}/article/new?return=${param.return} contains invalid expression(s): javax.el.ELException: The identifier [return] is not a valid Java identifier as required by section 1.19 of the EL specification (Identifier ::= Java language identifier). This check can be disabled by setting the system property org.apache.el