List text between two regex functions - java

hello everyone i wanted to get a text between two regex functions my log file is
11:40:04,202 [ERROR] JobStoreTX - Failed to close Connection
java.sql.SQLException: Already closed.
at org.apache.commons.dbcp.PoolableConnection.close(PoolableConnection.java:114)
at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:191)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.closeConnection(JobStoreSupport.java:3579)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.cleanupConnection(JobStoreSupport.java:3555)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3783)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTrigger(JobStoreSupport.java:2728)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:264)
11:40:04,202 [ERROR] QuartzSchedulerThread - quartzSchedulerThreadLoop: RuntimeException null
java.lang.reflect.UndeclaredThrowableException
at $Proxy1.rollback(Unknown Source)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.rollbackConnection(JobStoreSupport.java:3604)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3773)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTrigger(JobStoreSupport.java:2728)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:264)
Caused by:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:600)
at org.quartz.impl.jdbcjobstore.AttributeRestoringConnectionInvocationHandler.invoke(AttributeRestoringConnectionInvocationHandler.java:71)
... 5 more
Caused by:
java.sql.SQLException: Closed Connection
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:111)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:207)
at oracle.jdbc.driver.PhysicalConnection.rollback(PhysicalConnection.java:1132)
at org.apache.commons.dbcp.DelegatingConnection.rollback(DelegatingConnection.java:368)
at `enter code here`org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.rollback(PoolingDataSource.java:323)
... 10 more
11:41:47,203 [ERROR] JobStoreTX - Failed to close Connection
i want text between two timestamp ie. 11:40:04,202 and 11:40:04,202 which should contain this....
11:40:04,202 [ERROR] JobStoreTX - Failed to close Connection
java.sql.SQLException: Already closed.
at org.apache.commons.dbcp.PoolableConnection.close(PoolableConnection.java:114)
at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:191)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.closeConnection(JobStoreSupport.java:3579)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.cleanupConnection(JobStoreSupport.java:3555)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3783)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTrigger(JobStoreSupport.java:2728)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:264)
kk let me make it more simple....
static String str1 = "09:37:58,289 This is my small 09:39:18,129 example string which I'm going" +
" to use for pattern matching 09:38:15,835 This is my small example string which" +
" I'm going to use for pattern matching";
String patrn = "((\\d+):(\\d+):(\\d+),(\\d+))";
Pattern p = Pattern.compile(patrn);
Matcher m = p.matcher(str1);
/*while(m.find())
{
for(int i=1;i<m.groupCount();i++)
{
System.out.println(i);
System.out.println(m.group(i));
start = m.start();
System.out.println(start);
end = m.end();
System.out.println(end);
i+=3;
}
}*/
The output which i needed is.....
String1 = 09:37:58,289 This is my small
String2 = 09:39:18,129 example string which I'm going to use for pattern matching
String3 = 09:38:15,835 This is my small example string which I'm going to use for pattern matching

If you want to print only the stacktrace not the date and Log level then you may consider creating your own patter.
Java Doc for log4j pattern

Related

Error Creating TokenRegex Rules

