Deploying on remote JBoss 6.x with Cargo - deployment

I'm trying to setup an Ant Target to perform a remote deploy on a JBoss 6.x server, using Cargo.
Here is my target description:
<target name="deploy" depends="install-cargo,make-war">
<input message="Enter username for deployment..."
addproperty="deploy.username" />
<input message="Enter password for ${deploy.username}..."
addproperty="deploy.password" >
<handler type="secure" />
</input>
<cargo containerId="jboss6x" action="redeploy" type="remote">
<configuration type="runtime">
<property name="cargo.hostname" value="${deploy.host}" />
<property name="cargo.servlet.port" value="${deploy.host}" />
<property name="cargo.remote.username" value="${deploy.username}" />
<property name="cargo.remote.password" value="${deploy.password}" />
<deployable type="war" file="${dist.dir}/${ant.project.name}.war">
<property name="context" value="${ant.project.name}" />
</deployable>
</configuration>
</cargo>
Every jar inside [jboss.home]/client and [jboss.home]/lib is inside cargo.tasks classpath but when i try to execute the Target I get this error:
javax.security.auth.login.LoginException: impossibile trovare la classe LoginModule: org.jboss.security.ClientLoginModule
That is Java cannot find class org.jboss.security.ClientLoginModule (by the way: this class is located inside jbosssx.jar in [jboss.home]/lib).
Am I missing some jar? Do I need to configure something for jaas? Thanks for your help.

Related

Configuring database connection in Jboss FUSE

One way I know to configure DB in JBOSS FUSE is to use blueprint.xml.
Below configuration in blueprint.xml works
<bean id="gemsDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="${gems_url}" />
<property name="username" value="${gems_username}" />
<property name="password" value="${gems_password}" />
<property name="maxIdle" value="5" />
<property name="minIdle" value="1" />
<property name="initialSize" value="1" />
</bean>
However, Is there any way to configure it in JBOSS container specific configuration file. For example - In JBOSS EAP we can configure it in standalone.xml. On similar lines can we configure it in JBOSS FUSE?
Jboss Fuse provides the integration with various data sources. You need to configure them bundle wise like you have used. But no such configuration is there on container level.
You can define a Datasource in a bundle and export it. In other bundles you import and use it like a service.
Prerequisites
Install these features
features:install jdbc
features:install jndi
Datasource bundle
Drop an XML file inside deploy folder with following content:
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<bean id="dataSource" class="org.postgresql.jdbc3.Jdbc3SimpleDataSource">
<property name="url" value="jdbc:postgresql://localhost:5432/databasename"/>
<property name="user" value="username"/>
<property name="password" value="xxx"/>
</bean>
<service interface="javax.sql.DataSource" ref="dataSource">
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/yourdatabasename_ds"/>
</service-properties>
</service>
</blueprint>
This will export a service with javax.sql.DataSource interface and a JNDI name
Use Datasource service
When a bundle needs the datasource, ask OSGi to inject it.
<blueprint>
<reference id="yourDatabaseDs"
interface="javax.sql.DataSource"
availability="mandatory"
filter="(osgi.jndi.service.name=jdbc/yourdatabasename_ds)"/>
</blueprint>
The right Datasource is retrieved using the JNDI name you provided.
Using availability="mandatory" you can force your bundle to wait for the Datasource to become available. The bundle won't start without this reference.
You need the correct JDBC drivers for the database you are using.
Other goodies
You have a lot of commands in JBoss Fuse console to interact with the database now, like jdbc:datasources that will list all available datasources. With jdbc:query you can run any SQL against your DB (good for debugging issues and testing the connection)

Nlog with MongoDB connection and target

I am trying to use a logger that will log into MongoDB, but I can not get it to work. In the same configuration i have set up the loggers to log using an email and file and both work just fine.
Here is my NLog.config file
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<extensions>
<add assembly="NLog.MongoDB"/>
</extensions>
<!--
See http://nlog-project.org/wiki/Configuration_file
for information on customizing logging rules and outputs.
-->
<targets>
<target xsi:type="File" name="file" fileName="${basedir}/logs/${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${message}" />
<target xsi:type="Mongo"
name="mongoDefault"
connectionString="mongodb://localhost/nlog"
collectionName="cdss"
cappedCollectionSize="26214400">
<property name="ThreadID" layout="${threadid}" bsonType="Int32" />
<property name="ThreadName" layout="${threadname}" />
<property name="ProcessID" layout="${processid}" bsonType="Int32" />
<property name="ProcessName" layout="${processname:fullName=true}" />
<property name="UserName" layout="${windows-identity}" />
</target>
<target name="TcpOutlet" xsi:type="Chainsaw" address="tcp4://localhost:4505" > </target>
<target name="Email" xsi:type="Mail"
smtpServer="localhost"
smtpPort="25"
smtpAuthentication="None"
enableSsl="false"
from="ssss#sdsdfs"
to="ssss#sdsdfs" html="true"
/>
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="file,TcpOutlet,mongoDefault,Email" />
<logger name="*" minlevel="Error" writeTo="file,TcpOutlet,Email,mongoDefault" />
</rules>
</nlog>
I have installed the Nlog.Mongo nugget also. My database is called nlog. Whatever i do, the loggers do not write in the mongodb. I am using NLogger.

