Java EE #Resource isn't mapping to web.xml - java

I am trying to develop a web application with a java back end but I need to track if the tasks are complete and I am using the ManagedExecutorService for this.
I am trying to use the #Resource annotation to inject a ManagedExecutorService as follows.
#Resource(name = "myExecutionService")
private ManagedExecutorService mExecutionService;
web.xml:
<resource-env-ref>
<resource-env-ref-name>myExecutionService</resource-env-ref-name>
<resource-env-ref-type>javax.enterprise.concurrent.ManagedExecutorService</resource-env-ref-type>
</resource-env-ref>
but I keep getting an error saying that I am missing the "Services with missing/unavailable dependencies"
13:52:31,207 INFO [org.jboss.as.server] (management-handler-threads - 158) JBAS015870: Deploy of deployment "tbm-core-1.0.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"tbm-core-1.0.war\".WeldService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"tbm-core-1.0.war\".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [TestBedManager] with qualifiers [#Default] at injection point [[field] #Inject private com.shenick.teravm.core.ws.TestBedManagerWebService.testBedManager]"},"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.\"tbm-core-1.0\".\"tbm-core-1.0\".env.myExecutionServicejboss.naming.context.java.jboss.resources.myExecutionServiceMissing[jboss.naming.context.java.module.\"tbm-core-1.0\".\"tbm-core-1.0\".env.myExecutionServicejboss.naming.context.java.jboss.resources.myExecutionService]"]}

I have figured out the problem and it's because ManagedexecutorService is java 7 only apparently and jboss 7.1.1 will not deploy apps that use threads.
to solve this I will need to upgrade to EAP 6.1 (new name for jboss).

If you want just use the default implementation, use
#Resource(mappedName="java:comp/DefaultManagedExecutorService")
In this case, you don't need to specify it in web.xml.
If you want to use your own implementation, I think you should configure your application server resources first (set it with your implementation).
EDIT:
I found this by chance:
How to Configure Scheduled Tasks in Wildfly. It could help you, I think.

Related

Duplicate EJBContext error while deploying tests with Arquillian

When trying to deploy EJB with Arquillian, ShrikWrap it causes the following issue:
Service jboss.naming.context.java.module.test.test.EJBContext is already registered
The reason found when debugging was that, we were using separate custom EJBContext class in our context and somehow Arquillian's ShrinkWrap deploys a test.war which tries to re-register EJBContext which is then failing to complete the deployment process.
Throughout the debugging following bidingName is trying to redeploy to the container ("java:module/EJBContext")
My question is; Is there any way to avoid such duplication of deployment with Arquillian. or any better solution how to overcome this issue?
Used sample custom Context for EJB:
#Singleton
public class EJBContext
{
public EJBContext() {
}
}
Error log:
org.jboss.arquillian.container.spi.client.container.DeploymentException: Cannot deploy test.war: {"WFLYCTL0062: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-1" => {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"test.war\".INSTALL" => "WFLYSRV0153: Failed to process phase INSTALL of deployment \"test.war\"
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYEE0052: Failed to install component EJBContext
Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.naming.context.java.module.test.test.EJBContext is already registered"},"WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.unit.\"test.war\".beanmanager","jboss.deployment.unit.\"test.war\".WeldStartService"],"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.deployment.unit.\"test.war\".batch.artifact.factory is missing [jboss.deployment.unit.\"test.war\".beanmanager]","jboss.deployment.unit.\"test.war\".weld.weldClassIntrospector is missing [jboss.deployment.unit.\"test.war\".beanmanager, jboss.deployment.unit.\"test.war\".WeldStartService]"]}}}

Defining jboss-web.xml security-domain causes missing dependencies for my EJBs