I am creating a TokenRegex Rules list. This is what I have:
$STARTING_SEQUENCE = (/start/|/begin/)
{
ruleType: "tokens",
pattern: ([{lemma:$STARTING_SEQUENCE}]),
result: "START"
}
When I compile my code, the compiler gives me this error:
Reading TokensRegex rules from tr.txt
Exception in thread "main" java.lang.RuntimeException: Error parsing file: tr.txt
at edu.stanford.nlp.ling.tokensregex.CoreMapExpressionExtractor.createExtractorFromFile(CoreMapExpressionExtractor.java:258)
at MedicalTranscript.x(MedicalTranscript.java:37)
at MedicalTranscript.main(MedicalTranscript.java:76)
Caused by: java.lang.ClassCastException: edu.stanford.nlp.ling.tokensregex.TokenSequencePattern cannot be cast to java.lang.String
at edu.stanford.nlp.ling.tokensregex.parser.TokenSequenceParser.CoreMapVarValue(TokenSequenceParser.java:1673)
at edu.stanford.nlp.ling.tokensregex.parser.TokenSequenceParser.AttrValue(TokenSequenceParser.java:1534)
at edu.stanford.nlp.ling.tokensregex.parser.TokenSequenceParser.CoreMapNode(TokenSequenceParser.java:1434)
at edu.stanford.nlp.ling.tokensregex.parser.TokenSequenceParser.NodeBasic(TokenSequenceParser.java:1411)
at edu.stanford.nlp.ling.tokensregex.parser.TokenSequenceParser.NodeGroup(TokenSequenceParser.java:1378)
at edu.stanford.nlp.ling.tokensregex.parser.TokenSequenceParser.NodeDisjConj(TokenSequenceParser.java:1317)
at edu.stanford.nlp.ling.tokensregex.parser.TokenSequenceParser.BracketedNode(TokenSequenceParser.java:1178)
at edu.stanford.nlp.ling.tokensregex.parser.TokenSequenceParser.SeqRegexBasic(TokenSequenceParser.java:884)
at edu.stanford.nlp.ling.tokensregex.parser.TokenSequenceParser.SeqRegexDisjConj(TokenSequenceParser.java:1071)
at edu.stanford.nlp.ling.tokensregex.parser.TokenSequenceParser.SeqRegex(TokenSequenceParser.java:841)
at edu.stanford.nlp.ling.tokensregex.parser.TokenSequenceParser.BasicValue(TokenSequenceParser.java:383)
at edu.stanford.nlp.ling.tokensregex.parser.TokenSequenceParser.ValueExpression(TokenSequenceParser.java:292)
at edu.stanford.nlp.ling.tokensregex.parser.TokenSequenceParser.Expression(TokenSequenceParser.java:210)
at edu.stanford.nlp.ling.tokensregex.parser.TokenSequenceParser.FieldValue(TokenSequenceParser.java:345)
at edu.stanford.nlp.ling.tokensregex.parser.TokenSequenceParser.CompositeFieldValue(TokenSequenceParser.java:333)
at edu.stanford.nlp.ling.tokensregex.parser.TokenSequenceParser.Rule(TokenSequenceParser.java:122)
at edu.stanford.nlp.ling.tokensregex.parser.TokenSequenceParser.RuleList(TokenSequenceParser.java:107)
at edu.stanford.nlp.ling.tokensregex.parser.TokenSequenceParser.getExpressionExtractor(TokenSequenceParser.java:22)
at edu.stanford.nlp.ling.tokensregex.CoreMapExpressionExtractor.createExtractorFromFile(CoreMapExpressionExtractor.java:254)
... 2 more
What am I doing wrong?
Try
$STARTING_SEQUENCE = "/start|begin/"
Because it is a regular expression for matching the string field lemma, it needs to be a string expressing a normal regular expression over string.
You may also want to do something with the result or use actions to do some annotation:
Example:
{
ruleType: "tokens",
pattern: ([{lemma:$STARTING_SEQUENCE}]),
action: ( Annotate($0, ner, "START") )
}

program throws CharConversionException in Java?

