I am parsing a simple template and getting this error:
org.apache.velocity.loader - ResourceManager:
parse exception: Lexical error, Encountered: <EOF> after : "" at
If I add an empty line at the end of the template then I don't have the same issue,
And parse is done correctly.
Is it a parser bug?
update velocity version:
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
<version>2.0</version>
</dependency>
Related
I'm playing with lua, using the following link: https://www.lua.org/pil/8.html and got confused about this syntax error.
So, the file foo.lua is as the following:
function foo (x)
print(x)
end
Then,
~$ f = loadfile("foo.lua")
bash: syntax error near unexpected token `('
Any comments are greatly appreciated.
I am using the procedure-compiler in my pom file. Adding it and building gives the error in the title.
I learned here: neo4j: user defined procedure exception "Write operations are not allowed for `READ` transactions" that the #Procedure annotation is the old way before 3.1. However i am on 3.2.2.
Disabling the compiler and building seems to work fine so i am sure it is a false positive error. How do i silence it so i can use the compiler again?
Here is one example:
#Procedure(value = "WL.CreateArgumentGroup", mode = Mode.WRITE)
#Description("Takes node id's and create a new arg group with those nodes as premises")
public Stream<LongResult> CreateArgumentGroup(#Name("nodeIds") List<Long> nodeIds)
Pom code:
<properties>
<neo4j.version>3.2.2</neo4j.version>
</properties>
<dependencies>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>procedure-compiler</artifactId>
<version>${neo4j.version}</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
At compile time, I am getting the error
the attribute path is undefined for the annotation type
RequestMapping
I have imported org.springframework.web.bind.annotation.PathVariable, but I am still facing same issue.
In pom.xml check dependency version of spring-web. I solved it by changing the version dependency. Previously it was 4.1.4.RELEASE.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.2.7.RELEASE</version>
</dependency>
I want to take the .g files from Apache Hive and build a parser (targeting JavaScript) -- initially, as just a way to validate user-input Hive queries. The files I'm using come from apache-hive-1.0.0-src\ql\src\java\org\apache\hadoop\hive\ql\parse from the Hive tgz: HiveLexer.g, HiveParser.g, FromClauseParser.g, IdentifiersParser.g, SelectClauseParser.g.
I see no indication within the grammar files which version of ANTLR to use, so I've tried running antlr (from apt-get pccts), antlr3 and antlr4. they all throw errors of some sort, so I have no clue which one to run or if I can (or need to) convert the .g files between versions.
The errors I'm getting are as follows:
antlr -Dlanguage=JavaScript HiveParser.g (looks like it doesn't support JS anyway):
warning: invalid option: '-Dlanguage=JavaScript'
HiveParser.g, line 17: syntax error at "grammar" missing { QuotedTerm PassAction ! \< \> : }
HiveParser.g, line 17: syntax error at "HiveParser" missing { QuotedTerm PassAction ! \< \> : }
HiveParser.g, line 17: syntax error at ";" missing Eof
HiveParser.g, line 28: lexical error: invalid token (text was ',')
antlr3 -Dlanguage=JavaScript HiveParser.g:
error(10): internal error: Exception FromClauseParser.g:302:85: unexpected char: '-'#org.antlr.grammar.v2.ANTLRLexer.nextToken(ANTLRLexer.java:347): unexpected stream error from parsing FromClauseParser.g
error(150): grammar file FromClauseParser.g has no rules
error(100): FromClauseParser.g:0:0: syntax error: assign.types: <AST>:299:68: unexpected AST node: ->
error(100): FromClauseParser.g:0:0: syntax error: define: <AST>:299:68: unexpected AST node: ->
error(106): SelectClauseParser.g:151:18: reference to undefined rule: tableAllColumns
antlr4 -Dlanguage=JavaScript HiveParser.g:
warning(202): HiveParser.g:30:0: tokens {A; B;} syntax is now tokens {A, B} in ANTLR 4
error(50): HiveParser.g:636:34: syntax error: '->' came as a complete surprise to me while looking for rule element
error(50): HiveParser.g:636:37: syntax error: '^' came as a complete surprise to me
error(50): HiveParser.g:638:50: syntax error: '->' came as a complete surprise to me while looking for rule element
error(50): HiveParser.g:638:53: syntax error: '^' came as a complete surprise to me
The antlr3 error referencing #org.antlr.grammar.v2.ANTLRLexer.nextToken seems suspect. Is it using the v2 lexer instead of v3? If so, maybe v3 is what I should target, but it's somehow not hitting it?
Or is this not an issue with versioning and instead with invocation? Or is Hive built in a way that provides additional files needed?
According to Hive source code, they use ANTLR 3.4. But before you start remove the last string from FromClauseParser.g
//------------------------------------------------------------------------
We're running a modular application plattform using Apache ServiceMix 5.3.0. I need to extend our system with a persistence service - so I want to build an OSGi bundle containing Neo4J 2.1.6.
In my pom.xml (Maven) I'm using maven-bundle-plugin (org.apache.felix) to build the bundle. I've added nearly every package from neo4j-kernel and neo4j-lucene-index libs to the <Export-Package> section.
When deployed my bundle shows up in "resolved" state. But when beeing started it throws this:
org.osgi.framework.BundleException: Activator start error ...
...
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at org.neo4j.graphdb.factory.GraphDatabaseSettings.<clinit (GraphDatabaseSettings.java:69)
My activator code looks like this (the exception occurs at the last command):
GraphDatabaseFactory factory = new GraphDatabaseFactory();
/*
ArrayList<CacheProvider> caches = new ArrayList();
caches.add(new SoftCacheProvider());
factory.setCacheProviders(caches);
*/
GraphDatabaseBuilder builder = factory.newEmbeddedDatabaseBuilder("neo4j-db");
graphDb = builder.newGraphDatabase();
(It doesn't make a difference if the commented part is active or not.)
The error pattern looks similar like the one in this question.
I suspect the devil sitting in the following method from org.neo4j.graphdb.factory.GraphDatabaseSettings (line 259f) unable to find any CacheProvider instances, although they are packed and referenced in my bundle (org.neo4j.kernel.impl.cache...):
private static String[] availableCaches()
{
List<String> available = new ArrayList<>();
for ( CacheProvider cacheProvider : Service.load( CacheProvider.class ) )
{
available.add( cacheProvider.getName() );
}
...
return available.toArray( new String[available.size()] );
}
I believe this is very much an OSGi classloader issue rather than a Neo4J issue. Any ideas how to proceed here?
I managed to solve my problem meanwhile. As Neil already supposed, it was neither an OSGi-issue nor a Neo4J-bug. Instead I had to learn some more lessons about how Neo4J binds its extensions and how to shape OSGi dependencies accordingly in order to get ahead.
These are the results of my yesterday's research:
(1) Collect all packages
My mistake was to rely on maven-bundle-plugin's capability to parse the project and automatically break down all internal dependencies to package level (which is neccessary for OSGi). This works perfectly for class relations that are declared by import statements, but, of course, will fail where reflection methods are used to bind external stuff.
As the application worked perfectly in my JUnit environment the reasons for my problem had to include missing resources in the OSGi envirmonment.
The solution was to religiously list each single package of every library in the plugins Export-Package, Private-Package and Import-Package section accordingly (the list got quite lengthly) instead of trusting to wildcards.
(2) Neo4J kernel extensions
Heeding the above topics I got rid of the mentioned ArrayIndexOutOfBoundsException but I right ran into other (similar) exceptions. I got ahead after I learned about Neo4J's "kernel extension" concept.
Neo4J (I have version 2.1.6) has introduced "kernel extensions" to couple exchangeable modules for caching and indexing purpose at runtime. In order to apply a certain extension one just needs to add the according jar to the classpath. Each library carries one or more descriptor files under META-INF/services telling about the available implementations. These files are looked up and processed by the kernel in order to find and bind its extensions (extension for indexing and caching are mandatory).
After I securely had all neccessary java packages included in my bundly only the descriptor files in META-INF/services were missing. This code showed me a way how to add those resources to the bundle (search for the <Embed-Dependency> section in the maven-bundle-plugin.
Neo4J libs also contain a blueprint descriptor to automatically publish major classes as service (e.g. GraphDatabaseFactory). These resources are placed under OSGI-INF/blueprint/, which should also be included in the bundle.
The final pom.xml for my Neo4J OSGi bundle looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<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>my.group</groupId>
<artifactId>neo4jBundle</artifactId>
<version>0.1.0</version>
<packaging>bundle</packaging>
<properties>
<neo4j-version>2.1.6</neo4j-version>
<lucene-version>3.6.2</lucene-version>
</properties>
<dependencies>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-kernel</artifactId>
<version>${neo4j-version}</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-lucene-index</artifactId>
<version>${neo4j-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Name>org.neo4j.kernel</Bundle-Name>
<Export-Package>org.neo4j.graphdb.*;version=${neo4j-version},
... {all neo4j packages} ...
org.apache.lucene;version=${lucene-version},
... {all lucene packages} ...
org.slf4j.impl
</Export-Package>
<Private-Package>
javax.transaction,
javax.transaction.xa,
ch.qos.logback.classic,
... {all logback.classic packages} ...
ch.qos.logback.core,
... {all logback.core packages} ...
org.slf4j.*
</Private-Package>
<Import-Package>
javax.lang.model,
... {some javax packages to be imported from the runtime} ...
!sun.misc,
... {exclude uneccessary packages to limit dependency} ...
*
</Import-Package>
<Embed-Dependency>
*;groupId=org.neo4j;artifactId=neo4j-kernel;inline=META-INF/services/*,
*;groupId=org.neo4j;artifactId=neo4j-kernel;inline=OSGI-INF/blueprint/*,
*;groupId=org.neo4j;artifactId=neo4j-lucene-index;inline=META-INF/services/*,
*;groupId=org.neo4j;artifactId=neo4j-lucene-index;inline=OSGI-INF/blueprint/*
</Embed-Dependency>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
Remarks: This is a pure library bundle without any additional code. My application with the Activator resides in a seperate bundle.
This example only shows my aproach in solving my problems. My example doesn't claim to produce a general-purpose Neo4J bundle. Depending on the features you want and the society of already deployed stuff in the runtime you might need to add or leave out certain packages to get everything to work.