Ceylon module system: Guava class mismatch even though there's only one Guava in dependencies tree - guava

I'm defining an adapter for JSimpleDB (a persistence library) by subclassing a class that takes a Google Guava Converter as constructor parameter:
shared class RoleConverter() extends Converter<Role, String>() {
shared actual Role doBackward(String? name) {
"Cannot convert null to role."
assert (exists name);
return Role.ofName(name);
}
shared actual String doForward(Role? role) {
return role?.name else "null";
}
}
shared class RoleType() extends StringEncodedType<Role>(
javaClass<Role>(),
0,
RoleConverter()
) {
}
JSimpleDB doesn't export Guava by default, so I added the following overrides.xml to make sure the correct classes are visible to my application (I'm not using --auto-export-maven-depencies or --flat-classpath):
<overrides xmlns="http://www.ceylon-lang.org/xsd/overrides">
<module groupId="org.jsimpledb" artifactId="jsimpledb-coreapi">
<share groupId="com.google.guava" artifactId="guava" />
</module>
<module groupId="org.jsimpledb" artifactId="jsimpledb-main">
<!-- guava is already shared by jsimpledb-coreapi -->
<remove groupId="com.google.guava" artifactId="guava" />
<share groupId="org.jsimpledb" artifactId="jsimpledb-coreapi" />
<share groupId="org.jsimpledb" artifactId="jsimpledb-util" />
<share groupId="org.dellroad" artifactId="dellroad-stuff-main" />
</module>
</overrides>
This results in the following module hierarchy (my code is in fun.uschool.user.impl):
The correct com.google.guava:guava module should be exposed to my program, and indeed I can import Converter, but when I try to compile the above code I get the following error:
source/fun/uschool/user/impl/userImpl.ceylon:156: error: argument must be assignable to parameter 'arg2' of 'StringEncodedType': 'RoleConverter' is not assignable to 'Converter<Role,String>?'
RoleConverter()
^
source/fun/uschool/user/impl/userImpl.ceylon:153: error: Ceylon backend error: no suitable constructor found for StringEncodedType(no arguments)
shared class RoleType() extends StringEncodedType<Role>(
^
constructor StringEncodedType.StringEncodedType(Class<Role>,long,Converter<Role,String>) is not applicable
(actual and formal argument lists differ in length)
constructor StringEncodedType.StringEncodedType(String,Class<Role>,long,Converter<Role,String>) is not applicable
(actual and formal argument lists differ in length)
Note: Created module fun.uschool.feature.spi/1.0.0
Note: Created module fun.uschool.user.api/1.0.0
Note: Created module fun.uschool.feature.impl/1.0.0
Note: Created module fun.uschool.user.impl/1.0.0
ceylon compile: There were 2 errors
So apparently somehow the wrong com.google.guava:guava imported, even though there's only 1 visible in the module dependencies tree. How do I import the right one?
Here's the output of ceylon info's dependency analysis:
$ ceylon info fun.uschool.user.impl/1.0.0 --dependency-depth=all
Namespace: ceylon
Name: fun.uschool.user.impl
Version: 1.0.0
Artifacts: JVM (#8.1), Sources
Available: On local system
Origin: /home/ilmoeuro/Asiakirjat/Projektit/youschool/modules
Dependency Tree (up to depth ∞):
ceylon.buffer/1.3.2
ceylon.collection/1.3.2
ceylon.language/1.3.2
ceylon.interop.java/1.3.2
shared ceylon.collection/1.3.2 (already imported)
ceylon.language/1.3.2 (already imported)
shared java.base/7
ceylon.language/1.3.2 (already imported)
java.base/7 (already imported)
ceylon.interop.java/1.3.2 (already imported)
ceylon.language/1.3.2 (already imported)
ceylon.test/1.3.2
ceylon.collection/1.3.2 (already imported)
ceylon.file/1.3.2
ceylon.language/1.3.2 (already imported)
java.base/7 (already imported)
ceylon.language/1.3.2 (already imported)
ceylon.runtime/1.3.2
shared ceylon.language/1.3.2 (already imported)
shared com.redhat.ceylon.cli/1.3.2
shared com.redhat.ceylon.common/1.3.2
shared java.base/7 (already imported)
java.desktop/7
shared java.logging/7
shared com.redhat.ceylon.module-resolver/1.3.2
shared com.redhat.ceylon.common/1.3.2 (already imported)
shared com.redhat.ceylon.langtools.classfile/1.3.2
shared java.base/7 (already imported)
shared com.redhat.ceylon.model/1.3.2
shared com.redhat.ceylon.common/1.3.2 (already imported)
shared com.redhat.ceylon.langtools.classfile/1.3.2 (already imported)
shared java.base/7 (already imported)
shared java.logging/7 (already imported)
optional com.redhat.ceylon.module-resolver-aether/1.3.2
optional com.redhat.ceylon.module-resolver-javascript/1.3.2
optional com.redhat.ceylon.module-resolver-webdav/1.3.2
shared java.base/7 (already imported)
shared java.logging/7 (already imported)
javax.jaxws/7
javax.script/7
shared javax.xml/7
shared java.base/7 (already imported)
java.desktop/7 (already imported)
shared java.logging/7 (already imported)
shared optional org.tautua.markdownpapers.core/1.2.7
shared com.redhat.ceylon.common/1.3.2 (already imported)
shared com.redhat.ceylon.model/1.3.2 (already imported)
shared com.redhat.ceylon.module-resolver/1.3.2 (already imported)
com.redhat.ceylon.tool.provider/1.3.2
ceylon.language/1.3.2 (already imported)
shared com.redhat.ceylon.cli/1.3.2 (already imported)
shared com.redhat.ceylon.common/1.3.2 (already imported)
shared com.redhat.ceylon.compiler.java/1.3.2
ceylon.language/1.3.2 (already imported)
com.github.rjeschke.txtmark/0.13
shared java.base/7 (already imported)
shared com.redhat.ceylon.cli/1.3.2 (already imported)
shared com.redhat.ceylon.common/1.3.2 (already imported)
shared com.redhat.ceylon.langtools.classfile/1.3.2 (already imported)
shared com.redhat.ceylon.model/1.3.2 (already imported)
shared com.redhat.ceylon.module-resolver/1.3.2 (already imported)
shared com.redhat.ceylon.typechecker/1.3.2
shared com.redhat.ceylon.common/1.3.2 (already imported)
shared com.redhat.ceylon.model/1.3.2 (already imported)
shared com.redhat.ceylon.module-resolver/1.3.2 (already imported)
shared java.base/7 (already imported)
shared org.antlr.runtime/3.4
shared java.base/7 (already imported)
shared org.antlr.stringtemplate/3.2.1
shared java.base/7 (already imported)
shared java.desktop/7 (already imported)
shared org.antlr.antlr/2.7.7
shared java.base/7 (already imported)
shared java.desktop/7 (already imported)
shared java.base/7 (already imported)
shared java.compiler/7
java.desktop/7 (already imported)
java.logging/7 (already imported)
java.prefs/7
shared javax.xml/7 (already imported)
oracle.jdk.base/7
shared org.antlr.runtime/3.4 (already imported)
com.redhat.ceylon.compiler.js/1.3.2
ceylon.language/1.3.2 (already imported)
shared com.redhat.ceylon.cli/1.3.2 (already imported)
shared com.redhat.ceylon.common/1.3.2 (already imported)
shared com.redhat.ceylon.model/1.3.2 (already imported)
shared com.redhat.ceylon.module-resolver/1.3.2 (already imported)
com.redhat.ceylon.module-resolver-javascript/1.3.2
net.minidev.json-smart/1.1.1
shared java.base/7 (already imported)
shared com.redhat.ceylon.typechecker/1.3.2 (already imported)
shared java.base/7 (already imported)
shared java.logging/7 (already imported)
net.minidev.json-smart/1.1.1 (already imported)
shared org.antlr.runtime/3.4 (already imported)
com.redhat.ceylon.model/1.3.2 (already imported)
com.redhat.ceylon.module-loader/1.3.2
ceylon.language/1.3.2 (already imported)
com.redhat.ceylon.common/1.3.2 (already imported)
com.redhat.ceylon.model/1.3.2 (already imported)
shared com.redhat.ceylon.module-resolver/1.3.2 (already imported)
shared java.base/7 (already imported)
optional org.jboss.modules/1.4.4.Final
shared com.redhat.ceylon.module-resolver/1.3.2 (already imported)
com.redhat.ceylon.typechecker/1.3.2 (already imported)
shared java.base/7 (already imported)
org.jboss.modules/1.4.4.Final
shared java.base/7 (already imported)
shared java.instrument/7
shared java.logging/7 (already imported)
java.management/7
java.prefs/7 (already imported)
shared javax.xml/7 (already imported)
oracle.jdk.base/7 (already imported)
shared java.base/7 (already imported)
java.compiler/7 (already imported)
shared java.instrument/7 (already imported)
javax.xml/7 (already imported)
org.jboss.logmanager/2.0.3.Final
shared java.base/7 (already imported)
shared java.logging/7 (already imported)
java.management/7 (already imported)
shared java.tls/7
optional org.jboss.modules/1.4.4.Final
shared org.jboss.modules/1.4.4.Final (already imported)
java.base/7 (already imported)
org.jboss.modules/1.4.4.Final (already imported)
shared fun.uschool.feature.impl/1.0.0
ceylon.buffer/1.3.2 (already imported)
ceylon.interop.java/1.3.2 (already imported)
ceylon.language/1.3.2 (already imported)
shared maven:com.moandjiezana.toml:toml4j/0.7.1
maven:com.google.code.gson:gson/2.3.1
shared fun.uschool.feature.spi/1.0.0
ceylon.language/1.3.2 (already imported)
shared java.base/8 (already imported other version)
shared maven:org.jsimpledb:jsimpledb-main/3.5.0
maven:com.google.code.findbugs:jsr305/3.0.1 PROVIDED
maven:javax.el:javax.el-api/2.2.5
maven:javax.validation:validation-api/1.1.0.Final
maven:log4j:log4j/1.2.17 RUNTIME
optional maven:javax.mail:mail/1.4.3
optional maven:org.apache.geronimo.specs:geronimo-jms_1.1_spec/1.0
maven:org.apache.openejb:javaee-api/5.0-2 PROVIDED
maven:org.dellroad:dellroad-stuff-main/2.1.0
optional maven:au.com.bytecode:opencsv/2.4
maven:com.google.guava:guava/21.0
optional maven:com.google.code.findbugs:jsr305/1.3.9
optional maven:com.google.errorprone:error_prone_annotations/2.0.15
optional maven:com.google.j2objc:j2objc-annotations/1.1
optional maven:org.codehaus.mojo:animal-sniffer-annotations/1.14
maven:javax.validation:validation-api/1.1.0.Final (already imported)
optional maven:jline:jline/2.14.2
optional maven:log4j:log4j/1.2.17
optional maven:org.apache.ant:ant/1.9.7
optional maven:org.hibernate.javax.persistence:hibernate-jpa-2.1-api/1.0.0.Final
optional maven:org.hibernate:hibernate-core/5.0.7.Final
maven:org.slf4j:slf4j-api/1.7.25
maven:org.slf4j:slf4j-log4j12/1.7.25 RUNTIME
maven:log4j:log4j/1.2.17 (already imported)
maven:org.slf4j:slf4j-api/1.7.25 (already imported)
optional maven:org.springframework:spring-context/4.3.7.RELEASE
maven:org.hibernate:hibernate-validator/5.2.4.Final
maven:com.fasterxml:classmate/1.1.0
optional maven:com.thoughtworks.paranamer:paranamer/2.5.5
maven:javax.el:javax.el-api/2.2.4 PROVIDED (already imported other version)
maven:javax.validation:validation-api/1.1.0.Final (already imported)
optional maven:joda-time:joda-time/2.7
maven:org.glassfish.web:javax.el/2.2.4 PROVIDED
maven:javax.el:javax.el-api/2.2.4 (already imported other version)
optional maven:org.hibernate.javax.persistence:hibernate-jpa-2.1-api/1.0.0.Final
maven:org.jboss.logging:jboss-logging/3.2.1.Final
maven:log4j:log4j/1.2.16 PROVIDED (already imported other version)
maven:org.apache.logging.log4j:log4j-api/2.0 PROVIDED
maven:org.osgi:org.osgi.core/4.3.1 PROVIDED
maven:org.jboss.logmanager:jboss-logmanager/1.5.2.Final PROVIDED
optional maven:org.jboss.modules:jboss-modules/1.1.0.GA PROVIDED
maven:org.slf4j:slf4j-api/1.7.2 PROVIDED (already imported other version)
maven:org.jboss.logging:jboss-logging-processor/1.2.0.Final PROVIDED
maven:org.jboss.jdeparser:jdeparser/1.0.0.Final
maven:org.jboss.logging:jboss-logging/3.1.2.GA PROVIDED (already imported other version)
maven:org.jboss.logging:jboss-logging-annotations/1.2.0.Final
maven:org.jboss.logging:jboss-logging/3.1.2.GA PROVIDED (already imported other version)
optional maven:org.jsoup:jsoup/1.8.3
shared maven:org.jsimpledb:jsimpledb-coreapi/3.5.0
maven:com.google.code.findbugs:jsr305/3.0.1 PROVIDED (already imported)
maven:commons-codec:commons-codec/1.10
maven:log4j:log4j/1.2.17 RUNTIME (already imported other version)
maven:org.dellroad:dellroad-stuff-main/2.1.0 (already imported)
maven:org.jsimpledb:jsimpledb-kv/3.5.0
maven:com.google.code.findbugs:jsr305/3.0.1 PROVIDED (already imported)
maven:com.google.guava:guava/21.0 (already imported)
maven:log4j:log4j/1.2.17 RUNTIME (already imported other version)
maven:org.dellroad:dellroad-stuff-main/2.1.0 (already imported)
maven:org.jsimpledb:jsimpledb-util/3.5.0
maven:com.google.code.findbugs:jsr305/3.0.1 PROVIDED (already imported)
shared maven:com.google.guava:guava/21.0 (already imported)
maven:log4j:log4j/1.2.17 RUNTIME (already imported other version)
maven:org.slf4j:slf4j-api/1.7.25 (already imported other version)
maven:org.slf4j:slf4j-log4j12/1.7.25 RUNTIME (already imported)
maven:org.slf4j:slf4j-api/1.7.25 (already imported other version)
maven:org.slf4j:slf4j-log4j12/1.7.25 RUNTIME (already imported)
shared maven:org.jsimpledb:jsimpledb-util/3.5.0 (already imported)
maven:org.slf4j:slf4j-api/1.7.25 (already imported other version)
maven:org.slf4j:slf4j-log4j12/1.7.25 RUNTIME (already imported)
maven:org.jsimpledb:jsimpledb-kv/3.5.0 (already imported)
maven:org.jsimpledb:jsimpledb-kv-simple/3.5.0
maven:com.google.code.findbugs:jsr305/3.0.1 PROVIDED (already imported)
maven:com.google.guava:guava/21.0 (already imported)
maven:log4j:log4j/1.2.17 RUNTIME (already imported other version)
maven:org.dellroad:dellroad-stuff-main/2.1.0 (already imported)
maven:org.jsimpledb:jsimpledb-kv/3.5.0 (already imported)
maven:org.jsimpledb:jsimpledb-util/3.5.0 (already imported)
maven:org.slf4j:slf4j-api/1.7.25 (already imported other version)
maven:org.slf4j:slf4j-log4j12/1.7.25 RUNTIME (already imported)
maven:org.slf4j:slf4j-api/1.7.25 (already imported other version)
maven:org.slf4j:slf4j-log4j12/1.7.25 RUNTIME (already imported)
shared fun.uschool.feature.spi/1.0.0 (already imported)
shared fun.uschool.user.api/1.0.0
ceylon.language/1.3.2 (already imported)
shared fun.uschool.feature.spi/1.0.0 (already imported)
fun.uschool.user.impl/1.0.0
ceylon.buffer/1.3.2 (already imported)
ceylon.interop.java/1.3.2 (already imported)
ceylon.language/1.3.2 (already imported)
ceylon.test/1.3.2 (already imported)
shared fun.uschool.feature.impl/1.0.0 (already imported)
shared fun.uschool.feature.spi/1.0.0 (already imported)
shared fun.uschool.user.api/1.0.0 (already imported)
shared java.base/8 (already imported other version)
shared java.base/8 (already imported other version)
Dependencies (up to depth ∞):
ceylon.buffer/1.3.2
ceylon.collection/1.3.2
ceylon.file/1.3.2
ceylon.interop.java/1.3.2
ceylon.language/1.3.2
ceylon.runtime/1.3.2
ceylon.test/1.3.2
com.fasterxml:classmate/1.1.0
com.github.rjeschke.txtmark/0.13
com.google.code.findbugs:jsr305/3.0.1
com.google.code.gson:gson/2.3.1
com.google.guava:guava/21.0
com.moandjiezana.toml:toml4j/0.7.1
com.redhat.ceylon.cli/1.3.2
com.redhat.ceylon.common/1.3.2
com.redhat.ceylon.compiler.java/1.3.2
com.redhat.ceylon.compiler.js/1.3.2
com.redhat.ceylon.langtools.classfile/1.3.2
com.redhat.ceylon.model/1.3.2
com.redhat.ceylon.module-loader/1.3.2
com.redhat.ceylon.module-resolver/1.3.2
com.redhat.ceylon.module-resolver-javascript/1.3.2
com.redhat.ceylon.tool.provider/1.3.2
com.redhat.ceylon.typechecker/1.3.2
commons-codec:commons-codec/1.10
fun.uschool.feature.impl/1.0.0
fun.uschool.feature.spi/1.0.0
fun.uschool.user.api/1.0.0
fun.uschool.user.impl/1.0.0
java.base: 7, 8
java.compiler/7
java.desktop/7
java.instrument/7
java.logging/7
java.management/7
java.prefs/7
java.tls/7
javax.el:javax.el-api: 2.2.4, 2.2.5
javax.jaxws/7
javax.script/7
javax.validation:validation-api/1.1.0.Final
javax.xml/7
log4j:log4j: 1.2.16, 1.2.17
net.minidev.json-smart/1.1.1
oracle.jdk.base/7
org.antlr.antlr/2.7.7
org.antlr.runtime/3.4
org.antlr.stringtemplate/3.2.1
org.apache.logging.log4j:log4j-api/2.0
org.apache.openejb:javaee-api/5.0-2
org.dellroad:dellroad-stuff-main/2.1.0
org.glassfish.web:javax.el/2.2.4
org.hibernate:hibernate-validator/5.2.4.Final
org.jboss.jdeparser:jdeparser/1.0.0.Final
org.jboss.logging:jboss-logging: 3.1.2.GA, 3.2.1.Final
org.jboss.logging:jboss-logging-annotations/1.2.0.Final
org.jboss.logging:jboss-logging-processor/1.2.0.Final
org.jboss.logmanager/2.0.3.Final
org.jboss.logmanager:jboss-logmanager/1.5.2.Final
org.jboss.modules/1.4.4.Final
org.jsimpledb:jsimpledb-coreapi/3.5.0
org.jsimpledb:jsimpledb-kv/3.5.0
org.jsimpledb:jsimpledb-kv-simple/3.5.0
org.jsimpledb:jsimpledb-main/3.5.0
org.jsimpledb:jsimpledb-util/3.5.0
org.osgi:org.osgi.core/4.3.1
org.slf4j:slf4j-api: 1.7.2, 1.7.25
org.slf4j:slf4j-log4j12/1.7.25
Dependencies version conflicts (up to depth ∞):
java.base: 7, 8
javax.el:javax.el-api: 2.2.4, 2.2.5
log4j:log4j: 1.2.16, 1.2.17
org.jboss.logging:jboss-logging: 3.1.2.GA, 3.2.1.Final
org.slf4j:slf4j-api: 1.7.2, 1.7.25

Okay, I got it. The problem was that RoleConverter converts to ceylon.language.String, while the api was expecting a converter to java.lang.String. Fixed it now:
shared class RoleConverter() extends Converter<Role, JString>() {
shared actual Role doBackward(JString? name) {
"Cannot convert null to role."
assert (exists name);
return Role.ofName(name.string);
}
shared actual JString doForward(Role? role) {
return JString(role?.name else "null");
}
}

Related

Flink: Adding flink-sql-connector-kafka to fat-jar

I use Flink SQL (version 1.11) and would like to process data from Kafka. For this I wrote a job from the scala template and added the dependency to pom.xml.
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-kafka_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-sql-connector-kafka_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
</dependency>
When I want to run the job in the cluster, I get the following error:
Caused by: org.apache.flink.table.api.ValidationException: Could not find any factory for identifier 'kafka' that implements 'org.apache.flink.table.factories.DynamicTableSinkFactory' in the classpath.
Available factory identifiers are:
blackhole
print
If I add the flink-sql-connector-kafka jar to the /lib folder it works but then can't use the SQL client because it then loads once from its own lib folder and this connector and it is already loaded in the cluster. Then comes following error:
java.lang.ClassCastException: cannot assign instance of org.apache.commons.collections.map.LinkedMap to field org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumerBase.pendingOffsetsToCommit of type org.apache.commons.collections.map.LinkedMap in instance of org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer
How can I add the flink-sql-connector-kafka to the fat-jar? Or should these SQL connectors rather be added to the /lib folder?

JNA class not Found Error using FANNJ for Ubuntu in Eclipse

I'm trying to use FANNJ in Eclipse (on Ubuntu), trying to create a toy program but it keeps giving this error as shown below.
Code:
package myPackage;
import com.googlecode.fannj.Fann;
public class mainclass {
public static void man(String[] args) {
System.out.println("1");
Fann fann = new Fann("/home/sahil/Desktop/Intern/Java/eclipse/Workspace/UsingFANN/ANN_Net_Output1.net");
}
}
Error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/jna/Platform
at com.googlecode.fannj.Fann.<clinit>(Fann.java:51)
at myPackage.mainclass.main(mainclass.java:9)
Caused by: java.lang.ClassNotFoundException: com.sun.jna.Platform
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
Could someone who works with FANNJ on Ubuntu please explain why this error comes up?
Make sure you set the jna.library.path system property to the path to the FANN Library. This property is similar to java.library.path but only applies to libraries loaded by JNA.
You should also change the appropriate library access environment variable before launching the VM. (LD_LIBRARY_PATH on Linux)
From the command line:
LD_LIBRARY_PATH=/usr/local/lib
java -Djna.library.path=/usr/local/lib -cp fannj-0.6.jar:jna-3.2.2.jar YourClass
You have to download the missing library "jna". After get it you must point it in eclipse (Using the properties of your project > Java Build Path > Libraries, and adding the jar (you can browse it on "Add External JARs...").
A good way to get all dependancies for a project is by "maven". You can simply create a "pom.xml" file on root folder of your project. So write it down:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.something</groupId>
<artifactId>MyProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>MyProject</name>
<description>MyProject</description>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.googlecode.fannj/fannj -->
<dependency>
<groupId>com.googlecode.fannj</groupId>
<artifactId>fannj</artifactId>
<version>0.6</version>
</dependency>
</dependencies>
</project>
And finally, on commmand line type # mvn install, it will download the dependancies and by default put all libraries in your "homefolder/.m2". So, browse for JNA library, you gonna find it in some folder like this: "~/.m2/repository/net/java/dev/jna/jna/3.2.7". If your project uses other libraries besides fannj, you can add it in pom file to get everything together.

Importing External JAR to Websphere Liberty? [NoClassDefFoundError]

I want to use this JSON parser in my JAX-RS application that runs on Websphere Liberty.
I have done the following:
1) Right-click on Project -> Properties -> Java Build Path -> Add External Jar -> C:\javalib\quick-json.jar
2) Added C:\javalib to enviroment variable CLASSPATH
3) Added fileset xml to serverl.xml
<library id="ExternalLibs">
<fileset dir="C:\javalib" includes="*.jar"/>
</library>
4) Unchecked 'Enable project specific settings' in 'Java Compiler'
5) Cleaned the Project
[EDIT]
I was initially creating a new instance and then I turned it into an #ApplicationScoped bean and injected it. Now I get this error:
The JNDI lookup failed for JNDI name java:module/ConsoleREST with the following Exception CNTR4007E: An error occurred creating the websphere.jaxrs.service.ConsoleREST interface for the ConsoleREST enterprise bean in the WebApiConsole.war module in the WebApiConsole application. The enterprise bean look up failed using the java:module/ConsoleREST JNDI name. Exception: com/json/parsers/JsonParserFactory.
CNTR4007E: An error occurred creating the websphere.jaxrs.service.ConsoleREST interface for the ConsoleREST enterprise bean in the WebApiConsole.war module in the WebApiConsole application. The enterprise bean look up failed using the java:module/ConsoleREST JNDI name. Exception: com/json/parsers/JsonParserFactory
The first step was enough to get it to compile. Now I'm getting what I learned to be a runtime error. I would appreciate help!
You also need a <classloader> element in your application definition in the server.xml, which references the shared library. For example,
<application id="myapp" name="My App" type="war" location="somewhere.war">
<classloader commonLibraryRef="ExternalLibs" />
</application>
Alternatively, if your application is the only user of the library, you could package it in the WEB-INF/lib folder of your war. (Putting it in WebContent/lib in Eclipse should accomplish this.)

