Exposing SOAP service using apache Camel and WSDL - soap

I have a WSDL file located under src\main\resources\wsdl\ folder and it is having multiple operations defined within it. My application is running on Weblogic 12C server. I'm trying to expose the SOAP web-service using Apache Cammel (version: 2.18.3) with Java DSL -
I have written below code under configuration method of my RouteBuilder class -
CxfComponent cxfComponent = new CxfComponent(getContext());
CxfEndpoint serviceEndpoint = new CxfEndpoint("/soap/Manage_Order", cxfComponent);
serviceEndpoint.setAddress("http://<IP>:<PORT>/myproject/soap/ManageOrder_Details");
serviceEndpoint.setServiceClass(
"Fully qualified service interface name generated from WSDL file using maven with #WebService annotation");
serviceEndpoint.setEndpointName(<end point name defined in the service class with #WebEndpoint annotation>);
serviceEndpoint.setDataFormat(DataFormat.MESSAGE);
serviceEndpoint.setDefaultOperationName("manageOrder");
getContext().addEndpoint("myServiceEndPoint1", serviceEndpoint);
from("cxf:myServiceEndPoint1").log("Hi, I am here").end();
While I'm deploying the application, it is throwing below exception -
weblogic.application.ModuleException: java.lang.IllegalArgumentException: serviceClass must be specified
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:233)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:228)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
Truncated. see log file for complete stacktrace
Caused By: java.lang.IllegalArgumentException: serviceClass must be specified
at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:311)
at org.apache.camel.component.cxf.CxfEndpoint.createServerFactoryBean(CxfEndpoint.java:663)
at org.apache.camel.component.cxf.CxfConsumer.createServer(CxfConsumer.java:70)
at org.apache.camel.component.cxf.CxfConsumer.<init>(CxfConsumer.java:66)
at org.apache.camel.component.cxf.CxfEndpoint.createConsumer(CxfEndpoint.java:252)
Truncated. see log file for complete stacktrace
pom.xml
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-soap</artifactId>
<version>2.18.3</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cxf</artifactId>
<version>2.18.3</version>
<!-- use the same version as your Camel core version -->
</dependency>

