event:inbound-channel-adapter with payload-expression not able to resolve bean - events

I'm attempting to use the event:inbound-channel-adapter as an ApplicationEventListener to capture the ContextRefreshedEvent so I can dynamically start a file:inbound-channel-adapter like:
<file:inbound-channel-adapter id="filesIn" auto-startup="false"
directory="${input.location}" channel="fileInChannel">
<integration:poller ref="filesInPoller" />
</file:inbound-channel-adapter>
<event:inbound-channel-adapter id='appStarter' channel="nullChannel"
error-channel="errorChannel"
event-types="org.springframework.context.event.ContextRefreshedEvent"
payload-expression="#filesIn.start()"/>
But I get the following error indicating the sPel payload-expression cannot find the filesIn bean:
Exception in thread "main" org.springframework.expression.spel.SpelEvaluationException: EL1057E:(pos 1): No bean resolver registered in the context to resolve access to bean 'filesIn'
at org.springframework.expression.spel.ast.BeanReference.getValueInternal(BeanReference.java:45)
at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:49)
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:82)
at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:93)
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:72)
at org.springframework.integration.event.inbound.ApplicationEventListeningMessageProducer.sendEventAsMessage(ApplicationEventListeningMessageProducer.java:113)
at org.springframework.integration.event.inbound.ApplicationEventListeningMessageProducer.onApplicationEvent(ApplicationEventListeningMessageProducer.java:91)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:96)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:948)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
Am I correct in believing that the file:inbound-channel-adapter is able to be started in this way?
Thanks

What version of Spring Integration are you using? The ability to reference a bean #filesIn was added to this adapter in 3.0.
If you are using 2.2 or below, upgrade to the current release (or at least 3.0.4).
In any case, you can't just send that command to nullChannel, it will evaluate to null and you can't have a null payload; you'll have to send '#filesIn.start()' to a <control-bus/>.
EDIT:
Or, "#filesIn.start() == null ? 'foo' : 'bar'" will send foo to the nullChannel.

Related

shibboleth idp with OpenLDAP integration / Uncaught runtime exception java.lang.NullPointerException: null

I got install shibboleth idp with OpenLDAP integration
, it authenticate successfully but
it return exception error
Uncaught runtime exception java.lang.NullPointerException: null
the log file contains
Attribute Resolver 'ShibbolethAttributeResolver': Removing result of attribute definition 'uid', contains no values
Attribute Resolver 'ShibbolethAttributeResolver': Removing result of attribute definition 'mail', contains no values
and
the attribute-resolver.xml file contains
<AttributeDefinition xsi:type="Simple" id="uid">
<InputDataConnector ref="myLDAP" attributeNames="uid" />
<AttributeEncoder xsi:type="SAML1String" name="urn:mace:dir:attribute-def:uid" encodeType="false" />
<AttributeEncoder xsi:type="SAML2String" name="urn:oid:0.9.2342.19200300.100.1.3" friendlyName="uid" encodeType="false" />
</AttributeDefinition>
Thanks,
I found that it's a bug in shibboleth idp 4.0 ,
it should be fixed in the next version

Spring JMS URL - Converting SSL To TCP

We have some existing source code which connect to JMS using TCP protocol . We are providing EMS URL as shown below in properties file:
tib.ems.url=tcp://UK_ONES_DEV_0000.ldn.mywork.com:9222
Now our EMS URL has been changed to SSL but when we are making any changes to ems URL in properties file, it is changing SSL to TCP automatically and failing connection. I am wondering if we need to make any changes for SSL connection.
<bean id="orcaReplayConnectionFactory"
class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
<property name="targetConnectionFactory" ref="orcaProviderReplayConnectionFactory"/>
<property name="username" value="${jms.orca.username}"/>
<property name="password" value="${jms.orca.password}"/>
</bean>
<jee:jndi-lookup id="orcaProviderReplayConnectionFactory"
jndi-name="${jndi.orca.name.replay}">
<jee:environment>
java.naming.factory.initial=com.tibco.tibjms.naming.TibjmsInitialContextFactory
java.naming.provider.url=${jndi.orca.url}
java.naming.factory.url.pkgs=com.tibco.tibjms.naming
</jee:environment>
</jee:jndi-lookup>
15:43:12.923 [main] INFO o.s.s.c.ThreadPoolTaskScheduler -Initializing ExecutorService 'taskScheduler'
15:43:13.528 [main] WARN o.s.c.s.ClassPathXmlApplicationContext -Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.jms.listener.DefaultMessageListenerContainer#0': Cannot resolve reference to bean 'orcaConnectionFactory_v2' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orcaConnectionFactory_v2' defined in class path resource [spring/integration-context.xml]: Cannot resolve reference to bean 'orcaProviderConnectionFactory_v2' while setting bean property 'targetConnectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orcaProviderConnectionFactory_v2': Invocation of init method failed; nested exception is javax.naming.ServiceUnavailableException: Failed to query JNDI: Failed to connect to the server at tcp://UK_ONES_UAT_0000.ldn.mywork.com:9222 [Root exception is javax.jms.JMSException: Failed to connect to the server at tcp://UK_ONES_UAT_0000.ldn.mywork.com:9222]
Normally, when using JNDI, the connection URL is configured in the provider not the JNDI client. You need to fix the url in the provider.
After adding highlighted configuration while doing JNDI l, issue is resolved
<jee:environment>
java.naming.factory.initial=com.tibco.tibjms.naming.TibjmsInitialContextFactory
java.naming.provider.url=${jndi.orca.url}
java.naming.factory.url.pkgs=com.tibco.tibjms.naming
**com.tibco.tibjms.naming.security_protocol=ssl
com.tibco.tibjms.naming.ssl_enable_verify_host=false**
java.naming.security.principal=${jms.orca.username}
java.naming.security.credentials=${jms.orca.password}
</jee:environment>

