External properties Sign and Encrypt SOAP Messages with Apache CXF - apache

I am trying to externalize my sign and encrypt properties file.
But if I use the absolut path the context cannot get it.
¿Do you have and idea of how can I do?
¿How can I include an absolut path in my jboss classpath?
I am using jboss 5.1
I have this:
<entry key="user" value="${user.ws.security.firma}"/>
<entry key="signatureKeyIdentifier" value="DirectReference"/>
<entry key="signatureParts" value="{Element}{http://schemas.xmlsoap.org/soap/envelope/}Body"/>
<entry key="signaturePropFile" value="sign.properties"/>
<entry key="passwordCallbackClass" value="es.minhap.carpeta.front.ws.micc.security.ClientPasswordCallback"/>
I want something like this
<entry key="user" value="${user.ws.security.sign}"/>
<entry key="signatureKeyIdentifier" value="DirectReference"/>
<entry key="signatureParts" value="{Element}{http://schemas.xmlsoap.org/soap/envelope/}Body"/>
<entry key="signaturePropFile" value="C:/workspace/sign.properties"/>
<entry key="passwordCallbackClass" value="es.micc.security.ClientPasswordCallback"/>

Currently can't use absolute paths in CXF settings for encryption and signed, the files are loaded from the classpath by WSS4J:
Alternatively you can put your properties files in conf directory of JBoss. This directory is part of the classpath or add a custom directory to classpath in conf/jboss-service.xml as follows:
<classpath codebase="${jboss.server.lib.url}" archives="*"/>
<classpath codebase="${jboss.common.lib.url}" archives="*"/>
<classpath codebase="file:/C:/mycustomconfigdir/" archives="*"/>

Related

Intellij Build > Recomplie on html files Grayed out

OS: Windows 10
Intellij: 2016.3.2
Java: 1.7
I have a basic Springboot project using Thymeleaf as the templating engine. When I make a change to a Java file I can use menu option Build > Recompile (Ctrl + Shift + F9) to recompile.
This option is not available for *.html files. (Note: this used to work).
I am using an embedded tomcat as part of Spring.
Any idea as to why this option is now grayed out?
Assuming it must be a setting thing but I simply couldn't find anything on the web but I did read something about "Update classes and resources" options are only available when the deployment option is an "exploded" war.
Recompiling thymeleaf files is possible by Ctrl + Shift + F9. What worked for me was to rebuild the project from scratch hence indicating some sort of project setting causing this issue.
Looking at .idea/compiler.xml I can see the old file contained:
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
which may be the have caused this issue in conjunction with something else.

OrientDB Update runs into JVM memory issue 'Cannot allocate memory'

I just updated my OrientDB to the latest Version. So I just took the complete folder to test it without my custom settings. Then I tried to start the new version with:
sh server.sh
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000e04a0000, 357957632, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 357957632 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /home/ubuntu/orientdb/bin/hs_err_pid1885.log
But as you can see there is trouble with the JVM. Something with memory. But I did not change any setting. So how can this come?
I also cannot rember to set some custom Java settings on my system. Is there a way to check it?
What I changed
<properties>
<!-- DATABASE POOL: size min/max -->
<entry name="db.pool.min" value="1"/>
<entry name="db.pool.max" value="50"/>
<!-- PROFILER: configures the profiler as <seconds-for-snapshot>,<archive-snapshot-size>,<summary-size> -->
<entry name="profiler.enabled" value="true"/>
<!-- <entry name="profiler.config" value="30,10,10" /> -->
<!-- LOG: enable/Disable logging. Levels are: finer, fine, finest, info,
warning -->
<entry name="log.console.level" value="info"/>
<entry name="log.file.level" value="fine"/>
<!-- Memory -->
<entry name="memory.chunk.size" value="‭20971520‬"/>
</properties>
You should change one line in sever.sh from ORIENTDB_OPTS_MEMORY="-Xms512m -Xmx512m" to ORIENTDB_OPTS_MEMORY="-Xms128m -Xmx256m"

Migration from glassfish to apache

I created a project using Netbeans and selected Glassfish 3.1 as a server, it also uses Derby database. Now I want to migrate to Apache Tomcat 7, I just did the following:
Stopped Glassfish
Changed the Netbeans project's properties to use Apache 7 instead of Glassfish
Added Apache to Netbeans and started it
When I try to build the project, several error messages appear like:
error: cannot find symbol
import javax.persistence.Basic;
although I ensured that /bin path of Java is set correctly in Apache server properties in Netbeans and that src.zip path is also set.
I think there are some steps that must be followed to have a successful migration, can any one guide me?
Thanks
Apache Tomcat does not come with the JPA specification. It is a Servlet container only.
You must add JPA specification plus Hibernate (implementation) to your project and make sure it will be deployed on your WEB-INF/lib.
Then, make sure your Persistence Unit is of transaction-type="RESOURCE_LOCAL", and configure all necessary properties to create a connection.
Example:
<persistence-unit name="bookmark-ds" transaction-type="RESOURCE_LOCAL">
<class>com.sample.domain.YourEntity</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver" />
<property name="javax.persistence.jdbc.user" value="sa" />
<property name="javax.persistence.jdbc.password" value="" />
<property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:mem:." />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="false" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
</properties>
</persistence-unit>
Obs: this is an HSQLDB example. Adjust for Derby. ;-)
UPDATE: there's a great tutorial for Tomcat+JPA+EclipseLink here.