I am getting the below mentioned error in my catch block when i print using e.printStackTrace();This only occurs for few records when i read it from the DB2 database. So basically only few records throw the error rest work fine.
I have almost 1000 line of code and i am not sure were do i start from in order to understand/debug this error ? IS there any hint that i can get from the error message i should use to solve it ?
from the method getDataFromEMPHCForEmployeeDetails()----- com.ibm.db2.jcc.am.SqlException: [jcc][t4][1065][12306][3.63.123] Caught java.io.CharConversionException. See attached Throwable for details. ERRORCODE=-4220, SQLSTATE=null
at com.ibm.db2.jcc.am.fd.a(fd.java:663)
at com.ibm.db2.jcc.am.fd.a(fd.java:60)
at com.ibm.db2.jcc.am.fd.a(fd.java:112)
at com.ibm.db2.jcc.am.ic.a(ic.java:2820)
at com.ibm.db2.jcc.am.ic.p(ic.java:521)
at com.ibm.db2.jcc.am.ic.N(ic.java:1558)
at com.ibm.db2.jcc.am.vn.e(vn.java:1147)
at com.ibm.db2.jcc.am.vn.getString(vn.java:1122)
at com.ibm.db2.jcc.am.vn.getString(vn.java:1698)
at CreateChart.getDataFromEMPHCForEmployeeDetails(CreateChart.java:330)
at CreateChart.iterateDirectReportNamesFromArrayList(CreateChart.java:594)
at CreateChart.getDataFromEMPHCForDirectReport(CreateChart.java:295)
at CreateChart.iterateSecondLineManagerNamesFromArrayList(CreateChart.java:562)
at CreateChart.getDataFromEMPHCForSecondLine(CreateChart.java:251)
at CreateChart.iterateThirdLineManagerNamesFromArrayList(CreateChart.java:533)
at CreateChart.getDataFromEMPHCForThirdLine(CreateChart.java:208)
at CreateChart.iterateDirectorNamesFromArrayList(CreateChart.java:506)
at CreateChart.getDataFromEMPHCForDirector(CreateChart.java:168)
at CreateChart.iterateVPNamesFromArrayList(CreateChart.java:472)
at CreateChart.getDataFromEMPHCForVp(CreateChart.java:126)
at CreateChart.iterateFuncVPNamesFromArrayList(CreateChart.java:434)
at CreateChart.getDataFromEMPHCForFuncVp(CreateChart.java:95)
at CreateChart.main(CreateChart.java:613)
Caused by: java.nio.charset.MalformedInputException: Input length = 186
at com.ibm.db2.jcc.am.t.a(t.java:19)
at com.ibm.db2.jcc.am.ic.a(ic.java:2816)
... 19 more
Caused by: sun.io.MalformedInputException
at sun.io.ByteToCharUTF8.convert(Unknown Source)
at com.ibm.db2.jcc.am.t.a(t.java:16)
... 20 more
.
public void getDataFromEMPHCForEmployeeDetails(String funcvp_name11, String vp_name11, String director_name11, String thirdline_name11, String secondline_name11, String directreport_name11){
String myQuery11;
if(directreport_name11 == ""){directreport_name11 = " AND DIRECT_REPORT IS NULL";}
else{directreport_name11 =" AND DIRECT_REPORT ='"+ directreport_name11.replace("'", "''")+"'";}
myQuery11 = "SELECT DISTINCT(SERIAL_NUM) FROM DB2INST1.EMP_HC WHERE "+funcvp_name11+" "+vp_name11+" "+director_name11+" "+thirdline_name11+" "+ secondline_name11+""+directreport_name11;
arraylistofEmployeeDetails = new ArrayList<String>();
try {
resultSet = st.executeQuery(myQuery11);
while (resultSet.next())
{
String SERIAL_NUM = resultSet.getString("SERIAL_NUM");
if(SERIAL_NUM == null){SERIAL_NUM="";}
if (SERIAL_NUM.length() > 40){SERIAL_NUM = "Too Long";}
arraylistofEmployeeDetails.add(SERIAL_NUM);
System.out.println(SERIAL_NUM+"\n");
}
if(! (arraylistofEmployeeDetails.isEmpty())){
writeEmployeeDetailsToJsonFile(arraylistofEmployeeDetails);
}
} catch (SQLException e) {
e.printStackTrace();
StringWriter wtr = new StringWriter();
PrintWriter pwtr = new PrintWriter(wtr);
e.printStackTrace(pwtr);
String stackTrace = wtr.toString();
error_logs.append("from getDataFromEMPHCForEmployeeDetails()----- "+stackTrace+"\n");
}
}
I had similar problem with CharConversionException on DB2 jdbc driver with 1.8 Oracle Java with same error code, once updated to a never version it worked fine.
I downloaded db2jcc_license_cu and db2jcc.jar from these links.
Maybe it is worth of trying.
Try adding a JVM parameter -Ddb2.jcc.charsetDecoderEncoder=3, it solved the issue for me.
After setting the parameter db2.jcc.charsetDecoderEncoder=3, an exception will not be thrown when a non-UTF8 character is encountered but rather it will be substituted by its equivalent Unicode replacement character.
See the IBM Support article for more details https://www.ibm.com/support/pages/sqlexception-message-caught-javaiocharconversionexception-and-errorcode-4220

