ActiveMQ configuration: BrokerXMLConfig activemq.xml - relative path file not found - activemq

I'm configuring an embedded instance of ActiveMQ using a WEB-INF/resources.xml file in my Dynamic Web Project that references an external activemq.xml file. ActiveMQ starts & functions as expected using an absolute path to activemq.xml placed in Tomcat's {$CATALINA_HOME}/conf directory. When activemq.xml is placed into the project's WEB-INF directory, Tomcat fails to find the BrokerXmlConfig file using a relative path.
Is it possible to package the activemq.xml file with the project in the WEB-INF directory?
If possible, how is Tomcat parsing the path to the file?
working resources.xml
<resources>
<Resource id="jmsConnectionFactory" type="javax.jms.ConnectionFactory">
connectionMaxIdleTime = 15 Minutes
connectionMaxWaitTime = 5 seconds
poolMaxSize = 10
poolMinSize = 0
resourceAdapter = MyJmsResourceAdapter
transactionSupport = xa
</Resource>
<Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
BrokerXmlConfig = xbean:file:/absolute/path/to/activemq.xml
ServerUrl = tcp://localhost:61616
</Resource>
<resources>
failing resources.xml
<resources>
<Resource id="jmsConnectionFactory" type="javax.jms.ConnectionFactory">
connectionMaxIdleTime = 15 Minutes
connectionMaxWaitTime = 5 seconds
poolMaxSize = 10
poolMinSize = 0
resourceAdapter = MyJmsResourceAdapter
transactionSupport = xa
</Resource>
<Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
BrokerXmlConfig = xbean:file:WEB-INF/activemq.xml
ServerUrl = tcp://localhost:61616
</Resource>
<resources>
Other unsuccessful attempts:
BrokerXmlConfig = xbean:classpath:WEB-INF/activemq.xml
BrokerXmlConfig = xbean:file:WEB-INF/activemq.xml
BrokerXmlConfig = xbean:file:activemq.xml
BrokerXmlConfig = xbean:file:./activemq.xml
BrokerXmlConfig = xbean:file:../activemq.xml
BrokerXmlConfig = xbean:file:conf/activemq.xml

I never solved the xbean relative path problem. Using the absolute path works
BrokerXmlConfig = xbean:file:/absolute/path/to/activemq.xml
Aside from the path problem, I ended up not using a separate activemq.xml file. I just used the connection factory with the Default JMS Resource Adapter.
<resources>
<Resource id="jmsConnectionFactory" type="javax.jms.ConnectionFactory">
connectionMaxIdleTime = 15 Minutes
connectionMaxWaitTime = 5 seconds
poolMaxSize = 10
poolMinSize = 0
resourceAdapter = Default JMS Resource Adapter
transactionSupport = xa
</Resource>
<resources>

Related

Deploying Custom RoleMapper to WebLogic

