How to run appclient inside a deployed ear on wildfly? - java

I have an EAR-File containing an EJB-module, a WAR-module and two appclient-modules. I deployed the EAR using maven, so the EAR-File is not placed in the standalone/deployments-directory.
Connecting with jboss-cli.sh, I can see the deployment. The application is running and available via web browser.
Now I want to run one of the appclient-modules via command line. But I can not figure out how this is done, because I don't have the EAR-File available on the harddrive (it seems that an unzipped version is somewhere in standalone/tmp/vfs/...).
If the EAR was in standalone/deployments I would run:
./appclient.sh --host=127.0.0.1 path/to/myear.ear#appclient-module.jar
How can I run the appclient-module.jar contained by the deployed EAR? I tried using the deployment-name with the appclient.sh script:
./appclient.sh --host=127.0.0.1 deployment-name.ear#appclient-module.jar
But this results in:
java.lang.RuntimeException: JBAS013239: Could find application client /opt/wildfly-8.2.1.Final/bin/deployment-name.ear
at org.jboss.as.appclient.subsystem.Main.main(Main.java:135)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.jboss.modules.Module.run(Module.java:312)
at org.jboss.modules.Main.main(Main.java:460)
Thank you in advance!

It seems like there is no solution to the problem I described, so I came up with a workaround:
I am now using the maven-antrun-plugin to upload a copy of the deployed EAR-File. This second EAR-File is used in the cron-job.

Related

Datadog instrumentation on Spring boot container application - class not found

I'm currently running a spring boot application as container into a kubernetes cluster.
Datadog agent is running as containers on the cluster.
I have modified the container image build to include the datadog agent before running the application:
CMD ["/bin/sh","-c","java -javaagent:dd-java-agent.jar -Ddd.trace.config=datadog.properties -Dlogging.config=/logback.xml -jar service.jar"]
I also setup the environment variable to indicate the HOST IP of the agent to my container via the Deployment file.
The problem now is i'm getting this class not found exception when the application starts:
java.lang.NoClassDefFoundError: datadog/trace/instrumentation/springscheduling/SpringSchedulingInstrumentation
at java.lang.Class.getDeclaringClass0(Native Method)
at java.lang.Class.getDeclaringClass(Class.java:1235)
at java.lang.Class.getEnclosingClass(Class.java:1277)
at org.springframework.core.annotation.AnnotationsScanner.processClassHierarchy(AnnotationsScanner.java:233)
at org.springframework.core.annotation.AnnotationsScanner.processClassHierarchy(AnnotationsScanner.java:194)
at org.springframework.core.annotation.AnnotationsScanner.processClass(AnnotationsScanner.java:128)
at org.springframework.core.annotation.AnnotationsScanner.process(AnnotationsScanner.java:107)
at org.springframework.core.annotation.AnnotationsScanner.scan(AnnotationsScanner.java:97)
at org.springframework.core.annotation.AnnotationsScanner.scan(AnnotationsScanner.java:78)
at org.springframework.core.annotation.TypeMappedAnnotations.scan(TypeMappedAnnotations.java:242)
at org.springframework.core.annotation.TypeMappedAnnotations.get(TypeMappedAnnotations.java:149)
at org.springframework.core.annotation.TypeMappedAnnotations.get(TypeMappedAnnotations.java:131)
at org.springframework.core.annotation.AnnotationUtils.findAnnotation(AnnotationUtils.java:581)
at org.springframework.cloud.sleuth.DefaultSpanNamer.annotation(DefaultSpanNamer.java:71)
at org.springframework.cloud.sleuth.DefaultSpanNamer.name(DefaultSpanNamer.java:58)
at org.springframework.cloud.sleuth.instrument.async.TraceRunnable.<init>(TraceRunnable.java:59)
at org.springframework.cloud.sleuth.instrument.async.TraceRunnable.<init>(TraceRunnable.java:51)
at org.springframework.cloud.sleuth.instrument.async.LazyTraceThreadPoolTaskScheduler.scheduleWithFixedDelay(LazyTraceThreadPoolTaskScheduler.java:265)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.cloud.sleuth.instrument.async.ExecutorMethodInterceptor.invoke(ExecutorBeanPostProcessor.java:328)
Quite straigtforward, i need to include some dependencies into the application package. But i could not find anything useful on datadog website nor maven central repository.
Including the agent itself or the api libraries fix nothing. This class is present on the agent but under a different path.
Does anybody know which dependencies should be included in the classpath of the application to fix that ?
Spring is scanning your classpath that seems incomplete. Maybe it is related to Spring's class loading mechanisms. The class in question exists and seems to be part of the agent.
Possibly, you are using an outdated version of the agent.

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}

<HTTP> <BEA-101163> <Could not load user defined listener:

I have modified an EAR for Weblogic 10 ( BEA 10 )which is already running on BEA 8..
I am getting the following error while deploying the EAR..
[HTTP:101163]Could not load user defined listener: com.xxx.xxxx.jmx.LifecycleListener java.lang.NoClassDefFoundError: com/tibco/sdk/MException at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357) at java.lang.Class.getConstructor0(Class.java:2671) at java.lang.Class.newInstance0(Class.java:321) at java.lang.Class.newInstance(Class.java:303) at weblogic.servlet.internal.WebComponentContributor.getNewInstance(WebComponentContributor.java:187) at weblogic.servlet.internal.WebComponentContributor.createListenerInstance
Have you faced this error ?Please help me...
From the Exception it seems that some library is missing from your ear file. Make sure that com.xxx.xxxx.jmx.LifecycleListener is a valid package and included correctly in your ear.
If you are developing and building the ear with JDeveloper make sure you add this lib in your application resources. If you do this manualy make sure that this lib exists in your WEB-INF/lib folder