How to provide correct arguments to setAsciiStream method?

This is my FULL test code with the main method:
public class TestSetAscii {
public static void main(String[] args) throws SQLException, FileNotFoundException {
String dataFile = "FastLoad1.csv";
String insertTable = "INSERT INTO " + "myTableName" + " VALUES(?,?,?)";
Connection conStd = DriverManager.getConnection("jdbc:xxxxx", "xxxxxx", "xxxxx");
InputStream dataStream = new FileInputStream(new File(dataFile));
PreparedStatement pstmtFld = conStd.prepareStatement(insertTable);
// Until this line everything is awesome
pstmtFld.setAsciiStream(1, dataStream, -1); // This line fails
System.out.println("works");
}
}
I get the "cbColDef value out of range" error
Exception in thread "main" java.sql.SQLException: [Teradata][ODBC Teradata Driver] Invalid precision: cbColDef value out of range
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLBindInParameterAtExec(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setStream(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setAsciiStream(Unknown Source)
at file.TestSetAscii.main(TestSetAscii.java:21)
Here is the link to my FastLoad1.csv file. I guess that setAsciiStream fails because of the FastLoad1.csv file , but I am not sure
(In my previous question I was not able to narrow down the problem that I had. Now I have shortened the code.)
It would depend on the table schema, but the third parameter of setAsciiStream is length.
So
pstmtFld.setAsciiStream(1, dataStream, 4);
would work for a field of length 4 bytes.
But I dont think it would work as you expect it in the code. For each bind you should have separate stream.
This function setAsciiStream() is designed to be used for large data values BLOBS or long VARCHARS. It is not designed to read csv file line by line and split them into separate values.
Basicly it just binds one of the question marks with the inputStream.
After looking into the provided example it looks like teradata could handle csv but you have to explicitly tell that with:
String urlFld = "jdbc:teradata://whomooz/TMODE=ANSI,CHARSET=UTF8,TYPE=FASTLOADCSV";
I don't have enough reputation to comment, but I feel that this info can be valuable to those navigating fast load via JDBC for the first time.
This code will get the full stack trace and is very helpful for diagnosing problems with fast load:
catch (SQLException ex){
for ( ; ex != null ; ex = ex.getNextException ())
ex.printStackTrace () ;
}
In the case of the code above, it works if you specify TYPE=FASTLOADCSV in the connection string, but when run multiple times will fail due to the creation of the error tables _ERR_1 and _ERR_2. Drop these tables and clear out the destination tables to run again.

Pig - Unhandled internal error NoClassDefFoundException

I had a specific filtering problem (described here: Pig - How to manipulate and compare dates?), so as we told me, I decided to write my own filtering UDF. Here is the code:
import java.io.IOException;
import org.apache.pig.FilterFunc;
import org.apache.pig.data.Tuple;
import org.joda.time.*;
import org.joda.time.format.*;
public class DateCloseEnough extends FilterFunc {
int nbmois;
/*
* #param nbMois: if the number of months between two dates is inferior to this variable, then we consider that these two dates are close
*/
public DateCloseEnough(String nbmois_) {
nbmois = Integer.valueOf(nbmois_);
}
public Boolean exec(Tuple input) throws IOException {
// We're getting the date
String date1 = (String)input.get(0);
// We convert it into date
final DateTimeFormatter dtf = DateTimeFormat.forPattern("MM yyyy");
LocalDate d1 = new LocalDate();
d1 = LocalDate.parse(date1, dtf);
d1 = d1.withDayOfMonth(1);
// We're getting today's date
DateTime today = new DateTime();
int mois = today.getMonthOfYear();
String real_mois;
if(mois >= 1 && mois <= 9) real_mois = "0" + mois;
else real_mois = "" + mois;
LocalDate d2 = new LocalDate();
d2 = LocalDate.parse(real_mois + " " + today.getYear(), dtf);
d2 = d2.withDayOfMonth(1);
// Number of months between these two dates
String nb_months_between = "" + Months.monthsBetween(d1,d2);
return (Integer.parseInt(nb_months_between) <= nbmois);
}
}
I created a Jar file of this code from Eclipse.
I'm filtering my data with these lines of piglatin code:
REGISTER Desktop/myUDFs.jar
DEFINE DateCloseEnough DateCloseEnough('12');
experiences1 = LOAD '/home/training/Desktop/BDD/experience.txt' USING PigStorage(',') AS (id_cv:int, id_experience:int, date_deb:chararray, date_fin:chararray, duree:int, contenu_experience:chararray);
experiences = FILTER experiences1 BY DateCloseEnough(date_fin);
I'm launching my program with this linux command:
pig -x local "myScript.pig"
And I get this error:
2013-06-19 07:27:17,253 [main] INFO org.apache.pig.Main - Logging error messages to: /home/training/pig_1371652037252.log
2013-06-19 07:27:17,933 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 2998: Unhandled internal error. org/joda/time/ReadablePartial Details at logfile: /home/training/pig_1371652037252.log
I checked into the log file and I saw this:
Pig Stack Trace
ERROR 2998: Unhandled internal error. org/joda/time/ReadablePartial
java.lang.NoClassDefFoundError: org/joda/time/ReadablePartial
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.apache.pig.impl.PigContext.resolveClassName(PigContext.java:441)
at org.apache.pig.impl.PigContext.instantiateFuncFromSpec(PigContext.java:471)
at org.apache.pig.impl.PigContext.instantiateFuncFromAlias(PigContext.java:544)
at org.apache.pig.impl.logicalLayer.parser.QueryParser.EvalFuncSpec(QueryParser.java:4834)
at org.apache.pig.impl.logicalLayer.parser.QueryParser.PUnaryCond(QueryParser.java:1949)
at org.apache.pig.impl.logicalLayer.parser.QueryParser.PAndCond(QueryParser.java:1790)
at org.apache.pig.impl.logicalLayer.parser.QueryParser.POrCond(QueryParser.java:1734)
at org.apache.pig.impl.logicalLayer.parser.QueryParser.PCond(QueryParser.java:1700)
at org.apache.pig.impl.logicalLayer.parser.QueryParser.FilterClause(QueryParser.java:1548)
at org.apache.pig.impl.logicalLayer.parser.QueryParser.BaseExpr(QueryParser.java:1276)
at org.apache.pig.impl.logicalLayer.parser.QueryParser.Expr(QueryParser.java:893)
at org.apache.pig.impl.logicalLayer.parser.QueryParser.Parse(QueryParser.java:682)
at org.apache.pig.impl.logicalLayer.LogicalPlanBuilder.parse(LogicalPlanBuilder.java:63)
at org.apache.pig.PigServer$Graph.parseQuery(PigServer.java:1031)
at org.apache.pig.PigServer$Graph.registerQuery(PigServer.java:981)
at org.apache.pig.PigServer.registerQuery(PigServer.java:383)
at org.apache.pig.tools.grunt.GruntParser.processPig(GruntParser.java:717)
at org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptParser.java:273)
at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:166)
at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:142)
at org.apache.pig.tools.grunt.Grunt.exec(Grunt.java:89)
at org.apache.pig.Main.main(Main.java:320)
Caused by: java.lang.ClassNotFoundException: org.joda.time.ReadablePartial
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 24 more
I tried to modify my PIG_CLASSPATH variable but i figured out that this variable doesn't exist at all (some other pig scripts are working though).
Do you have an idea to solve te problem ?
Thanks.
At first, you need to tell Pig which jar you are using. See this answer: how to include external jar file using PIG. Configure build path to add it in eclipse is not enough. Eclipse will not help you generate the correct jar.
Secondly, String nb_months_between = "" + Months.monthsBetween(d1,d2); is wrong. You can use int nb_months_between = Months.monthsBetween(d1,d2).getMonths();. If you read the Months.toString, it returns "P" + String.valueOf(getValue()) + "M";. So you can not use this value and want to convert it to a int.
u need this package: org/joda/time/ReadablePartial
can find here: jarfinder
download the joda-time-1.5.jar. Add to your project, this to should resolve.

