Unresolved constraint in bundle - osgi.wiring.package; (osgi.wiring.package=org.apache.camel.routepolicy.quartz) - jbossfuse

I'am new with Jboss Fuse 6.3. I need to pull some files from a FTP server at a scheduled time. I found one solution that use 'CronScheduledRoutePolicy' (http://camel.apache.org/cronscheduledroutepolicy.html). I tried to use this solution in my bundle in this way:
<bean id="startPolicy" class="org.apache.camel.routepolicy.quartz.CronScheduledRoutePolicy">
<property name="routeStartTime" value="{{epayment.authorization.timer.cron}}"/>
</bean>
<camelContext id="epayment-batch" autoStartup="{{batch.authorization.autoStartup}}" trace="false" xmlns="http://camel.apache.org/schema/blueprint">
<route id="pullFileFromFtp" routePolicyRef="startPolicy" autoStartup="false">
<from uri="ftp://{{epayment.batch.username}}#{{epayment.batch.host}}{{epayment.batch.remotePath}}?password={{epayment.batch.password}}&move={{epayment.batch.remotePath.bkp}}"/>
<to uri="file://{{epayment.batch.localPathOut}}"/>
<log message="This is the body: ${body}"/>
</route>
</camelContext>
</blueprint>
but when Jboss Fuse starts, I receive this exception:
org.osgi.framework.BundleException: Unresolved constraint in bundle epayment [303]: Unable to resolve 303.0: missing requirement [303.0] osgi.wiring.package; (&(osgi.wiring.package=org.apache.camel.routepolicy.quartz)(version>=2.18.0)(!(version>=3.0.0)))
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4002)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2045)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1299)
at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:304)
at java.lang.Thread.run(Unknown Source)
Someone can help me? I tried to deploy camel-quartz-2.18.1.jar (coping it into deploy dir) but it is not helpful.

you can add this package in the import-packages section of maven-bundle-plugin at pom.xml.
Incase, this jar is still not installed in your server, use below command:
JBossFuse:karaf#root>install camel-quartz

Related

Cannot use MongoDB driver "mongodb-driver-sync" in OSGi Project: Unable to resolve

We are developing an OSGi application running on Apache Karaf. Our application uses Apache Camel and MongoDB.
First we successfully used a quite old version of "mongo-java-driver" (3.12.11): By adding this dependency to the modules pom.xml and to the osgi feature repository we were able to start our application and connect to MongoDB:
pom.xml (maven module1)
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.12.11</version>
</dependency>
feature.xml:
<repository>mvn:org.apache.camel.karaf/apache-camel/3.18.4/xml/features</repository>
<feature name="module1" description="An OSGi module" version="1.0.1-SNAPSHOT">
<feature>scr</feature>
<feature prerequisite="true">aries-blueprint</feature>
<feature>camel-core</feature>
<feature>camel-blueprint</feature>
<feature>camel-cxf</feature>
<feature>camel-xslt-saxon</feature>
<feature>camel-jetty</feature>
<feature>camel-rabbitmq</feature>
<feature>camel-openapi-java</feature>
<feature>camel-jackson</feature>
<capability>osgi.service;objectClass=org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace=http://camel.apache.org/schema/blueprint;effective:=active;
</capability>
<bundle dependency="true">mvn:org.mongodb/mongo-java-driver/3.12.11</bundle>
<bundle>mvn:my.own.project/module1/1.0.1-SNAPSHOT</bundle>
</feature>
But that driver is legacy, quite old and missing important features, so we would like to use a modern driver, namely mongodb-driver-sync (version 4.8.2).
We replaced the previous driver with "mongodb-driver-sync":
pom.xml (maven module1)
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>4.8.2</version>
</dependency>
feature.xml:
<repository>mvn:org.apache.camel.karaf/apache-camel/3.18.4/xml/features</repository>
<feature name="module1" description="An OSGI module" version="1.0.1-SNAPSHOT">
<feature>scr</feature>
<feature prerequisite="true">aries-blueprint</feature>
<feature>camel-core</feature>
...
<!-- <bundle dependency="true">mvn:org.mongodb/mongo-java-driver/3.12.11</bundle>-->
<bundle dependency="true">mvn:org.mongodb/mongodb-driver-sync/4.8.1</bundle>
<bundle>mvn:my.own.project/module1/1.0.1-SNAPSHOT</bundle>
</feature>
This fails when starting the feature in Karaf:
Error executing command: Unable to resolve root: missing requirement [root] osgi.identity;
osgi.identity=mesh; type=karaf.feature; version="[1.0.1.SNAPSHOT,1.0.1.SNAPSHOT]";
filter:="(&(osgi.identity=mesh)(type=karaf.feature)(version>=1.0.1.SNAPSHOT)(version<=1.0.1.SNAPSHOT))"
[caused by: Unable to resolve mesh/1.0.1.SNAPSHOT: missing requirement [mesh/1.0.1.SNAPSHOT] osgi.identity; osgi.identity=mesh-vms-tso01; type=karaf.feature
[caused by: Unable to resolve mesh-vms-tso01/1.0.1.SNAPSHOT: missing requirement [mesh-vms-tso01/1.0.1.SNAPSHOT] osgi.identity; osgi.identity=mesh-vms-tso01; type=osgi.bundle; version="[1.0.1.SNAPSHOT,1.0.1.SNAPSHOT]"; resolution:=mandatory
[caused by: Unable to resolve mesh-vms-tso01/1.0.1.SNAPSHOT: missing requirement [mesh-vms-tso01/1.0.1.SNAPSHOT] osgi.wiring.package; filter:="(&(osgi.wiring.package=com.btc.mesh.core.camel)(version>=1.0.0)(!(version>=2.0.0)))"
[caused by: Unable to resolve mesh-core/1.0.1.SNAPSHOT:
missing requirement [mesh-core/1.0.1.SNAPSHOT] osgi.wiring.package; filter:="(&(osgi.wiring.package=com.mongodb)(version>=4.8.0)(!(version>=5.0.0)))"]]]]
I also tried version 4.1.0 because an older documentation mentioned that it is a valid OSGI bundle:
The mongodb-driver-sync artifact is a valid OSGi bundle whose symbolic
name is org.mongodb.driver-sync."
https://mongodb.github.io/mongo-java-driver/4.1/driver/getting-started/installation/
But we also had no luck. Does the symbolic name help in any way?
After version 4.3.x the documentation moved from mongodb.github.io to www.mongodb.com and the reference to OSGi has been removed. The MANIFEST file of all mentioned drivers looks quite similar including the bundle information. So, AFAIK , OSGi should work. Very confusing.
So, we need your help
Has anyone more information about a modern MongoDB driver which is ready for OSGI?
Or maybe we are doing something wrong when integrating the driver into our OSGI module?
Thanx

