Modify workflowModel.xml in Alfresco - workflow

I want to change some data in workflowModel.xml (set the default value of requiredApprovePercent to 100).
Of course I'm not supposed to change the file in tomcat, I need to override it in my eclipse project.
Do I need to register the model in a context file, and in which directory am I supposed to put the file in my eclipse project?
I would appreciate any help

if you're going to create a custom workflow model you need Alfresco to pick it up when starting. So yesm you need to deploy it with:
<bean id="myworkflows.workflowBootstrap" parent="workflowDeployer">
<property name="models">
<list>
<-- Task Model associated with above process definition -->
<value>alfresco/workflow/customModel.xml</value>
</list>
</property>
<property name="workflowDefinitions">
<props>
<prop key="engineId">activiti</prop>
<prop key="location">alfresco/extension/customModel.bpmn2.0.xml</prop>
<prop key="mimetype">text/xml</prop>
<prop key="redeploy">false</prop>
</props>
</property>
</bean>
Or something similar in the context file (tomcat/shared/classes/alfresco/extension is the path where you want your custom files to be.
This is also a great link to start working with workflows in Alfresco.
Hope it helps a little bit.

Related

ClassCastException with spring-data-jpa

I'm working with Spring Web Services and Spring JPA Data.
I have three projects:
doc-ws. Web application that it's the endpoint of my documental web services.
sign-ws. Web application that it's the endpoint of my sign web services.
data-ws. Jar module with all the jpa entities (#Entity), spring jpa repositories (#Repository) and spring services classes (#Services).
Doc-ws and sign-ws has a dependence with data-ws, so a data-ws.jar is included in doc-ws.war and sign-ws.war.
When I deploy doc-ws web application alone, all the web services tests works fine.
When I deploy sign-ws web application alone, all the web services tests works fine.
But when I deploy both web applications together in the same Jboss EAP 7.1, I'm getting ClassCastExceptions when I exectute the web services tests.
java.lang.ClassCastException: com.ieci.mugeju.data.entity.IdocConfiguration cannot be cast to com.ieci.mugeju.data.entity.IdocConfiguration
List<IdocConfiguration> properties = idocConfigurationRepository.findAll(); <-- works fine
for (IdocConfiguration property: properties) <-- Here throws the ClassCastException
{
.... // CODE
}
Exception message reference the same jpa entity (com.ieci.mugeju.data.entity.IdocConfiguration), so I don't understand why this exception is being throwed.
It must be a classloading issue between both web applications, but I'm not sure.
I'm working with JBoss EAP 7.1, spring-data-jpa 2.0.5, eclipseling 2.6.4, spring-ws-core 3.0.1.
Any idea why I'm getting this exception? How could I solve?
Thanks
I discovered what the problem was. When I defined the 'entityManagerFactory', I was not setting the property called 'persistenceUnitName'. Then when the persistence context was created, it was created with the name 'default' in both web projects.
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter" ref="jpaAdapter" />
<property name="jpaDialect" ref="jpaDialect"/>
<property name="packagesToScan" value="com.ieci.mugeju.data.entity" />
...
</bean>
I don't know why but 'find repository methods' of second project return jpa entity classes defined in first project classloader. Very strange behaviour, I expected every web application using its own classloader, and isolated one from each other.
If I set a persistenceUnitName for every project, then everything works fine, and every web application uses its own classloader.
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter" ref="jpaAdapter" />
<property name="jpaDialect" ref="jpaDialect"/>
<property name="packagesToScan" value="com.ieci.mugeju.data.entity" />
<property name="persistenceUnitName" value="${spring.application.name}" />
...
</bean>

How to reach other project's resources from spring applicationContext?

I have a project named fc-jsf. This project's spring context refers to an other spring context named Beans.xml in the fc-bus project. I have fc-bus as project dependency for fc-jsf.
I import the Beans.xml like this:
<import resource="classpath*:com/fc/spring/Beans.xml" />
Its working, but it says that the fc-jsf project can't see the properties declared in Beans.xml:
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>com/fc/properties/database.properties</value>
</property>
</bean>
The exception is:
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/com/fc/properties/database.properties]
How to reach the database.properties without copying the properties file to the fc-jsf project?
edit: theese are maven projects, database.properties is in fc-bus -> src/main/resurces/com/fc folder.
Try using the properties like
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:com/fc/properties/database.properties</value>
</property>
</bean>
otherwise it doesn't know which package it should use it from
Try with <value>classpath*:database.properties</value>

which jar be responsible for parsing hibernate.cfg.xml?

I met a configuration problem like below:
when I am executing example by hibernate tool
After I have write
<session-factory>
<property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="hibernate.connection.url">jdbc:hsqldb:hsql://127.0.0.1</property>
<property name="hibernate.connection.username">sa</property>
<property name="connection.password"></property>
<property name="connection.pool_size">1</property>
<property name="hibernate.dialect"> org.hibernate.dialect.HSQLDialect</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">create</property>
<mapping?resource="com/vaannila/course/Course.hbm.xml"/>
<session-factory>
and open HSQLDB connection(using java -cp ./lib/hsqldb.jar org.hsqldb.Server and java -cp ./lib/hsqldb.jar org.hsqldb.util.DatabaseManager), when I use Hibernate Code Generation in Eclipse, why it pop up the error message:
In former step for the jar, instead of using package slf4j* ,I have used log4j, and I remember I have not include the changed jar to my classpath as vannilla required, do it have affects for the error? thanks first :)
hibernate3.jar is responsible for parsing hibernate.cfg.xml.
<property? //wrong
<property> //correct
Those question marks in <property?name.. are wrong - they should not be there. Remove them and try again.
If the ? characters aren't visible in your editor, they are probably some other unicode space character which the XML parser doesn't recognise. You'll have to select each one and re-type a space character. ( maybe?). Did you copy an example configuration from a web page?

