Duplicate EJBContext error while deploying tests with Arquillian - java

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]"]}}}

Related

How can I fix ClassNotFoundException for javax.servlet classes in this JBoss deployment?

This question is asked before, I know, but I have a special case which doesn't seem to fall under the other answers.
I already have two web apps who packages and deploys on to my JBoss EAP 7.x as expected. My third attempt, however, will not work. Here are where it is different from the other two:
It was originally created as a standard maven archetype, and not a web app archetype (jar pancaking not war). It is simply an auto-updating tool, which runs scheduled updates on data. It is not meant to host any pages, but I needed to code it as a web application, as it seemed the easiest way to deploy to a web application server, given my current knowledge and coding skills. I converted it using the Project Facets tab in project properties.
The web.xml does not include any servlets, but it does contain a ServletContextListener, which starts the update loop.
When I try to deploy my war-file, I get the following error:
Cannot upload deployment: {"WFLYCTL0080: Failed services" =>
{"jboss.undertow.deployment.default-server.default-host./auto-update-
tool.UndertowDeploymentInfoService" => "org.jboss.msc.service.StartException
in service jboss.undertow.deployment.default-server.default-host./auto-
update-tool.UndertowDeploymentInfoService: java.lang.ClassNotFoundException:
servlet.ServletContextListener from [Module \"deployment.auto-update-
tool.war:main\" from Service Module Loader] Caused by:
java.lang.ClassNotFoundException: servlet.ServletContextListener from
[Module \"deployment.auto-update-tool.war:main\" from Service Module
Loader]"}}
These kind of messages are not new to me, but this time I am struggling to solve it.
Basics first: How do I import the javax.servlet API in my Eclipse project?
I have followed this to the point. I do have the JavaEE dependency in my pom file. That goes for all three of my projects. They all have scope provided:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
If i completely remove this, I get a packaging error in maven command line. If I only remove the provided scope line, I get another, but similar error:
Cannot upload deployment: {"WFLYCTL0080: Failed services" =>
{"jboss.deployment.unit.\"auto-update-tool.war\".POST_MODULE" =>
"org.jboss.msc.service.StartException in service
jboss.deployment.unit.\"auto-update-tool.war\".POST_MODULE: WFLYSRV0153:
Failed to process phase POST_MODULE of deployment \"auto-update-tool.war\"
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException:
java.lang.ClassNotFoundException: servlet.ServletContextListener from
[Module \"deployment.auto-update-tool.war:main\" from Service Module Loader]
Caused by: java.lang.ClassNotFoundException: servlet.ServletContextListener
from [Module \"deployment.auto-update-tool.war:main\" from Service Module
Loader]"}}
I've also tried to switch out my javax dependency, with what I believe is the same version implemented in JBoss 7.x:
<dependency>
<groupId>org.jboss.spec.javax.servlet</groupId>
<artifactId>jboss-servlet-api_3.1_spec</artifactId>
<version>1.0.1.Final</version>
<scope>provided</scope>
</dependency>
The error message is now gone, but replaced with a simple "Upload failed" with no error message whatsoever. I tried to look in the log files, but nothing there either. And I still find it strange that both my other applications work with the other javax dependency.
I am lost. Any advice on how to proceed from here?

Failed to link a MDB to an inbound resource adapter on Wildfly 10.x - deployment failed

I progammed an simple tcp inbound resource adapter (RA) as an example project on github and deployed it successful to wildfly 10.x with standalone-full configuration. The message listener TcpMessageListener interface is located in the RA and defined in the ra.xml descriptor, but I can't connect a message driven bean (MDB) to it. The eis side of the RA works as expected, I can connect/send messages with telnet to it. When I try to deploy the MDB with the wildfly maven plugin, the MDB couldn't find the TcpMessageListener and I got java.lang.NoClassDefFoundError:
WARN [org.jboss.modules] (MSC service thread 1-7) Failed to define class de.bitc.ejb.InboundEventHandler in Module "deployment.ra-ear.ear.ra-user-ejb-0.0.1-SNAPSHOT.jar:main" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link de/bitc/ejb/InboundEventHandler (Module "deployment.ra-ear.ear.ra-user-ejb-0.0.1-SNAPSHOT.jar:main" from Service Module Loader): de/bitc/jca/inflow/TcpMessageListener
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
.
.
.
ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC000001: Failed to start service jboss.deployment.subunit."ra-ear.ear"."ra-user-ejb-0.0.1-SNAPSHOT.jar".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."ra-ear.ear"."ra-user-ejb-0.0.1-SNAPSHOT.jar".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of subdeployment "ra-user-ejb-0.0.1-SNAPSHOT.jar" of deployment "ra-ear.ear"
.
.
.
Caused by: java.lang.NoClassDefFoundError: Failed to link de/bitc/ejb/InboundEventHandler (Module "deployment.ra-ear.ear.ra-user-ejb-0.0.1-SNAPSHOT.jar:main" from Service Module Loader): de/bitc/jca/inflow/TcpMessageListener
.
.
.
ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 17) WFLYCTL0013: Operation ("add") failed - address: ([("deployment" => "ra-ear.ear")]) - failure description: {
"WFLYCTL0080: Failed services" => {"jboss.deployment.subunit.\"ra-ear.ear\".\"ra-user-ejb-0.0.1-SNAPSHOT.jar\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.subunit.\"ra-ear.ear\".\"ra-user-ejb-0.0.1-SNAPSHOT.jar\".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of subdeployment \"ra-user-ejb-0.0.1-SNAPSHOT.jar\" of deployment \"ra-ear.ear\"
Caused by: java.lang.NoClassDefFoundError: Failed to link de/bitc/ejb/InboundEventHandler (Module \"deployment.ra-ear.ear.ra-user-ejb-0.0.1-SNAPSHOT.jar:main\" from Service Module Loader): de/bitc/jca/inflow/TcpMessageListener"},
"WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.subunit.\"ra-ear.ear\".\"ra-user-ejb-0.0.1-SNAPSHOT.jar\".POST_MODULE"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined
The dependency in the ejb maven submodule is in the provided scope. I followed with the deployment of the RA the redhat guide. I also switched in the ejb submodule the maven dependency of the resource adapter from provided to compile. In this case I got the following errors
[ERROR] Caused by: java.lang.IllegalStateException: WFLYEJB0383: No message listener of type de.bitc.jca.inflow.TcpMessageListener found in resource adapter tcp-eis.rar"},
"WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.subunit.\"ra-ear.ear\".\"ra-user-ejb-0.0.1-SNAPSHOT.jar \".component.InboundEventHandler.CREATE"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined}}}
Here is the MDB
package de.bitc.ejb;
import java.util.logging.Logger;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import org.jboss.ejb3.annotation.ResourceAdapter;
import de.bitc.jca.inflow.TcpMessageListener;
#MessageDriven(
activationConfig = {
#ActivationConfigProperty(propertyName = "topic", propertyValue = "test")
} //, messageListenerInterface = TcpMessageListener.class
)
#ResourceAdapter(value="tcp-eis.rar")
public class InboundEventHandler implements TcpMessageListener {
/** The logger */
private static Logger log = Logger.getLogger(InboundEventHandler.class.getName());
/**
* Default constructor.
*/
public InboundEventHandler() {
// TODO Auto-generated constructor stub
}
/**
* #see TcpMessageListener#onMessage(String)
*/
#Override
public void onMessage(String msg) {
// TODO Auto-generated method stub
}
}
Here is the TcpListenerInterface
package de.bitc.jca.inflow;
/**
* TcpMessageListener
*
* #version $Revision: $
*/
public interface TcpMessageListener {
/**
* Receive message
*
* #param msg
* String.
*/
public void onMessage(String msg);
}
Here are the settings of the resource adapter in the jboss_cli
/subsystem=resource-adapters/resource-adapter=tcp-eis.rar:read-resource(recursive=true)
{
outcome => success,
result => {
archive => tcp-eis.rar,
beanvalidationgroups => undefined,
bootstrap-context => undefined,
config-properties => undefined,
module => undefined,
statistics-enabled => false,
transaction-support => XATransaction,
wm-security => false,
wm-security-default-groups => undefined,
wm-security-default-principal => undefined,
wm-security-domain => other,
wm-security-mapping-groups => undefined,
wm-security-mapping-required => false,
wm-security-mapping-users => undefined,
admin-objects => undefined,
connection-definitions => undefined
}
}
My question is, is there a missing step in the deployment that a MDB find the resource adapter. I think this is done with the #ResourceAdapter annotation? Did I need to define a queue or something? The resources about inbound resouce adapters are very rare and the most examples are outbound resource adapters. Thanks in advance.
The above linked inbound-ra-example is hosted on github. I described all steps to build and run it in the README.md in the github project. I want to host these example for others which have the same problems to find documentation.
I solved the class loading NoClassDefFoundError: Failed to link error and the now running example answers many open questions. I put all details to my example. The inbound resource adapter runs now as a sub-deployment in an ear archive on wildfly 10 (WF10). I generated the inbound resource adapter with the IronJacamar codegenerator. I described all steps how build and run in the example.
The main mistakes where, I did not use the jboss-deployment-structure descriptor in the ear archive and a maven dependency to the resource adapter api in the ear archive. I put the dependency into the ear while testing and forgot it.
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<sub-deployment name="ra-user-ejb.jar">
<dependencies>
<module name="deployment.ra-ear.ear.tcp-eis.rar" export="true" />
</dependencies>
</sub-deployment>
</jboss-deployment-structure>
Here are my biggest ear embedded inbound RA answers to solve the documentation leak a little bit:
The ra.xml descriptor is not needed, the #Connector annotation in the RA class is enough.
There is no additional configuration in WF10 needed. No queues, standallone-full.xml modification or jndi stuff. A simple deploy with the wildfly-maven-plugin works.
The now working resource adapter is not showing up as resource adapter in WF10. This confuses me and make my research very difficult.
The jboss-ejb3.xml descriptor is not needed. The #ResourceAdapter(value="ra-ear.ear#tcp-eis.rar") is enough. Take care, this is a jboss annotation, not an ee7. So you not find any resources in case of eg. websphere or tomee.
I will extend the example resource adapter in the next days to a full ee7 app and hope that this example help others on the way through the inbound resource adapter documentation hell.

Wildfly ClassNotFoundException

I'm trying to deploy my application to a Wildfly Application server but I keep getting the following error:
Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:1.1.0.Alpha1:deploy (default) on project medical-api:
Deployment failed: Operation failed: {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" =>
{
"Operation step-2" => {"JBAS014671: Failed services" =>
{
"jboss.deployment.unit.medical-api-ian.POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.medical-api-ian.POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment \"medical-api-ian\" Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: java.lang.ClassNotFoundException: dao.MaternityPlanDaoJpaImpl from [Module \"deployment.medical-api-ian:main\" from Service Module Loader] Caused by: java.lang.ClassNotFoundException: dao.MaternityPlanDaoJpaImpl from [Module \"deployment.medical-api-ian:main\" from Service Module Loader]"}
}
}
} -> [Help 1]
The class MaternityPlanDaoJpaImpl is in my folder structure I can see it clearly so I'm confused as to why it's throwing this error.
For shits and giggles I deleted the class and then it chose to throw the same exception about a different class in a different package.
Thanks in advance for any help.
First, change to the version 8.2.0.Final or 9.0.0.CR2.
Many Bugs Fixed since 8.1.0-Final version.
https://issues.jboss.org/browse/WFLY/?selectedTab=com.atlassian.jira.jira-projects-plugin:changelog-panel
You can see examples of use here.
https://github.com/wildfly/quickstart
Use the stable version of wildfly-maven-plugin.
<dependency>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.0.2.Final</version>
</dependency>
Note:
Possibly you are compiling with a JDK version that is not supported by WildFly.
You may be compiling with a version and running with a version in another.
I recommend you use the latest most stable version JDK if possible.
make a jar file using ant build and put it in WEB-INF/lib or WEB-INF/class folder in your war folder
use ant to compile or make jar with ant put jar files or class file in
deployment folder\war-folder\WEB_INF\lib or classes folder

Renaming of the endpoint class caused deploying fail on Wildfly

I renamed endpoint class in my project, rebuilt, redeployed it on Wildfly, but when I try to enable it failed with this error :
Caused by: java.lang.RuntimeException: javax.websocket.DeploymentException: UT003023: Multiple endpoints with the same logical mapping PathTemplate
How to avoid this problem or clean deployments?

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

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.

Categories

Resources