Amdatu rest example doesn't work? - jax-rs

I have created a bnd-workspace with amdatu-bootstrap jar file. Then created a testing rest project and a bnd run descriptor file to test it. When I run the the run descriptor file and navigated to http://localhost:8080/test, I faced 404 page :(.
HTTP ERROR: 404
Problem accessing /test. Reason:
Not Found
Here are the in-detail steps I took to do so:
Downloaded and used bootstrap-bin-r9.zip
In Amdatu Bootstrap UI, to initialize the workspace I issued "workspace-init" with "amdatu" template
Then I created a project "osgi.test" with "project-create" command
Then I created a test component "tmp.Test" with "/test" as url using "rest-createcomponent" command
Then I added rest required dependencies using "rest-install" command
Then I created launcher.bndrun with org.apache.felix.framework;version='[5.2.0,5.2.0]' and Java-1.8 as OSGI framework.
Then I added rest required libraries to launcher.bndrun with "rest-run" command
Then I added gogo and dm shell with "shell-run" command
Test component:
package tmp;
import java.util.List;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import java.util.Arrays;
import org.apache.felix.dm.annotation.api.Component;
#Component(provides = Object.class)
#Path("/test")
public class Test {
#GET
#Produces(MediaType.APPLICATION_JSON)
public List<String> list() {
return Arrays.asList("test");
}
}
Here is list of bundles:
lb
START LEVEL 1
ID|State |Level|Name
0|Active | 0|System Bundle (5.2.0)
1|Active | 1|Apache Felix Http Jetty (3.2.0)
2|Active | 1|Apache Felix Http API (3.0.0)
3|Active | 1|Apache Felix Servlet API (1.1.2)
4|Active | 1|Apache Felix Http Whiteboard (3.0.0)
5|Active | 1|org.amdatu.web.rest.jaxrs (1.1.1)
6|Active | 1|org.amdatu.web.rest.wink (3.0.1)
7|Active | 1|org.amdatu.web.rest.doc (1.2.3)
8|Active | 1|Jackson-annotations (2.6.3)
9|Active | 1|Jackson-core (2.6.3)
10|Active | 1|jackson-databind (2.6.3)
11|Active | 1|Jackson-JAXRS-base (2.6.3)
12|Active | 1|Jackson-JAXRS-JSON (2.6.3)
13|Active | 1|Apache Felix Dependency Manager (4.3.0)
14|Active | 1|Apache Felix Dependency Manager Runtime (4.0.3)
15|Active | 1|Apache Felix Metatype Service (1.0.12)
16|Active | 1|Apache Felix EventAdmin (1.3.2)
17|Active | 1|Apache Felix Configuration Admin Service (1.8.6)
18|Active | 1|OPS4J Pax Logging - API (1.7.0)
19|Active | 1|OPS4J Pax Logging - Service (1.7.0)
20|Active | 1|osgi.test (0.0.0)
21|Active | 1|Apache Felix Gogo Command (0.12.0)
22|Active | 1|Apache Felix Gogo Runtime (0.10.0)
23|Active | 1|Apache Felix Gogo Shell (0.10.0)
24|Active | 1|Apache Felix Dependency Manager Shell (4.0.4)
And here is the result of "dm" command
dm
[6] org.amdatu.web.rest.wink
[0] org.amdatu.web.rest.jaxrs.JaxRsSpi registered
[1] org.slf4j.impl.StaticLoggerBinder(OSGi) registered
org.osgi.service.log.LogService service optional available
[2] org.amdatu.web.rest.whiteboard.JaxRsWhiteboard registered
active{bundle.id=6} bundle required available
org.osgi.service.log.LogService service optional available
javax.ws.rs.core.Application (osgi.jaxrs.application.base=*) service optional unavailable
java.lang.Object (osgi.jaxrs.resource.base=*) service optional unavailable
[3] Adapter for interface org.amdatu.web.rest.jaxrs.ApplicationService registered
org.amdatu.web.rest.jaxrs.ApplicationService service optional unavailable
[14] org.apache.felix.dependencymanager.runtime
[4] org.apache.felix.dm.runtime.DependencyManagerRuntime registered
active (DependencyManager-Component=*) bundle optional unavailable
org.osgi.service.packageadmin.PackageAdmin service required available
org.osgi.service.log.LogService service optional available
When I navigate to http://localhost:8080/test following errors is shown
HTTP ERROR: 404
Problem accessing /test. Reason:
Not Found
Any helps appreciated.

changing the version of org.amdatu.web.rest.wink to 2.0.3 will solve the problem.
I don't know what is wrong with version 3+ and why it only works with 2.0.3 ?!!!

Related

Hyperledger besu with permissioning enabled error

