I need advice. My server application send objects with not
inialized proxies. Primitive types ok, but onetomany and etc. not
initialized proxies. As result my client application gets nothing when
retreive received object properties.
here is sample with src and conf files without libs
project on github
here is server log, where you can see that objects were retreive from
database and send with proxyinitialized = false
{operation})****************getEnhancements
00:53:36,906 DEBUG http-8080-1 FacadeService:getEnhancements:31 -
collect enhancements
Hibernate:
select
this_.id as id1_0_,
this_.description as descript2_1_0_,
this_.name as name1_0_,
this_.priceValue as priceValue1_0_,
this_.requestedDataFile_id as requeste5_1_0_,
this_.resultedDataFile_id as resulted6_1_0_
from
Enhancement this_
00:53:37,031 DEBUG http-8080-1 FacadeService:getEnhancements:34 -
return enhancements:
[com.garageteam.photoenhancer.model.misc.Enhancement#22,
com.garageteam.photoenhancer.model.misc.Enhancement#25,
com.garageteam.photoenhancer.model.misc.Enhancement#28]
{invoke} 125
{serialize} 15
[BlazeDS]02/14/2012 00:53:37.062 [DEBUG] [Service.Remoting] Adapter
'dpHibernateRemotingAdapter' called
'null.getEnhancements(java.util.Arrays$ArrayList (Collection size:0)
)'
[BlazeDS]02/14/2012 00:53:37.062 [DEBUG] [Service.Remoting] Result:
'java.util.ArrayList (Collection size:3)
[0] = ASObject(22809745){id=3, uid=206a60dd-2fa6-4a20-bcf4-
bf39684948b5, description=, name=cool, proxyKey=3,
requestedDataFile=ASObject(4002470)
{uid=12283196-3a44-4558-914c-95b3c5443f95, proxyKey=1,
proxyInitialized=false}, resultedDataFile=ASObject(26432381)
{uid=69f842b5-e9b7-4279-be51-3e6c72558aac, proxyKey=2,
proxyInitialized=false}, priceValue=1.0, proxyInitialized=true}
[1] = ASObject(21904789){id=6, uid=9dc2c08c-
da0b-4047-95ab-0e1a06cf03b7, description=, name=woov, proxyKey=6,
requestedDataFile=ASObject(28121199){uid=1968dfa7-f3d1-41ed-
b55b-47efbe09dfcc, proxyKey=4, proxyInitialized=false},
resultedDataFile=ASObject(18831011){uid=9c3e3c3b-7698-4b01-bcd4-
d58e4e6635a0, proxyKey=5, proxyInitialized=false}, priceValue=2.0,
proxyInitialized=true}
[2] = ASObject(7405703){id=9, uid=325fe743-4e2c-4d9b-9c01-
ebdb03ad1fea, description=, name=supercool, proxyKey=9,
requestedDataFile=ASObject(14262090){uid=89ee7148-78a0-450a-afe1-
b638a2b40256, proxyKey=7, proxyInitialized=false},
resultedDataFile=ASObject(23654984)
{uid=888141a6-20df-40ed-861d-4968bd5d8042, proxyKey=8,
proxyInitialized=false}, priceValue=3.0, proxyInitialized=true}
'
[BlazeDS]02/14/2012 00:53:37.062 [DEBUG] [Endpoint.AMF] Serializing
AMF/HTTP response
Version: 3
(Message #0 targetURI=/3/onResult, responseURI=)
(Typed Object #0 'flex.messaging.messages.AcknowledgeMessage')
timestamp = 1.329170017062E12
headers = (Object #1)
body = (Externalizable Object #2
'flex.messaging.io.ArrayCollection')
(Array #3)
[0] = (Typed Object #4
'com.garageteam.photoenhancer.model.misc.Enhancement')
id = 3
uid = "206a60dd-2fa6-4a20-bcf4-bf39684948b5"
description = ""
name = "cool"
proxyKey = 3
requestedDataFile = (Typed Object #5
'com.garageteam.photoenhancer.model.misc.DataFile')
uid = "12283196-3a44-4558-914c-95b3c5443f95"
proxyKey = 1
proxyInitialized = false
resultedDataFile = (Typed Object #6
'com.garageteam.photoenhancer.model.misc.DataFile')
uid = "69f842b5-e9b7-4279-be51-3e6c72558aac"
proxyKey = 2
proxyInitialized = false
priceValue = 1.0
proxyInitialized = true
[1] = (Typed Object #7
'com.garageteam.photoenhancer.model.misc.Enhancement')
id = 6
uid = "9dc2c08c-da0b-4047-95ab-0e1a06cf03b7"
description = ""
name = "woov"
proxyKey = 6
requestedDataFile = (Typed Object #8
'com.garageteam.photoenhancer.model.misc.DataFile')
uid = "1968dfa7-f3d1-41ed-b55b-47efbe09dfcc"
proxyKey = 4
proxyInitialized = false
resultedDataFile = (Typed Object #9
'com.garageteam.photoenhancer.model.misc.DataFile')
uid = "9c3e3c3b-7698-4b01-bcd4-d58e4e6635a0"
proxyKey = 5
proxyInitialized = false
priceValue = 2.0
proxyInitialized = true
[2] = (Typed Object #10
'com.garageteam.photoenhancer.model.misc.Enhancement')
id = 9
uid = "325fe743-4e2c-4d9b-9c01-ebdb03ad1fea"
description = ""
name = "supercool"
proxyKey = 9
requestedDataFile = (Typed Object #11
'com.garageteam.photoenhancer.model.misc.DataFile')
uid = "89ee7148-78a0-450a-afe1-b638a2b40256"
proxyKey = 7
proxyInitialized = false
resultedDataFile = (Typed Object #12
'com.garageteam.photoenhancer.model.misc.DataFile')
uid = "888141a6-20df-40ed-861d-4968bd5d8042"
proxyKey = 8
proxyInitialized = false
priceValue = 3.0
proxyInitialized = true
correlationId = "A01CE051-DFDD-6914-4308-78B4E961321B"
messageId = "8BB1B217-C60E-32D4-9FD3-7A9BB427085E"
timeToLive = 0.0
clientId = "8AE5EEA5-0008-798D-0980-4DC9F378C296"
destination = null
00:53:37,093 DEBUG http-8080-1 DispatcherServlet:doDispatch:822 - Null
ModelAndView returned to DispatcherServlet with name
'springMessageBroker': assuming HandlerAdapter completed request
handling
00:53:37,093 DEBUG http-8080-1 DispatcherServlet:processRequest:674 -
Successfully completed request
Are you using the dpHibernate RemoteObject object or the standard flex/blazeds RemoteObject tag. It looks like the server is returning the right proxy objects, so the problem should be client side. And if you are not using the dpHibernate RemoteObject tag to make the request, dpHibernate can't proxy load the lazy items for you. Also use a tool like service capture to see if the calls backs to the server are happening and that there isn't a server error being returned from your load method.
Related
I have the following YAML :-
loadRules:
- table: accounts
rows: 10
columns:
- name: id
util: PrimaryIntGen
params:
- 1
- 10
- name: name
util: RandomStringNumeric
params:
- 10
executeRules:
- transaction_name: Account_query1
weight: 50
query:
queries:
- SELECT * FROM accounts WHERE id > ? and id < ?
- SELECT * FROM accounts WHERE id <= ?
bindings:
- binding:
- name: RowRandomBoundedInt
params:
- 5
- 10
- name : RowRandomBoundedInt
params:
- 5
- 10
- binding:
- name : RowRandomBoundedInt
params:
- 5
- 10
- transaction_name: Account_query2
weight: 50
query:
queries:
- SELECT * FROM accounts WHERE id < ? and id > ?
- SELECT * FROM accounts WHERE id >= ?
bindings:
- binding:
- name : RowRandomBoundedInt
params :
- 5
- 10
- name: RowRandomBoundedInt
params:
- 5
- 10
- binding:
- name : RowRandomBoundedInt
params :
- 5
- 10
I want to run these transactions from YAML.
I have written this code so far :-
Ignore the txnType for now.(Its passed from another function).
int executeRuleIndex= txnType.getId()-1;
HierarchicalConfiguration<ImmutableNode> executeRule=config.configurationsAt("executeRules").get(executeRuleIndex);
HierarchicalConfiguration<ImmutableNode> query=executeRule.configurationAt("query");
List<String> executeQueries = query.getList(String.class, "queries");
List<HierarchicalConfiguration<ImmutableNode>>bindings=
query.configurationsAt("bindings");
System.out.println("Transaction id" +executeRuleIndex+ "\n");
for(int i=0;i<executeQueries.size();i++)
{
PreparedStatement stmt= conn.prepareStatement(executeQueries.get(i));
HierarchicalConfiguration<ImmutableNode> bindingsForThisQuery= bindings.get(i);
executeRulesYaml(stmt,bindingsForThisQuery,txnType.getId());
}
I am not able to iterate for a single binding I pass to the executeRulesYaml :- bindingsForThisQuery.
I want to make a List of String and Object mapping for these bindings. I have done the same for loadRules :
List<HierarchicalConfiguration<ImmutableNode>> loadRulesConfig = config.configurationsAt("loadRules");
if (loadRulesConfig.isEmpty()) {
throw new RuntimeException("Empty Load Rules");
}
LOG.info("Using YAML for load phase");
for (HierarchicalConfiguration loadRuleConfig : loadRulesConfig) {
List<HierarchicalConfiguration<ImmutableNode>>
columnsConfigs = loadRuleConfig.configurationsAt("columns");
List<Map<String, Object>> columns = new ArrayList<>();
for (HierarchicalConfiguration columnsConfig : columnsConfigs) {
Iterator columnKeys = columnsConfig.getKeys();
Map<String, Object> column = new HashMap<>();
while (columnKeys.hasNext()) {
String element = (String) columnKeys.next();
System.out.println(element);
Object params;
if (element.equals("params")) {
params = columnsConfig.getList(Object.class, element);
} else {
params = columnsConfig.get(Object.class, element);
}
column.put(element, params);
}
columns.add(column);
}
}
}
Any help would be appreciated as I am new to Java.
I created two realms for authentication in apache shiro, but when i tried to call hasRole("any") it throws the following exception (if the role exists, it returns true):
java.lang.ClassCastException: org.apache.shiro.subject.SimplePrincipalCollection cannot be cast to java.lang.String
at com.ws.shiro.RedisStringSerializer.serialize(RedisStringSerializer.java:13) ~[shiro-redis-3.0.2.jar:?]
at org.crazycake.shiro.RedisCache.get(RedisCache.java:79) ~[shiro-redis-3.2.2.jar:?]
at org.apache.shiro.realm.AuthorizingRealm.getAuthorizationInfo(AuthorizingRealm.java:328) ~[shiro-core-1.3.2.jar:1.3.2]
at org.apache.shiro.realm.AuthorizingRealm.hasRole(AuthorizingRealm.java:573) ~[shiro-core-1.3.2.jar:1.3.2]
at org.apache.shiro.authz.ModularRealmAuthorizer.hasRole(ModularRealmAuthorizer.java:374) ~[shiro-core-1.3.2.jar:1.3.2]
at org.apache.shiro.mgt.AuthorizingSecurityManager.hasRole(AuthorizingSecurityManager.java:153) ~[shiro-core-1.3.2.jar:1.3.2]
at org.apache.shiro.subject.support.DelegatingSubject.hasRole(DelegatingSubject.java:224) ~[shiro-core-1.3.2.jar:1.3.2]
at com.ws.user.login.LoginResource.login(LoginResource.java:65) ~[main/:?]
the SHIRO.INI is:
# =======================
# Shiro INI configuration
# =======================
## Using Sha256 cryptography
credentialsMatcher = org.apache.shiro.authc.credential.HashedCredentialsMatcher
credentialsMatcher.hashAlgorithmName=SHA-256
credentialsMatcher.hashIterations = 1024
credentialsMatcher.storedCredentialsHexEncoded = false
dbRealm = com.ws.user.realm.DataBaseRealm
dbRealm.credentialsMatcher = $credentialsMatcher
credentialsMatcherToken = com.ws.user.realm.CustomCredentialMatcherToken
credentialsMatcherToken.hashAlgorithmName=SHA-256
credentialsMatcherToken.hashIterations = 1024
credentialsMatcherToken.storedCredentialsHexEncoded = false
tokenRealm = com.ws.user.realm.DataBaseBearerRealm
tokenRealm.credentialsMatcher = $credentialsMatcherToken
securityManager.realms = $dbRealm, $tokenRealm
#redisManager
redisManager = com.ws.shiro.RedisManager
redisManager.host = <THERE IS A HOST HERE>
redisManager.port = 6379
redisManager.expire = 1000
redisManager.timeout = 0
#============redisSessionDAO=============
redisSessionDAO = com.ws.shiro.RedisSessionDAO
redisSessionDAO.redisManager = $redisManager
sessionManager = org.apache.shiro.web.session.mgt.DefaultWebSessionManager
sessionManager.sessionDAO = $redisSessionDAO
securityManager.sessionManager = $sessionManager
#============redisCacheManager===========
cacheManager = com.ws.shiro.RedisCacheManager
cacheManager.redisManager = $redisManager
securityManager.cacheManager = $cacheManager
It seems to be some config, cause when debugging, it goes just for the actual token that I tried to authenticate, but in the class ModularRealmAuthorizer, method hasRole, it was called twice, one each realm, the first was ok, and then in the second Realm, it throws the exception.
Problem solved! I forgot to override the method getAuthorizationCacheKey, in one of my custom realm.
I'm using the Kafka JDK client ver 0.10.2.1 . I am able to produce simple messages to Kafka for a "heartbeat" test, but I cannot consume a message from that same topic using the sdk. I am able to consume that message when I go into the Kafka CLI, so I have confirmed the message is there. Here's the function I'm using to consume from my Kafka server, with the props - I pass the message I produced to the topic only after I have indeed confirmed the produce() was succesful, I can post that function later if requested:
private def consumeFromKafka(topic: String, expectedMessage: String): Boolean = {
val props: Properties = initProps("consumer")
val consumer = new KafkaConsumer[String, String](props)
consumer.subscribe(List(topic).asJava)
var readExpectedRecord = false
try {
val records = {
val firstPollRecs = consumer.poll(MAX_POLLTIME_MS)
// increase timeout and try again if nothing comes back the first time in case system is busy
if (firstPollRecs.count() == 0) firstPollRecs else {
logger.info("KafkaHeartBeat: First poll had 0 records- trying again - doubling timeout to "
+ (MAX_POLLTIME_MS * 2)/1000 + " sec.")
consumer.poll(MAX_POLLTIME_MS * 2)
}
}
records.forEach(rec => {
if (rec.value() == expectedMessage) readExpectedRecord = true
})
} catch {
case e: Throwable => //log error
} finally {
consumer.close()
}
readExpectedRecord
}
private def initProps(propsType: String): Properties = {
val prop = new Properties()
prop.put("bootstrap.servers", kafkaServer + ":" + kafkaPort)
propsType match {
case "producer" => {
prop.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer")
prop.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer")
prop.put("acks", "1")
prop.put("producer.type", "sync")
prop.put("retries", "3")
prop.put("linger.ms", "5")
}
case "consumer" => {
prop.put("group.id", groupId)
prop.put("enable.auto.commit", "false")
prop.put("auto.commit.interval.ms", "1000")
prop.put("session.timeout.ms", "30000")
prop.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer")
prop.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer")
prop.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest")
// poll just once, should only be one record for the heartbeat
prop.put("max.poll.records", "1")
}
}
prop
}
Now when I run the code, here's what it outputs in the console:
13:04:21 - Discovered coordinator serverName:9092 (id: 2147483647
rack: null) for group 0b8947e1-eb68-4af3-ac7b-be3f7c02e76e. 13:04:23
INFO o.a.k.c.c.i.ConsumerCoordinator - Revoking previously assigned
partitions [] for group 0b8947e1-eb68-4af3-ac7b-be3f7c02e76e 13:04:24
INFO o.a.k.c.c.i.AbstractCoordinator - (Re-)joining group
0b8947e1-eb68-4af3-ac7b-be3f7c02e76e 13:04:25 INFO
o.a.k.c.c.i.AbstractCoordinator - Successfully joined group
0b8947e1-eb68-4af3-ac7b-be3f7c02e76e with generation 1 13:04:26 INFO
o.a.k.c.c.i.ConsumerCoordinator - Setting newly assigned partitions
[HeartBeat_Topic.Service_5.2018-08-03.13_04_10.377-0] for group
0b8947e1-eb68-4af3-ac7b-be3f7c02e76e 13:04:27 INFO
c.p.p.l.util.KafkaHeartBeatUtil - KafkaHeartBeat: First poll had 0
records- trying again - doubling timeout to 60 sec.
And then nothing else, no errors thrown -so no records are polled. Does anyone have any idea what's preventing the 'consume' from happening? The subscriber seems to be successful, as I'm able to successfully call the listTopics and list partions no problem.
Your code has a bug. It seems your line:
if (firstPollRecs.count() == 0)
Should say this instead
if (firstPollRecs.count() > 0)
Otherwise, you're passing in an empty firstPollRecs, and then iterating over that, which obviously returns nothing.
I have a connection error...
Im using an API Restful for connect my Android App with DataBase(MySql)
api.php:
require_once 'vendor/autoload.php';
require 'funciones.php';
$app = new \Slim\Slim();
$db = new mysqli("XX.XXX.XXX.XXX", "user_BD", "pass_BD", "name_BD");
.
.
.
$app->get("/sp_login_principal/:user/:pass", function($user,$pass) use($db, $app) {
// sleep(3);
$query = $db->query("SELECT * FROM usuarios WHERE
user = '".$user."'
***line 63:*** AND password= '".$pass."' ;");
$usuarios = array();
while ($fila = $query->fetch_assoc()) {
$usuarios[] = $fila;
}
utf8_encode_deep($usuarios);
echo json_encode($usuarios);
});
"line 63:" it's only a commet, is not really in the code.
When i use the next url to call the select:
http://XXXX.000webhostapp.com/eldo/slim/api.php/sp_login_principal/useraname/passxxxx
I have the next error:
*
Slim Application Error
The application could not run because of the following error:
Details
Type: ErrorException
Code: 2
Message: mysqli::query(): Couldn't fetch mysqli
File: /storage/XXX/XXX/XXXXXXX/public_html/eldo/slim/api.php
Line: 63
Trace
#0 [internal function]: Slim\Slim::handleErrors(2, 'mysqli::query()...', '/storage/XXXX/2...', 63, Array)
#1 /storage/XXXX/XXX/XXXXXXX/public_html/eldo/slim/api.php(63): mysqli->query('SELECT * FROM u...')
#2 [internal function]: {closure}('username', 'passxxxx')
#3 /storage/XXX/XXX/XXXXXX/public_html/eldo/slim/vendor/slim/slim/Slim/Route.php(468): call_user_func_array(Object(Closure), Array)
#4 /storage/XXX/XXX/XXXXXX/public_html/eldo/slim/vendor/slim/slim/Slim/Slim.php(1357): Slim\Route->dispatch()
#5 /storage/XXX/XXX/XXXXXX/public_html/eldo/slim/vendor/slim/slim/Slim/Middleware/Flash.php(85): Slim\Slim->call()
#6 /storage/XXX/XXX/XXXXXX/public_html/eldo/slim/vendor/slim/slim/Slim/Middleware/MethodOverride.php(92): Slim\Middleware\Flash->call()
#7 /storage/XXX/XXX/XXXXXX/public_html/eldo/slim/vendor/slim/slim/Slim/Middleware/PrettyExceptions.php(67): Slim\Middleware\MethodOverride->call()
#8 /storage/XXX/XXX/XXXXXX/public_html/eldo/slim/vendor/slim/slim/Slim/Slim.php(1302): Slim\Middleware\PrettyExceptions->call()
#9 /storage/XXX/XXX/XXXXXX/public_html/eldo/slim/api.php(1164): Slim\Slim->run()
#10 {main}
*
I think the error is in the server file, because i used the same code on another server withoud problems.
Thanks!
Im using javabridge to connect php to jasper reports and Im trying to pass two parameters but I get warnings and errors
Warning: Unchecked exception detected: [[o:Response$UndeclaredThrowableErrorMarker]:"FATAL: Undeclared java.lang.RuntimeException detected. java.lang.Exception: CreateInstance failed: new java.util.Date((o:String)[o:String]). Cause: java.lang.IllegalArgumentException VM: 1.7.0_79#http://java.oracle.com/" at: #-10 java.util.Date.parse(Unknown Source) #-9 java.util.Date.<init>(Unknown Source) #-8 sun.reflect.GeneratedConstructorAccessor57.newInstance(Unknown Source) #-7 sun.reflect.DelegatingConstructorAccessor[...]/java/Java.inc(361): java_Arg->getResult(false) #2 http://localhost:8080/JavaBridgeTemplate/java/Java.inc(364): java_Client->getWrappedResult(false) #3 http://localhost:8080/JavaBridgeTemplate/java/Java.inc(536): java_Client->getInternalResult() #4 http://localhost:8080/JavaBridgeTemplate/java/Java.inc(1930): java_Client->createObject('java.util.Date', Array) #5 C:\wamp\www\advanced\backend\javabridge\generate.php(49): Java->Java('java.util.Date', '12/Feb/16') #6 {main}] in http://localhost:8080/JavaBridgeTemplate/java/Java.inc on line 202
Fatal error: Uncaught [[o:Exception]:"java.lang.Exception: Invoke failed: [[c:JasperFillManager]]->fillReport((o:JasperReport)[o:JasperReport], (i:Map)[o:HashMap], (i:Connection)[o:Connection]). Cause: net.sf.jasperreports.engine.JRException: Incompatible php.java.bridge.Response$UndeclaredThrowableErrorMarker value assigned to parameter FInicio in the Reubicados dataset. VM: 1.7.0_79#http://java.oracle.com/" at: #-16 net.sf.jasperreports.engine.fill.JRFillDataset.setParameter(JRFillDataset.java:903) #-15 net.sf.jasperreports.engine.fill.JRFillDataset.setFillParameterValues(JRFillDataset.java:642) #-14 net.sf.jasperreports.engine.fill.JRFillDataset.setParameterValues(JRFillDataset.java:585) #-13 net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:1280) #-12 net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:901) #-11 net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:845) #-10 net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:58) #-9 net.sf.jas in http://localhost:8080/JavaBridgeTemplate/java/Java.inc on line 195
The problem is when it tries to create java.util.Date instance. HereĀ“s php file:
<?php
require_once("http://localhost:8080/JavaBridgeTemplate/java/Java.inc");
try {
$Param1 = date('d/M/y', strtotime($_POST['FInicio']));
$Param2 = date('d/M/y', strtotime($_POST['FFin']));
$jasperxml = new java("net.sf.jasperreports.engine.xml.JRXmlLoader");
$jasperDesign = $jasperxml->load(realpath("Reubicados.jrxml"));
$query = new java("net.sf.jasperreports.engine.design.JRDesignQuery");
$jasperDesign->setQuery($query);
$compileManager = new JavaClass("net.sf.jasperreports.engine.JasperCompileManager");
$report = $compileManager->compileReport($jasperDesign); } catch (JavaException $ex) {
echo $ex; }
$fillManager = new JavaClass("net.sf.jasperreports.engine.JasperFillManager"); //aqui se pasan los parametros (Fecha Inicio y Fecha Fin)
$params = new Java("java.util.HashMap");
$date=new Java('java.util.Date',$Param1);
$date1=new Java('java.util.Date',$Param2);
$params->put("FInicio",$date);
$params->put("FFin",$date1);
$class = new JavaClass("java.lang.Class"); $class->forName("com.mysql.jdbc.Driver"); $driverManager = new JavaClass("java.sql.DriverManager");
//db username and password
$conn = $driverManager->getConnection("jdbc:mysql://localhost/viajestrafico?zeroDateTimeBehavior=convertToNull", "root", "root"); $jasperPrint = $fillManager->fillReport($report, $params, $conn);
$exporter = new java("net.sf.jasperreports.engine.JRExporter");
And sql query in ireports:
SELECT
ayudante_situacion_laboral.`FechaInicio` AS ayudante_situacion_laboral_FechaInicio,
ayudante_situacion_laboral.`FechaFin` AS ayudante_situacion_laboral_FechaFin,
ayudante_situacion_laboral.`Cant_Horas` AS ayudante_situacion_laboral_Cant_Horas,
ayudante_situacion_laboral.`Descripcion` AS ayudante_situacion_laboral_Descripcion,
ayudante.`Registro` AS ayudante_Registro,
ayudante.`Nombre` AS ayudante_Nombre,
situacion_laboral.`Estado` AS situacion_laboral_Estado
FROM
`ayudante` ayudante INNER JOIN `ayudante_situacion_laboral` ayudante_situacion_laboral ON ayudante.`Ayudante_ID` = ayudante_situacion_laboral.`AyudanteAyudante_ID`
INNER JOIN `situacion_laboral` situacion_laboral ON ayudante_situacion_laboral.`Situacion_LaboralSitL_ID` = situacion_laboral.`SitL_ID`
WHERE
situacion_laboral.Estado = 'Reubicado' and $P{FInicio}<= ayudante_situacion_laboral.`FechaInicio` and $P{FFin}>=ayudante_situacion_laboral.`FechaFin`
UNION
SELECT
chofer_situacion_laboral.`FechaInicio` AS chofer_situacion_laboral_FechaInicio,
chofer_situacion_laboral.`FechaFin` AS chofer_situacion_laboral_FechaFin,
chofer_situacion_laboral.`Cant_Horas` AS chofer_situacion_laboral_Cant_Horas,
chofer_situacion_laboral.`Descripcion` AS chofer_situacion_laboral_Descripcion,
chofer.`Registro` AS chofer_Registro,
chofer.`Nombre` AS chofer_Nombre,
situacion_laboral.`Estado` AS situacion_laboral_Estado
FROM
`chofer` chofer INNER JOIN `chofer_situacion_laboral` chofer_situacion_laboral ON chofer.`Chofer_ID` = chofer_situacion_laboral.`ChoferChofer_ID`
INNER JOIN `situacion_laboral` situacion_laboral ON chofer_situacion_laboral.`Situacion_LaboralSitL_ID` = situacion_laboral.`SitL_ID`
WHERE
(situacion_laboral.Estado = 'Reubicado' and $P{FInicio}<= chofer_situacion_laboral.`FechaInicio` and $P{FFin}>=chofer_situacion_laboral.`FechaFin`)
Looking to your error message, the java.util.Date cannot be created with '12/Feb/16':
java_Client->createObject('java.util.Date', Array)
#5 C:\wamp\www\advanced\backend\javabridge\generate.php(49):
Java->Java('java.util.Date', '12/Feb/16') #6 {main}] in
If you want to instanciate a java date object, use the java.util.Date(long date) constructor which accepts a timestamp expressed in milliseconds :
<?php
$startDate = $_POST['FInicio']; // better to filter this :)
$Param1 = strtotime($startDate) * 1000; // to get milliseconds
if ($Param1 == 0) {
throw new Exception("FInicio date parameter could not be parsed");
}
// ...
$javaDate = new Java('java.util.Date',$Param1); // This is a java date
Your $date parameter should now be a valid java.util.Date object.
You can test it :
$simpleDateFormat = new Java("java.text.SimpleDateFormat", 'yyyy-MM-dd');
echo $simpleDateFormat->format($javaDate);
// should print your date in Y-m-d format
Alternatively, you can parse the date in Java through the java.text.SimpleDateFormatter object:
$date = '2016-12-21';
$simpleDateFormat = new Java("java.text.SimpleDateFormat", 'yyyy-MM-dd');
$javaDate = $simpleDateFormat->parse($date); // This is a Java date
Both approaches works...
JasperReport issue with date
Not exactly linked to your question, but if you want to use your Date as a query parameter you should use the java.sql.Date(long date) object instead of java.util.Date... Here's a little dirty snippet to summarize changes:
// php
$sqlDate = new Java('java.sql.Date', strtotime($_POST['FInicio']) * 1000));
$params->put('FInicio', $sqlDate);
// in your report header (.jrxml):
<parameter name="FInicio" class="java.sql.Date">
// in your report query (.jrxml):
$P{FInicio} <= chofer_situacion_laboral.`FechaInicio`
You can also have a look to the soluble-japha javabridge client (refactored Java.inc client), the syntax differs a bit but there's a documentation about dates that might reveal useful.
It was simple, just a problem I had from the beginning in php code.
$query = new java("net.sf.jasperreports.engine.design.JRDesignQuery");
$jasperDesign->setQuery($query);
This code was preventing xrml query from executing, because it was creating a query object empty.