Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have problems to declare an e-mail session as an OSGI service.
I am using Apache Karaf 3.0.1 as container, Apache Aries for the blueprint JPA and JNDI enhancement.
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<bean id="mailSession" class="javax.mail.Session" init-method="getInstance">
<property name="mail.smtp.host" value="mysmptpip"/>
<property name="mail.smtp.port" value="25"/>
</bean>
<service auto-export="interfaces" ref="mailSession">
<service-properties>
<entry key="osgi.jndi.service.name" value="java:mail/MailSession"/>
</service-properties>
</service>
</blueprint>
I have an error of type enable to find a matching method on class javax.mail.Session for arguments [{mail.smtp.host=mysmptpip, mail.smtp.port=25}] ...
Does anybody have any idea how this should be fixed ?
In addtion I would like to know how can I declare a JavaMail session as a JNDI resource via Apache blueprint (that will create the service)?
I think you could provide a configured mail Session as a service. So the configuration would be centralized.
BundleContext#registerService() suffices; you can add properties to the service registration if you want to, but it's not necessary. Remember to unregister the service when it's closed.
Related
We are using the jboss application server version 4.2.3.
After starting the server, One of the destination queue 'testQueue' bound becomes to CLOSED state.
While checking the logs, the below information was present.
2014-01-07 20:55:49,855 INFO [genericEventJmsContainer-1]- Setup of
JMS message listener invoker failed for destination
'JBossQueue[testQueue]' - trying to recover. Cause: The object is
closed javax.jms.IllegalStateException: The object is closed at
org.jboss.jms.client.container.ClosedInterceptor.invoke(ClosedInterceptor.java:159)
at
org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:105)
at
org.jboss.jms.client.delegate.ClientConsumerDelegate$receive_N8299950230150603585.invokeNext(ClientConsumerDelegate$receive_N8299950230150603585.java) at
org.jboss.jms.client.delegate.ClientConsumerDelegate.receive(ClientConsumerDelegate.java)
at
org.jboss.jms.client.JBossMessageConsumer.receive(JBossMessageConsumer.java:86)
at
org.springframework.jms.connection.CachedMessageConsumer.receive(CachedMessageConsumer.java:74)
at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveMessage(AbstractPollingMessageListenerContainer.java:405)
at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:308)
at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:261)
at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:982)
at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:974)
at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:876)
at java.lang.Thread.run(Thread.java:662)
Could anyone kindly provide us with some inputs on the reason why a selected destination becomes to CLOSED state after a certain period of time from the server start time?
It may be the bug https://issues.jboss.org/browse/JBESB-1491 which is in version 4.2.1 ,which is fixed version is 4.3.
Please share the JMS configuration you have done for Queue.
Also you can find related topic http://docs.jboss.org/jbossas/jboss4guide/r1/html/ch6.chapt.html
Thanks for your comments
<mbean code="org.jboss.jms.server.destination.QueueService" name="jboss.esb.quickstart.destination:service=Queue,name=testQueue" xmbean-dd="xmdesc/Queue-xmbean.xml"> <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer </depends> <depends>jboss.messaging:service=PostOffice</depends> <attribute name="RedeliveryDelay">1000</attribute> <attribute name="MaxDeliveryAttempts">15</attribute> <attribute name="Clustered">true</attribute> </mbean>
Above is a sample configuration we make for a Queue destination.
These queues are defined in JBOSS SOA server version 4.3 and being listened by components deployed in JBOSS Application Server version 4.2.3
We use Windows Server 8 with Oracle 10g (R 10.2.0.2).
We believe that the Oracle JDBC Jar is correct, we tested some possibilities.
The problem now when we tested the connection is: "provided data source type not supported".
Anybody have any suggestion?
Thanks so much!
I believe there must be an issue with your datasource configuration defined in master-datasources.xml or any other *-datasources.xml you are using in your environment. Please double check whether the following line is defined properly in your datasource configuration. All the RDBMS databases should be configured having the definition type as "RDBMS".
<definition type="RDBMS">
A complete sample datasource configuration for your requirement is depicted below.
<datasource>
<name>testds</name>
<description>The datasource used for registry and user manager</description>
<jndiConfig>
<name>jdbc/testds</name>
</jndiConfig>
<definition type="RDBMS">
<configuration>
<url>jdbc:oracle:thin:#localhost:1521:XE</url>
<username>test</username>
<password>test</password>
<driverClassName>oracle.jdbc.OracleDriver</driverClassName>
<maxActive>50</maxActive>
<maxWait>60000</maxWait>
<testOnBorrow>true</testOnBorrow>
<validationQuery>SELECT 1 FROM DUAL</validationQuery>
<validationInterval>30000</validationInterval>
</configuration>
</definition>
</datasource>
Hope this helps.
Regards,
Prabath
I am in process of implementing a REST API server using Apache CXF JAX-RS v(2.30). I am using spring as container. I am thinking of making use of org.apache.cxf.jaxrs.ext.RequestHandler to implement few features like license check, authentication, authorization (All of which has custom code). My idea is to segregate this code in individual implementation classes (implementing RequestHandler) and configure it for a base REST url something like /rest/*. Being new to Apache CXF and JAX-RS, I want to understand following things.
Is this approach the right way to implement the features I want to?
If yes, then is the order in which the RequestHandlers are declared is the order of their invocation?
For example if in my definition I declare:
<beans>
<jaxrs:server id="abcRestService" address="/rest">
<jaxrs:serviceBeans>
<bean class="com.abc.api.rest.service.FooService" />
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="licenseFilter" />
<ref bean="authorizationFilter" />
</jaxrs:providers>
</jaxrs:server>
<bean id="licenseFilter" class="com.abc.api.rest.providers.LicenseValidator">
<!-- License check bean properties -->
</bean>
<bean id="authorizationFilter" class="com.abc.api.rest.providers.AuthorizationFilter">
<!-- authorization bean properties -->
</bean>
</beans>
then will the licenseFilter always get invoked before authorizationFilter?
I did not find a mention of invocation ordering of RequestHandlers as well as ResponseHandlers.
Thanks in advance.
Figured this out.
It gets invoked in the order of declaration of beans in <jaxrs:providers>. Thus in case mentioned in question, licenseFilter will get invoked before authorizationFilter.
For JAAS authentication I have configured a datasource as follows:
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/SomeDS</jndi-name>
<connection-url>jdbc:path-to-server</connection-url>
<driver-class>interbase.interclient.Driver</driver-class>
<user-name>DBUSER</user-name>
<password>dbpass</password>
<min-pool-size>0</min-pool-size>
<metadata>
<type-mapping>Firebird</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
Unfortunately JBoss keeps the database connection open which can cause severe performance problems on our InterBase database.
As this connection is used only by the JAAS module internally, our web application has no way to force-close the connection.
Is there a way to tell JBoss to close connections after use?
Have you tried adding <idle-timeout-minutes>? - It defines the maximum time a connection may be idle before being closed. Setting to 0 disables it. Default is 15 minutes.
See http://community.jboss.org/wiki/ConfigDataSources for details.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Any way to share session state between different applications in tomcat?
How can i share a session Attribute in 2 web project in the same work space ?
i read that the session is on the server why when i go the 2nd project in the same work space i dont find any session Attribute .
i mean i cant use that in the énd project
<%
if(session.getAttribute("UserName") != null ){
%>
do Some work
<% } %>
i'm usign Tomcat V7 as a server
and eclipse
hmmm! if you are using tomcat you can set crossContext=true in server.xml i.e.
<Context allowLinking="true" docBase="/home/appA" path="/appA" reloadable="true" crossContext="true"/>
<Context allowLinking="true" docBase="/home/appB" path="/appB" reloadable="true" crossContext="true"/>
and then you can share the sessions, also if you can tell me the situation then I might be more helpful
i try to do what the answer say so i change them like that
<Context docBase="SpeedyService" path="/SpeedyService" reloadable="true" source="org.eclipse.jst.jee.server:SpeedyService" crossContext="true"/><Context docBase="HiberBarti" path="/HiberBarti" reloadable="true" source="org.eclipse.jst.jee.server:HiberBarti" crossContext="true"/><Context docBase="SpeedyServiceClient" path="/SpeedyServiceClient" reloadable="true" source="org.eclipse.jst.jee.server:SpeedyServiceClient" crossContext="true"/></Host>
but i found a 2nd file service.xml in my work space i didnt change
<Context docBase="F:\workspacetravailProject\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\ROOT" path="" reloadable="false"/><Context docBase="F:\workspacetravailProject\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\SpeedyService" path="/SpeedyService" reloadable="true" source="org.eclipse.jst.jee.server:SpeedyService"/><Context docBase="F:\workspacetravailProject\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\HiberBarti" path="/HiberBarti" reloadable="true" source="org.eclipse.jst.jee.server:HiberBarti"/><Context docBase="F:\workspacetravailProject\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\SpeedyServiceClient" path="/SpeedyServiceClient" reloadable="true" source="org.eclipse.jst.jee.server:SpeedyServiceClient"/></Host>