PropertyPlaceholderConfigurer works from Maven command line, but not from Eclipse?

I have Eclipse configured to use an external maven instance. Nonetheless I have an integration test that runs fine from the command line, but fails from within Eclipse. The error is a class Spring application context bean error:
Cannot convert value of type [java.lang.String] to required type
The culprit it a bean that sets property values using a PropertyPlaceholderConfigurer.
<!-- property settings for non-JNDI database connections -->
<bean id="placeholderConfigUuid" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="location" value="classpath:database.properties" />
<property name="placeholderPrefix" value="$DS{" />
</bean>
I know which bean is failing because it appears in the stack trace and because when I replace the $DS{hibernate.dialect} with a static value it works.
EDIT: Here is where the property values are used:
<bean id="myTestLocalEmf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="myapp-core" />
.......ommitted for brevity.......
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true" />
<!-- The following use the PropertyPlaceholderConfigurer but it doesn't work in Eclipse -->
<property name="database" value="$DS{hibernate.database}" />
<property name="databasePlatform" value="$DS{hibernate.dialect}" />
</bean>
</property>
</bean>
I have two questions:
1) Since M2Eclipse is using the same Maven setup as the command line, why does one work and the other fail?
2) How to fix this? I really like the ability to run a single jUnit test from within Eclipse on demand.
Does filtering work for a "regular" unit test under Eclipse?
Is m2eclipse configured to process resources and tests resources on resource changes:
alt text http://www.imagebanana.com/img/rwd919ek/screenshot_008.png
Is there anything particular to mention about your integration tests (from a Maven point of view)?
You are using M2Eclipse (up-to-date release?) you are using Maven 3 inside Eclipse, but i assume you are using Maven 2 (2.2.1?) on command line...On the other side you are saying that your "Integration test" is running on command line (build an environment etc.) but you would like to run "Unit Test" from within Eclipse...A Unit Test is different from an integration test...and i'm not astonished that you integration test does not work from Eclipse...May be we can say more if we see the POM's which are used and the code?

JBoss Microcontainer + AOP in a standalone app

I'm trying to create a standalone app using JBoss Microcontainer for IoC and JBoss AOP for, well, AOP.
I've boot-strapped, deployed a descriptor with AOP XML, so far so good.
But the aspect is not performed. Do I need to enable AOP plugin or something?
Note that I don't want to add a build step - I want it to work like Spring AOP.
Please check the code below.
Thanks for help.
<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:bean-deployer:2.0 bean-deployer_2_0.xsd"
xmlns="urn:jboss:bean-deployer:2.0"
xmlns:aop="urn:jboss:aop-beans:1.0">
<bean name="myGarage" class="jbmctest.Garage">
<property name="car">
<bean name="myCar" class="jbmctest.Car">
<property name="name">Red Devil</property>
</bean>
</property>
</bean>
<aop:interceptor name="FuelInterceptor" class="jbmctest.FuelInterceptor"/>
<aop:bind pointcut="execution(* *->*(..)">
<aop:interceptor-ref name="FuelInterceptor"/>
</aop:bind>
</deployment>
You're missing the pieces that are in aop.xml in JBossAS5 -> conf/bootstrap/aop.xml.
I've eventually solved this, and wrote an article for those who will try the same.
http://ondra.zizka.cz/stranky/programovani/java/jboss-aop-howto-example-standalone-app.texy