java-ee

Spring MVC Annotations with Global Context context:component-scan?

穿精又带淫゛_ 提交于 2019-12-19 04:06:11
问题 I have a spring dispatcher servlet with servlet-name "spring-mvc". The spring-mvc-servlet.xml appears as follows: <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> </bean> <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/> <bean class="org

Java EE 7 CDI Manual Instantiation

痴心易碎 提交于 2019-12-19 03:45:56
问题 I have a Class with fields annotated with @Inject. I instantiate the Class using reflection, but I want the CDI to inject instances to do the Class instance fields. Is there a way of doing it? Object myInstanceWithDependecies = Class.forName(“com.package.MyClass").newInstance(); CDI.injectAll(myInstanceWithDependecies);//This is what i want Does someone know how to do this? I would appreciate if there was a way of doing it without scanning each field using reflection. Thanks in advance. 回答1:

When should you explicity name a Managed Bean?

为君一笑 提交于 2019-12-19 03:41:38
问题 With all the research I've done on creating managed beans, what I've not noticed (or what I may have overlooked) is when to use explicit naming of the bean e.g. @Named(name = "someBean") . I guess what it hard for me to understand is why you would want to name the bean anything other than your class name: @Named(name = "someBean") public class SomeBean implements Serializebale { } With all the examples I've seen, some use the the explicit name and some just use @Named to leave the default

Hosting Static Content and JAX-RS Services Under the Same Root Context

心已入冬 提交于 2019-12-19 03:18:07
问题 We have multiple Java web apps packaged as WARs all packaged in an EAR. Our RESTful services are built using JAX-RS and in version specific WARs. We'd like to add static content for each of these version specific WARs, but use the root context (of the WAR) for both the static content and the RESTful service API calls, such that all of the following URLs will work: {hostname}/v1/swagger.yaml <-- Static Content describing the v1 API {hostname}/v1/orders/{uid} <-- JAX-RS RESTful API (v1)

error when deploying Java WS in Jboss 6.3.0 EAP

会有一股神秘感。 提交于 2019-12-19 03:08:20
问题 I am migrating an application with Java WS from Jboss 5.1.0 to Jboss 6.3.0 EAP. It works fine with Jboss 5.1.0 but I am getting error while deploying the same in Jboss 6.3.0 EAP. 14:42:10,887 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deploy ment.unit."my-app.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."dtm-banking. war".INSTALL: JBAS018733: Failed to process phase INSTALL of deployment "dtm

JSF2 : inject service objects to managedbean from Spring?

爷,独闯天下 提交于 2019-12-19 02:29:27
问题 I have tested this, trying to inject an service object to a @ManagedBean, but it failed with a nullpointerexception, being the userService is null. I am currently using Tomcat 7, JSF 2, and here are some of my pom.xml <properties> <java-version>1.6</java-version> <org.springframework-version>3.0.3.RELEASE</org.springframework-version> <org.hibernate-version>3.6.0.Final</org.hibernate-version> .... </properties> Here is the exception trace : javax.faces.el.EvaluationException: java.lang

JSF2 : inject service objects to managedbean from Spring?

徘徊边缘 提交于 2019-12-19 02:29:00
问题 I have tested this, trying to inject an service object to a @ManagedBean, but it failed with a nullpointerexception, being the userService is null. I am currently using Tomcat 7, JSF 2, and here are some of my pom.xml <properties> <java-version>1.6</java-version> <org.springframework-version>3.0.3.RELEASE</org.springframework-version> <org.hibernate-version>3.6.0.Final</org.hibernate-version> .... </properties> Here is the exception trace : javax.faces.el.EvaluationException: java.lang

What is the equivalent of @ManagedBean(eager=true) in CDI

怎甘沉沦 提交于 2019-12-19 00:45:51
问题 As we all know that it is recommended to use annotations from javax.enterprise.context instead of javax.faces.bean as they are getting deprecated. And we all found ManagedBeans with eager="true" annotated with @ApplicationScoped from javax.faces.bean and having a @PostConstruct method are very useful to do web application initialization e.g: read properties from file system, initialize database connections, etc... Example : import javax.faces.bean.ApplicationScoped; import javax.faces.bean

How to serve a socket from a Java EE application?

痴心易碎 提交于 2019-12-18 21:23:10
问题 We would like to serve some client requests within our Java EE application server (JBoss 4.2.3). I read that the Java EE spec doesn't allow opening a socket from an enterprise bean. But the spec suggests no alternatives. Specifically, enterprise beans should not: listen on, accept connections on, or multicast from a network socket So the question is: What can I do to serve some binary tcp based protocols (not http) from within an application server? Here someone suggests to implement a

How to get rid of 'java.lang.IllegalArgumentException: Unknown entity' while running a simple hibernate app?

早过忘川 提交于 2019-12-18 20:04:23
问题 I am new to Hibernate. While creating a small app using it I got following exception: Exception in thread "main" java.lang.IllegalArgumentException: Unknown entity: model.Students at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:223) at controller.Main.main(Main.java:50) Can anybody please help me out? The Entity classes are as follows: Other details: NetBeans Version: 6.7.1 Hibernate : 3.2.5 Entity Students package model; import java.io.Serializable;