How to query eXist db from java

I'm trying to query a file based on the eXist database.
Through a simple function to display the contents of the file, no problem:
XMLResource res = (XMLResource) col.getResource(resourceName);
System.out.println(res.getContent());
But when I try against making a request impossible.
String xQuery = "for $x in doc(\"" + resourceName + "\")." + "return data($x).";
ResourceSet result = service.query(xQuery);
ResourceIterator i = result.getIterator();
I have the following errors:
Exception in thread "main" org.xmldb.api.base.XMLDBException: Failed to invoke method queryP in class org.exist.xmlrpc.RpcConnection: org.exist.xquery.StaticXQueryException: exerr:ERROR org.exist.xquery.XPathException: exerr:ERROR err:XPST0003 in line 1, column 58: unexpected token: .
at org.exist.xmldb.RemoteXPathQueryService.query(RemoteXPathQueryService.java:114)
at org.exist.xmldb.RemoteXPathQueryService.query(RemoteXPathQueryService.java:71)
at ExistAccess.main(ExistAccess.java:45)
Caused by: org.apache.xmlrpc.XmlRpcException: Failed to invoke method queryP in class org.exist.xmlrpc.RpcConnection: org.exist.xquery.StaticXQueryException: exerr:ERROR org.exist.xquery.XPathException: exerr:ERROR err:XPST0003 in line 1, column 58: unexpected token: .
at org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:197)
at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:156)
at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143)
at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)
at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:158)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:147)
at org.exist.xmldb.RemoteXPathQueryService.query(RemoteXPathQueryService.java:99)
... 2 more
[B#105081caorg.apache.xmlrpc.XmlRpcException: Failed to invoke method queryP in class org.exist.xmlrpc.RpcConnection: org.exist.xquery.StaticXQueryException: exerr:ERROR org.exist.xquery.XPathException: exerr:ERROR err:XPST0003 in line 1, column 58: unexpected token: .
I checked all my .jar file, and all of them are present... I really need help ! Thanks in advance!
Your query:
String xQuery = "for $x in doc(\"" + resourceName + "\")." + "return data($x).";
The core of the error:
err:XPST0003 in line 1, column 58: unexpected token: .
As the error message states, eXist-db recognizes an error with the "."; this period/dot is invalid XQuery. Remove the dot from the query, and you should be fine. The query text itself should look like this:
for $x in doc("/db/mycollection/mydocument.xml") return data($x)
Also, it appears your FLWOR loop is iterating over a single item - the resource. Therefore, the FLWOR is extraneous. You could refactor this as:
data(doc("/db/mycollection/mydocument.xml"))
I think you string concat make this issue, why not try to add a space after ".". Change your code like
String xQuery = "for $x in doc(\"" + resourceName + "\"). " + "return data($x).";

Categories