how to use poller in int-ftp:outbound-gateway?

first,thanks for your attention
i defined a outbound-gateway ftp adapter with polling as bellow code :
<int-ftp:outbound-gateway id="gatewayLS"
session-factory="ftpClientFactory"
request-channel="inboundFileChannel"
command="ls"
command-options="-1"
expression="'books/*'"
reply-channel="outboundJobRequestChannel">
<int:poller fixed-rate="5000"/>
</int-ftp:outbound-gateway>
but I got the following exception:
org.xml.sax.SAXParseException; lineNumber: 57; columnNumber: 40; cvc-complex-type.2.4.a: Invalid content was found starting with element 'int:poller'. One of '{"http://www.springframework.org/schema/integration/ftp":request-handler-advice-chain}' is expected.
what is correct action for above problem?
thanks
This was fixed in version 4.1. The current version is 4.1.3.
If you can't move to 4.1.x (recommended), you can add a <bridge/> to bridge the pollable channel to a direct channel.

OpenAM with OpenDJ - NameNotFoundException: ldap/idp/userDN - when starting up JBoss

I'm using OpenAM, with its embedded OpenDJ as the LDAP service, to protect my web application running on JBoss 7.
When I start my JBoss I get this error:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ldapUserDN'
...
Caused by: javax.naming.NameNotFoundException: ldap/idp/userDN -- service jboss.naming.context.java.ldap.idp.userDN
So apparently Spring is looking for the JNDI node ldap/idp/userDN. But the jboss configuration file that I got with the project has these entries:
<simple name="ldap/opendj/url" value="ldap://localhost:50389"/>
<simple name="ldap/opendj/userDN" value="cn=Directory Manager"/>
<simple name="ldap/opendj/password" value="mypassword"/>
<simple name="ldap/opendj/baseDN" value="dc=opensso,dc=java,dc=net"/>
And these properties are added to my JNDI tree on JBoss.
If I change these to "ldap/idp/userDN", for instance, then I get rid of the error, but I was wondering if there's anywhere, where "ldap/opendj/userDN" should be mapped to "ldap/idp/userDN", that I've missed.
If you're using Spring LDAP, the actual configuration of the ldap-context-source goes in the a spring config file, and might look like this:
<jee:jndi-lookup jndi-name="ldap/idp/url" id="ldapUrl"/>
<jee:jndi-lookup jndi-name="ldap/idp/userDN" id="ldapUserDN"/>
<jee:jndi-lookup jndi-name="ldap/idp/password" id="ldapPassword"/>
<jee:jndi-lookup jndi-name="ldap/idp/baseDN" id="ldapBaseDN"/>
<ldap:context-source url="#{ldapUrl}"
username="#{ldapUserDN}"
password="#{ldapPassword}"
base="#{ldapBaseDN}"
native-pooling="true"/>
So the jndi entries in your jboss config file should match the ones above.

calling ejb3.0 in action class. application server : websphere7.0 and IDE: RAD7.5

I have written one stateless session bean and deployed in the server. when i tried to access that particular ejb, it's throwing error.
Code sample:
TestServiceBeanRemote : Remore bean
TestServiceBean : Actual bean
Context context = new InitialContext();
TestServiceBeanRemote test = (TestServiceBeanRemote)context.lookup("com.test.ejb.TestServiceBean");
test.hello("ejb3.0");
Error :
[5/23/11 14:27:00:250 IST] 0000001b SystemErr R javax.naming.NameNotFoundException: Context: gopatilbNode01Cell/nodes/gopatilbNode01/servers/server1, name: com.test.ejb.TestServiceBean: First component in name com.test.ejb.TestServiceBean not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]
[5/23/11 14:27:00:250 IST] 0000001b SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.mapNotFoundException(CNContextImpl.java:4365)
**: Do i need to configure anything in was7.0 ? or do i need to write any xml file for jndi lookup in ejb3.0 ? please help.
The default bindings in WebSphere Application Server are the interface name (e.g., com.test.ejb.TestService) and <app>/<module>/<bean>#<interface> (e.g., MyTest.ear/test.jar/TestServiceBean#com.test.ejb.TestService). These can be changed during the deploy process or using ibm-ejb-jar-bnd.xml. More information is available in the EJB 3.0 application bindings overview InfoCenter topic.

Resources