Multiple Deployments of JaxRS App in TomEE causing DuplicateDeploymentIdException - java

I'm trying to deploy multiple instances of our service on our staging server, all on the same TomEE instance. They all have different context paths (platform_foo, platform_bar).
I'm getting an exception:
Caused by: org.apache.openejb.DuplicateDeploymentIdException: Application cannot be deployed as it contains deployment-ids which are in use: app: /var/www/apache-tomee-jaxrs-1.6.0/webapps/platform_foo
UsersService
SessionsService
My openejb-jar.xml:
<openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
<pojo-deployment class-name="jaxrs-application">
<properties>
cxf.jaxrs.providers = <redacted>
</properties>
</pojo-deployment>
</openejb-jar>
I tried everything from setting an ID on the web-app element in web.xml, to setting the deployment-id in the openejb-jar.xml. Nothing seems to work.

Looks like someone has answered a similar question that I just didn't search for hard enough.
Tomcat / "Application cannot be deployed as it contains deployment-ids" error

Just deploy in another folder that webapp. I had same issue in tomEE and solved with this

Related

Multiple applications sharing common EJB JAR in TomEE

I have an EJB jar DetailsLookup.jar which needs to be shared by two consumer applications - VehicleMake.war and VehicleModel.war
I have placed the EJB jar file under <catalina_base>/lib and both the war file under <catalina_base>/webapps
When I deploy only one of the WAR files, the deployment is successful, but with 2 WAR files I get the error as below. It seems, TomEE is trying to deploy the EJB for every consumer application instead of deploying it only once
Caused by: org.apache.openejb.DuplicateDeploymentIdException: Application cannot be deployed as it contains deployment-ids which are in use: app: D:\apache-tomcat\instance1\webapps\VehicleModel
DetailsLookup
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:790)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:756)
at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1308)
... 32 more
I have also noticed that when I deploy only VehicleMake.war, the JNDI name for my EJB has the application context path also appended (which says that the EJB is deployed per project and not common)
Expected JNDI name:
global/DetailsLookup!com.my.company.details.service.DetailsLookup
Actual JNDI name:
global/VehicleMake/DetailsLookup!com.my.company.details.service.DetailsLookup
Can anyone help me to identify what the issue is with deploying EJB and if I need to change any configurations to deploy it as a common EJB instead of application specific?
In conf/system.properties, you can change the name of deployed artifacts to avoid collisions.
Try adding this line:
openejb.deploymentId.format = {appId}/{ejbJarId}/{ejbName}

Error in Bluemix Liberty when injecting a simple CDI managed bean into a servlet

When injecting a simple CDI managed bean into a servlet (starting from the generated code sample "SimpleServlet"), when accessing the servlet, Bluemix Liberty logs this error :
"SimpleServlet cannot be injected as class
wasdev.sample.servlet.SimpleServlet is not in a bean archive."
This is so even when a beans.xml file with discovery "all" is used.The target looks like this
Reason for Error :
The error is due to not having a beans.xml in the built application war i.e. JavaHelloWorldApp.war
Currently, for performance reasons, the beans.xml file is always required in order to use CDI on Bluemix.
Solution :
Copied the bean.xml inside the /src/main/webapp/WEB-INF/beans.xml then built the code.
This made sure that the bean.xml is packaged into the war file i.e. JavaHelloWorldApp.war and the error is resolved.
To verify bean.xml is deployed correctly to Bluemix, select the java application on Bluemix console, click and open the java application dashboard. Select Runtime, select Files tab, browse and verify that the bean.xml is deployed correctly inside WEB-INF as shown in the snapshot below.

JNDI NameNotFoundException after Tomcat 8 upgrade

I upgraded from Tomcat 8.0.18 to 8.0.23 and all of the sudden I have a JNDI issue. I looked at the changelogs, Tomcat 8 Changelogs, and I see three JNDI changes, though none strike me as something that would break a previously working configuration.
JNDI related changes were made for bugs 49785, 57587, and an entry under 8.0.19 under "Other".
I am receiving this exception when I start up Tomcat with 8.0.23:
javax.naming.NameNotFoundException: Name [jdbc/MyCluster] is not bound in this Context. Unable to find [jdbc].
In my web application I have a resource link defined:
<Context>
<ResourceLink name="jdbc/MyCluster" global="jdbc/MyCluster" auth="Container" type="javax.sql.DataSource" />
</Context>
I have Tomcat configured with:
<Resource name="jdbc/MyCluster" global="jdbc/MyCluster" ......./>
I am stumped... I cannot figure out what makes my code break after my upgrade from 18 to 23 :(
Just in case anyone was curious about how upgrading from Tomcat 8.0.18 to 8.0.24 could really cause JNDI to screw up, the answer lies in ANT.
ANT Copy documentation
Myself and some other engineers had no idea that ANT Copy does nothing if the file you are trying to overwrite has a newer timestamp... who knew copy had such a complicated condition!?! I believe this is why me and multiple people never looked at the documentation, it is such an unexpected behavior.
Anyways, by upgrading to the newer version of Tomcat my context.xml that contained the resourcelink jdbc/MyCluster was failing to overwrite the newer and more recent timestamp of Tomcat's default context.xml! Once the overwrite flag is set to true, JNDI works again :)

Glassfish 4.1 / validation.xml not loaded

I've ported an application from JEE6 to JEE7 (glassfish 3.1.2.2 to 4.1),
I've upgraded the META-INF/validation.xml with latest version (as stated here): http://antoniogoncalves.org/2013/06/04/java-ee-7-deployment-descriptors/):
<validation-config
xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.1.xsd"
version="1.1">
<message-interpolator>com.infomaxgroup.adaecommerce.validation.DatabaseMessageInterpolator</message-interpolator>
</validation-config>
The custom messageinterpolator is never called, so I've tried to set a name of a non existent class:
<message-interpolator>foo.foo.foo.Bar</message-interpolator>
and tried to insert an error (xxx after the opening tag):
<message-interpolatorxxx>foo.foo.foo.Bar</message-interpolator>
I've no exception into log, seems like that validation.xml (that my JEE6 application processes good) is not loaded at all into my ported JEE7 application...
Any idea on how to solve the issue ?
Many thanks in advance...
Solved from myself,
the problem was that validation.xml must be placed into META-INF/validation.xml folder of the "ejb module", into my JEE6 application I had that file into WEB-INF folder of the "web module" (strangely the JEE6 application works good...), now my JEE7 application correctly load validation.xml configuration and works using the message interpolator, very good !

java.lang.illegalstatexception Application was not properly initialized

I am getting the following error when deploying an application on JBoss 4.2.1
7:05:59,673 ERROR [Application Name]StandardWrapper.Throwable
java.lang.IllegalStateException: Application was not properly initialized at
startup, could not find Factory: javax.faces.context.FacesContextFactory
I browsed the net and I found many posts which suggested to add an entry in web.xml but that entry was already there. And all the required libraries are there in web-inf.
So any solutions anybody ?
Ensure that your classpath is clean (i.e. no duplicate different versioned classes/JAR files, keep in mind that JBoss ships with builtin JSF libraries!) and that your web.xml is declared as at least Servlet 2.3.

Categories

Resources