JBoss eap 6 JNDI Issue

I am trying out the following tutorial which creates a simple EJB and then accesses via a Java SE client:
http://www.tutorialspoint.com/ejb/ejb_create_application.htm
This tutorial uses ant but I am using maven. Now, in my client, I am getting the following error while creating the initial context:
javax.naming.NoInitialContextException: Cannot instantiate class:
org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException:
org.jnp.interfaces.NamingContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:674)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
at javax.naming.InitialContext.init(InitialContext.java:242)
at javax.naming.InitialContext.<init>(InitialContext.java:216)
at EJBDriver.main(EJBDriver.java:21)
I have added the following dependencies to my pom.xml:
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-ejb-client-bom</artifactId>
Finally, the jndi properties:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=localhost:4447
How to solve this issue?
I solved the problem as follows
1- If the EJB classes are in different projects, than the project with EJB classes needs to be added to the classpath of the project containing the client. For Eclipse:
Right Click on project->Build Path->Configure Build Path-> Projects tab->Add->Select the desired project->OK->OK
2- The jboss-client.jar file needs to be added to the class path of the EJB client project as well.
Right Click on project->Build Path->Configure Build Path-> Projects tab->Librariers->Add External JAR
Browse to the jboss-client.jar file(In windows its located in JBoss_Installation/bin/client)
Select the file and click OK twice.
jboss 6 should use the following properties:
naming factory= org.jboss.naming.remote.client.InitialContextFactory
provider url= remote://localhost:4447