I am using the quickstart network provided by Hyperledger besu, and I want to test and see how permissioning works with the permissioning management dapp. I use this repo: https://github.com/bretthenderson/besu-quickstart
So when I run the run-permissioning.sh script to build the dapp and run the test network everything works fine and the network starts succesfully then when I run the run-permissioning-dapp.sh script it works fine and it compiles and deploys the permissioning smart contracts then restarts the network with permissioning enabled but after that the bootnode container crashes with these logs :
2021-04-02 10:25:11.294+00:00 | main | INFO | KeyPairUtil | Loaded public key 0xc1979a8a48693db804316b5acebe35e11731e1fb1c9c21ff7268ab25db6f6e03390a429b83cf0ec0865a7205f2669ec1ace652a3def11e2e01571c74939cbe22 from /opt/besu/keys/key
Setting logging level to INFO
2021-04-02 10:25:42.930+00:00 | main | INFO | AbstractAltBnPrecompiledContract | Using LibEthPairings native alt bn128
2021-04-02 10:25:55.841+00:00 | main | INFO | SECP256K1 | Using native secp256k1
2021-04-02 10:25:55.933+00:00 | main | INFO | Besu | Starting Besu version: besu/v21.1.3/linux-x86_64/oracle_openjdk-java-11
2021-04-02 10:25:59.261+00:00 | main | WARN | Besu | --min-gas-price has been ignored because --miner-enabled was not defined on the command line.
2021-04-02 10:26:00.299+00:00 | main | INFO | Besu | Static Nodes file = /opt/besu/data/static-nodes.json
2021-04-02 10:26:00.322+00:00 | main | INFO | StaticNodesParser | StaticNodes file /opt/besu/data/static-nodes.json does not exist, no static connections will be created.
2021-04-02 10:26:00.351+00:00 | main | INFO | Besu | Connecting to 0 static nodes.
2021-04-02 10:26:00.368+00:00 | main | INFO | Besu | Security Module: localfile
2021-04-02 10:26:00.661+00:00 | main | INFO | DatabaseMetadata | Lookup database metadata file in data directory: /opt/besu/data
2021-04-02 10:26:01.646+00:00 | main | INFO | RocksDBKeyValueStorageFactory | Existing database detected at /opt/besu/data. Version 1
2021-04-02 10:26:03.790+00:00 | main | INFO | KeyPairUtil | Loaded public key 0xc1979a8a48693db804316b5acebe35e11731e1fb1c9c21ff7268ab25db6f6e03390a429b83cf0ec0865a7205f2669ec1ace652a3def11e2e01571c74939cbe22 from /opt/besu/keys/key
2021-04-02 10:26:04.310+00:00 | main | INFO | ProtocolScheduleBuilder | Protocol schedule created with milestones: [Petersburg: 0]
ANTLR Tool version 4.7.1 used for code generation does not match the current runtime version 4.8ANTLR Runtime version 4.7.1 used for parser compilation does not match the current runtime version 4.8ANTLR Tool version 4.7.1 used for code generation does not match the current runtime version 4.8ANTLR Runtime version 4.7.1 used for parser compilation does not match the current runtime version 4.8ANTLR Tool version 4.7.1 used for code generation does not match the current runtime version 4.8ANTLR Runtime version 4.7.1 used for parser compilation does not match the current runtime version 4.8ANTLR Tool version 4.7.1 used for code generation does not match the current runtime version 4.8ANTLR Runtime version 4.7.1 used for parser compilation does not match the current runtime version 4.8
Error: node permissioning contract at address 0x0000000000000000000000000000000000009999 does not match the expected interface version 1
I can't find anything about this error anywhere as hyperledger besu have a very small community...
The fix is to the issue is to add --permissions-nodes-contract-version=2 to your besu command line.
This is because in v 2.0.0 of permissioning smart contracts repo we changed the interface as per the changelog https://github.com/ConsenSys/permissioning-smart-contracts/releases/tag/v2.0.0
It is in the besu docs here https://besu.hyperledger.org/en/stable/HowTo/Limit-Access/Specify-Perm-Version/ but I have already reported this issue and it has been fixed on the documentation of on-chain permissioning tutorial.
you can find more details here
Github issue
Besu Docs
i'm facing the same issue even with --permissions-nodes-contract-version=2 is added, check my post here : https://ethereum.stackexchange.com/questions/132573/hyperledger-besu-onchain-permissioning-error

Felix + WAR packaging => Component descriptor entry 'OSGI-INF/*.xml' not found