I have a working webapp (a .war that includes a .jar with three EJBs) that works fine.
I define an LDAP security domain through jboss-cli:
/subsystem=elytron/dir-context=pepDirContext:add(url="ldap://127.0.0.1:10389",principal="uid=admin,ou=system",credential-reference={clear-text="secret"})
/subsystem=elytron/ldap-realm=pepRealm:add(dir-context=pepDirContext,identity-mapping={search-base-dn="ou=Users,dc=jboss,dc=org",rdn-identifier=uid,user-password-mapper={from="userPassword"},attribute-mapping=[{filter-base-dn="ou=Roles,dc=jboss,dc=org",filter="(&(objectClass=groupOfNames)(member={1}))",from="cn",to="Roles"}]})
/subsystem=elytron/simple-role-decoder=from-roles-attribute:add(attribute=Roles)
/subsystem=elytron/security-domain=pepSD:add(realms=[{realm=pepRealm,role-decoder=from-roles-attribute}],default-realm=pepRealm,permission-mapper=default-permission-mapper)
/subsystem=elytron/http-authentication-factory=pep-http-auth:add(http-server-mechanism-factory=global,security-domain=pepSD,mechanism-configurations=[{mechanism-name=BASIC,mechanism-realm-configurations=[{realm-name=pepRealm}]}]
/subsystem=undertow/application-security-domain=pepASD:add(http-authentication-factory=pep-http-auth)
/subsystem=undertow/application-security-domain=pepSD:add(http-authentication-factory=pep-http-auth)
Note: I have decided two "application-security-domain" as part of the tests, ideally I wanted to use only pepASD.
Now, I add to my war the WEB-INF/jboss-web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<security-domain>pepSD</security-domain>
</jboss-web>
and when I deploy it, I get:
14:48:31,347 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 2) WFLYCTL0013: Operation ("full-replace-deployment") failed - address: ([]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => ["jboss.security.security-domain.pepSD"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.deployment.unit.\"frontend.war\".component.UsuarioEjb.CREATE is missing [jboss.security.security-domain.pepSD]",
"jboss.deployment.unit.\"frontend.war\".component.GerenciaEjb.CREATE is missing [jboss.security.security-domain.pepSD]",
"jboss.deployment.unit.\"frontend.war\".component.FlujoEjb.CREATE is missing [jboss.security.security-domain.pepSD]"
What am I missing?
I am using WildFly 18.0.0.1 on Java 11.
It turns out that for EJBs I need to define an application security domain into the ejb3 subsystem:
/subsystem=ejb3/application-security-domain=pepASD:add(security-domain=pepSD)
I need to try it a little more to check the relationships (if any) between the ejb3's and undertow's application-security-domain

JBOSS deployment warning - contains CDI annotations but beans.xml was not found

I am getting this warning when I start my JBOSS server 7.0.0.. after deploying the my EAR file. I am using Spring 4.1, Hibernate 4
16:44:09,254 WARN [org.jboss.weld.deployer] (MSC service thread 1-1)
JBAS016012: Deployment deployment "ExampleService.ear" contains CDI
annotations but beans.xml was not found.
Kindly let me know how can i resolve this?
If you want Spring manage your beans, as opposed to the JBoss' support for Java EE 6 CDI, you can safely ignore this warning. Spring will happily scan the classpath for javax.inject.* annotations and configure your application accordingly.
The bean archive descriptor beans.xml should be located at META-INF/beans.xml or WEB-INF/beans.xml.more information about CDI

Jersey deployment Error CDI

I have a problem deploying my jersey 2.0 web Applications, there is CDI deployment failure, Here the error log :
org.glassfish.deployment.common.DeploymentException: CDI deployment failure:WELD-001408 <Br> Unsatisfied dependencies for type [IterableProvider<InjectionResolver<Object>>] with qualifiers [#Default] at injection point [[BackedAnnotatedParameter] Parameter 2 of [BackedAnnotatedConstructor] #Inject org.glassfish.jersey.internal.inject.JerseyClassAnalyzer(#Named ClassAnalyzer, IterableProvider<InjectionResolver<Object>>)]
This error happens only sometimes. When it does I clean my project and restart my glassfish until deployment succeeds but this takes too much time. I don't have any idea how to fix this problem permanently. Can anybody help me?

Cannot inject EJB specified in applicationcontext.xml in jboss 7

I'm trying to migrate my Java EE application from jboss 5.1 to jboss 7.1 and getting a deployment error.
My EAR has 2 EJB modules and 1 WAR module. both EJB modules gets deployed without any issue. but when i'm trying to deploy with the WAR module it says
Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name "className" Injection of resource fields failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'java:global/ear/ejb/FacadeBean!com.ejb.business.SearchFacade' is defined: not found in JNDI environment
because of copyright issues i'm unable to disclose the full class names. but "classname" is defined as a bean in my spring application context file and it has a dependency injection of SearchFacade which again has some dependencies.
whats confusing is that in the jboss log it shows that SearchFacade is deployed without any issues.
i'm finding so hard to find a solution for this issue. any help will be greatly appreciated.
thanks in advance.
Looks like spring is not able to determine that the EJB component is in that EJB Jar and you need to enforce that the components in that EJB jar are initialized and started before the components in you WAR.
Did you tried to set element into your application*xml and see if that helped?
Something like this in your application.xml
<application-name>EAR</application-name>
<initialize-in-order>true</initialize-in-order>
<module><ejb>EJB.jar</ejb></module>
<module><web><web-uri>WAR.war</web-uri><context-root>....

Categories

Resources