I am trying to deploy a basic web service, my wsdl is located as shown in the following beans.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<jaxws:endpoint
id="helloWorld"
implementor="com.tsdevelopment.HelloWorldImpl"
wsdlLocation="src/main/resources/wsdl/HelloWorld.wsdl"
address="/HelloWorld" />
</beans>
When i deploy with mvn wildfly:deploy i get the following error:
Caused by: java.io.FileNotFoundException: C:\Users\codereadystudio\jboss-eap-7.3\bin\src\main\resources\wsdl\HelloWorld.wsdl (The system cannot find the path specified)
at java.base/java.io.FileInputStream.open0(Native Method)
at java.base/java.io.FileInputStream.open(FileInputStream.java:211)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:153)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:108)
at java.base/sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:86)
at java.base/sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:189)
at org.apache.xerces#2.12.0.SP02-redhat-00001//org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:1009)
at org.apache.xerces#2.12.0.SP02-redhat-00001//org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:144)
at org.apache.xerces#2.12.0.SP02-redhat-00001//org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:832)
at org.apache.xerces#2.12.0.SP02-redhat-00001//org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:798)
at org.apache.xerces#2.12.0.SP02-redhat-00001//org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:108)
at org.apache.xerces#2.12.0.SP02-redhat-00001//org.apache.xerces.parsers.DOMParser.parse(DOMParser.java:230)
at org.apache.xerces#2.12.0.SP02-redhat-00001//org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:298)
at deployment.soap-cxf-wsdlfirst-jbosseap73-1.0-SNAPSHOT.war//com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(WSDLReaderImpl.java:2188)
... 56 more
Why is it searching for the WSDL in the jboss installation folder and not in the code?
It seems the reason that it was unable to find the WSDL was that while in pom.xml the wsdl paths were as following:
<wsdlOptions>
<wsdlOption>
<wsdl>
src/main/resources/wsdl/HelloWorld.wsdl
</wsdl>
<wsdlLocation>wsdl/HelloWorld.wsdl</wsdlLocation>
</wsdlOption>
</wsdlOptions>
The java class that the cxf cxf-codegen-plugin generated did not include the wsdlLocation parameter in the #WebService annotation. Also please note that the parameter path must contain only the folders under your build path. That said, while my pom.xml location was /src/main/resources/wsdl/HelloWorld.wsdl, my parameter was wsdl/HelloWorld.wsdl, because i had already included the /src/main/resources folder on the build path.
Related
I wish to present a README file on CodeArtifact. I deployed a new version that contains a README.MD file however the Description (marked in red) is still greyed out.
Found an AWS documentation however I did not understand what I should do to present my .MD file.
can view the README at Bitbucket and inside the Intellij.
code is in Java.
use Maven for project management.
Following #Ermiya Eskandary comment, I made two README files, one in the root and a second in root of the module. After redeploying, the description is still not showing.
Project structure:
The POM file of the relevant module:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>---</artifactId>
<groupId>---</groupId>
<version>1.0.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>---</artifactId>
<version>1.0.14</version>
<dependencies>
<dependency>
<groupId>---</groupId>
<artifactId>---</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
</project>
Unfortunately CodeArtifact does not currently support displaying Readme files for Maven packages. The GetPackageVersionReadme API will return "not found" for all Maven packages.
$ aws codeartifact get-package-version-readme \
> --domain test \
> --repo my-repo-name \
> --format maven \
> --package commons-lang \
> --namespace commons-lang \
> --package-version 2.1 \
> --profile my_profile_name
An error occurred (ResourceNotFoundException) when calling the GetPackageVersionReadme operation: The readme file of this package version is not found
I developed a spring boot application and I've put the following entries in src/main/resources/application.properties:
spring.mvc.view.prefix: /
spring.mvc.view.suffix: .jsp
server.port=5000
Now when I start it (mvn clean spring-boot:run) locally, I'm getting the output Tomcat started on port(s): 5000 (http) and the app is accessible in the browser under http://localhost:5000/welcome .
I created a Java instance in Amazon Elastic Bean Stalk, I've uploaded war, I even opened the port 5000 in the corresponding Security Group on EC2 instance:
but when I now go to http://my-aws-ebs-instance.com/welcome:5000, I'm getting the following message:
Whitelabel Error Page This application has no explicit mapping for
/error, so you are seeing this as a fallback.
Thu Dec 20 16:30:33 UTC 2018 There was an unexpected error (type=Not
Found, status=404). /welcome.jsp
Why oh why does it happen like this? What did I forget to configure?
----EDIT
as requested, here's the root java class:
package com.hellokoding.auth;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
#SpringBootApplication
public class WebApplication extends SpringBootServletInitializer {
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(WebApplication.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(WebApplication.class, args);
}
}
Here is also the structure of my project with highlighted welcome.jsp page:
When I unzip the generated war file, this is the file structure on my hard drive:
My pom.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>auth</artifactId>
<name>auth</name>
<description>my descr</description>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.7</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
and the UserController class contains:
...
#Controller
#Scope("session")
public class UserController {
#RequestMapping(value = {"/", "/welcome"}, method = RequestMethod.GET)
public String welcome(Model model) {
return "welcome";
}
...
I added some logs inside the welcome method and I see it is running correctly. Also, in log files I can see the following entry:
Mapped "{[/ || /welcome],methods=[GET]}" onto public java.lang.String com.hellokoding.auth.web.UserController.welcome(org.springframework.ui.Model)
so I have no idea why this thing does not work. After trying for 11 hours straight to make it work I'm questioning my life choices, and also I'm wondering why anyone would ever use such a stupid framework since it doesn't work ootb.
--- edit:
I've uploaded a simplified code to github https://github.com/nalogowiec/springbootProblem
Solution 1:
If you want Spring Boot With JSPs in Executable Jars
Keep in mind that we will ultimately place the JSP templates under src/main/resources/META-INF/resources/WEB-INF/jsp/
Note :
define the template prefix and suffix for our JSP files in application.properties
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
Then your can run jar file using below command :
java -jar <your jar name>
for your project you can below command
java -jar auth-1.3.5.RELEASE.jar
For More reference : https://dzone.com/articles/spring-boot-with-jsps-in-executable-jars-1
Solution 2:
JSP Limitations
When running a Spring Boot application that uses an embedded servlet container (and is packaged as an executable archive), there are some limitations in the JSP support.
With Jetty and Tomcat, it should work if you use war packaging. An executable war will work when launched with java -jar, and will also be deployable to any standard container. JSPs are not supported when using an executable jar.
Undertow does not support JSPs.
Creating a custom error.jsp page does not override the default view for error handling. Custom error pages should be used instead.
I have clone your GitHub project able to run project(if you follow below steps your problem will get solve definitely)
Step To run your project :
Step 1 : Create war package of your project
Step 2 : Run your war package using below command
java -jar <your war file name>
i.e for your project command should be like :
java -jar auth-1.3.5.RELEASE.war
Step 3 : Hit the URL http://localhost:5000/
You can see the result in browser.
More reference : https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-web-applications.html#boot-features-jsp-limitations
Nice explanation #dipak-thoke.
Just to add if anyone automating the deployment process (In my case, it was through CodeBuild And CodeDeploy), you can create Procfile and deploy the war. I have added Procfile into the root directory of the project and added it as an artifact.
Hope this helps someone looking for same usage case :)
ProcFile:
web: java -jar <your_war_file>.war
This is how my CodeBuild Buildspec looks like:
version: 0.2
phases:
build:
commands:
# - command
- ./gradlew bootWar
post_build:
commands:
# - command
- echo Build must be completed
- mv build/libs/*.war <WarFileName>.war
artifacts:
files:
# - location
- <WarFileName>.war
- Procfile
#name: $(date +%Y-%m-%d)
#discard-paths: yes
#base-directory: location
#cache:
#paths:
# - paths
If you check the Spring Boot docs, its clear that you are using the wrong directory structure.
https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-spring-mvc
By default, Spring Boot serves static content from a directory called /static (or /public or /resources or /META-INF/resources) in the classpath or from the root of the ServletContext ... Do not use the src/main/webapp directory if your application is packaged as a jar. Although this directory is a common standard, it works only with war packaging, and it is silently ignored by most build tools if you generate a jar.
Since you have your app on port 5000 it is accessible on that port, not default http port 80.
Either access it with
http://my-aws-ebs-instance.com:5000/welcome
or create port forwarding rune in AWS so traffing going to port 80 will be pushed you application server's port 5000.
I wrote a python script which copies local files to HDFS.
Upgraded python version 2.6 to 2.7 in all nodes of cluster. Installed pydoop-1.0 version and using CDH 5.4
If I run the py script in command line it is working perfectly. This same script is throwing below error when I run in oozie.
Error:
import pydoop.hdfs as hdfs
ImportError: No module named pydoop.hdfs
Failing Oozie Launcher, Main class
[org.apache.oozie.action.hadoop.ShellMain], exit code [1]
Oozie workflow
<?xml version="1.0" encoding="UTF-8"?>
<workflow-app name="FileLogPy" xmlns="uri:oozie:workflow:0.4">
<start to="FileLog"/>
<action name="FileLog">
<shell xmlns="uri:oozie:shell-action:0.2">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<prepare>
<delete path='${outputHadoopDirectory}'/>
</prepare>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>${queueName}</value>
</property>
</configuration>
<exec>python</exec>
<argument>FileLog.py</argument>
<argument>${inputDir}</argument>
<argument>${outputHadoopDirectory}</argument>
<argument>${kpi}</argument>
<argument>${sourceName}</argument>
<argument>${wf:id()}</argument>
<file>${LogScriptPath}#FileLog.py</file>
<capture-output/>
</shell>
<ok to="end"/>
<error to="kill"/>
</action>
<kill name="kill">
<message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<end name="end"/>
</workflow-app>
Added hashbang to the script. So that it will not check for python 2.6 version.
#!/usr/bin/python
import pydoop.hdfs as hdfs
Need Help !
Thanks.
This can be because of the lack of pydoop library in all the nodes. If you run the script locally, the python script is getting triggered in the same machine. In that machine you have pydoop library. But if you run this script through oozie, this script can execute in any of the nodes in the cluster. So install all the required python packages in all the nodes (nodemanager nodes) in the hadoop cluster.
I'd like to have a hot-reloading enabled jetty with wro4j that does not kill the whole server for a few seconds just because a character has changed in a css file.
I have set up wro4j to locate css resources that is outside of the classpath.
<?xml version="1.0" encoding="UTF-8"?>
<groups xmlns="http://www.isdc.ro/wro">
<group name="style">
<css>file:src/main/less/style.css</css>
</group>
</groups>
I have set up jetty to watch only the webapp directory for changes:
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.1.0.M0</version>
<configuration>
<scanTargets>
<scanTarget>${basedir}/src/main/webapp</scanTarget>
</scanTargets>
<scanIntervalSeconds>1</scanIntervalSeconds>
</configuration>
</plugin>
Still, if I change something in the directory /src/main/less, jetty restarts itself:
[INFO] restarting o.e.j.m.p.JettyWebAppContext#6ebc4e13{/,[file:/home/tamas/ux/src/main/webapp/, jar:file:/home/tamas/.m2/repository/org/webjars/jshint/2.1.3/jshint-2.1.3.jar!/META-INF/resources/, jar:file:/home/tamas/.m2/repository/org/webjars/less/1.3.3/less-1.3.3.jar!/META-INF/resources/, jar:file:/home/tamas/.m2/repository/org/webjars/emberjs/1.0.0-rc.5/emberjs-1.0.0-rc.5.jar!/META-INF/resources/, jar:file:/home/tamas/.m2/repository/org/webjars/jquery/1.9.1/jquery-1.9.1.jar!/META-INF/resources/, jar:file:/home/tamas/.m2/repository/org/webjars/handlebars/1.0.0-rc.4/handlebars-1.0.0-rc.4.jar!/META-INF/resources/, jar:file:/home/tamas/.m2/repository/org/webjars/coffee-script/1.6.3/coffee-script-1.6.3.jar!/META-INF/resources/, jar:file:/home/tamas/.m2/repository/org/webjars/jslint/c657984cd7/jslint-c657984cd7.jar!/META-INF/resources/, jar:file:/home/tamas/.m2/repository/org/webjars/json2/20110223/json2-20110223.jar!/META-INF/resources/],AVAILABLE}{file:/home/tamas/ux/src/main/webapp/}
I'd like to avoid this restart as it's very annoying.
I am using wro4j 1.7.1, Maven 3.0.4 and Jetty 9.1.0.M0.
Update: The restart happened because I edited the files with Eclipse. Jetty doesn't restart itself otherwise.
You could try using "resourceWatcherUpdatePeriod" wro4j configuration instead if you want to get the latest change whenever there is a modification. I think jetty by default performs a restart when a change is detected.
I am getting the following exception when I try to hit a HelloWorld RESTful web service implemented using Jersey and maven on Apache Tomcat.
URL: http://localhost:8080/TestRest/rest/hello/abcd
com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
I looked at various sources on internet, they say the exception occurs because of not having class in the package structure given in web.xml, but I made sure that they are all correct.
Any help regarding this is greatly appreciated.
Following is the code of pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my.test.rest</groupId>
<artifactId>TestRest</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>TestRest Maven Webapp</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>maven2-repository.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.8</version>
</dependency>
</dependencies>
<build>
<finalName>TestRest</finalName>
</build>
</project>
This is the simple HelloWorldService.
package com.rest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
#Path("/hello")
public class HelloWorldService {
#GET
#Path("/{param}")
public Response getMsg(#PathParam("param") String msg) {
String output = "Hello, " + msg;
return Response.status(200).entity(output).build();
}
}
And finally, the web.xml
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Restful Web Application</display-name>
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.rest</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
I hope the directory structure of mine is correct too, please correct me if it isn't.
You have the HelloWorldService.java in the wrong source folder. It must be in src/main/java not in src/main/resources. It's a big big difference!
It means that your Java code has not been compiled and that's why you get the error. No class that can handle the request.
Take a look at the Maven Standard Directory Layout.
Yes, its a problem in Eclipse Indigo while developing RESTful web services in Java using Maven because it doesn't create correct directory structure. So, deleting the given source directory and adding source as src/main/java as #maba rightly mentioned is the best workaround.
You may refer this for detailed explanation on developing RESTful web services in Java in Eclipse Indigo using Maven...
http://kausalmalladi.blogspot.in/2012/11/developing-restful-java-web-service-in.html