Additional properties files for spring-batch-admin

I have a web application using spring-batch and I'm now integrating spring-batch-admin for basic administration.
The problem is that the jobs configuration files (which are shared with the configuration of the existing application) use properties from files in my application's classpath, but spring-batch-admin's context is not able to load them.
The quick solution was to override the placeholderProperties bean in spring-batch-admin just to add my properties files:
<bean id="placeholderProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:/org/springframework/batch/admin/bootstrap/batch.properties</value>
<value>classpath:batch-default.properties</value>
<value>classpath:batch-${ENVIRONMENT:hsql}.properties</value>
<value>classpath:/path/to/jobs-config.properties</value> <!-- adding my properties here -->
</list>
</property>
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="ignoreResourceNotFound" value="true" />
<property name="ignoreUnresolvablePlaceholders" value="false" />
<property name="order" value="1" />
</bean>
I don't want to move my properties to one of spring-batch-admin's default files. Is there a simpler way to do this?
Answering my own question here...
As described in the documentation, every job configuration file placed under META-INF/spring/batch/jobs/*.xml is loaded by spring-batch-admin as a child context and property placeholders from the parent (i.e. this default bean) are inherited, but the child context can always create its own placeholder bean.
Given that, in my case, the job configuration files are shared with an existing application and use properties from the application classpath, the solution is to create a new job file in META-INF/spring/batch/jobs/*.xml specific for spring-batch-admin:
<!-- placeholder bean with additional properties for the child context -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:/path/to/job-config.properties</value>
</list>
</property>
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="ignoreResourceNotFound" value="true" />
<property name="ignoreUnresolvablePlaceholders" value="false" />
<property name="order" value="1" />
</bean>
<!-- external job configuration file is imported -->
<import resource="classpath*:/path/to/job.xml" />

IIS virtual directory creation fails on IIS 7.0 / windows server 2008

When I tried to create a virtual directory in the remote server using NAnt build script It could not create and shows the error message below:
The webservice at 'remote_machine' does not exist or is not reachable
The OS of remote server is Windows server 2008. Here I have used NAnt 0.92 and natcontrib 0.92.
Any suggestions would be appreciated.
EDiT: It is working for local machine but not for the remote. Any suggestion Please.
the code portion:
<property name="serverName" value="MyServer"/>
<property name="currentDeployName" value="Research"/>
<property name="deployDir" value="\\${serverName}\wwwroot\${currentDeployName}"/>
<property name="currentDir" value="${deployDir}"/>
<property name="DeployWebDir" value="${sourceDir}\Deployment\Deployment.Web"/>
<property name="webrootDir" value="C:\Inetpub\wwwroot"/>
<deliisdir iisserver="${serverName}" vdirname="${currentDeployName}" />
<mkdir dir="${deployDir}" />
<copy todir="${deployDir}" overwrite="true">
<fileset basedir="${DeployWebDir}">
<include name="**\*" />
</fileset>
</copy>
<mkiisdir iisserver="${serverName}" dirpath="${webrootDir}\${currentDeployName}"
vdirname="${currentDeployName}"/>

Unable to invoke an EJB deployed on JBoss 7.1 from JBoss ESB 4.10

I'm trying to invoke an Stateless Session Bean (EJB 3) deployed on Jboss 7.1 Final from an remote instance of JBoss ESB 4.10.
In my jboss-esb.xml I have the following information:
<action name="EJBTestWithReturnValue" class="org.jboss.soa.esb.actions.EJBProcessor">
<property name="ejb3" value="true" />
<property name="method" value="login" />
<property name="jndi-name" value="gwtbatis-ear/gwtibatis-ejb/UserServiceEJB!com.aestasit.gwtibatis.UserServiceRemote" />
<property name="initial-context-factory" value="org.jnp.interfaces.NamingContextFactory" />
<property name="security-principal" value="xxxx" />
<property name="security-credentials" value="xxxx" />
<property name="provider-url" value="localhost:4447" />
<property name="ejb-params">
<arg0 type="java.lang.String">username</arg0>
<arg1 type="java.lang.String">password</arg1>
</property>
<property name="esb-out-var" value="org.jboss.soa.esb.message.defaultEntry"/>
Whatever JNDI binding I try I always get an error "invalid stream header: 00000018".
I successfully invoke the same EJB from a Java client but I use a different context factory ("org.jboss.naming.remote.client.InitialContextFactor").
Is there a way to invoke the remote EJB from ESB, without importing the client lib required by JBoss 7 and wriying my own EJB invoker?