Creating DDL scripts from JPA/Hibernate Annotation Classes Using ANT

I would like to generate SQL DDL scripts from Hibernate/JPA Annotation Classes using ANT.
Below is the ANT script that I wrote based on Hibernate Dev Docs URL: http://docs.jboss.org/hibernate/orm/4.1/devguide/en-US/html_single/
<project name="yourmarketnet" default="all" basedir=".">
<target name="ddl_generation">
<!-- paths to required jars -->
<path location="web/WEB-INF/lib/hibernate-annotations.jar" />
<path location="web/WEB-INF/lib/ejb3-persistence.jar" />
<path location="web/WEB-INF/lib/hibernate-entitymanager.jar" />
<path location="web/WEB-INF/lib/javaassist.jar" />
<path location="web/WEB-INF/lib/hibernate-tools.jar"/>
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask.jar">
<classpath path="${build.dir}/web/WEB-INF/lib/hibernate-tools.jar"/>
</taskdef>
<!-- output destination -->
<hibernatetool destdir="${build.dir}">
<!-- were the annotation beans files are located-->
<classpath>
<path location="${build.dir}/web/WEB-INF/classes/com/yourmarketnet/beans" />
</classpath>
<!-- list exporters here -->
<hbm2ddl
export="false"
update="false"
drop="true"
create="true"
outputfilename="myApps.ddl"
delimiter=";"
format="false"
haltonerror="true"/>
</hibernatetool>
</target>
</project>
Im getting ERROR taskdef class org.hibernate.tool.ant.HibernateToolTask cannot be found
using the classloader AntClassLoader[]
I also checked to see if hibernate-tools.jar was actually in the path and it was (C:\Users\naim\Documents\NetBeansProjects\yourmarketnet\build\web\WEB-INF\lib\hibernate-tools.jar)
Can someone please tell me step by step how to fix/debug this issue , thanks.
Error message clearly tells you that ant can't find your tools. When you declare
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" >
<classpath path="${build.dir}/web/WEB-INF/lib"/>
</taskdef>
it's already wrong because tool classes are not in directory but in jar. Secondly, your intent seems to be to use ${build.dir} as output location, so why would it contain tool classes? Anyway, you didn't even define this directory.
So if you really have your hibernate-tools.jar in web/WEB-INF/lib, you probably want something like
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" >
<classpath path="web/WEB-INF/lib/hibernate-tools.jar"/>
</taskdef>
Note that it's relative to your project directory.

Adding folder to classpath in Velocity using Spring framework

How can I add an entire folder to Velocity and use the files inside as resource bundles?
Currently in my velocity.xml I have this code:
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="parentMessageSource">
<ref bean="globMessageSource"/>
</property>
<property name="basenames">
<list>
<value>classpath:/WEB-INF/i18n</value>
<value>/WEB-INF/templates/velocity/my_vm_template</value>
</list>
</bean>
I need to add i18n folder to the classpath so that its containing files can be seen by the VelocityTools version 1.4 in the toolbox.xml:
<tool>
<key>test</key>
<scope>request</scope>
<class>org.apache.velocity.tools.generic.ResourceTool</class>
<parameter name="bundles" value="i18n.ss_messages"/>
<parameter name="locale" value="en_US"/>
</tool>
The code is giving me an error message: "java.util.MissingResourceException: Can't find bundle for base name i18n.ss_messages, locale en_US"
This question relates to VelocityTools error - "java.util.MissingResourceException: Can't find bundle for base name WEB-INF.conf.resources.ss_messages, locale en_US"
Sorry if it's a silly question, but I can't find anywhere describing how to add an entire folder to the classpath and be available as a bundle so it can support Velocity template localization.
IMPORTANT NOTE!! If I place my ss_messages_bg_BG.properties and ss_messages_en_US.properties files in /WEB-INF/classes/i18n then it works, but I want to place them in a different folder ideally in /WEB-INF/templates/i18n. How do I do that?
Do you use maven? You could tell maven to use that directory as a resource:
<resource>
<!-- Velocity requires to be in classpath -->
<directory>src/main/webapp/WEB-INF/i8n</directory>
<filtering>true</filtering>
</resource>