How set jdni.properties on ireport

7.2 with ejbql connection my problem is that when i test the connection, fails because Could not find datasource, in the log says:
Caused by: org.hibernate.HibernateException: Could not find datasource
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
I guees can be the jndi.properties that in the wrong directory, i tried put into java_home/lib but doesn't work
Finally after a lot of work i made the ejbql connection with ireport. Follow this steps to do it!!
1) i'm using jboss 4.2.3, so if you using glashfish or other server, find the libraries that match with the jboss that i'm using
2) You need to find in your jboss directory server/default/lib the follow libraries:
hibernate3.jar
hibernate-entitymanager.jar
jboss-common.jar
hibernate-annotations.jar
ejb3-persistence.jar
jboss.jar
3) copy the libraries previously named and copy your ireport installation directory in this path \Jaspersoft\iReport-3.7.2\ireport\modules\ext and replace it, note that the library call hibernate-common-annotation and jpa.jar need to be erase from that path. You need to do it because this library creates conflicts with hibernate-annotations and ejb3-persistence.jar.
4) get the jar of your project and copy it in your in this example let's called example-core.jar to the installation directory in the path \Jaspersoft\iReport-3.7.2\ireport\libs
5) modify the jar the persistence.xml of your project (in our case "example.jar") and sets with this next properties,
<?xml version="1.0" encoding="UTF-8"?>
<persistence
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="example" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>/jdbc/example</non-jta-data-source>
<properties>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
</properties>
</persistence-unit>
</persistence>
6)Go to ireport and add the libraries to the classpath, in tools, options in the tab of classpath
7) go to the installation directory of ireport in the path Jaspersoft\iReport3.7.2\ireport\modules open the jar called com-jaspersoft-ireport with winrar or other tool , and go to META-INF/MANIFEST.INF in the part of Class-Path modify the name of the library "hibernate-common-annotation.jar" (renember you erase this library) for the "hibernate-annotations.jar"
8)Go to Jboss_home/server/default/deploy and modify the datasource xml of your project and put this configuration, (renember in this example the project is call "example" and the datasource should be called example-ds.xml)
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/example</jndi-name>
<use-java-context>false</use-java-context>
<connection-url>jdbc:oracle:thin:#localhost:1521:XE</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>example</user-name>
<password>example</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
Note that the property usa-java-context in false is that allow you to access to the data source outside of the jboss in our case from ireport
9)go to the ireport and add the follow libraries into the ireport classpath
jnp-client.jar
jboss-client.jar
jbossall-client.jar
the database driver in my case ojdbc.jar (for oracle)
jboss-ejb3x.jar
10) sets your jndi.properties and put it into the jar hibernate-entitymanager.jar
11) Now run the jboss, go to ireport and create the ejql connection, in the persistence unit name sets the name that place in the persistence.xml of the jar located in installation directory Jaspersoft\iReport-3.7.2\ireport\libs, in this case the persistence unit name is "example" without the quotes marks
I hope that this help to somebody or someone jeje, i know that's pretty hard, and sorry for my english its not my first language