Jboss7 + neo4j + hibernate-ogm = StoreLockException? - java

I'm trying to setup neo4j under JBoss7 using hibernate=ogm, heres my pon.xml:
<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>Think01</groupId>
<artifactId>CityMiners</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>RESTfulDemoApplication Maven Webapp</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>jboss</id>
<url>http://repository.jboss.org/maven2</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-neo4j</artifactId>
<version>4.1.3.Final</version>
</dependency>
</dependencies>
<build>
<finalName>CityMiners</finalName>
</build>
</project>
here's my persistance.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
<persistence-unit name="ogm-neo4j" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
<properties>
<property name="hibernate.ogm.neo4j.database_path" value="d:/dev/q7"/>
<property name="hibernate.ogm.datastore.provider" value="neo4j_embedded"/>
<property name="hibernate.search.default.directory_provider" value="ram" />
</properties>
</persistence-unit>
</persistence>
here's my singleton bean:
#Singleton
#Startup
public class Test {
private EntityManagerFactory emf;
#PostConstruct
public void init() {
emf = Persistence.createEntityManagerFactory("ogm-neo4j");
}
#PreDestroy
public void kill() {
emf.close();
}
}
and heres what I receive after deploy:
[2015-06-06 11:04:14,734] Artifact CityMiners:war: java.lang.Exception: {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"CityMiners.war\".component.Test.START" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"CityMiners.war\".component.Test.START: java.lang.IllegalStateException: JBAS011048: Failed to construct component instance
Caused by: java.lang.IllegalStateException: JBAS011048: Failed to construct component instance
Caused by: javax.ejb.EJBException: javax.persistence.PersistenceException: Unable to build entity manager factory
Caused by: javax.persistence.PersistenceException: Unable to build entity manager factory
Caused by: org.hibernate.service.spi.ServiceException: OGM000071: Unable to start datatore provider
Caused by: java.lang.RuntimeException: Error starting org.neo4j.kernel.EmbeddedGraphDatabase, d:\\dev\\q7
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.StoreLockerLifecycleAdapter#c5c0fa' was successfully initialized, but failed to start. Please see attached cause exception.
Caused by: org.neo4j.kernel.StoreLockException: Unable to obtain lock on store lock file: d:\\dev\\q7\\store_lock. Please ensure no other process is using this database, and that the directory is writable (required even for read-only access)
Caused by: java.io.IOException: Couldn't lock lock file d:\\dev\\q7\\lock because another process already holds the lock."}}
the stack trace says "Couldn't lock lock file d:\dev\q7\lock because another process already holds the lock." but I'm pretty sure no external process even touches that file ( I do not run another neo4j proces in parallel ) - it looks like somehow JBoss itself holds that lock...
do you know how to come over this?
Thanks in advance!

Related

Jdivert java.lang.ClassNotFoundException error when ran

Trying to use this library, but whenever I run it. It gives me the following. I updated my pom file and thought it would be the solution, but I still receive an error.
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/jna/Pointer
at org.example.Main.main(Main.java:11)
Caused by: java.lang.ClassNotFoundException: com.sun.jna.Pointer
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 1 more
Here is my code
public class Main {
public static void main(String[] args) throws WinDivertException {
System.out.println("Hello world!");
WinDivert w = new WinDivert("tcp.DstPort == 80 and tcp.PayloadLength > 0");
w.open(); // packets will be captured from now on
Packet packet = w.recv(); // read a single packet
System.out.println(packet);
w.send(packet); // re-inject the packet into the network stack
w.close(); // stop capturing packets
}
}
And here is my pom.xml file
<?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>org.example</groupId>
<artifactId>Glacial1.1</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.github.ffalcinelli</groupId>
<artifactId>jdivert</artifactId>
<version>1.1</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>18</maven.compiler.source>
<maven.compiler.target>18</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
Tried updating my pom file and it didn't work

How to solve the problem: java.io.FileNotFoundException when deploying jee app to Wildfly 25

I get the error below when deploying the app to Wildfly:
{"WFLYCTL0080: Failed services" => {"jboss.persistenceunit."funmusic-back.war#productPU"" => "jakarta.persistence.PersistenceException: [PersistenceUnit: productPU] Unable to build Hibernate SessionFactory
Caused by: jakarta.persistence.PersistenceException: [PersistenceUnit: productPU] Unable to build Hibernate SessionFactory
Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Unable to open specified script target file for writing : productDrop.ddl
Caused by: java.io.FileNotFoundException: productDrop.ddl (Permission denied)"}}
The tricky point I met is, when I start the wildfly by standalone.sh, it is alright. However, when I start it using systemctl start wildfly, this problem happen. I am wondering whether it is the problem related to the Domain Mode and Standalone Mode of Wildfly, but could not recognize the missing piece I should learn in order to solve the problem. My OS using is CentOS 7 and the Wildfly version is 25.
Below is the persistence.xml for your reference:
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd"
version="2.2">
<!-- transaction-type is the type of transactions used by EntityManagers from this persistence unit. -->
<persistence-unit name="productPU" transaction-type="JTA">
<properties>
<property name ="javax.persistence.schema-generation.database.action" value="drop-and-create"></property>
<property name ="javax.persistence.schema-generation.scripts.action" value="drop-and-create"></property>
<property name ="javax.persistence.schema-generation.scripts.create-target" value="productCreate.ddl"></property>
<property name ="javax.persistence.schema-generation.scripts.drop-target" value="productDrop.ddl"></property>
</properties>
</persistence-unit>
I get a single #Entity which is a very simple POJO with a few fields within. As it is simple, I am going to skip it here.
It would be grateful if you could point out the cause of the problem and give me some insight of it. Also, document reference with section specified would be more appreciated.
Thank you!

How can I solve "org.slf4j.impl.StaticLoggerBinder" error to run my Javalin web app?

I am using IntelliJ IDE where I created a maven project to build a website. I am trying to use Javalin as it is a lightweight framework to use. As per the documentation of Javalin, my pom.xml files is:
<?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>org.example</groupId>
<artifactId>Web-App</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>io.javalin</groupId>
<artifactId>javalin</artifactId>
<version>3.13.6</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>
</properties>
</project>
And under src/main/java, I created a HelloWorld.java to run my webapp. The code is:
import io.javalin.Javalin;
public class HelloWorld {
public static void main(String[] args) {
Javalin app = Javalin.create().start(7000);
app.get("/", ctx -> ctx.result("Hello World"));
}
}
When I run, I get a error like this:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/NoWhenBranchMatchedException
at io.javalin.core.JavalinConfig$Inner.<init>(JavalinConfig.java:73)
at io.javalin.core.JavalinConfig.<init>(JavalinConfig.java:63)
at io.javalin.Javalin.<init>(Javalin.java:52)
at io.javalin.Javalin.create(Javalin.java:88)
at io.javalin.Javalin.create(Javalin.java:76)
at HelloWorld.main(HelloWorld.java:5)
Caused by: java.lang.ClassNotFoundException: kotlin.NoWhenBranchMatchedException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 6 more
Under this circumstances. what could have been my error behind this?
Thanks in advance.
You are missing a logging implementation. I recommend you use this "javalin-bundle" dependency:
<dependency>
<groupId>io.javalin</groupId>
<artifactId>javalin-bundle</artifactId>
<version>3.13.6</version>
</dependency>
It includes some extra libraries, including logging libraries, which are missing if you only use <artifactId>javalin</artifactId>.
(You also get Jackson, which is used by Javalin behind the scenes to handle JSON rsources - for example ctx.json(obj).)
You don't have to use the bundle - you can provide your own logging implementation.

Run a jar file from unix command line

I have created a jar file from mvn command but when i am trying to run it i am getting below error :
java -cp target/new-repl.jar package.repl
Error: Could not find or load main class package.repl
Caused by: java.lang.ClassNotFoundException: package.repl
I got many links on stack overflow but none of them helped me. Could you please help me to run this from command line. Below is the my .java file:
package repl;
public class Test {
public static void main(String[] args) throws IOException {
....
}
}
POM.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>repl</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>repl</name>
<description>build tar for repl</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<build>
<finalName>new-repl</finalName>
<directory>target</directory>
</build>
</project>
You can do like this. Type fully qualified class name instead of typing package name
java -cp target/new-repl.jar repl.Test
The error says it all
Error: Could not find or load main class package.repl
your class name is not package.repl, it is repl.Test

Issue with deploying maven project with multiple modules to Tomcat 7.0

So I have two modules, let's call them moduleA and moduleB. My goal is to deploy both of them to Tomcat. Here is what I have done:
parent pom.xml
<project>
....
<artifactId>parentModule</artifactId>
<packaging>pom</packaging>
<modules>
<module>moduleA</module>
<module>moduleB</module>
</modules>
....
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.4.3</version>
</dependency>
</dependencies>
</dependencyManagement>
...
</project>
moduleA pom.xml
<project>
...
<parent>
...
<artifactId>parentModule</artifactId>
</parent>
...
</project>
moduleB pom.xml
<project>
...
<parent>
...
<artifactId>parentModule</artifactId>
</parent>
...
</project>
The directory structure looks like this
Users/swidjaja/dev/parentProject
pom.xml
moduleA
pom.xml
moduleB
pom.xml
These are the steps that I do to deploy it to Tomcat
[On Terminal] mvn clean install
[On Terminal] mvn eclipse:eclipse
[Eclipse] import project
[Eclipse] Create new Tomcat 7.0 server and add the two modules to Resources [Eclipse] Run Tomcat server
Running the Tomcat server, I got the following exception
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'awsCredentials' defined in file [/Users/swidjaja/dev/parentProject/moduleA/target/moduleA-SNAPSHOT/WEB-INF/classes/applicationContext.xml]: null
at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:209)
at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:220)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:84)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:681)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:656)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:446)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5003)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5517)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
And here is what the file applicationContext.xml looks like
<beans>
<bean id="awsCredentials" class="com.amazonaws.auth.BasicAWSCredentials">
<constructor-arg index="0" value="accessKey" />
<constructor-arg index="1" value="secretKey" />
</bean>
</beans>
My guess here is that somehow I didn't deploy it correctly. The BasicAWSCredentials class is part of aws-java-sdk which is defined as dependency in parent pom.xml and it looks like this module is not deployed correctly to Tomcat.
What did I do wrong in my steps? What will be the correct way to deploy such project? I've been struggling with this for 2 days now.
Any help is highly appreciated. Many Thanks!

Categories

Resources