I'm trying to deploy the Java backend of a web application on GlassFish 4.1.1. I use OSGi with declarative services. Declarative services seem to work when the bundle in question is published as a JAR but I'm having some trouble with WARs: Felix doesn't seem to find the the component descriptors (OSGI-INF/SomeComponent.xml).
I put together a very simple example to illustrate this.
The bundle is called com.ex.client.
Here's the MANIFEST.MF:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Client
Bundle-SymbolicName: com.ex.client
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: com.ex.auth,
javax.servlet;version="3.1.0",
javax.servlet.http;version="3.1.0",
org.osgi.framework
Service-Component: OSGI-INF/ClientServlet.xml
Web-ContextPath: /hi
Bundle-ClassPath: WEB-INF/classes
Here's the structure of the resulting WAR file:
com.ex.client.war
|
+-- META-INF
| |
| +-- MANIFEST.MF (as shown above)
|
+-- OSGI-INF
| |
| +-- ClientServlet.xml
|
+-- WEB-INF
|
+-- classes
| |
| +-- binaries
|
+-- web.xml
And here's Felix complaining that it cannot find OSGI-INF/ClientServlet.xml:
Info: Installed C:\glassfish-4.1.1\glassfish\domains\domain1\autodeploy\bundles\com.ex.client.war
Severe: ERROR: com.ex.client (333): Component descriptor entry 'OSGI-INF/ClientServlet.xml' not found
Info: Started bundle: file:/C:/glassfish-4.1.1/glassfish/domains/domain1/autodeploy/bundles/com.ex.client.war
Info: Started bundle: file:/C:/glassfish-4.1.1/glassfish/domains/domain1/autodeploy/bundles/com.ex.client.war
Info: Expanded at file:/C:/glassfish-4.1.1/glassfish/domains/domain1/osgi-cache/felix/bundle309/data/applications/bundle333-1456241385614/
Info: visiting unvisited references
Info: uris = [file:/C:/glassfish-4.1.1/glassfish/domains/domain1/osgi-cache/felix/bundle309/data/applications/bundle333-1456241385614/WEB-INF/classes/]
Info: visiting unvisited references
Info: visiting unvisited references
Info: total number of classes with faces annotation = 0
Info: Loading application [com.ex.client_1.0.0.qualifier] at [/hi]
Info: Registered ServletContext as a service with properties: {osgi.web.symbolicname=com.ex.client, osgi.web.version=1.0.0.qualifier, osgi.web.contextpath=/hi}
Info: deployed bundle com.ex.client [333] at file:/C:/glassfish-4.1.1/glassfish/domains/domain1/osgi-cache/felix/bundle309/data/applications/bundle333-1456241385614/
When I go to the location
C:/glassfish-4.1.1/glassfish/domains/domain1/osgi-cache/felix/bundle309/data/applications/bundle333-1456241385614/
mentioned above I see the exact same structure as within the WAR file. OSGI-INF/ClientServlet.xml is there.
I googled "Component descriptor entry * not found" and found the code that logs the message (note: I'm not sure if this is the correct version): http://grepcode.com/file/repo1.maven.org/maven2/org.apache.felix/org.apache.felix.scr/1.8.2/org/apache/felix/scr/impl/BundleComponentActivator.java#150
URL[] descriptorURLs = findDescriptors( m_bundle, descriptorLocation );
if ( descriptorURLs.length == 0 )
{
// 112.4.1 If an XML document specified by the header cannot be located in the bundle and its attached
// fragments, SCR must log an error message with the Log Service, if present, and continue.
log( LogService.LOG_ERROR, "Component descriptor entry ''{0}'' not found", new Object[]
{ descriptorLocation }, null, null, null );
continue;
}
Where as far as I can tell descriptorLocation should be OSGI-INF/ClientServlet.xml (what I wrote in the Service-Component in the manifest). Somehow findDescriptors( m_bundle, descriptorLocation ), doesn't find the XML file.
I copied the findDescriptors method into a class in my bundle and I'm printing the results:
Info: bundle://333.0:0/OSGI-INF/ClientServlet.xml
So /OSGI-INF/ClientServlet.xml is indeed there and can be found using the same code that is failing for BundleComponentActivator (again, if this is really the same version of the code; I'm struggling to find out which version GlassFish 4.1.1 uses). So I think the problem is that when BundleComponentActivator first tries to find this XML, it isn't there yet. It works later for me because at that point it has been unpacked and made available.
So... what to do? Am I wrong to think that this should work? Am I packing things incorrectly?

JAX-RS in ServiceMix / Fuse ESB

I got the below error when I try to install a CXF example from Talend into FuseESB.
FuseESB:karaf#root> features:install talend-cxf-example-jaxrs-intro
Error executing command: Can not resolve feature:
Unsatisfied requirement(s):
---------------------------
package:(&(package=javax.ws.rs.core)(version>=2.0.0)(!(version>=3.0.0)))
Intro JAX-RS Example Common
package:(&(package=javax.ws.rs)(version>=2.0.0)(!(version>=3.0.0)))
Intro JAX-RS Example REST Resource Bundle
package:(&(package=javax.ws.rs)(version>=2.0.0)(!(version>=3.0.0)))
Intro JAX-RS Example Common
package:(&(package=javax.ws.rs.core)(version>=2.0.0)(!(version>=3.0.0)))
Intro JAX-RS Example REST Resource Bundle
I have JSR-311 running
FuseESB:karaf#root> list|grep -i 311
[ 165] [Active ] [ ] [ ] [ 10] Apache ServiceMix :: Specs :: JSR-311 API 1.1.1 (1.9.0)
How to resolve Unsatisfied requirement(s) error?
Fuse uses older versions of CXF than Talend does for their ESB and does not currently support CXF 2.7.x which is where the 2.x version of the JAX-RS implementation was added. The 2.6.x version of CXF that they include only supported JAX-RS 1.1. You possibly could edit the Talend example to drop it to 1.1 level. Not sure how well that would work.

Sonar for Eclipse: unable to run local analysis

I have successfully installed sonar plug-in for eclipse, however when I try to 'Run Local Analysis' for sonar, eclipse gives an error saying:
An internal error occurred during: "Sonar Analysis".
Unable to create markers
and console for Sonar has following info printed:
Usage: javaw [-options] class [args...]
(to execute a class)
or javaw [-jar] [-options] jarfile [args...]
(to execute a jar file)
where options include:
-cp -classpath
set search path for application classes and resources
-D=
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version
-version:
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
include/exclude user private JREs in the version search
-agentlib:[=]
load native agent library , e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:[=]
load native agent library by full pathname
-javaagent:[=]
load Java programming language agent, see java.lang.instrument
-? -help print this help message
-X print help on non-standard options
-splash: show splash screen with specified image
-ea[:...|:]
-enableassertions[:...|:]
enable assertions
-da[:...|:]
-disableassertions[:...|:]
disable assertions
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
Plz help with how to proceed for Local analysis in eclipse.
[Update: Version Details]
Eclipse: Indigo (3.7.1)
Sonar Plug-in: 3.0.0
Sonar(Server): 3.4.1
Sonar Web Service Client: 3.4.0
Java: 1.4.1 ('Java EE IDE' property in Eclipse Features)
Local Java Installation: 1.6

Error starting Sonar

I'm using SONAR for my project.
While using "StartSonar.bat" for launch of Sonar, it is throwing the following exception.
wrapper | --> Wrapper Started as Console
wrapper | Launching a JVM...
jvm 1 | Error occurred during initialization of VM
jvm 1 | java/lang/NoClassDefFoundError: java/lang/Object
wrapper | JVM exited while loading the application.
wrapper | Launching a JVM...
jvm 2 | Error occurred during initialization of VM
jvm 2 | java/lang/NoClassDefFoundError: java/lang/Object
wrapper | JVM exited while loading the application.
wrapper | Launching a JVM...
jvm 3 | Error occurred during initialization of VM
jvm 3 | java/lang/NoClassDefFoundError: java/lang/Object
wrapper | JVM exited while loading the application.
wrapper | Launching a JVM...
jvm 4 | Error occurred during initialization of VM
jvm 4 | java/lang/NoClassDefFoundError: java/lang/Object
wrapper | JVM exited while loading the application.
wrapper | Launching a JVM...
jvm 5 | Error occurred during initialization of VM
jvm 5 | java/lang/NoClassDefFoundError: java/lang/Object
wrapper | JVM exited while loading the application.
wrapper | There were 5 failed launches in a row, each lasting less than 300 seconds.
Giving up.
wrapper | There may be a configuration problem: please check the logs.
wrapper | <-- Wrapper Stopped
Press any key to continue . . .
Using Java 1.7.0._09. Please help me in getting out of this.
Also, I tried configuring Sonar in IntelliJ IDEA 11 Community Edition. It fails in the startup of IDE. Are any plugins available for Community Edition to run Sonar.
what value do you have for the 'wrapper.java.command' in the wrapper.conf file? Seems like the is no JVM available
Are you sure you have installed a JDK, and not just the JRE?
Also Check JAVA_HOME is configured correctly. Make sure to set the JAVA_HOME environment variable to point to the JDK root folder.
Do one thing, go to <sonarDirectory>\conf and edit the wrapper.conf file and set these 2 lines:
wrapper.java.command=C:\Program Files\Java\jdk1.8.0_20\bin\java
#wrapper.java.command=java