-
Find the system modules directory, which is something like
$JBOSS_HOME/modules
or.../jboss-eap/modules/system/layers/base/
. -
Add a new directory
com/foundationdb/main
there. (There should already be com and org or you probably don't have the right starting directory.) -
Put the
module.xml
file into that new directory. -
Copy
fdb-java-2.0.8.jar
into the same directory. (If you still have a build area from before, it will be in target/appname/WEB-INF/lib.) -
Change the pom to have
<scope>provided</scope>
so that the .jar is not duplicated in the .war. -
Add a
src/main/webapp/WEB-INF/jboss-deployment-structure.xml
to reference the system module. -
Commands like
mvn jboss-as:deploy
andredeploy
should work now.
Last active
August 29, 2015 14:08
-
-
Save MMcM/0eccc83871df4d07923a to your computer and use it in GitHub Desktop.
Converting JBoss application to use shared FDB to avoid api_version_already_set
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Marker file indicating CDI should be enabled --> | |
<beans xmlns="http://java.sun.com/xml/ns/javaee" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation=" | |
http://java.sun.com/xml/ns/javaee | |
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> | |
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.foundationdb.jboss; | |
import com.foundationdb.Database; | |
import com.foundationdb.FDB; | |
import com.foundationdb.Transaction; | |
import com.foundationdb.async.Function; | |
public class FDBService { | |
private FDB fdb; | |
private Database db; | |
public FDBService() { | |
fdb = FDB.selectAPIVersion(200); | |
db = fdb.open(); | |
} | |
public String getValue(final String key) { | |
return db.run(new Function<Transaction,String>() { | |
@Override | |
public String apply(Transaction tr) { | |
byte[] value = tr.get(key.getBytes()).get(); | |
if (value != null) { | |
return new String(value); | |
} | |
else { | |
return "Not found"; | |
} | |
} | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.foundationdb.jboss; | |
import java.io.IOException; | |
import java.io.PrintWriter; | |
import javax.inject.Inject; | |
import javax.servlet.ServletException; | |
import javax.servlet.annotation.WebServlet; | |
import javax.servlet.http.HttpServlet; | |
import javax.servlet.http.HttpServletRequest; | |
import javax.servlet.http.HttpServletResponse; | |
@WebServlet("/HelloFDB") | |
public class HelloFDBServlet extends HttpServlet { | |
static String PAGE_HEADER = "<html><head><title>Hello FDB</title></head><body>"; | |
static String PAGE_FOOTER = "</body></html>"; | |
@Inject | |
FDBService fdbService; | |
@Override | |
protected void doGet(HttpServletRequest req, HttpServletResponse resp) | |
throws ServletException, IOException { | |
resp.setContentType("text/html"); | |
PrintWriter writer = resp.getWriter(); | |
writer.println(PAGE_HEADER); | |
writer.println("<code>" + fdbService.getValue("foo") + "</code>"); | |
writer.println(PAGE_FOOTER); | |
writer.close(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<jboss-deployment-structure> | |
<deployment> | |
<dependencies> | |
<module name="com.foundationdb"/> | |
</dependencies> | |
</deployment> | |
</jboss-deployment-structure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<module xmlns="urn:jboss:module:1.1" name="com.foundationdb"> | |
<properties> | |
<property name="jboss.api" value="unsupported"/> | |
</properties> | |
<resources> | |
<resource-root path="fdb-java-2.0.8.jar"/> | |
</resources> | |
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<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/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.foundationdb</groupId> | |
<artifactId>jboss-hello-fdb</artifactId> | |
<version>0.0.1</version> | |
<packaging>war</packaging> | |
<name>JBoss Hello FDB</name> | |
<description>JBoss FDB Integration Example</description> | |
<properties> | |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
<version.jboss.maven.plugin>7.4.Final</version.jboss.maven.plugin> | |
<version.jboss.spec.javaee.6.0>3.0.2.Final-redhat-7</version.jboss.spec.javaee.6.0> | |
<version.war.plugin>2.1.1</version.war.plugin> | |
<maven.compiler.target>1.6</maven.compiler.target> | |
<maven.compiler.source>1.6</maven.compiler.source> | |
</properties> | |
<dependencyManagement> | |
<dependencies> | |
<dependency> | |
<groupId>org.jboss.spec</groupId> | |
<artifactId>jboss-javaee-6.0</artifactId> | |
<version>${version.jboss.spec.javaee.6.0}</version> | |
<type>pom</type> | |
<scope>import</scope> | |
</dependency> | |
</dependencies> | |
</dependencyManagement> | |
<dependencies> | |
<dependency> | |
<groupId>javax.enterprise</groupId> | |
<artifactId>cdi-api</artifactId> | |
<scope>provided</scope> | |
</dependency> | |
<dependency> | |
<groupId>org.jboss.spec.javax.annotation</groupId> | |
<artifactId>jboss-annotations-api_1.1_spec</artifactId> | |
<scope>provided</scope> | |
</dependency> | |
<dependency> | |
<groupId>org.jboss.spec.javax.servlet</groupId> | |
<artifactId>jboss-servlet-api_3.0_spec</artifactId> | |
<scope>provided</scope> | |
</dependency> | |
<dependency> | |
<groupId>com.foundationdb</groupId> | |
<artifactId>fdb-java</artifactId> | |
<version>2.0.8</version> | |
<!-- See WEB-INF/jboss-deployment-structure.xml. --> | |
<scope>provided</scope> | |
</dependency> | |
</dependencies> | |
<build> | |
<finalName>${project.artifactId}</finalName> | |
<plugins> | |
<plugin> | |
<artifactId>maven-war-plugin</artifactId> | |
<version>${version.war.plugin}</version> | |
<configuration> | |
<failOnMissingWebXml>false</failOnMissingWebXml> | |
</configuration> | |
</plugin> | |
<plugin> | |
<groupId>org.jboss.as.plugins</groupId> | |
<artifactId>jboss-as-maven-plugin</artifactId> | |
<version>${version.jboss.maven.plugin}</version> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment