spring hbase properties : where to specify apache config timeout? - java

Where do I set properties like 'hbase.client.retries.number' when using hbase.version : 1.1.1
Using xml to configure spring. In my xml:
<context:property-placeholder location="classpath:webr/hbase.properties" />
<context:component-scan base-package="com.mine.xx" />
<hdp:configuration id="hadoopConfiguration">
fs.defaultFS=file:///usr/local/XX
</hdp:configuration>
<!-- configuration-ref="hadoopConfiguration" -->
<hdp:hbase-configuration configuration-ref="hadoopConfiguration"
zk-quorum="${hbase.zk.host}" zk-port="${hbase.zk.port}" />
But when I set (in webr/hbase.properties) :
hbase.client.retries.number=0
zookeeper.session.timeout=38000
zookeeper.recovery.retry=0
hbase.rpc.timeout=29000
zookeeper.recovery.retry=0
They do not get picked up (the program hangs for more than 3 minutes) after a scan is sent.
The hadoop install is on my lan.

Related

How to use Vaadin add-on with Spring Boot?

I'm using Vaadin 7.6.3 with Spring Boot. I'm trying to use the PopupButton add-on (but I don't think the issue is specific to the add-on).
I added the add-on as a dependency to gradle. This is the code for creating a PopupButton:
PopupButton btn = new PopupButton("Test Button");
btn.setContent(new Label("Test"));
layout.addComponent(btn);
Via the Vaadin plugin for Gradle I ran the task vaadinCompile which created the file src/main/resources/addon/client/ListaideWidgetset.gwt.xml and serveral files in src/main/webapp/VAADIN/gwt-unitCache and
src/main/webapp/VAADIN/widgetsets/addon.client.ListaideWidgetset. I also added #Widgetset("addon.client.ListaideWidgetset") to my UI. I confirmed that the widgetset is used via the client's ?debug mode.
Content of ListaideWidgetset.gwt.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Vaadin//DTD Vaadin 7//EN" "https://raw.github.com/vaadin/gwt/master/distro-source/core/src/gwt-module.dtd">
<!-- WS Compiler: manually edited -->
<module>
<inherits name="com.vaadin.DefaultWidgetSet" />
<set-configuration-property name="devModeRedirectEnabled" value="true" />
<set-property name="user.agent" value="ie8,ie9,gecko1_8,safari,ie10" />
<source path="client" />
<source path="shared" />
<collapse-all-properties />
<set-property name="compiler.useSymbolMaps" value="true" />
</module>
The problem is that on the client the button shows up as a standard button (no chevron) and doesn't open a popup when clicked.
Your widgetset does not contain the addon. See the the example:
<inherits name="org.vaadin.hene.popupbutton.widgetset.PopupbuttonWidgetset" />
Once added, recompile the widgetset, restart your application.
Usually the gradle plugin can handle this for you, but that feature can be disabled and or some other configuration error could prevent it. Hard to tell without the build.gradle...
edit
The gradle vaadin plugin seems not to be able to handle this addon properly. As a workaround disable the automatic management for widgetset, which prevents regeneration of the gwt.xml. See manageWidgetset in https://github.com/johndevs/gradle-vaadin-plugin/wiki/Tasks-and-configuration-DSL). E.g. add vaadinCompile.manageWidgetset = false in your vaadin{}-block.

Wildfly Data Persistence

I am currently working on a Java EE project and am working with the Wildfly server.
I have a Web project and EJB project which are deployed onto the Wildfly server.
I can save a user for example, but only for as long as the server is running.
There is no data persistence between server downtimes.
I have searched through the internet but couldn't find an answer.
My persistence.xml looks like this:
<persistence-unit name="primary">
<!-- If you are running in a production environment, add a managed
data source, this example data source is just for development and testing! -->
<!-- The datasource is deployed as WEB-INF/kitchensink-quickstart-ds.xml, you
can find it in the source at src/main/webapp/WEB-INF/kitchensink-quickstart-ds.xml -->
<jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.show_sql" value="false" />
<value="true"/>
</properties>
If I want to persist any information, do i need to reconfigure this file?
I hope you can help me :)
Your problem is this line
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
Everytime when the wildfly starts up, JPA creates a new database model with an empty database.
Adjust your code to
<property name="hibernate.hbm2ddl.auto" value="update" />
You are using "ExampleDS" which is set up as H2 in-memory database by default. It therefore does not persist data between restarts on purpose (useful for development/testing). Go to wildfly's standalone/configuration/standalone.xml configuration file and search for "ExampleDS" in the "datasources" section. It should show:
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
where "mem" means in-memory. You can change "mem:test" to any write path, e.g.
<connection-url>jdbc:h2:~/test;DB_CLOSE_DELAY=-1</connection-url>
to use a H2 file-based database stored as "test" in your home-folder (assuming *nix).
You can also define additional databases (Postgresql, Oracle, etc) in the datasources-section.

Spring: Nested beans reference to another bean is not working

I am trying to use nested beans with a profile to setup an embedded jms broker when I am in dev mode. Here is my xml:
<beans ...>
...
other bean definition
...
<beans profile="embeddedBroker">
<!-- Configure an embedded ActiveMQ Broker with a TCP connector.
This broker is never set to start automatically by default, it is the broker service wrapper that
will take care to start it if configured to do so.
-->
<amq:broker id="jmsBroker" brokerId="EmbeddedBroker" brokerName="EmbeddedBroker"
persistent="false" useJmx="true" start="false">
<amq:plugins>
<!-- lets enable detailed logging in the broker but ignore ConnectionEvents -->
<amq:loggingBrokerPlugin logMessageEvents="true" logConnectionEvents="false"/>
<amq:timeStampingBrokerPlugin zeroExpirationOverride="1000" ttlCeiling="60000" futureOnly="true"/>
<amq:traceBrokerPathPlugin />
</amq:plugins>
<!-- Create a connector to give an external remote access to this broker. -->
<amq:transportConnectors>
<amq:transportConnector uri="tcp://127.0.0.1:35000" />
</amq:transportConnectors>
</amq:broker>
<!-- This broker service (wrapper) control the lifecycle of the jms broker defined above.
By default the internal broker will be initialized, but not started. It will usually be started only for
internal integration and unit tests.
-->
<bean id="jmsBrokerService" class="com.imetrik.global.common.jms.AMQBrokerService"
init-method="start"
destroy-method="stop">
<property name="broker" ref="jmsBroker" />
<property name="enabled" value="true" />
</bean>
</beans>
</beans>
But when I run my application with the correct profile, spring complain that the jmsBroker reference cannot be found!
Error creating bean with name 'jmsBrokerService' defined in class path resource [jms-beans.xml]: Cannot resolve reference to bean 'jmsBroker' while setting bean property 'broker';
Is there a way to fix that? Is it because the reference bean is not in the same namespace?
I know that if I put it out of the nested beans, it is working fine.
I am using Spring 4.1

Connections keep piling up in Redis from Java client

I have Redis installed on my machine and I am using a Jedis client within my Spring app to write some data onto Redis. For certain reasons, with each write, the number of connections to Redis keep piling up until I get a JedisConnectionFailureException.
My Spring Jedis Config file looks like this :
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- Redis conection factory configurations -->
<bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
p:host-name="${redis.host}"
p:port="${redis.port}"
p:password="${redis.password}"
p:use-pool="true" />
<!-- Redis String Serializer -->
<bean id="stringRedisSerializer" class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
<!-- JDK Serialization Redis Serializer -->
<bean id="jdkSerializationRedisSerializer" class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer"/>
<!-- Configuring the Redis Template -->
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate"
p:connection-factory-ref="redisConnectionFactory"
p:keySerializer-ref="stringRedisSerializer"
p:valueSerializer-ref="jdkSerializationRedisSerializer" />
Within my entire app, this is the only place where I'm creating connections.
In my spring-app, I'm using the connections as follows :
redisTemplate.opsForValue().set("key", "value");
The issue is around wrong Spring Data Redis TX Sync algorithm - it has bugs.
It has been fixed and is available since Spring Data Redis 1.3 GA

