Missing jboss.jdbc-driver.org_postgresql_Driver - jboss7.x

I'm trying to configure a Postgres datasource in standalone.xml. I've put the driver jar in the right place "jboss-as-7.2.0.Final\modules\org\postgresql\main" and this is my "standalone.xml":
<datasource jta="true" jndi-name="java:jboss/datasources/ProcessEngine" pool-name="ProcessEngine" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:postgresql://localhost:5432/camunda_process_engine</connection-url>
<driver-class>org.postgresql.Driver</driver-class>
<driver>postgresql</driver>
<security>
<user-name>postgres</user-name>
<password>postgres</password>
</security>
</datasource>
<drivers>
</driver>
<driver name="postgresql" module="org.postgresql">
<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
</driver>
</drivers>
...
"jboss-as-7.2.0.Final\modules\org\postgresql\main\module.xml"
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="org.postgresql">
<resources>
<resource-root path="postgresql-9.3-1102.jdbc41.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
I'm trying to start server but it shows errors.
JBAS014775: New missing/unsatisfied dependencies:
service jboss.jdbc-driver.org_postgresql_Driver (missing) dependents: [service jboss.driver-demander.java:jboss/datasources/ProcessEngine, service jboss.data-source.java:jboss/datasources/ProcessEngine]

You also have to add a dependency on your new module to your application. The easiest way to do this is to add a jboss-deployment-structure.xml to the META-INF of your Ear, or if you just have a war, put it in WEB-INF.
<?xml version="1.0"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<deployment>
<dependencies>
<module name="org.postgresql" />
</dependencies>
</deployment>
</jboss-deployment-structure>
When you redeploy, JBoss will know to put your new custom module in the classpath. Decent guide to classloading in AS7 here.

Related

Can't register AWS-SDK on Jboss modules correctly

I found the dependency aws-java-sdk was being compiled on a legacy code, having as result a very heavy EAR.
I declared this dependency as provided and wanted to put it as part of the Jboss modules, but no matter where I put it, I'm still having the ClassNotFound issue.
Here is my module.xml:
<module xmlns="urn:jboss:module:1.1" name="com.amazonaws">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<resource-root path="aws-java-sdk-1.11.584.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.xml.stream.api"/>
<module name="javax.xml.bind.api"/>
<module name="com.fasterxml.jackson"/>
<module name="org.joda.time"/>
</dependencies>
</module>
And the error:
Caused by: java.lang.NoClassDefFoundError: com/amazonaws/auth/AWSCredentials
The problem was on the JAR file, needed sdk-core. Check your JARs always.

JBoss EAP 7.1.0.GA + picketlink 2.7.1.Final causes org.jboss.modules.ModuleLoadError

I'm using an Red Hat JBoss Enterprise Application Platform - Version 7.1.0.GA and trying to use picketlink 2.7.1.Final causes org.jboss.modules.ModuleLoadError.
So, I added in standalone.xml
<extension module="org.wildfly.extension.picketlink"/>
Then ran the picketlink-installer-2.7.1.Final with the ant that gave me: BUILD SUCCESSFUL, and when I try to launch my app with jboss, I get an:
WARN [org.jboss.modules] (ServerService Thread Pool -- 31) Failed to define class org.picketlink.identity.federation.web.handlers.saml2.SAML2IssuerTrustHandler in Module "org.picketlink.federation" from local module loader #58134517 (finder: local module finder #4450d156 (roots: D:\Jboss\bin\..\modules,D:\Jboss\bin\..\modules\system\layers\base)): org.jboss.modules.ModuleLoadError: org.jboss.common-core
I added the picketlink.xml file with the Handlers:
<Handlers xmlns="urn:picketlink:identity-federation:handler:config:2.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:picketlink:identity-federation:handler:config:2.1 ">
<Handler class="org.picketlink.identity.federation.web.handlers.saml2.SAML2IssuerTrustHandler" />
<Handler class="org.picketlink.identity.federation.web.handlers.saml2.SAML2LogOutHandler"/>
<Handler class="org.picketlink.identity.federation.web.handlers.saml2.SAML2AuthenticationHandler"/>
<Handler class="org.picketlink.identity.federation.web.handlers.saml2.RolesGenerationHandler"/>
</Handlers>
I added in \Jboss\modules\system\layers\base\org\jboss\common-core\main\jboss-common-4.2.2.GA.jar and an module.xml with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.5" name="org.jboss.common-core">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<dependencies>
<module name="javax.api"/>
</dependencies>
<resources>
<resource-root path="jboss-common-4.2.2.GA.jar"/>
</resources>
</module>
And that error is gone, I have other errors now...