As the error says, you have not mentioned the service class and endpoint names.serviceEndpoint.setServiceClass("Fully qualified service interface name generated from WSDL file using maven with #WebService annotation");
serviceEndpoint.setEndpointName(<end point name defined in the service class with #WebEndpoint annotation>);
Step 1: Generate the service from your wsdl using wsdl2java command or your choice of IDE.
Step 2: Have that in your code classpath
Step 3: Mention the class name and endpoint names in the above piece of code

Related

Having "APPLICATION FAILED TO START" error on Spring Boot startup

I'm developing an API on Spring Boot using Vault and Mongo, but it refuses to start.
2022-09-07 13:58:56.510 WARN 23885 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.cloud.vault.config.VaultReactiveBootstrapConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'spring.cloud.vault-org.springframework.cloud.vault.config.VaultProperties': Could not bind properties to 'VaultProperties' : prefix=spring.cloud.vault, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is javax.validation.NoProviderFoundException: Unable to create a Configuration, because no Jakarta Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.
2022-09-07 13:58:56.513 INFO 23885 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-09-07 13:58:56.521 ERROR 23885 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
The Bean Validation API is on the classpath but no implementation could be found
Action:
Add an implementation, such as Hibernate Validator, to the classpath
EDIT: I think the problem is that Spring Boot tries to use javax and jakarta at the same time according to this part of the error:
nested exception is javax.validation.NoProviderFoundException: Unable to create a Configuration, because no Jakarta Bean Validation provider could be found.. Is this a normal behavior?
Consider to bypass the problem: try to add compile 'de.flapdoodle.embed:de.flapdoodle.embed.mongo' to your build.gradle, and #Bean public MongoClient embeddedMongoClient() to return a dummy Mongo client during the Init phase.
The real mongo Url could be fetched (and used) from the Vault later, during run time, once required, via a customized extends of spring-data-mongodb's MongoDbFactory.
Adding hibernate-validator 6 and spring-boot-starter-validation solved the problem.
Thing to know: hibernate-validator < 7 uses Javax, hibernate-validator => 7 uses Jakarta.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.2.4.Final</version>
</dependency>

Using Spring Boot auto configuration of MongoDB with Camel, how to know what application.properties

I'm trying to add a Camel rout to a working project with Spring Boot for using MongoDB. I've using Mongo with Spring Boot autoconfigure, and it worked pretty easily.
I was confused about how to specify the bean that Spring Boot generates, but I finally found an answer to a related question on SO that said the name of the bean is "mongo". So I changed my rout to .to("mongodb:mongo?....
No Spring is trying to connect to default parameters, localhost and 72017, etc. So how do I figure out what properties to specify in application.properties to set the connection parameters? The documentation isn't being helpful here.
{Edit: I managed to figure this out. The below works now}
Here are the Maven dependencies I added:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-mongodb</artifactId>
<version>${camel-version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-mongodb-starter</artifactId>
<version>${camel-version}</version>
</dependency>
And here are the additions to my application.properties file
spring.data.mongodb.host=<IP>
spring.data.mongodb.port=27017
spring.data.mongodb.database=dev
spring.data.mongodb.username=test
spring.data.mongodb.password=password
And the Camel route:
package Order;
import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;
#Component
public class OrderRouter extends RouteBuilder {
#Override
public void configure() {
// Process message
from("jms:topic:order")
.log("JMS Message: ${body}")
.choice()
.when().jsonpath("$.[?(#.type=='partial')]")
.to("mongodb:mongo?database=dev&collection=order&operation=insert");
}
}
Does this mean I need to define a bean when connecting with Camel? Looking at the documentation it seems that it should generate a bean by adding camel-mongodb-starter along with the application.properteis
https://camel.apache.org/components/latest/mongodb-component.html#_spring_boot_auto_configuration
I found the spring bean name, but only by looking around for examples...
spring.data.mongodb

"The current backend id,DB2UDBNT_V91_1, does not have equivalent deployed code in the jar." error while WAS 8.5 server startup

we are migrating our project from Websphere 6.1 to 8.5 and java from 1.5 to 1.7. While starting the server, we are getting this error. Not sure of the reason, could someone help me. Its been 2 days now :( We are using DB2.
[3/3/16 12:45:26:555 IST] 00000049 SharedEJBRunt I WSVR0057I: EJB jar started: BDSService.jar
[3/3/16 12:45:26:609 IST] 00000049 SharedEJBRunt I WSVR0037I: Starting EJB jar: batchejb.jar
[3/3/16 12:45:26:614 IST] 00000049 WASNameSpaceB I CNTR0167I: The server is binding the com.s1.arch.batch.core.BatchThreadProcessorServiceHome interface of the BatchService enterprise bean in the batchejb.jar module of the epj2ee application. The binding location is: ejb/com/s1/arch/batch/BatchService
[3/3/16 12:45:26:617 IST] 00000049 AbstractEJBRu I CNTR0167I: The server is binding the com.s1.arch.batch.core.BatchThreadProcessorServiceHome interface of the BatchService enterprise bean in the batchejb.jar module of the epj2ee application. The binding location is: java:global/epj2ee/batchejb/BatchService!com.s1.arch.batch.core.BatchThreadProcessorServiceHome
[3/3/16 12:45:26:621 IST] 00000049 SharedEJBRunt I WSVR0057I: EJB jar started: batchejb.jar
[3/3/16 12:45:26:672 IST] 00000049 SharedEJBRunt I WSVR0037I: Starting EJB jar: coreejb.jar
[3/3/16 12:45:26:686 IST] 00000049 PMModuleCooki E PMGR1010E: The current backend id,DB2UDBNT_V91_1, does not have equivalent deployed code in the jar.
[3/3/16 12:45:26:686 IST] 00000049 PMModuleCooki E PMGR0000E: Call stack:
com.ibm.ws.ejbpersistence.utilpm.PersistenceManagerException: PMGR1010E: The current backend id,DB2UDBNT_V91_1, does not have equivalent deployed code in the jar.
at com.ibm.ws.ejbpersistence.beanextensions.ConcreteBeanClassExtensionImpl.createPMException(ConcreteBeanClassExtensionImpl.java:340)
at com.ibm.ws.ejbpersistence.beanextensions.PMModuleCookieImpl.getBindingName(PMModuleCookieImpl.java:460)
at com.ibm.ws.ejbpersistence.beanextensions.PMModuleCookieImpl.beanInstall(PMModuleCookieImpl.java:365)
at com.ibm.ws.ejbpersistence.beanextensions.PersistenceManagerImpl.beanInstall(PersistenceManagerImpl.java:66)
at com.ibm.ws.runtime.component.WASEJBRuntimeImpl.addHome(WASEJBRuntimeImpl.java:1686)
at com.ibm.ws.ejbcontainer.runtime.AbstractEJBRuntime.startModule(AbstractEJBRuntime.java:639)
at com.ibm.ws.ejbcontainer.runtime.SharedEJBRuntimeImpl.startModule(SharedEJBRuntimeImpl.java:336)
at com.ibm.ws.runtime.component.EJBContainerImpl.start(EJBContainerImpl.java:3576)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1175)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1370)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:639)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:968)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:774)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2182)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:445)
at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:388)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$500(CompositionUnitMgrImpl.java:116)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$CUInitializer.run(CompositionUnitMgrImpl.java:994)
at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:502)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1862)
[3/3/16 12:45:26:688 IST] 00000049 AbstractEJBRu E CNTR0035E: EJB container caught javax.ejb.EJBException: nested exception is: com.ibm.ws.ejbpersistence.utilpm.PersistenceManagerException: PMGR1010E: The current backend id,DB2UDBNT_V91_1, does not have equivalent deployed code in the jar.
at com.ibm.ws.ejbpersistence.beanextensions.PMModuleCookieImpl.getBindingName(PMModuleCookieImpl.java:460)
at com.ibm.ws.ejbpersistence.beanextensions.PMModuleCookieImpl.beanInstall(PMModuleCookieImpl.java:365)
at com.ibm.ws.ejbpersistence.beanextensions.PersistenceManagerImpl.beanInstall(PersistenceManagerImpl.java:66)
at com.ibm.ws.runtime.component.WASEJBRuntimeImpl.addHome(WASEJBRuntimeImpl.java:1686)
at com.ibm.ws.ejbcontainer.runtime.AbstractEJBRuntime.startModule(AbstractEJBRuntime.java:639)
at com.ibm.ws.ejbcontainer.runtime.SharedEJBRuntimeImpl.startModule(SharedEJBRuntimeImpl.java:336)
at com.ibm.ws.runtime.component.EJBContainerImpl.start(EJBContainerImpl.java:3576)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1175)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1370)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:639)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:968)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:774)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2182)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:445)
at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:388)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$500(CompositionUnitMgrImpl.java:116)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$CUInitializer.run(CompositionUnitMgrImpl.java:994)
at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:502)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1862)
Caused by: com.ibm.ws.ejbpersistence.utilpm.PersistenceManagerException: PMGR1010E: The current backend id,DB2UDBNT_V91_1, does not have equivalent deployed code in the jar.
at com.ibm.ws.ejbpersistence.beanextensions.ConcreteBeanClassExtensionImpl.createPMException(ConcreteBeanClassExtensionImpl.java:340)
... 20 more
and is throwing com.ibm.ejs.container.ContainerException: ; nested exception is:
javax.ejb.EJBException: nested exception is: com.ibm.ws.ejbpersistence.utilpm.PersistenceManagerException: PMGR1010E: The current backend id,DB2UDBNT_V91_1, does not have equivalent deployed code in the jar..
Looks like you are using CMP EJB. During deployment you have to select backend_ID for generated EJB code. You are currently selecting DB2UDBNT_V91_1, but looks like you dont have code generated for that.
You either have to select correct backendID, or check Deploy EJB option during installation.
First check if in your EJB module, you have that backendID folder. I don't remember in which exact subfolder it should be, but you should have backends subfolder with generated files (CMPs are dead technology, I didn't use it for some time).
You may have folder with different backend name or no folder. You may need to generate mapping for CMPs and generate code once again, if your database is changing. You should be able to recreate mapping and generate code from Rational Application Developer tool.