Cannot save to commons config in JBoss 5.1

I am writing a web application that uses Apache Commons config to read/write a system.properties file. The file itself is placed in WEB-INF/classes/config. Reading is no problem, and I can write to it when I deploy using Apache Tomcat. When I deploy the application using JBoss, however, I cannot write (using cofig.setProperty(...). I get the following error (JBoss only):
2012-01-06 12:53:48,879 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/flint].[flint]] (http-0.0.0.0-8080-1) Servlet.service() for servlet flint threw exception
java.net.UnknownServiceException: protocol doesn't support output
at java.net.URLConnection.getOutputStream(URLConnection.java:792)
at org.apache.commons.configuration.AbstractFileConfiguration.save(AbstractFileConfiguration.java:449)
at org.apache.commons.configuration.AbstractFileConfiguration.save(AbstractFileConfiguration.java:377)
at org.apache.commons.configuration.AbstractFileConfiguration.possiblySave(AbstractFileConfiguration.java:750)
at org.apache.commons.configuration.AbstractFileConfiguration.clearProperty(AbstractFileConfiguration.java:789)
at org.apache.commons.configuration.AbstractConfiguration.setProperty(AbstractConfiguration.java:481)
at org.apache.commons.configuration.AbstractFileConfiguration.setProperty(AbstractFileConfiguration.java:782)
at com.talecris.flint.server.config.SystemConfiguration.setResultInvalidColor(SystemConfiguration.java:571)
at com.talecris.flint.controller.SystemAdminController.setSystemColors(SystemAdminController.java:496)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
As I said, it all works fine in Tomcat. The system.properties permissions look fine (owner=Jboss). I even opened the permissions up to rw for everyone just to test, but I still get the same error. Is there some JBoss setting that is preventing my application from writing to the path in which it is deployed?
I can write files and subfolders to the deployment directory, but I cannot write changes to system.properties (via apache commons config).
The problem had to do with using VFSFileChangedReloadingStrategy when on JBoss.
Here's a problem that frustrated me for a bit: When using Apache Commons Configuration under JBoss 5, I kept running into the following error when attempting to save to my configuration file (which was a resource under the deployed /classes path):
ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/xxxx].[xxxx]] (http-0.0.0.0-8080-1) Servlet.service() for servlet flint threw exception
java.net.UnknownServiceException: protocol doesn't support output
at java.net.URLConnection.getOutputStream(URLConnection.java:792)
at org.apache.commons.configuration.AbstractFileConfiguration.save(AbstractFileConfiguration.java:449)
What the heck? This error happened every time I attempted to save to my configuration file. It worked fine in Tomcat 6.x, but any time I tested on JBoss, while I could read from the configuration file, the above error was thrown every time I attempted to write to it.
JBoss 5.x VFS (virtual file abstraction) for the files that it deploys, and this causes problems with Commons Config's default FileChangedReloadingStrategy. So the fix is to do something like this instead:
VFSFileChangedReloadingStrategy f = VFSFileChangedReloadingStrategy();
((FileConfiguration) config).setReloadingStrategy(f);
It turns out that we really want to use VFSFileChangedReloadingStrategy (which means using Apache Commons Config 1.7) . This also requires that the Apache Commons VFS API be on your classpath. The good news is that VFSFileChangedReloadingStrategy works well even with non-VFS deployments (i.e. plain old Tomcat and Jetty). Problem solved!

EJB Spec violation: The message driven bean must declare one onMessage() method

I am working on some migration project, involves moving around quite a few stuff from Ant/CVS/Jboss4/Java5 to Maven/SVN/Jboss7/Java6 - this gets nasty.
First step, I am working on moving the ant build to maven - that it in iteslf involve a lot of complication. Now that I get the ear file built, and I compared it with the ear from ant build, I think I got it good with the maven build.
Now, deploying on Jboss4 first, I encouter
[ejb.EJBDeployer.verifier] EJB spec violation:
Warning: The message driven bean must declare one onMessage() method.
2011-11-08 15:25:03,079 ERROR (Thread: main) [jboss.deployment.MainDeployer] Could not create deployment: file:/opt/jboss-4.0.3SP1/server/default/tmp/deploy/tmp46514Billing-EAR-1.0.ear-contents/processsubscriptionbean-1.0.jar
org.jboss.deployment.DeploymentException: Verification of Enterprise Beans failed, see above for error messages.
at org.jboss.ejb.EJBDeployer.create(EJBDeployer.java:575)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:118)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
at $Proxy24.create(Unknown Source)
at org.jboss.deployment.MainDeployer.create(MainDeployer.java:935)
at org.jboss.deployment.MainDeployer.create(MainDeployer.java:925)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:789)
I came across this thread jBoss deployment of message-driven bean spec violation - so I figured I was using the wrong library on my new maven build, I replaced it and made sure it's using the same javax.jms library (this now points to the same jar containing javax.jms.Message as the original ant build) - in fact I simply grabbed the jar referenced by the ant build and upload it to maven repo and reference it from my maven build.
But I still encounter the above problem. The original ant-build would deploy with no problem, but currently I am stuck at this issue for the maven-build ear.
Any suggestion on what other steps i can take to make sure there are no different class files issue? Thanks!
Is the javax.jms library being packaged in your ear (jboss-j2ee.jar, jboss-client.jar, etc)? If so, you don't want that since you want to use the one provided by the app server. You can fix this by changing the dependency in your pom to have the <scope>provided</scope> for anything that shouldn't be in your ear.

Categories

Resources