Jboss AS7 - jboss-deployment-structure.xml deployment error

When I add the jboss-deployment-structure.xml in to my .war and deploy in the AS7 giving the following error.
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2,1]
Message: Unexpected element '{urn:jboss:deployment-structure:1.2}jboss-deployment-structure'
at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:108) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
Sample xml is attached below.
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
</deployment>
</jboss-deployment-structure>
Is there any reason why I get the deployment error?
It looks like it's complaining that you haven't specified the namespace. I updated the documentation for excluding log4j to add the namespace.
Try this:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
<deployment>
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
</deployment>
</jboss-deployment-structure>

Logback and Jboss 7 - don't work together?

I am having a curious problem. I had this Java application which was previously deployed in tomcat and happily used logback classic as an slf4j implementation. Now when we tried to deploy the same app in a jboss 7.1.final server it doesn't even deploy the application maoning about
java.lang.ClassCastException: org.slf4j.impl.Slf4jLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext
This is the offending line of code
final LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
The class that has his is spring injected and that is failing - hence the whole application cannot be deployed. Anyone got a solution to this? Thanks in advance
After looking in this site plus other forums I realised that Jboss 7 comes bundled with it's own slf4j implementation and implement the same ILoggerFactory interface that LoggerContext in logback does. Our application tried to get an instance of the same but the app server imposes it's own slf4j implementation.
I tried to modify the module.xml in jboss\modules\org\slf4j\impl\main and pointed it to logback jars.
<resources>
<resource-root path="logback-classic-0.9.28.jar"/>
<resource-root path="logback-core-0.9.28.jar"/>
</resources>
Now when I start the application I am getting a serious error
Exception starting filter WicketFilter: java.lang.ClassCastException: ch.qos.logback.classic.LoggerContext cannot be cast to ch.qos.logback.classic.LoggerContext
I am at my wits end. Any jboss and logback experts can help?
Thanks in advance
You need to exclude the servers version of slf4j from your deployment. Create a jboss-deployment-structure.xml file and place it in either your WARS META-INF or WEB-INF directory.
The contents of the file should look like this:
<jboss-deployment-structure>
<deployment>
<!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
<exclusions>
<module name="org.slf4j" />
<module name="org.slf4j.impl" />
</exclusions>
</deployment>
</jboss-deployment-structure>
If you are using the bridges for jul or jcl in your app, you should exclude them too:
<module name="org.slf4j" />
<module name="org.slf4j.jcl-over-slf4j" />
<module name="org.slf4j.impl" />
<module name="org.jboss.logging.jul-to-slf4j-stub" />
There is alternative approach:
you got logging configured in your war
you got all dependencies in your war
you don't configure anything in JBoss server directory, not even additional JBoss modules
Just disable JBoss logging completely and rely on the dependencies in your war. Edit your jboss-deployment-structure.xml as follows:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<deployment>
<exclusions>
<module name="org.apache.commons.logging" />
<module name="org.apache.log4j" />
<module name="org.jboss.logging" />
<module name="org.jboss.logging.jul-to-slf4j-stub" />
<module name="org.jboss.logmanager" />
<module name="org.jboss.logmanager.log4j" />
<module name="org.slf4j" />
<module name="org.slf4j.impl" />
<module name="org.slf4j.jcl-over-slf4j" />
</exclusions>
</deployment>
</jboss-deployment-structure>
Once you deploy your app, bootstrap logging (boot.log) keeps working also server.log will show deployment logging. But all your application is logged through your (in this example) slf4j+logback in your war.
Note that you should not need to run JBoss with -Dorg.jboss.logging.provider=slf4j, if you specify this, you will need to provide JBoss modules (typically slf4j-api, logback-classic and logback-core), but it is not worth the effort, as JBoss logging is now used only for bootstrap (boot.log) and for deployment info (server.log).
References:
http://tinyapps.blogspot.com/2013/01/getting-logback-and-slf4j-to-work-in.html
https://stackoverflow.com/a/19695680/2587343
To make independent logging with Logback + Json in JBoss EAP 7.0 I need to exclude outdated Jackson implementation too:
jboss-deployment-structure.xml
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<deployment>
<!-- https://docs.jboss.org/author/display/AS7/Class%20Loading%20in%20AS7.html -->
<!-- https://docs.wildfly.org/16/Developer_Guide.html -->
<exclusions>
<!-- Rely on WAR's SLF4j + Logback instead of JBoss logmananger. -->
<module name="org.apache.commons.logging" />
<module name="org.apache.log4j" />
<module name="org.jboss.as.logging" />
<module name="org.jboss.logging" />
<module name="org.jboss.logging.jul-to-slf4j-stub" />
<module name="org.jboss.logmanager" />
<module name="org.jboss.log4j.logmanager" />
<module name="org.slf4j" />
<module name="org.slf4j.ext" />
<module name="org.slf4j.impl" />
<module name="org.slf4j.jcl-over-slf4j" />
<!-- Built-in Jackson is without the field: Feature.USE_THREAD_LOCAL_FOR_BUFFER_RECYCLING, need to bundle own version. -->
<!-- https://docs.jboss.org/resteasy/docs/3.0.2.Final/userguide/html/json.html -->
<module name="org.jboss.resteasy.resteasy-jackson-provider"/>
<module name="org.jboss.resteasy.resteasy-jackson2-provider"/>
</exclusions>
</deployment>
</jboss-deployment-structure>
pom.xml
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.9</version>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>7.0.1</version>
</dependency>
logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true">
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<charset>UTF-8</charset>
<pattern>%d{HH:mm:ss.SSS} %5p [%15.15t] %logger %m%ex</pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder>
<charset>UTF-8</charset>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %5p [%t] %-40.40logger{39} %m%n%ex</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${my.log.dir}/test-servlet-logging-%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>30</maxHistory>
<totalSizeCap>500MB</totalSizeCap>
</rollingPolicy>
</appender>
<appender name="JSON-FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${my.log.dir}/test-servlet-logging-%d{yyyy-MM-dd}.ndjson</fileNamePattern>
<maxHistory>30</maxHistory>
<totalSizeCap>500MB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<includeContext>false</includeContext>
<includeMdc>true</includeMdc>
<timestampPattern>uuuu-MM-dd'T'HH:mm:ss.SSSxxx</timestampPattern>
<fieldNames>
<timestamp>#timestamp</timestamp>
<message>message</message>
<thread>thread</thread>
<logger>logger</logger>
<level>level</level>
<levelValue>[ignore]</levelValue>
<version>[ignore]</version>
<stackTrace>ex</stackTrace>
</fieldNames>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
<appender-ref ref="JSON-FILE" />
</root>
</configuration>

