how to import osgi blueprint xml - blueprint-osgi

I am trying to import an OSGI blueprint XML file in to another OSGi blueprint XML file.
e.g.:
blueprint1.xml:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint ....>
<bean id="myBean1" class="com.company.Class1"/>
<bean id="myBean2" class="com.company.Class2"/>
</blueprint>
</xml>
blueprint2.xml:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint ....>
<!-- DOES NOT WORK -->
<import resource="blueprint1.xml" />
</blueprint>
The <import> works for spring but not for blueprint.
Does anybody know a way of doing this in OSGi blueprint XML files?

Apparently, Spring like imports are not currently possible in blueprint.
However, if the files are in the same OSGi bundle then they are in the same context and can be used from other blueprint files.
Also, see here: http://fusesource.com/forums/message.jspa?messageID=15091#15091

If you're using Gemini Blueprint (formerly Spring DM) you can simply tell it to load both files, and basically treat them as if they were one big file:
In the absence of the Spring-Context header the extender expects every
".xml" file in the META-INF/spring folder to be a valid Spring
configuration file [...].
It also treats any xml files in /OSGI-INF in the same way.

Related

Is it possible to use messaging, and kafka-messaging separately from helidon?

I created library using helidon-messaging, helidon-messaging-kafka. Also I created an example Java SE app using that library and all works fine. But when I try to use that library in Java EE (Weblogic) legacy application I have got an exception while that application starts:
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Config with qualifiers #Default
at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] #Inject io.helidon.messaging.connectors.kafka.KafkaConnector(Config)
at io.helidon.messaging.connectors.kafka.KafkaConnector.<init>(KafkaConnector.java:0)
Is it possible some how to switch off CDI stuff there?
Did you try to exclude the connector package from bean scanning?
Something like this should help:
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
version="2.0"
bean-discovery-mode="annotated">
<scan>
<exclude name="io.helidon.messaging.connectors.kafka.**" />
</scan>
</beans>
More info can be found here

Wicket 8 web.xml myproject example

Never having use Wicket before I installed Apache Wicket 8.0.0-M8 on Windows 10. I also installed apache-tomcat-9.0.7.
I replaced the following Tomcat conf folder files with those provided by wicket:
context.xml, server.xml
I used Eclipse Neon's Maven option to create a project called myproject. Eclipse generated the following web.xml file which I relocated to:
<TOMCAT_HOME>\webapps\myproject\WEB-INF
That web.xml file looks like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/web-app_4_0.xsd" version="4.0">
<display-name>myproject</display-name>
<!--
There are three means to configure Wickets configuration mode and they
are tested in the order given.
1) A system property: -Dwicket.configuration
2) servlet specific <init-param>
3) context specific <context-param>
The value might be either "development" (reloading when templates change) or
"deployment". If no configuration is found, "development" is the default. -->
<filter>
<filter-name>wicket.myproject</filter-name>
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
<init-param>
<param-name>applicationClassName</param-name>
<param-value>com.quantech.myproject.WicketApplication</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>wicket.myproject</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
Eclipse found the following problems with this file:
Referenced file contains errors (http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/web-app_3_1.xsd). web.xml /myproject/src/main/webapp/WEB-INF line 1 XML Problem
TargetNamespace.1: Expecting namespace 'http://java.sun.com/xml/ns/javaee', but the target namespace of the schema document is 'http://xmlns.jcp.org/xml/ns/javaee'.
When I load web.xml into XMLSpy I get the message:
This file is not valid. Root element 'web-app' is not defined in DTD/Schema.
Anyone have a clue what is wrong here?
thanks,
Terry
I replaced the following Tomcat conf folder files with those provided by wicket:
context.xml, server.xml
Wicket doesn't provide such files!
Eclipse generated the following web.xml file
Eclipse found the following problems with this file:
Bad Eclipse!
Just ignore these errors/warnings. Tomcat won't complain.
To make Eclipse happy you will have tweak its configuration. I can't help you with that though. I use different IDE.

In IntelliJ 2016.2 Ultimate edition, how to add JPA facet when we don't use a persistence.xml?