EAR application works on Websphere8.5 but refuses to work on Websphere liberty 16.0.0.4

I get in inheritance EAR application which I need to continue to develop. The problem that I can't cause it work on Websphere Liberty 16.0.0.4 while on Websphere Application Server Full Profile 8.5 it works fine. Unfortunately or (fortunately :) ) my working station is Macbook Pro, and WAS Full Profile can't be installed on OSX (can't find links right now, but have done some search and find enough evidences for it) so I need to use VirtualBox with Linux or try to run this app on Liberty.
The latest solution doesn't work so well for me, I get the following error:
[ERROR ] CWWJP0012E: The persistence unit name is not specified and
a unique persistence unit is not found in the BigEnterpriseAppEAR
application and BigEnterpriseAppEJB.jar module. [ERROR ] CWWJP0029E:
The server cannot find the persistence unit in the
BigEnterpriseAppEJB.jar module and the BigEnterpriseAppEAR
application. [ERROR ] CWNEN0035E: The java:comp/env/BigEnterpriseApp
reference of type javax.persistence.EntityManager for the DataProvider
component in the BigEnterpriseAppEJB.jar module of the
BigEnterpriseAppEAR application cannot be resolved. [ERROR ]
CNTR0020E: EJB threw an unexpected (non-declared) exception during
invocation of method "getDataByOwner" on bean
"BeanId(BigEnterpriseAppEAR#BigEnterpriseAppWEB.war#DataAPI, null)".
Exception data: javax.ejb.EJBTransactionRolledbackException: nested
exception is: javax.ejb.EJBException: The
java:comp/env/BigEnterpriseApp reference of type
javax.persistence.EntityManager for the DataProvider component in the
BigEnterpriseAppEJB.jar module of the BigEnterpriseAppEAR application
cannot be resolved.
The app is pretty simple EAR = JPA + EJB + WAR
I don't know which configuration files would be helpful, so just write in a comments what to post and I will do it.
Thank you in advance.
UPDATE 1:
server.xml file:
<server description="new server">
<!-- Enable features -->
<featureManager>
<feature>localConnector-1.0</feature>
<feature>servlet-3.1</feature>
<feature>ejbLite-3.1</feature>
<feature>jndi-1.0</feature>
<feature>jaxrs-1.1</feature>
<feature>ssl-1.0</feature>
<feature>jpa-2.0</feature>
<feature>cdi-1.0</feature>
</featureManager>
<basicRegistry id="basic" realm="BasicRealm">
<!-- <user name="yourUserName" password="" /> -->
</basicRegistry>
<!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
<httpEndpoint httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint"/>
<!-- Automatically expand WAR files and EAR files -->
<applicationManager autoExpand="true"/>
<applicationMonitor updateTrigger="mbean"/>
<library id="DB2JCC4Lib">
<fileset dir="/Users/anatoly/developer/sql_drivers" includes="*.jar"/>
</library>
<dataSource id="db2_slc" jndiName="jdbc/BEADB" type="javax.sql.DataSource">
<jdbcDriver libraryRef="DB2JCC4Lib"/>
<properties.db2.jcc databaseName="beadb" password="********" portNumber="50000" serverName="db2server" user="db2username"/>
</dataSource>
<keyStore id="defaultKeyStore" password="******"/>
<enterpriseApplication id="BigEnterpriseAppEAR" location="BigEnterpriseAppEAR.ear" name="BigEnterpriseAppEAR"/>
</server>
persistence.xml file, located in BigEnterpriseAppJPA > src > META-INF > persistence.xml
in packaged EAR persistence.xml located in BigEnterpriseAppEAR -> BigEnterpriseAppJPA.jar -> META-INF -> persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="BigEnterpriseApp">
<jta-data-source>jdbc/BEADB</jta-data-source>
<class>com.bea.entities.System</class>
<class>com.bea.entities.Data</class>
<class>com.bea.entities.User</class>
<class>com.bea.entities.Group</class>
<properties>
<property name="openjpa.jdbc.Schema" value="BEADB" />
<property name="openjpa.ConnectionRetainMode" value="transaction" />
</properties>
</persistence-unit>
</persistence>
[ERROR ] CWWJP0012E: The persistence unit name is not specified and a unique persistence unit is not found in the BigEnterpriseAppEAR application and BigEnterpriseAppEJB.jar module.
This would imply your persistence.xml roots are not at the legal locations defined by the JPA spec, section 8.2:
In Java EE environments, the root of a persistence unit must be one of the following:
an EJB-JAR file
the WEB-INF/classes directory of a WAR file[87]
a jar file in the WEB-INF/lib directory of a WAR file
a jar file in the EAR library directory
an application client jar file
NOTE: Java Persistence 1.0 supported use of a jar file in the root of the EAR as the root of a
persistence unit. This use is no longer supported. Portable applications should use the EAR
library directory for this case instead
Your setup seems to be trying to use #4?
BigEnterpriseAppEAR -> BigEnterpriseAppJPA.jar -> META-INF -> persistence.xml
BigEnterpriseAppJPA.jar should be placed inside your EAR library directory. I believe this will be BigEnterpriseAppEAR/lib by default, but you can configure this with your /META-INF/application.xml in the EAR
Also note, that the persistence-unit name must be unique. Make sure that all persistence-unit names are not using the same name.

Failed to import bean definitions from URL location [classpath:META-INF/cxf/cxf.xml

Hi I am getting error when try to run camel project in fuse container
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem:
Failed to import bean definitions from URL location [classpath:quote-endpoints.xml] Offending resource: URL [bundle://251.0:0/META-INF/spring/applicationContext.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem:
Failed to import bean definitions from URL location [classpath:META-INF/cxf/cxf.xml]
Offending resource: OSGi resource[classpath:quote-endpoints.xml|bnd.id=251|bnd.sym=null]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from OSGi resource[classpath:META-INF/cxf/cxf.xml|bnd.id=251|bnd.sym=null]; nested exception is java.io.FileNotFoundException: OSGi resource[classpath:META-INF/cxf/cxf.xml|bnd.id=251|bnd.sym=null] cannot be resolved to URL because it does not exist
Any help appreciated
Thanks
Check your xml files and remove those CXF imports. They are no longer required for many years. eg look for anything with META-INF/cxf/cxf.xm and similar and remove those.
Yes - there are two xml files -
applicationContext.xml which imports quote-endpoints.xml
<import resource="classpath:quote-endpoints.xml" />
AND
quote-endpoints.xml impor resource="classpath:META-INF/cxf/cxf.xml" /> please see below
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
http://camel.apache.org/schema/cxf
http://camel.apache.org/schema/cxf/camel-cxf.xsd
http://cxf.apache.org/transports/http/configuration
http://cxf.apache.org/schemas/configuration/http-conf.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
Check the version of cxf in the POM.xml file. Most probably, you may be having unsupported cxf version for the project.

Lookup failed for 'java:comp/BeanManager' when deploying to Glassfish 4

I already made some research on Google and SO but could not find a solution.
I am writing a java ee 7 Web application including Omnifaces and Primefaces using Eclipse. When deploying the application to Glassfish 4, I get the following error:
javax.naming.NamingException: Lookup failed for 'java:comp/BeanManager'
The longer part of the stacktrace is
java.lang.IllegalStateException: javax.naming.NamingException: Lookup failed for 'java:comp/BeanManager' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Error retrieving java:comp/BeanManager [Root exception is java.lang.IllegalStateException: Cannot resolve bean manager]]
at org.omnifaces.util.JNDI.lookup(JNDI.java:87)
at org.omnifaces.config.BeanManager.init(BeanManager.java:76)
at org.omnifaces.config.BeanManager.getReference(BeanManager.java:115)
at org.omnifaces.application.OmniApplication.createConverter(OmniApplication.java:86)
at javax.faces.application.ApplicationWrapper.createConverter(ApplicationWrapper.java:403)
at org.primefaces.config.ConfigContainer.initConfig(ConfigContainer.java:69)
But I highly doubt that the problem is related to Omnifaces, it's more to state that I didn't do any messy call to cause this.
There is a beans.xml in WEB-INF, it's not completely empty.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="all">
<interceptors>
<class>x.y.z.security.SecurityInterceptor</class>
</interceptors>
</beans>
For the discovery-mode=all, I know it is not recommended, but this is due to an issue I found here: https://java.net/jira/browse/GLASSFISH-20667
If you need more information, facets config or the like, I am happy to post it - but as I've run out of ideas where to locate the problem I don't want to post the everything like complete POM, Glassfish, Eclipse, Maven config or all the code.
edit 2014-01-27:
Ok, after I had written my below comment (the one in comments), I got an idea. Can someone maybe check it out/confirm easily? I was able to load the application to GF after recreating a new database. Can eclipselink cause the above? I am using MS SQL Server 2012, and of course I get SQLExceptions and warnings that tables+fks already exist when redploying, but warnings should not fail my application deployment, should they?
<persistence-unit name="xyzPersistenceUnit" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/xyzDS</jta-data-source>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>

maven tomcat7 deploy

POM.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://localhost:8080/manager/html</url>
<server>myserver</server>
<path>/test</path>
<warFile>${project.build.directory}/${project.build.finalName}.war</warFile>
</configuration>
</plugin>
Eclipse used: Eclipse indigo 3.7 with m2e plugin
modified
Tomcat7/conf/tomcat-users.xml
<role rolename="admin"/>
<role rolename="manager"/>
<user username="admin" password="admin" roles="admin,manager"/>
</tomcat-users>
Context.xml
Tomcat7/conf/context.xml, change <context> to
<Context antiJARLocking="true" antiResourceLocking="true">
under apache-maven\conf\settings.xml
add following entry under server tag:
<servers>
<server>
<id>myserver</id>
<username>admin</username>
<password>admin</password>
</server>
Start tomcat server.
target run: tomcat:deploy and tomcat:undeploy
getting following error:
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:redeploy (default-cli) on project test: Cannot invoke Tomcat manager: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/html/deploy?path=%2Ftest&war=&update=true -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
project name: test
war file name: test-1.0-SNAPSHOT.war
similar issue found but didnot get much use: Tomcat-maven-plugin 401 error
tomcat-maven-plugin 403 error
Though a late answer , someone might find this useful.
If you are using maven3 and tomcat7.The below method worked for me.I was not aware of the change in application manager endpoint in tomcat7.
Environment - Apache Maven 3.0.4,apache-tomcat-7.0.34,Windows 7
Tomcat7 has changed its deployment end point from http://tomcatserver:8080/manager/html to http://tomcatserver:8080/manager/text .
So my pom.xml will be
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://tomcatserver:8080/manager/text</url>
<server>tomcat</server>
<path>/myWebApp</path>
</configuration>
</plugin>
In tomcat-users.xml
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<user username="root" password="root" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/>
In maven settings.xml
<server>
<id>tomcat</id>
<username>root</username>
<password>root</password>
</server>
In context.xml , though this is optional and is not related to maven3 deployment to tomcat7 ,sometimes jar locking might happen,so to be on the safer side.
<Context antiJARLocking="true" antiResourceLocking="true">
Now issue
mvn tomcat:deploy
Remember to start tomcat before maven deployment.
If deployment is success , your application will be available at
http://tomcatserver:8080/myWebApp
Add manager-gui to the roles:
<user username="admin" password="admin" roles="admin,manager,manager-gui" />
And restart Tomcat.
Make sure that your XML configuration files are in use. A simple way to do this is writing an unclosed tag inside them and checking the error messages. If you don't get any error message you've written in an unused XML.
in tomcat 7 you should set
<user username="admin" password="admin" roles="manager-script,manager-gui" />
to deploy using maven plugin
For tomcat 7 you're using the wrong goals. Try tomcat7:deploy and tomcat7:undeploy instead.
Found Quick Solution on Mentioned Website...
http://www.avajava.com/tutorials/lessons/how-do-i-deploy-a-maven-web-application-to-tomcat.html
Working as expected in Eclipse and Sprint Test Suite
Note :- I have used clean tomcat:deploy, worked perfectly for me.