Resteasy Bean Validation Not Working on Remote Server

I have a problem similar to the one described here.
I am using RESTEasy within a standalone Jetty application. When I start the application locally and call a service (e.g. localhost:16880/rest/user/login) bean validation works fine, i.e. I get validation errors like this:
[PARAMETER]
[UserService#login(arg0).appKey]
[app_key may not be null or empty]
[]
However, when I deploy my application to a remote host and call the same service (e.g. remotehost:16880/rest/user/login) bean validation is not invoked at all.
I am using the #ValidateRequest annotation for the service and #Valid annotation for the bean parameter.
My Resteasy version is 3.0.13.Final, though I have tried earlier versions as well. I have tried to write my custom validator, but that didn't work either.
I am puzzled why the validation works locally, but not on remote server. Any suggestions would be highly appreciated.
Since you are using Jetty as standalone server, you have to define RESTEasy validation providers where you define ServletContextHandler. Note that in standalone server there is no container to scan for #Provider classes and to activate them, so you must do it manually.
I expect that you create and start your server app something like:
//create a server listening at some port
Server server= new Server(port);
//add server handlers
HandlerList handlers= new HandlerList();
initHandlers(handlers);
server.setHandler(handlers);
//start the server
server.start();
In initHandlers you must have defined your RESTEasy support:
public void initHandlers(List<HandlerList> handlers) {
//define root context handler
ServletContextHandler servletContextHandler= new ServletContextHandler(ServletContextHandler.SESSIONS);
servletContextHandler.setContextPath("/");
handlers.addHandler(servletContextHandler);
//define RESTEasy handler
ServletHolder restServlet= new ServletHolder(new HttpServlet30Dispatcher());
//since this is a standalone server, somewhere you have to define RESTful services and Singletons
restServlet.setInitParameter("javax.ws.rs.Application", "com.exampleapp.MyRestApplication");
restServlet.setInitParameter("resteasy.servlet.mapping.prefix", "rest");
servletContextHandler.addServlet(restServlet, "rest/*");
}
So what is left to do now is to add Validation provider as init parameter:
restServlet.setInitParameter("resteasy.providers", "org.jboss.resteasy.plugins.validation.ValidatorContextResolver,org.jboss.resteasy.api.validation.ResteasyViolationExceptionMapper");
On this link I tried to find the name of the validator providers: https://docs.jboss.org/resteasy/docs/3.0.4.Final/userguide/html/Validation.html
RESTEasy obtains a bean validation implemenation by looking in the available META-INF/services/javax.ws.rs.Providers files for an implementation of ContextResolver
So it does not say what, but says where. Now open the "resteasy-hibernatevalidator-provider-3...*.jar (from Eclipse -> Maven dependencies or manually unzip) and look into META-INF/services/javax.ws.rs.ext.Providers It says:
org.jboss.resteasy.plugins.validation.hibernate.ValidatorContextResolver
org.jboss.resteasy.api.validation.ResteasyViolationExceptionMapper
If you don't have this dependency, then add it to your pom file:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-hibernatevalidator-provider</artifactId>
<version>${resteasy.version}</version>
</dependency>
One more note: that at the same place where you described validation providers, you also add other providers, if you happen to need them (such as JacksonJaxbJson, etc).

Trying to configure an active MQ broker with a plugin in Java, where should <bean class="..."> attribute be pointing to?

I'm trying to configure an activemq broker with a plugin installed, but can't seem to get the qualified name of the plugin class right in the broker configuration file.
I have pasted the error message followed by the broker config below. Basicallly in the element I'm specifying
class="file:C:/Marcus/JavaProjects/Project/build/prod/classes/com/foo/jms/amqplugin/XmlValidationPlugin"
which is absolute path to the XmlValidationPlugin.class file(have tried appending .class to path above but I get the same error).
Initially I assumed that the class attribute should be pointing to the .class file but have tried pointing it to .java and still doesn't work.
I have read the active MQ faq on developing plugins, FAQs, spring documentation etc.
My class path is
.;JAVA_HOME\lib;C:\Marcus\JavaProjects\Project;C:\Marcus\JavaProjects\Project\build\prod\classes
and JAVA_HOME is:
C:\Program Files\Java\jdk1.7.0_03
all the java source resides in
C:\Marcus\JavaProjects\Project\src
and the .class files are in
C:\Marcus\JavaProjects\Project\build\prod\classes
( file structure in classes mirrors that in src,so for example
com.foo.jms.amqplugin.XmlValidationPlugin
will have its .class file in
classes/com/foo/jms/amqplugin )
the plugin in question is XmlValidationPlugin.java, and is in folder src in package:
com.foo.jms.amqplugin
I have tried putting XmlValidationPlugin.class in a JAR and putting the JAR in activemqinstalldir/lib,( as was recommended to other people who had a similar problem) but this has not helped.
I have spent a day and a half on this already, and would really appreciate if anyone has any idea what the value of the plugins class attribute should be, as I have tried everything... Thanks in advance!
TOP OF ERROR OUTPUT:
C:\Program Files\apache-activemq-5.5.1>bin\activemq xbean:file:C:/Marcus/JavaProjects/Project/config/custom-broker.xml
Java Runtime: Oracle Corporation 1.7.0_03 C:\Program Files\Java\jdk1.7.0_03\jre
Heap sizes: current=15872k free=14246k max=506816k
JVM args: -Dcom.sun.management.jmxremote -Xmx512M -Dorg.apache.activemq.UseDedicatedTaskRunner=true -Djava.util.logging.config.file=logging.properties -Dactivemq.classpath=C:\Program Files\apache-
activemq-5.5.1\bin\../conf;C:\Program Files\apache-activemq-5.5.1\bin\../conf; -Dactivemq.home=C:\Program Files\apache-activemq-5.5.1\bin\.. -Dactivemq.base=C:\Program Files\apache-activemq-5.5.1\bin\
..
ACTIVEMQ_HOME: C:\Program Files\apache-activemq-5.5.1\bin\..
ACTIVEMQ_BASE: C:\Program Files\apache-activemq-5.5.1\bin\..
Loading message broker from: xbean:file:C:/Marcus/JavaProjects/Project/config/custom-broker.xml
INFO | Refreshing org.apache.activemq.xbean.XBeanBrokerFactory$1#7a8ba4: startup date [Thu Apr 12 10:38:26 CEST 2012]; root of context hierarchy
ERROR: java.lang.RuntimeException: Failed to execute start task. Reason: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to load type: file:C:/Marcus/JavaProjects/Project/build/prod/classes/com/foo/jms/amqplugin/XmlValidationPlugin. Reason: java.lang.ClassNotFoundException: file:C:/Marcus/JavaProjects/Project/build/prod/classes/com/foo/jms/amqplugin/XmlValidationPlugin; nested exception is java.lang.ClassNotFoundException: file:C:/Marcus/JavaProjects/Project/build/prod/classes/com/foo/jms/amqplugin/XmlValidationPlugin
java.lang.RuntimeException: Failed to execute start task. Reason: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to load type: file:C:/Marcus/JavaProjects/Project/build/prod/classes/com/foo/jms/amqplugin/XmlValidationPlugin.
Reason: java.lang.ClassNotFoundException: file:C:/Marcus/JavaProjects/Project/build/prod/classes/com/foo/jms/amqplugin/XmlValidationPlugin; nested exception is java.lang.ClassNotFoundException: file:C:/Marcus/JavaProjects/Project/build/prod/classes/com/foo/jms/amqplugin/XmlValidationPlugin
at org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:98)
at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:143)
at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
...
BROKER CONFIG FILE:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
<!-- Allows us to use system properties as variables in this configuration file -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>file:${activemq.base}/conf/credentials.properties</value>
</property>
</bean>
<!--The <broker> element is used to configure the ActiveMQ broker. -->
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost"
dataDirectory="${activemq.base}/data">
...
<!--plugin-->
<plugins>
<bean xmlns="http://www.springframework.org/schema/beans"
id="xmlValidationPlugin"
class="com.foo.jms.amqplugin.XmlValidationPlugin"/>
</plugins>
</broker>
</beans>
Basicallly in the element I'm specifying class="file:C:/Marcus/JavaProjects/Project/build/prod/classes/com/foo/jms/amqplugin/XmlValidationPlugin" which is absolute path to the XmlValidationPlugin.class file(have tried appending .class to path above but I get the same error). Initially I assumed that the class attribute should be pointing to the .class file but have tried pointing it to .java and still doesn't work.
It seems that the error you are getting is from the classloader.
Reason: java.lang.ClassNotFoundException: file:C:/Marcus/JavaProjects/Project/build/prod/classes/com/foo/jms/amqplugin/XmlValidationPlugin; nested exception is java.lang.ClassNotFoundException: file:C:/Marcus/JavaProjects/Project/build/prod/classes/com/foo/jms/amqplugin/XmlValidationPlugin
Classloader expects a fully qualified class-name instead of a path to the class file. Try to specify the fully qualified class name instead of the path to the class file .
Instead of:
file:C:/Marcus/JavaProjects/Project/build/prod/classes/com/foo/jms/amqplugin/XmlValidationPlugin
Use:
com.foo.jms.amqplugin.XmlValidationPlugin
and do make sure that CLASSPATH environment variable will contain: C:/Marcus/JavaProjects/Project/build/prod/classes
If ActiveMQ uses some custom classloader for loading plug-ins (I do not know the details), you might need to specify the classpath in some ActivemMQ-specific way.