My Project doesnot have a persistence.xml.
I use annotations in my spring-boot based application.
How can I add the JPA facet ?
When I try to add a jpa facet, it enforces me to select persistence.xml, and if it is not present, it is trying to create one, which I don't want.
Can anyone help me with this?
For now I got this working with a near-empty persistence.xml in the META-INF folder of my project.
After this it works fine, but I would love this to work without this persistence.xml as well.
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" version="2.1">
<persistence-unit name="myPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<properties>
<!– Scan for annotated classes and Hibernate mapping XML files –>
<property name="hibernate.archive.autodetection" value="class" />
</properties>
</persistence-unit>
</persistence>
If anybody knows any other solution please comment.
else if this works for you, you can rate this answer up :-)

How to externalize properties of persistence.xml for JBOSS 7.1.1?

My persistence.xml is currently present in the application war(in META-INF folder.). However, for the application to be run across multiple DBs the persistence needs to be changed again and again. I want to avoid it. But, I am not able to understand how will i configure the properties(like dialect) in the persistence.xml from, say, a property file which i would change based on my DB, hence not compelling me to update and redeploy my war.
My problem can also be resolved if i can configure the dialect in the datasource in standalone.xml where i have mentioned other DB details. I am not being able to make out what the property would be.
Though i would prefer a solution for the first one.
PS: I am rookie in Web App development. Questions might annoy you. :D
I use a method that works well for hibernate.
1) put the hibernate configuration properties in a xml file (call it hibernate.cfg.xml but it's not mandatory)
this is an example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.hbm2ddl.auto">create-drop</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.search.default.directory_provider">ram</property>
</session-factory>
</hibernate-configuration>
you can put there only hibernate properties that do not start with hibernate.ejb
2) Create a jboss module. It's very simple. Suppose you want to call the module com.myorganization.config than create a directory structure in the modules folder of you server installation: /com/myorganization/config/main. In the main folder put the hibernate.cfg.xml file and the following module.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.myorganization.config">
<resources>
<resource-root path="."/>
</resources>
</module>
3) In your persistence.xml adding the following property:
<property name="hibernate.ejb.cfgfile" value="/hibernate.cfg.xml" />
4) Finally, in the META-INF/MANIFEST.MF file add the following line:
Dependencies: com.myorganization.config
If you like maven use the maven-war-plugin in order to change the MANIFEST.MF:
<configuration>
<archive>
<manifestEntries>
<Dependencies>com.myorganization.config</Dependencies>
</manifestEntries>
</archive>
</configuration>
That's all.

Octopus Deploy cannot find namespace in transform file

Have been trying to apply a transformation to one of my config files in Visual Studio 2010
The target file starts like this:
forms.config
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:x="http://www.sitecore.net/xmlconfig/">
<sitecore>
<formsDataProvider type="Sitecore.Forms.Data.DataProviders.WFMDataProvider,Sitecore.Forms.Core">
<param desc="connection string">connection string goes here</param>
</formsDataProvider>
...
The transformation file is as follows:
forms.Staging.config
<?xml version="1.0" encoding="utf-8" ?>
<!-- For more information on using transformations
see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:x="http://www.sitecore.net/xmlconfig/" xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<sitecore>
<formsDataProvider type="Sitecore.Forms.Data.DataProviders.WFMDataProvider,Sitecore.Forms.Core">
<param desc="connection string" xdt:Transform="Replace" xdt:Locator="Match(desc)">connection string for staging goes here</param>
</formsDataProvider>
</sitecore>
</configuration>
When the staging build runs on Octopus this is what's in the log:
DEBUG [XML Transformation] The expected namespace http://schemas.microsoft.com/XML-Document-Transform was not found in the transform file.
Have tried to remove the other xmlns attributes to no avail.
Said namespace is clearly on the transform file as an attribute in the configuration node. We have numerous other such files and transformations are applied fine. The Build Action for all transform files is set to Content.
Not sure if we can make Octopus log such messages as errors instead of Debug though.
Has anyone else had a similar problem?
Thanks in advance.
It looks like it might be trying to apply your forms.config as a transformation file instead of a target.
What do you have specified in the deployment step's Additional Transforms? Did you accidentally include forms.config itself?