Use of arquillian glassfish container

I used to have the following maven dependencies to use arquillian glassfish container:
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-junit</artifactId>
<scope>test</scope>
<version>1.0.0.Alpha5</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-glassfish-embedded-3.1</artifactId>
<version>1.0.0.Alpha5</version>
</dependency>
I was able to run my tests successfully until I wanted to inject specific resources, that could not be looked up through JNDI.
I improved my domain.xml to have the relevant resources I wanted. But for now, I am not sure arquillian load successfully all the domain.xml (look up failed on "jca/Neo4j/resource").
My arquillian.xml (in src/test/resources):
<?xml version="1.0" encoding="UTF-8"?>
<arquillian xmlns="http://jboss.com/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:glassfish="urn:arq:org.jboss.arquillian.container.glassfish.embedded_3">
<glassfish:container>
<glassfish:instanceRoot>src/test/resources/glassfish</glassfish:instanceRoot>
<glassfish:bindPort>9090</glassfish:bindPort>
<glassfish:autoDelete>false</glassfish:autoDelete>
</glassfish:container>
My domain.xml (in src/test/resources/glassfish/config/):
<domain log-root="${com.sun.aas.instanceRoot}/logs" applicationroot="${com.sun.aas.instanceRoot}/applications" version="10.0">
<resources>
<connector-connection-pool name="jca/Neo4j/pool" resource-adapter-name="neo4j-connector-0.1-SNAPSHOT" connection-definition-name="com.netoprise.neo4j.connection.Neo4JConnectionFactory">
<property name="dir" value="${com.sun.aas.instanceRoot}/lib/databases/neo4j"></property>
<property name="xa" value="true"></property>
</connector-connection-pool>
<connector-resource pool-name="jca/Neo4j/pool" jndi-name="jca/Neo4j/resource"></connector-resource>
</resources>
<servers>
<server name="server" config-ref="server-config">
<application-ref ref="neo4j-connector-0.1-SNAPSHOT" virtual-servers="server"></application-ref>
<resource-ref ref="jca/Neo4j/resource"></resource-ref>
</server>
</servers>
...
</domain>
Thanks,
Alex
The Alpha5 was a bit hard to handle :)
Stuff changed a bit and if you like to give the latest 1.0.0.Final-SNAPSHOT a try, you could have a more detailed look at a configuration here:
http://blog.eisele.net/2012/01/arquillian-with-netbeans-glassfish.html
Thanks,
M