No embedded stylesheet instruction for file: spring-security.xml

while trying to run my app-engine spring project, i am getting the blow error.
I have xslt in my spring security file but still getting the error.
And eclipse is creating a file named spring-security.out.xml
16:54:39,148 INFO [main] Main - javax.xml.transform.TransformerFactory=null
16:54:39,151 INFO [main] Main - java.endorsed.dirs=C:\Program Files\Java\jdk1.7.0_45\jre\lib\endorsed
16:54:39,156 INFO [main] Main - launchFile: E:\spring+gapp_32kepler\workspace_new\.metadata\.plugins\org.eclipse.wst.xsl.jaxp.launching\launch\launch.xml
16:54:39,264 FATAL [main] Main - No embedded stylesheet instruction for file: file:/E:/spring+gapp_32kepler/workspace_new/cms/war/WEB-INF/spring-security.xml
org.eclipse.wst.xsl.jaxp.debug.invoker.TransformationException: No embedded stylesheet instruction for file: file:/E:/spring+gapp_32kepler/workspace_new/cms/war/WEB-INF/spring-security.xml
at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.transform(JAXPSAXProcessorInvoker.java:223)
at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.transform(JAXPSAXProcessorInvoker.java:187)
at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.Main.main(Main.java:73)
Caused by: org.eclipse.wst.xsl.jaxp.debug.invoker.TransformationException: No embedded stylesheet instruction for file: file:/E:/spring+gapp_32kepler/workspace_new/cms/war/WEB-INF/spring-security.xml
at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.transform(JAXPSAXProcessorInvoker.java:213)
... 2 more
spring-security.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<!-- This is where we configure Spring-Security -->
<security:http auto-config="false" use-expressions="true" access-denied-page="/jsp/admin/login" entry-point-ref="authenticationEntryPoint" >
<security:intercept-url pattern="/jsp/admin" access="permitAll"/>
<security:intercept-url pattern="/jsp/admin/**" access="hasRole('ROLE_ADMIN')"/>
<security:intercept-url pattern="/jsp/user/**" access="permitAll"/>
<security:logout invalidate-session="true" logout-success-url="/jsp/admin/login" logout-url="/logout" />
<security:custom-filter ref="authenticationFilter" position="FORM_LOGIN_FILTER"/>
</security:http>
<!-- Custom filter to deny unwanted users even though registered -->
<!-- Custom filter for username and password. The real customization is done in the customAthenticationManager -->
<bean id="authenticationFilter" class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter"
p:authenticationManager-ref="customAuthenticationManager"
p:authenticationFailureHandler-ref="customAuthenticationFailureHandler"
p:authenticationSuccessHandler-ref="customAuthenticationSuccessHandler" />
<!-- Custom authentication manager. In order to authenticate, username and password must not be the same -->
<bean id="customAuthenticationManager" class="com.tut.yudi.authentication.CustomAuthenticationManager" />
<!-- We just actually need to set the default failure url here -->
<bean id="customAuthenticationFailureHandler" class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler"
p:defaultFailureUrl="/login?error=true" />
<!-- We just actually need to set the default target url here -->
<bean id="customAuthenticationSuccessHandler" class="org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler"
p:defaultTargetUrl="/jsp/admin/home" />
<!-- The AuthenticationEntryPoint is responsible for redirecting the user to a particular page, like a login page,
whenever the server sends back a response requiring authentication -->
<!-- See Spring-Security Reference 5.4.1 for more info -->
<bean id="authenticationEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint"
p:loginFormUrl="/login"/>
<!-- The tag below has no use but Spring Security needs it to autowire the parent property of
org.springframework.security.authentication.ProviderManager. Otherwise we get an error
A probable bug. This is still under investigation-->
<security:authentication-manager/>
</beans>
It is because you are running wrong file in Eclipse.
Make sure you have selected the class where your mail function is and then press the Run button(the little green on top).
The issue is resolved automatically.
It might be some bug of eclipse, b'cox when I started the eclipse another day, my project work fine. Even i didn't made any changes.

Categories