I am trying to deploy a Custom Role Mapper in WebLogic 10.3.5.0 - this is very similar to this question - Weblogic Providers, but I cannot get the provider to appear in the poplist.
Config file:
<MBeanType Name="DatabaseRoleMapping"
DisplayName="DatabaseRoleMapping"
Package="com.bynx.weblogic.mbean.rolemapping"
Extends="weblogic.management.security.authorization.RoleMapper"
PersistPolicy = "OnUpdate">
<MBeanAttribute
Name = "ProviderClassName"
Type = "java.lang.String"
Writeable = "false"
Preprocessor = "weblogic.management.configuration.LegalHelper.checkClassName(value)"
Default = ""com.bynx.weblogic.mbean.rolemapping.DatabaseRoleMappingProvider""
/>
<MBeanAttribute
Name = "Description"
Type = "java.lang.String"
Writeable = "false"
Default = ""Provider that performs Role Mapping held in a database""
/>
<MBeanAttribute
Name = "Version"
Type = "java.lang.String"
Writeable = "false"
Default = ""1.0""
/>
<!--
<MBeanAttribute
Name = "DataSourceJNDI"
Type = "java.lang.String"
Default = ""UserDataSource""
Description = "DataSource JNDI name"
/> -->
</MBeanType>
Provider Imlementation:
package com.bynx.weblogic.mbean.rolemapping;
import weblogic.management.security.ProviderMBean;
import weblogic.security.spi.RoleMapper;
import weblogic.security.spi.RoleProvider;
import weblogic.security.spi.SecurityServices;
public class DatabaseRoleMappingProvider implements RoleProvider
{
DatabaseRoleMapper mapper;
private String description;
#Override
public String getDescription()
{
return description;
}
#Override
public void initialize(ProviderMBean provider, SecurityServices services)
{
//DatabaseRoleMappingProviderMBean mBean = (DatabaseRoleMappingProviderMBean)provider;
//mapper = new DatabaseRoleMapper(mBean.getDataSourceJNDI());
mapper = new DatabaseRoleMapper("UserDataSource");
description = provider.getName() + " " + provider.getVersion();
}
#Override
public void shutdown()
{
}
#Override
public RoleMapper getRoleMapper()
{
return mapper;
}
}
Build file:
<?xml version="1.0"?>
<project name="dbuser_authentication_provider" default="all" basedir=".">
<!-- global properties -->
<property environment="env"/>
<property name="jdk" value="C:/Program Files (x86)/Java/jdk1.6.0_26"/>
<property name="lib" value="P:/Web_Dev/Projects/WebLogic_Home/wlserver_10.3/server/lib"/>
<property name="mbeantypes" value="${lib}/mbeantypes"/>
<property name="sampleprovidersjar" value="databaseRoleMapping.jar"/>
<property name="sample_dir" location="."/>
<property name="src_dir" value="${sample_dir}/src"/>
<property name="provider_src_dir" value="${src_dir}/com"/>
<property name="build_dir" value="${sample_dir}/build"/>
<property name="class_dir" value="${sample_dir}/classes"/>
<property name="namespace" value="http://www.bea.com/ns/90/weblogic/security/samples"/>
<target name="all" depends="clean">
<!-- Set up the build directories -->
<mkdir dir="${build_dir}"/>
<mkdir dir="${class_dir}"/>
<!-- Only copy over the commo dtd and sample provider xml files for now -->
<copy todir="${build_dir}" flatten="true">
<fileset dir="${lib}">
<include name="commo.dtd"/>
</fileset>
</copy>
<copy todir="${build_dir}" flatten="true">
<fileset dir="${provider_src_dir}">
<include name="**/*.xml"/>
<include name="**/*.java"/>
</fileset>
</copy>
<!-- Build the sample security providers' jar file -->
<java classname="weblogic.management.commo.WebLogicMBeanMaker" fork="true" failonerror="true">
<jvmarg line="-cp '${jdk}/lib/tools.jar';${lib}/weblogic.jar -Dfiles=${build_dir} -DMDFDIR=${build_dir} -DMJF=${build_dir}/${sampleprovidersjar} -DtargetNameSpace=${namespace} -DpreserveStubs=true -DcreateStubs=true"/>
</java>
</target>
<target name="clean">
<delete quiet="true" dir="${build_dir}"/>
<delete quiet="true" dir="${class_dir}"/>
</target>
</project>
Everything compiles fine and there don't appear to be any missing class files in the generated jar, but putting the jar in the mbeantypes directory and restarting it doesn't appear in the list. It will eventually look at a database, but I have stripped it down to the minimum to try and get it working. Any suggestions - or where to look in the logs for any issues would be appreciated.
I've managed to get this working, so thought I would share my solution in case anyone else stumbles upon this.
First the statement in the documentation:
However, if you want WebLogic Server to look for MBean types in additional directories, use the -Dweblogic.alternateTypesDirectory= command-line flag when starting your server, where is a comma-separated list of directory names. When you use this flag, WebLogic Server will always load MBean types from WL_HOME\server\lib\mbeantypes first, then will look in the additional directories and load all valid archives present in those directories (regardless of their extension).
Doesn't appear to be correct. We are using the alternateTypesDirectory parameter and I could only get WebLogic to pickup my custom MBean if I put the jar in one of the directories in the command-line flag.
Secondly, if you have anything deployed that uses versioning (e.g. one or more of the optional deployable libraries), your custom provider must implement the weblogic.security.spi.VersionableApplicationProvider interface and haveImplements = "weblogic.management.security.ApplicationVersioner" in the MBeanType element of the definition XML.

