I have generated two simple wildfly swarm projects. First has EJB facade with Remote interface, second should lookup it and send message. So second should be as client.
I am used
Wildfly swarm version 2017.9.4
My EJB facade lookup paths:
java:global/ejb-one/PingFacade!io.project.core.interfaces.PingFacadeRemote
java:app/ejb-one/PingFacade!io.project.core.interfaces.PingFacadeRemote
java:module/PingFacade!io.project.core.interfaces.PingFacadeRemote
java:jboss/exported/ejb-one/PingFacade!io.project.core.interfaces.PingFacadeRemote
java:global/ejb-one/PingFacade
java:app/ejb-one/PingFacade
java:module/PingFacade
My client :
public static void main(String[] args) {
BackendConnectionManager manager = new BackendConnectionManager();
try {
manager.getPingFacadeRemote().savePingMessage("halloooooo");
} catch (NamingException ex) {
Logger.getLogger(BackendConnectionManager.class.getName()).log(Level.SEVERE, null, ex);
}
}
public PingFacadeRemote getPingFacadeRemote() throws NamingException {
final Hashtable jndiProperties = new Hashtable();
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
jndiProperties.put(Context.PROVIDER_URL,"http-remoting://localhost:8080");
//jndiProperties.put(Context.PROVIDER_URL,"http://localhost:8080");
final Context context = new InitialContext(jndiProperties);
return (PingFacadeRemote) context
.lookup("java:global/ejb-one/PingFacade!io.project.core.interfaces.PingFacadeRemote");
}
Added client dependencies to pom.xml
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>ejb-remote</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-naming</artifactId>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-ejb-client</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jboss.xnio</groupId>
<artifactId>xnio-api</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jboss.xnio</groupId>
<artifactId>xnio-nio</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jboss.remoting3</groupId>
<artifactId>jboss-remoting</artifactId>
<version>3.3.3.Final</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jboss.sasl</groupId>
<artifactId>jboss-sasl</artifactId>
<scope>runtime</scope>
<version>1.0.5.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.marshalling</groupId>
<artifactId>jboss-marshalling-river</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.transaction</groupId>
<artifactId>jboss-transaction-api_1.2_spec</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.jms</groupId>
<artifactId>jboss-jms-api_2.0_spec</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.ejb</groupId>
<artifactId>jboss-ejb-api_3.2_spec</artifactId>
<scope>runtime</scope>
</dependency>
I do not what is whole dependencies for client and always has
javax.naming.CommunicationException: WFNAM00018: Failed to connect to remote host [Root exception is org.jboss.remoting3.ServiceOpenException: Unknown service name]
at org.wildfly.naming.client.remote.RemoteContext.getRemoteTransport(RemoteContext.java:80)
at org.wildfly.naming.client.remote.RemoteContext.lambda$lookupNative$0(RemoteContext.java:106)
at org.wildfly.naming.client.NamingProvider.performExceptionAction(NamingProvider.java:150)
at org.wildfly.naming.client.remote.RemoteContext.lookupNative(RemoteContext.java:104)
at org.wildfly.naming.client.AbstractFederatingContext.lookup(AbstractFederatingContext.java:74)
at org.wildfly.naming.client.AbstractFederatingContext.lookup(AbstractFederatingContext.java:60)
at org.wildfly.naming.client.WildFlyRootContext.lookup(WildFlyRootContext.java:150)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at io.project.ejbtwo.rest.BackendConnectionManager.getPingFacadeRemote(BackendConnectionManager.java:57)
at io.project.ejbtwo.rest.BackendConnectionManager.main(BackendConnectionManager.java:43)
Caused by: org.jboss.remoting3.ServiceOpenException: Unknown service name
Also how to solve problem with passing security credentials in client lookup?
Projects by itself here
https://drive.google.com/open?id=0B45Md1_c5-gGQ0p3Q2pURUxOY00
In BackendConnectionManager.java, line 57, you are trying to look up the service java:global/ejb-one/PingFacade!io.project.core.interfaces.PingFacadeRemote, but it seems to not exist. PingFacadeRemote interface is a part of ejb-core module. Yes, it is true that you implement it in ejb-one module, but you registered the interface as a remote (#Remote(PingFacadeRemote.class), in PingFacade.java).
You might try to replace it with java:global/ejb-core/PingFacade!io.project.core.interfaces.PingFacadeRemote.
Related
Using Quarkus I get the following error at execution time:
Caused by: java.lang.IllegalArgumentException: Multiple matching
properties for name "security.jaxrs.deny-unannotated-endpoints"
property was matched by both public boolean
io.quarkus.resteasy.reactive.common.runtime.JaxRsSecurityConfig.denyJaxRs
and public boolean
io.quarkus.resteasy.runtime.JaxRsSecurityConfig.denyJaxRs. This is
likely because you have an incompatible combination of extensions that
both define the same properties (e.g. including both reactive and
blocking database extensions)
My pom properties are:
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus-plugin.version>1.13.3.Final</quarkus-plugin.version>
<quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.version>1.13.3.Final</quarkus.platform.version>
And dependencies:
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-mutiny</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-mutiny</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-reactive</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-jwt</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-jwt-build</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-postgresql</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
I'm just trying to stream using Multi from mutiny and Server Sent Elements:
#GET
#Produces(MediaType.SERVER_SENT_EVENTS)
#RestSseElementType(MediaType.TEXT_PLAIN)
#Path("/stream/{count}/{name}")
public Multi<String> greetingsAsStream(int count, String name) {
return service.greetings(count, name);
}
You have both classic RESTEasy (quarkus-resteasy-jsonb, quarkus-resteasy-mutiny) and RESTEasy Reactive (quarkus-resteasy-reactive). You need to pick one and stick to it.
For example, if you want RESTEasy Reactive, you'd remove quarkus-resteasy-mutiny (no need for extra dependency with RESTEasy Reactive), and replace quarkus-resteasy-jsonb with quarkus-resteasy-reactive-jsonb.
I am facing a similar problem:
java.lang.RuntimeException: java.lang.IllegalArgumentException:
Multiple
matching properties for name "security.jaxrs.deny-unannotated-endpoints"
property was matched by both public boolean
io.quarkus.resteasy.reactive.common.runtime.JaxRsSecurityConfig.denyJaxRs
and
public boolean io.quarkus.resteasy.runtime.JaxRsSecurityConfig.denyJaxRs. This
is likely because you have an incompatible combination of extensions that both
define the same properties (e.g. including both reactive and blocking database
extensions)
I am using Swagger OpenAPIGenerate:
generatorName.set("jaxrs-spec")
Gradle dependencies:
dependencies {
implementation(Libs.quarkus_resteasy){
exclude(group = "io-quarkus", module = "quarkus-resteasy-runtime")
}
implementationList(LibGroups.quarkus_rest_server)
}
Libs.quarkus_resteasy
> val quarkus_resteasy = "io.quarkus:quarkus-resteasy"
LibGroups.quarkus_rest_server
>val quarkus_rest_server = listOf(
> > "io.quarkus:quarkus-vertx",
> > "io.quarkus:quarkus-resteasy-reactive-jackson"
> > //"io.quarkus:quarkus-resteasy-reactive"
> )
After excluding the clashing module, I am still getting the same error.
Any poin
I am trying to lookup for a connectionFactory in a code which is deployed as part of osgi bundle in servicemix (karaf)
final Hashtable<String, Object> jndiContext = new Hashtable<String, Object>();
jndiContext.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
jndiContext.put(Context.SECURITY_AUTHENTICATION, "none");
jndiContext.put(Context.PROVIDER_URL, pJndiLDAPserver);
ctx = new InitialContext(jndiContext);
ConnectionFactory lResult = (ConnectionFactory) ctx.lookup(pJndiCFname);
The issue I am facing is -
when I do a ctx.lookup("xyz") - It gives me a object of javax.naming.Reference instead of MQconnectionFactory. (The same code works perfectly fine as standalone java application)
Also, ctx = new InitialContext(jndiContext) gives me an object of InitialContext with defaultInitContext as -
org.apache.aries.jndi.DelegateContext. Ideally it should give me defaultInitiContext as LdapCtx (as my provider url is a Ldap server)
I have the following dependency in my pom.xml -
<dependency>
<groupId>javax.jms</groupId>
<artifactId>javax.jms-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>com.ibm.mq.osgi</groupId>
<artifactId>java</artifactId>
<version>9.0.0.0</version>
</dependency>
<dependency>
<groupId>com.ibm.msg.client.osgi.jms</groupId>
<artifactId>prereq</artifactId>
<version>9.0.0.0</version>
</dependency>
<dependency>
<groupId>com.ibm.msg.client.osgi</groupId>
<artifactId>jms</artifactId>
<version>9.0.0.0</version>
</dependency>
<dependency>
<groupId>com.ibm.msg.client.osgi.commonservices</groupId>
<artifactId>j2se</artifactId>
<version>9.0.0.0</version>
</dependency>
<dependency>
<groupId>com.ibm.mq.osgi</groupId>
<artifactId>allclient</artifactId>
<version>9.0.0.0</version>
</dependency>
<dependency>
<groupId>com.ibm.mq.osgi</groupId>
<artifactId>allclientprereqs</artifactId>
<version>9.0.0.0</version>
</dependency>
<dependency>
<groupId>com.ibm.msg.client.osgi</groupId>
<artifactId>nls</artifactId>
<version>9.0.0.0</version>
</dependency>
<dependency>
<groupId>com.ibm.msg.client.osgi.wmq</groupId>
<artifactId>nls</artifactId>
<version>9.0.0.0</version>
</dependency>
<dependency>
<groupId>com.ibm.msg.client.osgi.wmq</groupId>
<artifactId>prereq</artifactId>
<version>9.0.0.0</version>
</dependency>
<dependency>
<groupId>com.ibm.msg.client.osgi</groupId>
<artifactId>wmq</artifactId>
<version>9.0.0.0</version>
</dependency>
<dependency>
<groupId>com.csg.npms.pilatus</groupId>
<artifactId>pilatus-common</artifactId>
<version>0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-api</artifactId>
<version>1.8.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.3.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0-m09</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.1.4</version>
<scope>provided</scope>
</dependency>
and the same com.ibm dependency has been installed as part of karaf bundles.
So, therefore w.r.t abouve point 2, how can I bypass default jndi aries lookup in Karaf (org.apache.aries.jndi.DelegateContext), so that it gives me LdapContextFactory Object instead of DelegateContext. Am I missing any jars as part of mq in karaf.
This is the key part of the error:
Unresolved requirements: [[org.apache.qpid.jms.client [464](R 464.8)] osgi.wiring.package; (&(osgi.wiring.package=javax.jms (version>=1.1.0)(!(version>=2.0.0)))
This says that the bundle named org.apache.qpid.jms.client cannot be resolved because it imports the package javax.jms but there is no other bundle that exports the package javax.jms. In OSGi, every import must be matched by an export of that package. Additionally there is a version constraint: you need version [1.1.0, 2.0.0), i.e at least 1.1.0 but less than 2.0.0.
I would suggest using the following bundle from Maven Central: https://search.maven.org/#artifactdetails%7Corg.jboss.spec.javax.jms%7Cjboss-jms-api_1.1_spec%7C1.0.1.Final%7Cjar.
While I don't know how to bypass default jndi look up in karaf , something I myself am struggling with at the moment, trying to figure out how to get it to use an initial context factory that i need , i was able to get a MQ connection factory working by instantiating it directly via a bean in a blueprint, then you can name it and reference it from jndi as a normal service , like this:
<bean id="wmqcf" class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="hostname" value="my.host">
...port, channel, queue manager, etc ...
</bean>
<service interface="javax.jms.ConnectionFactory" ref="wmqcf">
<service-properties>
<entry key="osgi.jndi.service.name" value="jms/wmqcf">
</service-properties>
</srevice>
This way you don't need to worry about any bridges, pools, etc. Just a quick way to get a connection factory in your application for wmq.
UPDATE: I found some similar test in neo4j timetree source but using GraphAwareIntegrationTest, which extends ServerIntegrationTest. So I tried creating a GraphDatabaseService Bean for my test with the following, but still no luck. I get "There is no procedure with the name ga.timetree.events.attach registered for this database instance." Is this not possible?
#Bean
public GraphDatabaseService graphDatabaseService() {
GraphDatabaseService gds = new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder().newGraphDatabase();
Procedures procedures = (Procedures)((GraphDatabaseFacade) gds).getDependencyResolver().resolveDependency(Procedures.class);
try {
ClassPathProcedureUtils.registerAllProceduresAndFunctions(procedures);
}catch (Exception ex) {
log.error("error", ex);
}
return gds;
}
=====================
Similar to this issue but I'm using Spring Boot 2, SDN5 with neo4j 3.2.5, graphaware and time tree. I have automatic event attachment setup, and i see events getting saved to the timetree, but I can't query using the procedure call using cypher. I get the error:
Caused by: org.neo4j.ogm.exception.CypherException: Error executing Cypher; Code: Neo.ClientError.Procedure.ProcedureNotFound; Description: There is no procedure with the name `ga.timetree.range` registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed.
at org.neo4j.ogm.drivers.embedded.request.EmbeddedRequest.executeRequest(EmbeddedRequest.java:176)
I don't see a TimeTreeProcedures class as answered in the linked issue. Is this still supported in embedded/unit testing?
Also, if it is supported, I would like to use a CustomRootTimeTree. Any help or pointer to cypher that I can define the custom root tree id in the procedure call would also be very much appreciated. Thanks for any help!
Test:
#Test
public void testSingleTimeTree() {
User user = new User("alper#alper.com", "alper", "alper");
userRepository.save(user);
Collection<User> found = userRepository.findByEmail("alper#alper.com");
user = found.iterator().next();
Workout workout = new Workout(new DateTime().plusMonths(2).getMillis());
workoutRepository.save(workout);
GraphUnit.printGraph(graphDb);
Iterable<Workout> workouts = workoutRepository.findWorkouts();
for(Workout workout1 : workouts) {
log.info("workout: {}", workout1);
}
}
Repo (hard coded start/end for now):
public interface WorkoutRepository extends Neo4jRepository<Workout, Long> {
#Query("CALL ga.timetree.range({start: 1506826887000, end: 1512097287, create: false})")
Iterable<Workout> findWorkouts();
}
pom.xml:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<spring-data-releasetrain.version>Kay-RELEASE</spring-data-releasetrain.version>
<!--<neo4j-ogm.version>3.0.0</neo4j-ogm.version>-->
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-releasetrain</artifactId>
<version>${spring-data-releasetrain.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-neo4j</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-ogm-embedded-driver</artifactId>
<version>${neo4j-ogm.version}</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>3.2.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- added by me -->
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-kernel</artifactId>
<version>3.2.5</version>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>com.graphaware.neo4j</groupId>
<artifactId>graphaware-framework-embedded</artifactId>
<version>3.2.5.51</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.graphaware.neo4j</groupId>
<artifactId>timetree</artifactId>
<version>3.2.1.51.27</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-graphdb-api</artifactId>
<version>3.2.5</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-io</artifactId>
<version>3.2.5</version>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>com.graphaware.neo4j</groupId>
<artifactId>tests</artifactId>
<version>3.2.5.51</version>
</dependency>
</dependencies>
I was able to finally get it working by debugging into the neo4j source. The tests that test and use Procedures are in https://github.com/graphaware/neo4j-timetree, and it's using ClassPathProcedureUtils class to load classes from target/classes directory. It looks for #Procedure annotations and will process those classes and the Procedures become available. Without modifying that to load classes from jars as well as target/classes, the only way I could get it to work (albeit a hack) is to copy the target/classes output from neo4j-timetree project into my project target/classes output dir.
UPDATE:
I was also able to get it working by just registering the procedures required directly using:
#Bean
public GraphDatabaseService graphDatabaseService() {
GraphDatabaseService gds = new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder().newGraphDatabase();
try {
ClassPathProcedureUtils.registerAllProceduresAndFunctions(procedures);
Procedures procedures = ((GraphDatabaseFacade)gds).getDependencyResolver().resolveDependency(Procedures.class);
procedures.registerProcedure(TimedEventsProcedure.class);
procedures.registerProcedure(TimeTreeProcedure.class);
procedures.registerFunction(TimedEventsProcedure.class);
procedures.registerFunction(TimeTreeProcedure.class);
}catch (Exception ex) {
log.error("error", ex);
}
return gds;
}
I created a drools project using the version 6.5.0.Final and is running fine. But when i created a maven project its throwing error
Caused by: java.lang.NoSuchMethodError: com.thoughtworks.xstream.XStream.fromXML(Ljava/net/URL;)Ljava/lang/Object;
at org.drools.compiler.kproject.models.KieModuleModelImpl$kModuleMarshaller.fromXML(KieModuleModelImpl.java:207)
at org.drools.compiler.kproject.models.KieModuleModelImpl.fromXML(KieModuleModelImpl.java:154)
at org.drools.compiler.kie.builder.impl.ClasspathKieProject.fetchKModule(ClasspathKieProject.java:179)
at org.drools.compiler.kie.builder.impl.ClasspathKieProject.fetchKModule(ClasspathKieProject.java:141)
at org.drools.compiler.kie.builder.impl.ClasspathKieProject.discoverKieModules(ClasspathKieProject.java:112)
at org.drools.compiler.kie.builder.impl.ClasspathKieProject.init(ClasspathKieProject.java:84)
at org.drools.compiler.kie.builder.impl.KieContainerImpl.<init>(KieContainerImpl.java:139)
at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieClasspathContainer(KieServicesImpl.java:135)
at org.drools.compiler.kie.builder.impl.KieServicesImpl.getKieClasspathContainer(KieServicesImpl.java:101)
at org.drools.compiler.kie.builder.impl.KieServicesImpl.getKieClasspathContainer(KieServicesImpl.java:79)
at com.powerschool.cc.validationengine.engine.ValidationEngine.getKieSession(ValidationEngine.java:49)
at com.powerschool.cc.validationengine.engine.ValidationEngine.validationEngine(ValidationEngine.java:24)
Here is my dependencies in POM file
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20140107</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
<version>${runtime.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>${runtime.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>${runtime.version}</version>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>${cdi.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
<version>${weld.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.10-java7</version> </dependency>
</dependencies>
This is the code
private KieSession getKieSession(){
KieServices services = null;
KieContainer container = null;
KieSession kieSession = null;
try{
services = KieServices.Factory.get();
container = services.getKieClasspathContainer();
kieSession = container.newKieSession("ksession-rules");
}catch(Exception e){
e.printStackTrace();
}
return kieSession;
}
getKieClasspathContainer is throwing the error.
Googled the error and found that adding Xstream dependency will solve the issue but its not. Uing Java 7 and tomcat 7. Do i need to add any other dependency to the POM?
Anybody is having any idea?
The version in the dependency in your POM for xstream is 1.4.10-java7.
Drools 6.5.0-Final comes with the jar file xstream-1.4.9.jar and that means that the Drools jars have been compiled against this version.
I cannot guarantee that this is the reason why you get this error but it is worth a try.
I'm trying to integrate Swagger into my Jersey application following the guide they provide: https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-1.X-Project-Setup-1.5
I'm using Jersy v1.17 and I'm using a custom application rather than web.xml
The following is everything I have in my simple test project which is failing!
public class ResConfig extends DefaultResourceConfig { // custom app
public ResConfig() {
super();
BeanConfig beanConfig = new BeanConfig();
beanConfig.setVersion("1.0.2");
beanConfig.setSchemes(new String[] { "http" });
beanConfig.setHost("localhost:9998");
beanConfig.setBasePath("/api");
beanConfig.setResourcePackage("test.resources"); // the package containing my resource
beanConfig.setScan(true);
}
}
The simple resource I have
#Path("hello")
#Produces("application/json")
public class Res {
public Res() {
}
#GET
public Response getHello() {
Result result = new Result(); // Result is annotated with XmlRootElement and contains one field String str;
result.setStr("hello");
return Response.status(Status.OK).entity(result).build();
}
}
The main:
public static void main(String[] args) throws Exception {
ResConfig resConfig = new ResConfig();
resConfig.getClasses().add(Res.class);
resConfig.getClasses().add(io.swagger.jaxrs.listing.ApiListingResource.class);
resConfig.getClasses().add(io.swagger.jaxrs.listing.SwaggerSerializers.class);
GrizzlyServerFactory.createHttpServer("http://localhost:9998/", resConfig);
System.in.read();
}
the POM contains the following:
<dependencies>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jersey-jaxrs</artifactId>
<version>1.5.9</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-grizzly2</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
The Jersey Grizzly server fails on start by throwing exception:
SEVERE: The following errors and warnings have been detected with resource and/or provider classes:
SEVERE: Missing dependency for method public javax.ws.rs.core.Response io.swagger.jaxrs.listing.ApiListingResource.getListing(javax.ws.rs.core.Application,javax.servlet.ServletConfig,javax.ws.rs.core.HttpHeaders,javax.ws.rs.core.UriInfo,java.lang.String) at parameter at index 1
SEVERE: Method, public javax.ws.rs.core.Response io.swagger.jaxrs.listing.ApiListingResource.getListing(javax.ws.rs.core.Application,javax.servlet.ServletConfig,javax.ws.rs.core.HttpHeaders,javax.ws.rs.core.UriInfo,java.lang.String), annotated with GET of resource, class io.swagger.jaxrs.listing.ApiListingResource, is not recognized as valid resource method.
SEVERE: Missing dependency for field: javax.servlet.ServletContext io.swagger.jaxrs.listing.ApiListingResource.context
Exception in thread "main" com.sun.jersey.spi.inject.Errors$ErrorMessagesException
at com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:170)
at com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:136)
at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:199)
at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:795)
at com.sun.jersey.api.container.ContainerFactory.createContainer(ContainerFactory.java:172)
at com.sun.jersey.api.container.ContainerFactory.createContainer(ContainerFactory.java:134)
at com.sun.jersey.api.container.grizzly2.GrizzlyServerFactory.createHttpServer(GrizzlyServerFactory.java:243)
at com.sun.jersey.api.container.grizzly2.GrizzlyServerFactory.createHttpServer(GrizzlyServerFactory.java:137)
I searched the first 2 pages of Google for an answer but nothing helped!
Swagger uses Servlet APIs, so the application MUST run in a servlet environment. The way you are configuring Grizzly does not set up a servlet container. It is only an HTTP server.
You want to use the jersey-grizzly2-servlet dependency instead, and use the GrizzlyWebContainerFactory to bootstrap the application. This will set up a servlet container.
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-grizzly2-servlet</artifactId>
<version>1.19.1</version>
</dependency>
Map<String, String> initParams = new HashMap<>();
initParams.put("javax.ws.rs.Application", "com.package.ResConfig");
GrizzlyWebContainerFactory.create(uri, initParams);