I would like to cross-compile some Rust code for a Raspberry Pi, i.e. use the armv7-unknown-linux-gnueabihf linker. In this package, I used the Rodio library for interfacing with the sound system. This package compiles and runs fine on the build OS (macOS) but I cant compile it to the target, because I then get this error.
Compiling backtrace-sys v0.1.33 Compiling alsa-sys v0.1.2 Compiling minimp3-sys v0.3.2 Compiling syn v1.0.16 Compiling lewton v0.9.4 error: failed to run custom build command for `alsa-sys v0.1.2`
Caused by: process didn't exit successfully: `$HOME/Documents/Personal/Code/Projects/rust_playground/handtekening/target/debug/build/alsa-sys-643139a54771ba41/build-script-build` (exit code: 101)
--- stderr thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "Cross compilation detected. Use PKG_CONFIG_ALLOW_CROSS=1 to override"', src/libcore/result.rs:1188:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
warning: build failed, waiting for other jobs to finish... error: failed to run custom build command for `backtrace-sys v0.1.33`
Caused by: process didn't exit successfully: `$HOME/Documents/Personal/Code/Projects/rust_playground/handtekening/target/debug/build/backtrace-sys-3dc6e67ada300248/build-script-build` (exit code: 1)
--- stdout cargo:rustc-cfg=rbt TARGET = Some("armv7-unknown-linux-gnueabihf") OPT_LEVEL = Some("0") HOST = Some("x86_64-apple-darwin") CC_armv7-unknown-linux-gnueabihf = None CC_armv7_unknown_linux_gnueabihf = None TARGET_CC = None CC = None CROSS_COMPILE = None CFLAGS_armv7-unknown-linux-gnueabihf = None CFLAGS_armv7_unknown_linux_gnueabihf = None TARGET_CFLAGS = None CFLAGS = None CRATE_CC_NO_DEFAULTS = None CARGO_CFG_TARGET_FEATURE = None running: "arm-linux-gnueabihf-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-march=armv7-a" "-I" "src/libbacktrace" "-I" "/Users/tresink/Documents/Personal/Code/Projects/rust_playground/handtekening/target/armv7-unknown-linux-gnueabihf/debug/build/backtrace-sys-771c80e09bcc7056/out" "-fvisibility=hidden" "-DBACKTRACE_ELF_SIZE=32" "-DBACKTRACE_SUPPORTED=1" "-DBACKTRACE_USES_MALLOC=1" "-DBACKTRACE_SUPPORTS_THREADS=0" "-DBACKTRACE_SUPPORTS_DATA=0" "-DHAVE_DL_ITERATE_PHDR=1" "-D_GNU_SOURCE=1" "-D_LARGE_FILES=1" "-Dbacktrace_full=__rbt_backtrace_full" "-Dbacktrace_dwarf_add=__rbt_backtrace_dwarf_add" "-Dbacktrace_initialize=__rbt_backtrace_initialize" "-Dbacktrace_pcinfo=__rbt_backtrace_pcinfo" "-Dbacktrace_syminfo=__rbt_backtrace_syminfo" "-Dbacktrace_get_view=__rbt_backtrace_get_view" "-Dbacktrace_release_view=__rbt_backtrace_release_view" "-Dbacktrace_alloc=__rbt_backtrace_alloc" "-Dbacktrace_free=__rbt_backtrace_free" "-Dbacktrace_vector_finish=__rbt_backtrace_vector_finish" "-Dbacktrace_vector_grow=__rbt_backtrace_vector_grow" "-Dbacktrace_vector_release=__rbt_backtrace_vector_release" "-Dbacktrace_close=__rbt_backtrace_close" "-Dbacktrace_open=__rbt_backtrace_open" "-Dbacktrace_print=__rbt_backtrace_print" "-Dbacktrace_simple=__rbt_backtrace_simple" "-Dbacktrace_qsort=__rbt_backtrace_qsort" "-Dbacktrace_create_state=__rbt_backtrace_create_state" "-Dbacktrace_uncompress_zdebug=__rbt_backtrace_uncompress_zdebug" "-Dmacho_get_view=__rbt_macho_get_view" "-Dmacho_symbol_type_relevant=__rbt_macho_symbol_type_relevant" "-Dmacho_get_commands=__rbt_macho_get_commands" "-Dmacho_try_dsym=__rbt_macho_try_dsym" "-Dmacho_try_dwarf=__rbt_macho_try_dwarf" "-Dmacho_get_addr_range=__rbt_macho_get_addr_range" "-Dmacho_get_uuid=__rbt_macho_get_uuid" "-Dmacho_add=__rbt_macho_add" "-Dmacho_add_symtab=__rbt_macho_add_symtab" "-Dmacho_file_to_host_u64=__rbt_macho_file_to_host_u64" "-Dmacho_file_to_host_u32=__rbt_macho_file_to_host_u32" "-Dmacho_file_to_host_u16=__rbt_macho_file_to_host_u16" "-o" "$HOME/Documents/Personal/Code/Projects/rust_playground/handtekening/target/armv7-unknown-linux-gnueabihf/debug/build/backtrace-sys-771c80e09bcc7056/out/src/libbacktrace/alloc.o" "-c" "src/libbacktrace/alloc.c"
--- stderr
error occurred: Failed to find tool. Is `arm-linux-gnueabihf-gcc` installed?
warning: build failed, waiting for other jobs to finish... error: failed to run custom build command for `minimp3-sys v0.3.2`
Caused by: process didn't exit successfully: `$HOME/Documents/Personal/Code/Projects/rust_playground/handtekening/target/debug/build/minimp3-sys-592af14148b11e3c/build-script-build` (exit code: 1)
--- stdout TARGET = Some("armv7-unknown-linux-gnueabihf") OPT_LEVEL = Some("0") HOST = Some("x86_64-apple-darwin") CC_armv7-unknown-linux-gnueabihf = None CC_armv7_unknown_linux_gnueabihf = None TARGET_CC = None CC = None CROSS_COMPILE = None CFLAGS_armv7-unknown-linux-gnueabihf = None CFLAGS_armv7_unknown_linux_gnueabihf = None TARGET_CFLAGS = None CFLAGS = None CRATE_CC_NO_DEFAULTS = None DEBUG = Some("true") CARGO_CFG_TARGET_FEATURE = None running: "arm-linux-gnueabihf-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-march=armv7-a" "-I" "minimp3/" "-Wall" "-Wextra" "-DMINIMP3_IMPLEMENTATION" "-o" "$HOME/Documents/Personal/Code/Projects/rust_playground/handtekening/target/armv7-unknown-linux-gnueabihf/debug/build/minimp3-sys-0a9af7541b5f3089/out/minimp3.o" "-c" "minimp3.c"
--- stderr
error occurred: Failed to find tool. Is `arm-linux-gnueabihf-gcc` installed?
warning: build failed, waiting for other jobs to finish... error: linker `arm-linux-gnueabihf` not found | = note: No such file or directory (os error 2)
error: aborting due to previous error
error: could not compile `lewton`. warning: build failed, waiting for other jobs to finish... error: build failed`
I think it is because I didn't compile the rodio package for the target, because all the failing compiling targets are audio related, but I can't find how to include this library in the cross-compilation process.
I´m coding a small example in Spark Structured Streaming where I´m trying to process the output of the netstatcommand and can´t figure out how to invoke the windowfunction.
These are the relevant lines of my build.sbt:
scalaVersion := "2.11.4"
scalacOptions += "-target:jvm-1.8"
libraryDependencies ++= {
val sparkVer = "2.3.0"
Seq(
"org.apache.spark" %% "spark-streaming" % sparkVer % "provided",
"org.apache.spark" %% "spark-streaming-kafka-0-8" % sparkVer % "provided",
"org.apache.spark" %% "spark-core" % sparkVer % "provided" withSources(),
"org.apache.spark" %% "spark-hive" % sparkVer % "provided",
)
}
And the code:
case class NetEntry(val timeStamp: java.sql.Timestamp, val sourceHost: String, val targetHost: String, val status: String)
def convertToNetEntry(x: String): NetEntry = {
// tcp 0 0 eselivpi14:icl-twobase1 eselivpi149.int.e:48442 TIME_WAIT
val array = x.replaceAll("\\s+"," ").split(" ").slice(3,6)
NetEntry(java.sql.Timestamp.valueOf(LocalDateTime.now()), array(0),array(1),array(2))
}
def main(args: Array[String]) {
// Initialize spark context
val spark: SparkSession = SparkSession.builder.appName("StructuredNetworkWordCount").getOrCreate()
spark.sparkContext.setLogLevel("ERROR")
val lines = spark.readStream
.format("socket")
.option("host", args(0))
.option("port", args(1).toInt)
.load()
import spark.implicits._
val df = lines.as[String].map(x => convertToNetEntry(x))
val wordsArr: Dataset[NetEntry] = df.as[NetEntry]
wordsArr.printSchema()
// Never get past this point
val windowColumn = window($"timestamp", "10 minutes", "5 minutes")
val windowedCounts = wordsArr.groupBy( windowColumn, $"targetHost").count()
val query = windowedCounts.writeStream.outputMode("complete").format("console").start()
query.awaitTermination()
}
I have with Spark 2.1, 2,2 and 2.3 with the same results. What is really bizarre is that, I have a Spark Cluster, I log in the Spark Shell and copy all the lines... and it works! Any idea of what am I doing wrong?
The error at compilation time:
[error] C:\code_legacy\edos-dp-mediation-spark-consumer\src\main\scala\com\ericsson\streaming\structured\StructuredStreamingMain.scala:39: not found: value window
[error] val windowColumn = window($"timestamp", "10 minutes", "5 minutes")
[error] ^
[warn] 5 warnings found
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 19 s, completed 16-mar-2018 20:13:40
Update: To make things weirder, I have check the API docs and I could not found a valid reference here either:
https://spark.apache.org/docs/2.3.0/api/scala/index.html#org.apache.spark.sql.SparkSession$implicits$
You need to import the window function to compile it, which is already imported in spark-shell.
Add this import statement:
import org.apache.spark.sql.functions.window
I'm getting a really vague exception from Hibernate when trying to use it with Oracle.(it works normally with MySQL)
I have the following configuration:
Play Framework: 2.3.7
ojdbc14.jar
Hibernate: 4.3.8.Final
I'm using Oracle 10i
The application manages to connect, but fails when trying to build the Entity Manager.
I tried to build it manually, but I got the same error when using Play's annotation #play.db.jpa.Transactional
For example: Accessing via raw JDBC works normally.
My database settings in application.conf:
db.default.driver=oracle.jdbc.driver.OracleDriver
db.default.url="jdbc:oracle:thin:#IP:1521:SID"
db.default.user=USER_NAME
db.default.pass=ROOT
db.default.jndiName=DefaultDS
jpa.default=defaultPersistenceUnit
My Persistence.xml:
<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_2_0.xsd"
version="2.0">
<persistence-unit name="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>DefaultDS</non-jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
</properties>
</persistence-unit>
</persistence>
Here's the exception:
play.api.UnexpectedException: Unexpected exception[PersistenceException: Unable to build entity manager factory]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:166) ~[play_2.11-2.3.7.jar:2.3.7]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:130) ~[play_2.11-2.3.7.jar:2.3.7]
at scala.Option.map(Option.scala:145) ~[scala-library-2.11.1.jar:na]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:130) ~[play_2.11-2.3.7.jar:2.3.7]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(App licationProvider.scala:128) ~[play_2.11-2.3.7.jar:2.3.7]
Caused by: javax.persistence.PersistenceException: Unable to build entity manager factory
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:83) ~[hibernate-entitymanager-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:54) ~[hibernate-entitymanager-4.3.8.Final.jar:4.3.8.Final]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55) ~[hibernate-jpa-2.1-api-1.0.0.Final.jar:1.0.0.Final]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39) ~[hibernate-jpa-2.1-api-1.0.0.Final.jar:1.0.0.Final]
at play.db.jpa.JPAPlugin.onStart(JPAPlugin.java:38) ~[play-java-jpa_2.11-2.3.7.jar:2.3.7]
Caused by: java.lang.NullPointerException: null
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:244) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1887) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
/////////////////////////////////////////////
UPDATED:
The properties that hibernate receives are:
0 = {HashMap$Node#10729} "gopherProxySet" -> "false"
1 = {HashMap$Node#10730} "awt.toolkit" -> "sun.lwawt.macosx.LWCToolkit"
2 = {HashMap$Node#10731} "file.encoding.pkg" -> "sun.io"
3 = {HashMap$Node#10732} "java.specification.version" -> "1.8"
4 = {HashMap$Node#10733} "sun.cpu.isalist" ->
5 = {HashMap$Node#10734} "sun.jnu.encoding" -> "UTF-8"
6 = {HashMap$Node#10735} "hibernate.dialect" -> "org.hibernate.dialect.Oracle10gDialect"
7 = {HashMap$Node#10736} "java.class.path" -> "/Users/rodrigoarantes1/Library/Application Support/IntelliJIdea14/Scala/launcher/sbt-launch.jar:/Applications/IntelliJ IDEA 14.app/Contents/lib/idea_rt.jar"
8 = {HashMap$Node#10737} "java.naming.provider.url" -> "/"
9 = {HashMap$Node#10738} "sbt.global.base" -> "/private/var/folders/8l/k806t46d2fl5sq2rt6gzp7z00000gp/T/sbt-global-plugin1stub"
10 = {HashMap$Node#10739} "java.vm.vendor" -> "Oracle Corporation"
11 = {HashMap$Node#10740} "sun.arch.data.model" -> "64"
12 = {HashMap$Node#10741} "jline.shutdownhook" -> "false"
13 = {HashMap$Node#10742} "java.vendor.url" -> "http://java.oracle.com/"
15 = {HashMap$Node#10744} "javax.persistence.jdbc.user" -> "USERNAME"
16 = {HashMap$Node#10745} "hibernate.transaction.factory_class" -> "class org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory"
17 = {HashMap$Node#10746} "javax.persistence.jdbc.url" -> "jdbc:oracle:thin:#127.0.0.1:1521:XE"
18 = {HashMap$Node#10747} "jline.terminal" -> "none"
19 = {HashMap$Node#10748} "os.name" -> "Mac OS X"
20 = {HashMap$Node#10749} "java.vm.specification.version" -> "1.8"
21 = {HashMap$Node#10750} "sun.java.launcher" -> "SUN_STANDARD"
23 = {HashMap$Node#10752} "sun.boot.library.path" -> "/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib"
24 = {HashMap$Node#10753} "sun.java.command" -> "xsbt.boot.Boot run"
25 = {HashMap$Node#10754} "http.nonProxyHosts" -> "local|*.local|169.254/16|*.169.254/16"
26 = {HashMap$Node#10755} "sun.cpu.endian" -> "little"
27 = {HashMap$Node#10756} "user.home" -> "/Users/rodrigoarantes1"
28 = {HashMap$Node#10757} "user.language" -> "en"
29 = {HashMap$Node#10758} "java.specification.vendor" -> "Oracle Corporation"
30 = {HashMap$Node#10759} "java.home" -> "/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre"
31 = {HashMap$Node#10760} "file.separator" -> "/"
32 = {HashMap$Node#10761} "line.separator" -> "\n"
33 = {HashMap$Node#10762} "java.vm.specification.vendor" -> "Oracle Corporation"
34 = {HashMap$Node#10763} "java.specification.name" -> "Java Platform API Specification"
35 = {HashMap$Node#10764} "java.awt.graphicsenv" -> "sun.awt.CGraphicsEnvironment"
36 = {HashMap$Node#10765} "javax.persistence.jdbc.driver" -> "oracle.jdbc.driver.OracleDriver"
37 = {HashMap$Node#10766} "sun.boot.class.path" -> "/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/sunrsasign.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/classes"
38 = {HashMap$Node#10767} "jline.esc.timeout" -> "0"
39 = {HashMap$Node#10768} "sun.management.compiler" -> "HotSpot 64-Bit Tiered Compilers"
40 = {HashMap$Node#10769} "ftp.nonProxyHosts" -> "local|*.local|169.254/16|*.169.254/16"
41 = {HashMap$Node#10770} "java.runtime.version" -> "1.8.0_45-b14"
42 = {HashMap$Node#10771} "java.naming.factory.initial" -> "tyrex.naming.MemoryContextFactory"
43 = {HashMap$Node#10772} "user.name" -> "rodrigoarantes1"
44 = {HashMap$Node#10773} "path.separator" -> ":"
45 = {HashMap$Node#10774} "os.version" -> "10.10.4"
46 = {HashMap$Node#10775} "java.endorsed.dirs" -> "/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/endorsed"
47 = {HashMap$Node#10776} "java.runtime.name" -> "Java(TM) SE Runtime Environment"
48 = {HashMap$Node#10777} "sbt.log.noformat" -> "true"
49 = {HashMap$Node#10778} "hibernate.ejb.persistenceUnitName" -> "oraclePersistenceUnit"
50 = {HashMap$Node#10779} "file.encoding" -> "UTF8"
51 = {HashMap$Node#10780} "sun.nio.ch.bugLevel" ->
52 = {HashMap$Node#10781} "java.vm.name" -> "Java HotSpot(TM) 64-Bit Server VM"
53 = {HashMap$Node#10782} "java.vendor.url.bug" -> "http://bugreport.sun.com/bugreport/"
54 = {HashMap$Node#10783} "java.io.tmpdir" -> "/var/folders/8l/k806t46d2fl5sq2rt6gzp7z00000gp/T/"
55 = {HashMap$Node#10784} "java.version" -> "1.8.0_45"
57 = {HashMap$Node#10786} "os.arch" -> "x86_64"
58 = {HashMap$Node#10787} "java.vm.specification.name" -> "Java Virtual Machine Specification"
59 = {HashMap$Node#10788} "java.awt.printerjob" -> "sun.lwawt.macosx.CPrinterJob"
60 = {HashMap$Node#10789} "sun.os.patch.level" -> "unknown"
61 = {HashMap$Node#10790} "java.library.path" -> ":/Library/Oracle/instantclient_11_2:/Users/rodrigoarantes1/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.:/Users/rodrigoarantes1/SourceTree-Repos/Project/target/native_libraries/64bits"
62 = {HashMap$Node#10791} "java.vendor" -> "Oracle Corporation"
63 = {HashMap$Node#10792} "java.vm.info" -> "mixed mode"
64 = {HashMap$Node#10793} "java.vm.version" -> "25.45-b02"
65 = {HashMap$Node#10794} "hibernate.bytecode.use_reflection_optimizer" -> "false"
66 = {HashMap$Node#10795} "hibernate.connection.datasource" -> "OracleDS"
67 = {HashMap$Node#10796} "sun.io.unicode.encoding" -> "UnicodeBig"
68 = {HashMap$Node#10797} "java.ext.dirs" -> "/Users/rodrigoarantes1/Library/Java/Extensions:/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/ext:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java"
69 = {HashMap$Node#10798} "javax.persistence.jdbc.password" -> "ROOT"
70 = {HashMap$Node#10799} "java.class.version" -> "52.0"
71 = {HashMap$Node#10800} "socksNonProxyHosts" -> "local|*.local|169.254/16|*.169.254/16"
More Details:
The metadata generated by hibernate is:
connection = {OracleConnection#10996}
url = {String#10997} "jdbc:oracle:thin:#127.0.0.1:1521:XE"
user = {String#10998} "USER_NAME"
password = {String#10999} "ROOT"
database = {String#11000} "127.0.0.1:1521:XE"
auto_commit = true
protocol = {String#11001} "thin"
db_access = {TTC7Protocol#11002}
conversion = {TTCConversion#11003}
lob_dbaccess = null
XA_wants_error = false
UsingXA = false
m_txn_mode = 0
fdo = null
big_endian = null
statement_table = {Hashtable#11004} size = 0
closed = false
m_clientIdSet = false
m_clientId = null
default_batch = 1
default_row_prefetch = 10
report_remarks = false
include_synonyms = false
restrict_getTables = false
m_accumulateBatchResult = true
m_j2ee13Compliant = false
m_v8compatible = false
looseTimestampDateCheck = false
dataSizeScale = 1
noCachingBuffer = false
trans_level = 2
map = null
m_javaObjectMap = {Hashtable#11005} size = 0
descriptorCache = {Hashtable#11006} size = 0
statement_holding_line = null
m_dbMetaData = {OracleDatabaseMetaData#10994}
connection = {OracleConnection#10996}
url = {String#10997} "jdbc:oracle:thin:#127.0.0.1:1521:XE"
user = {String#10998} "USER_NAME"
password = {String#10999} "ROOT"
database = {String#11000} "127.0.0.1:1521:XE"
auto_commit = true
protocol = {String#11001} "thin"
db_access = {TTC7Protocol#11002}
conversion = {TTCConversion#11003}
lob_dbaccess = null
XA_wants_error = false
UsingXA = false
m_txn_mode = 0
fdo = null
big_endian = null
statement_table = {Hashtable#11004} size = 0
closed = false
m_clientIdSet = false
m_clientId = null
default_batch = 1
default_row_prefetch = 10
report_remarks = false
include_synonyms = false
restrict_getTables = false
m_accumulateBatchResult = true
m_j2ee13Compliant = false
m_v8compatible = false
looseTimestampDateCheck = false
dataSizeScale = 1
noCachingBuffer = false
trans_level = 2
map = null
m_javaObjectMap = {Hashtable#11005} size = 0
descriptorCache = {Hashtable#11006} size = 0
statement_holding_line = null
m_dbMetaData = {OracleDatabaseMetaData#10994}
connection = {OracleConnection#10996}
url = {String#10997} "jdbc:oracle:thin:#127.0.0.1:1521:XE"
user = {String#10998} "USER_NAME"
password = {String#10999} "ROOT"
database = {String#11000} "127.0.0.1:1521:XE"
auto_commit = true
protocol = {String#11001} "thin"
db_access = {TTC7Protocol#11002}
conversion = {TTCConversion#11003}
lob_dbaccess = null
XA_wants_error = false
UsingXA = false
m_txn_mode = 0
fdo = null
big_endian = null
statement_table = {Hashtable#11004} size = 0
closed = false
m_clientIdSet = false
m_clientId = null
default_batch = 1
default_row_prefetch = 10
report_remarks = false
include_synonyms = false
restrict_getTables = false
m_accumulateBatchResult = true
m_j2ee13Compliant = false
m_v8compatible = false
looseTimestampDateCheck = false
dataSizeScale = 1
noCachingBuffer = false
trans_level = 2
map = null
m_javaObjectMap = {Hashtable#11005} size = 0
descriptorCache = {Hashtable#11006} size = 0
statement_holding_line = null
m_dbMetaData = {OracleDatabaseMetaData#10994}
physicalStatus = true
logicalHandle = false
m_opc = null
m_opc_oc = null
m_osql = {OracleSql#11007}
m_warning = null
m_readOnly = false
m_startTime = 0
statementCache = null
m_stmtClearMetaData = false
m_process_escapes = true
m_defaultAutoRefetch = true
m_occ = null
m_privData = null
defaultFixedString = false
m_svptStmt = null
wrapper = null
connectionProperties = {Properties#11008} size = 3
timeout = null
m_clientData = null
m_sessionTimeZone = null
m_dbTzCalendar = null
procedureResultUnknown = 0
procedureNoResult = 1
procedureReturnsResult = 2
procedureColumnUnknown = 0
procedureColumnIn = 1
procedureColumnInOut = 2
procedureColumnOut = 4
procedureColumnReturn = 5
procedureColumnResult = 3
procedureNoNulls = 0
procedureNullable = 1
procedureNullableUnknown = 2
columnNoNulls = 0
columnNullable = 1
columnNullableUnknown = 2
versionColumnUnknown = 0
versionColumnNotPseudo = 1
versionColumnPseudo = 2
importedKeyCascade = 0
importedKeyRestrict = 1
importedKeySetNull = 2
typeNoNulls = 0
typeNullable = 1
typeNullableUnknown = 2
typePredNone = 0
typePredChar = 1
typePredBasic = 2
typeSearchable = 3
tableIndexStatistic = 0
tableIndexClustered = 1
tableIndexHashed = 2
tableIndexOther = 3
attributeNoNulls = 0
attributeNullable = 1
attributeNullableUnknown = 2
sqlStateXOpen = 1
sqlStateSQL99 = 2
physicalStatus = true
logicalHandle = false
m_opc = null
m_opc_oc = null
m_osql = {OracleSql#11007}
isV8Compatible = false
current_argument = 1
parameterCount = 0
i = 26
length = 26
c = 'E' 69
first = false
in_string = false
odbc_sql = {String#11009} "SET TRANSACTION READ WRITE"
oracle_sql = {StringBuffer#11010} "SET TRANSACTION READ WRITE"
token_buffer = {StringBuffer#11011} ""
isLocate = false
m_warning = null
m_readOnly = false
m_startTime = 0
statementCache = null
m_stmtClearMetaData = false
m_process_escapes = true
m_defaultAutoRefetch = true
m_occ = null
m_privData = null
defaultFixedString = false
m_svptStmt = null
wrapper = null
connectionProperties = {Properties#11008} size = 3
0 = {Hashtable$Entry#11018} "user" -> "USER_NAME"
1 = {Hashtable$Entry#11019} "dll" -> "ocijdbc9"
2 = {Hashtable$Entry#11020} "protocol" -> "thin"
timeout = null
m_clientData = null
m_sessionTimeZone = null
m_dbTzCalendar = null
procedureResultUnknown = 0
procedureNoResult = 1
procedureReturnsResult = 2
procedureColumnUnknown = 0
procedureColumnIn = 1
procedureColumnInOut = 2
procedureColumnOut = 4
procedureColumnReturn = 5
procedureColumnResult = 3
procedureNoNulls = 0
procedureNullable = 1
procedureNullableUnknown = 2
columnNoNulls = 0
columnNullable = 1
columnNullableUnknown = 2
versionColumnUnknown = 0
versionColumnNotPseudo = 1
versionColumnPseudo = 2
importedKeyCascade = 0
importedKeyRestrict = 1
importedKeySetNull = 2
typeNoNulls = 0
typeNullable = 1
typeNullableUnknown = 2
typePredNone = 0
typePredChar = 1
typePredBasic = 2
typeSearchable = 3
tableIndexStatistic = 0
tableIndexClustered = 1
tableIndexHashed = 2
tableIndexOther = 3
attributeNoNulls = 0
attributeNullable = 1
attributeNullableUnknown = 2
sqlStateXOpen = 1
sqlStateSQL99 = 2
physicalStatus = true
logicalHandle = false
m_opc = null
m_opc_oc = null
m_osql = {OracleSql#11007}
isV8Compatible = false
current_argument = 1
parameterCount = 0
i = 26
length = 26
c = 'E' 69
first = false
in_string = false
odbc_sql = {String#11009} "SET TRANSACTION READ WRITE"
oracle_sql = {StringBuffer#11010} "SET TRANSACTION READ WRITE"
token_buffer = {StringBuffer#11011} ""
isLocate = false
m_warning = null
m_readOnly = false
m_startTime = 0
statementCache = null
m_stmtClearMetaData = false
m_process_escapes = true
m_defaultAutoRefetch = true
m_occ = null
m_privData = null
defaultFixedString = false
m_svptStmt = null
wrapper = null
connectionProperties = {Properties#11008} size = 3
timeout = null
m_clientData = null
m_sessionTimeZone = null
m_dbTzCalendar = null
procedureResultUnknown = 0
procedureNoResult = 1
procedureReturnsResult = 2
procedureColumnUnknown = 0
procedureColumnIn = 1
procedureColumnInOut = 2
procedureColumnOut = 4
procedureColumnReturn = 5
procedureColumnResult = 3
procedureNoNulls = 0
procedureNullable = 1
procedureNullableUnknown = 2
columnNoNulls = 0
columnNullable = 1
columnNullableUnknown = 2
versionColumnUnknown = 0
versionColumnNotPseudo = 1
versionColumnPseudo = 2
importedKeyCascade = 0
importedKeyRestrict = 1
importedKeySetNull = 2
typeNoNulls = 0
typeNullable = 1
typeNullableUnknown = 2
typePredNone = 0
typePredChar = 1
typePredBasic = 2
typeSearchable = 3
tableIndexStatistic = 0
tableIndexClustered = 1
tableIndexHashed = 2
tableIndexOther = 3
attributeNoNulls = 0
attributeNullable = 1
attributeNullableUnknown = 2
sqlStateXOpen = 1
sqlStateSQL99 = 2
The Exception being thrown by Hibernate:
File: JdbcServicesImpl.java
Method: meta.supportsNamedParameters();
SQLState = null
vendorCode = 17023
next = null
detailMessage = {String#13599} "Unsupported feature"
cause = {SQLException#13595} "java.sql.SQLException: Unsupported feature"
stackTrace = {StackTraceElement[0]#13600}
suppressedExceptions = {Collections$UnmodifiableRandomAccessList#13601} size = 0
Could someone help me figuring out what the problem might be and how to solve it?
Any help is really appreciated.
Thank you
Since I havent used play, my answer is not a copy and paste but it will show you the way how to do it.
It seems that you are missing a lot of properties in your persistence unit. You are not providing required fields such as username, password, url schema etc. Please have a look at:
https://docs.jboss.org/hibernate/entitymanager/3.5/reference/en/html/configuration.html
An example for hsqldb is from the docs above:
<persistence>
<persistence-unit name="manager1" transaction-type="RESOURCE_LOCAL">
<class>org.hibernate.ejb.test.Cat</class>
<class>org.hibernate.ejb.test.Distributor</class>
<class>org.hibernate.ejb.test.Item</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
<property name="javax.persistence.jdbc.user" value="sa"/>
<property name="javax.persistence.jdbc.password" value=""/>
<property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:."/>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/
<property name="hibernate.max_fetch_depth" value="3"/>
<!-- cache configuration -->
<property name="hibernate.ejb.classcache.org.hibernate.ejb.test.Item" value="read-write"/>
<property name="hibernate.ejb.collectioncache.org.hibernate.ejb.test.Item.distributors" value="read-write, RegionName"/>
<!-- alternatively to <class> and <property> declarations, you can use a regular hibernate.cfg.xml file -->
<!-- property name="hibernate.ejb.cfgfile" value="/org/hibernate/ejb/test/hibernate.cfg.xml"/ -->
</properties>
</persistence-unit>
</persistence>
The issue was related to the Oracle driver.
My original configuration works fine with the driver ojdbc7.jar
So my play/jpa configuration remained as:
application.conf
db.default.driver=oracle.jdbc.driver.OracleDriver
db.default.url="jdbc:oracle:thin:#IP:1521:SID"
db.default.user=USER_NAME
db.default.pass=ROOT
db.default.jndiName=DefaultDS
jpa.default=defaultPersistenceUnit
persistence.xml
<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_2_0.xsd"
version="2.0">
<persistence-unit name="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>DefaultDS</non-jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
</properties>
</persistence-unit>
</persistence>
I hope it helps someone
EDITED:
I also tried with ojdbc14.jar because I needed to connect o an oracle 8i server.
You only need to add the following property to your persistence.xml
<property name="hibernate.temp.use_jdbc_metadata_defaults" value="false"/>
Thanks
I am trying to return data I get using boss_db over a websocket connection. In this example I want to return the questions I fetch, you can see the logs print out the question, however there is some error which is causing terminated with reason: bad return value: ok.
Below is my code and error:
websocket/fan_games_game_websocket.erl
-module(fan_games_game_websocket, [Req, SessionId]).
-behaviour(boss_service_handler).
-record(state,{users}).
%% API
-export([
init/0,
handle_incoming/4,
handle_join/3,
handle_broadcast/2,
handle_close/4,
handle_info/2,
terminate/2
]).
init() ->
io:format("~p (~p) starting...~n", [?MODULE, self()]),
%timer:send_interval(1000, ping),
{ok, #state{users=dict:new()}}.
handle_join(ServiceName, WebSocketId, State) ->
error_logger:info_msg("~p ~p ~p", [ServiceName, WebSocketId, SessionId]),
#state{users=Users} = State,
{noreply, #state{users=dict:store(WebSocketId, SessionId, Users)}}.
handle_close(Reason, ServiceName, WebSocketId, State) ->
#state{users=Users} = State,
io:format("ServiceName ~p, WebSocketId ~p, SessiondId ~p, close for Reason ~p~n",
[ServiceName, WebSocketId, SessionId, Reason]),
{noreply, #state{users=dict:erase(WebSocketId, Users)}}.
handle_broadcast(Message, State) ->
io:format("Broadcast Message ~p~n",[Message]),
{noreply, State}.
handle_incoming(_ServiceName, WebSocketId, Message, State) ->
error_logger:info_msg(Message),
Questions = boss_db:find(question, []),
error_logger:info_msg("~p~n", [Questions]),
WebSocketId ! {text, list_to_binary(Questions)},
{noreply, State}.
handle_info(state, State) ->
#state{users=Users} = State,
error_logger:info_msg("state:~p~n", [Users]),
{noreply, State};
handle_info(ping, State) ->
error_logger:info_msg("pong:~p~n", [now()]),
{noreply, State};
handle_info(tic_tac, State) ->
#state{users=Users} = State,
Fun = fun(X) when is_pid(X)-> X ! {text, "tic tac"} end,
All = dict:fetch_keys(Users),
[Fun(E) || E <- All],
{noreply, State};
handle_info(_Info, State) ->
{noreply, State}.
terminate(_Reason, _State) ->
ok.
question.erl
-module(question, [Id, GameId, Text]).
-has({answers, many}).
-belongs_to(game).
Update
Here are my updated logs with your suggestions:
Here are the logs from a sample request submitting "a"
11:14:25.401 [info] a
fan_games_game_websocket (<0.299.0>) starting...
11:14:25.401 [info] [{question,"question-2","game-2","Who will have the most rushing yards in the first quarter?"}]
11:14:25.402 [error] ** Boss Service Handler fan_games_game_websocket terminating in handle_incoming/4
for the reason error:badarg
ServiceUrl: "/websocket/game"
WebSocketId: <0.285.0>
SessionId : undefined
Message : <<"a">>
State : {state,{dict,0,16,16,8,80,48,{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},{{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}}}
** Stacktrace: [{erlang,list_to_binary,[[{question,"question-2","game-2","Who will have the most rushing yards in the first quarter?"}]],[]},{fan_games_game_websocket,handle_incoming,5,[{file,"/Users/blanecordes/Documents/Code/erlang/fan_game/fan_games/src/websocket/fan_games_game_websocket.erl"},{line,42}]},{boss_service_worker,handle_cast,2,[{file,"src/boss/boss_service_worker.erl"},{line,173}]},{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,604}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,239}]}]
11:14:25.402 [error] gen_server fan_games_game_websocket terminated with reason: bad return value: ok
11:14:25.402 [error] CRASH REPORT Process <0.297.0> with 0 neighbours exited with reason: bad return value: ok in gen_server:terminate/6 line 744
11:14:25.402 [error] Supervisor {global,boss_service_sup} had child fan_games_game_websocket started with boss_service_worker:start_link(fan_games_game_websocket, <<"/websocket/game">>) at <0.297.0> exit with reason bad return value: ok in context child_terminated
I believe the problem comes from the line
WebSocketId ! {text, <<Questions>>},
in handle_incoming/4, because <<Questions>> is not a proper binary. Try changing it to this:
WebSocketId ! {text, list_to_binary(Questions)},
instead.