Localized file resource not found

I have included these files in my project with Build Action set to Content:
\Resources\Myfolder\Myfiles-de-DE.zip
\Resources\Myfolder\Myfiles-en-US.zip
\Resources\Myfolder\Myfiles-sv-SV.zip
\Resources\Myfolder\Myfiles-fr-FR.zip
In my Package.appxmanifest I have tried this [when "Open With..." "XML (Text) Editor"]:
<Resources>
<!-- First = Default -->
<Resource Language="en-US" />
<Resource Language="sv-SV" />
<Resource Language="de-DE" />
<Resource Language="fr-FR" />
</Resources>
and this:
<Resources>
<Resource Language="x-generate" />
</Resources>
In code I am trying to access the file like this:
Dim ZipPath As String = "Resources\Myfolder\Myfiles-.zip"
Dim fs As System.IO.Stream = Await _
Windows.ApplicationModel.Package.Current.InstalledLocation.OpenStreamForReadAsync(ZipPath)
But I get only a FileNotFoundException! What am I doing wrong?
PS: The file loads if I change the code to this:
Dim ZipPath As String = "Resources\Myfolder\Myfiles-en-US.zip"
It isn't fully clear what you're trying to accomplish. But the code should throw that exception unless you have Resources\Myfolder\Myfiles-.zip file loaded in there by default.
I'm guessing you want to load in the specific zip file based on their prefer language, but no where in your code do attempt to get their language.
You can try to do a LocalizedStrings : How to build a localized app for Windows Phone 8
Or you can just get their prefer language and append it to the ZipPath that you have
string ZipPath = "Resources\Myfolder\Myfiles-" + culture_extention + ".zip";
where culture_extention is Windows.System.UserProfile.GlobalizationPreferences.Languages[0]

Infinispan cache.put does not work

I have created a two node cluster running Infinispan cache in replication mode. I see the cache comes up fine. and both the nodes connect to each other. I am here using TreeCache Api to convert the Map based structure to tree based as below:
private static Cache<Object, Object> Cache1;
private static TreeCache<Object, Object> Cache;
Cache1 = new DefaultCacheManager("infinispan.xml").getCache();
Cache = new TreeCacheFactory().createTreeCache(Cache1);
If i call Cache.put , I dont get any error but the entry does not get saved to the cache. I confirmed it by getting the data again which returns NULL.
Cache.put(fqn,key, value);
if(Cache.get(fqn, key) == null)
{
System.out.println("Entry is not saved");
}
Below is the config file,
<?xml version="1.0" encoding="UTF-8"?>
<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:5.3 http://www.infinispan.org/schemas/infinispan-config-5.3.xsd"
xmlns="urn:infinispan:config:5.3">
<global>
<globalJmxStatistics enabled = "true" allowDuplicateDomains = "true"/>
<transport clusterName = "test_cluster">
<properties>
<property name="configurationFile" value="tcp.xml" />
</properties>
</transport>
</global>
<default>
<clustering mode="replication">
<async asyncMarshalling="true" useReplQueue="true" replQueueInterval="10" replQueueMaxElements="100" />
<stateTransfer timeout="2000000"/>
</clustering>
<invocationBatching enabled = "true"/>
<locking isolationLevel = "REPEATABLE_READ"
writeSkewCheck = "false"
concurrencyLevel = "1000"/>
<jmxStatistics enabled="true"/>
</default>
</infinispan>
Is it that I am missing to initialize any thing?

Deploying .war containing JavaFX .jar to GlassFish NoClassDefFoundError

My JavaFX application requires a class in another jar file.
Both are deployed as part of a war file
The JavaFX jar is not finding the my-xxx.class contained in WEB-INF/lib/MyJavaFXClient.jar
The contents of my war file are:
images/
META-INF/
META-INF/MANIFEST.MF
WEB-INF/
WEB-INF/lib/
WEB-INF/lib/bin/glass.dll
WEB-INF/lib/MyJavaFxClient.jar ( this is the jar my JavaFX app requires )
WEB-INF/sun-web.xml
WEB-INF/web.xml
index.jsp
index.html
MyJavaFxApp.jnlp
MyJavaFxApp.jar (my JavaFx app)
JNLP:
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0" xmlns:jfx="http://javafx.com" href="MyJavaFxApp.jnlp">
<information>
<title>App: TestDriver</title>
<vendor>Demo</vendor>
<description>JavaFX application test client</description>
<homepage href="http://localhost:8080/testdriver/"/>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<jfx:javafx-runtime version="2.2+"
href="http://javadl.sun.com/webapps/download/GetFile/javafx-latest/windows- i586/javafx2.jnlp"/>
</resources>
<resources>
<j2se version="1.6+" java-vm-args="-verbose:class
href="http://java.sun.com/products/autodl/j2se"/>
<property name="javafx.verbose" value="true"/>
<property name="java.library.path" value="WEB-INF/lib/bin"/>
<jar href="MyJavaFxApp.jar" size="318607" download="eager" />
</resources>
<applet-desc width="800" height="600"
main-class="com.javafx.main.NoJavaFXFallback"
name="MyJavaFxApp" >
<param name="requiredFXVersion" value="2.2+"/>
</applet-desc>
<jfx:javafx-desc width="800" height="600"
main-class="ui.client.MyJavaFXMain" name="MyJavaFxApp" />
<update check="background"/>
</jnlp>

URIs when using domain.xml at embedded glassfish

I'm embedding a Java EE 5 application using GlassFish 3.0.1. I already can deploy it (when using without specific configuration), but when trying to run server with the domain.xml (basically JAAS info), I get this error:
java.lang.IllegalArgumentException: URI is not absolute
My code is this (error points to the last line):
Server.Builder builder = new Server.Builder("ipc");
EmbeddedFileSystem.Builder efsb = new EmbeddedFileSystem.Builder();
File domainDir = new File( "domains/ipc-domain" );
File domainXML = new File( domainDir.getAbsoluteFile(), "config/domain.xml" );
efsb.instanceRoot( domainDir.getAbsoluteFile() );
efsb.configurationFile( domainXML.getAbsoluteFile() );
EmbeddedFileSystem efs = efsb.build();
builder.embeddedFileSystem(efs);
//Trying to set variable used at domain.xml (blind shot)
Properties props = new Properties();
props.setProperty( "com.sun.aas.instanceRoot" , domainDir.toURI().toString());
Server server = builder.build( props );
My domain.xml (specific part) have this:
<domain log-root="${com.sun.aas.instanceRoot}/logs" application-root="${com.sun.aas.instanceRoot}/applications" version="10.0">
<system-applications/>
<applications>
<application context-root="/IPC" location="${com.sun.aas.instanceRoot}/applications/IPC/" name="IPC" object-type="user">
<property name="keepSessions" value="false"></property>
<property name="defaultAppName" value="IPC"></property>
<module name="IPC">
<engine sniffer="ejb"></engine>
<engine sniffer="security"></engine>
<engine sniffer="jpa"></engine>
<engine sniffer="web"></engine>
</module>
</application>
</applications>
<resources>
<jdbc-connection-pool pool-resize-quantity="1" datasource-classname="org.apache.derby.jdbc.ClientDataSource" max-pool-size="2" res-type="javax.sql.DataSource" steady-pool-size="1" name="ipc-pool">
<property name="PortNumber" value="1527"></property>
<property name="ServerName" value="0.0.0.0"></property>
<property name="User" value="app"></property>
<property name="Password" value="root"></property>
<property name="DatabaseName" value="IPC"></property>
</jdbc-connection-pool>
<jdbc-resource pool-name="ipc-pool" jndi-name="jdbc/IPC"></jdbc-resource>
</resources>
I've already tried to change the parts related to the "${com.sun.aas.instanceRoot}" variable, but then I have small variations of the URI error. Any insight?