I have a web app I want to deploy on Azure. I followed the recommended instructions and deployed my app, and according to the Azure portal, everything is working just fine. However, when I visit the base URL my app should reside in, I see a page that says the following:
This Java based web application has been successfully created
There's nothing here yet, but Microsoft Azure makes it simple to
publish content with GIT and FTP
Also when I visit any one of the endpoints (in this case, the /live endpoint) my app should have, I always see a page with the following message:
HTTP ERROR 404
Problem accessing /live. Reason:
Not Found
Powered by Jetty:// 9.3.13.v20161014
When I look at the directories on the machine, everything seems to be in place. All my files are inside wwwroot. However, there's another directory named webapp under wwwroot and inside it is another directory named ROOT with two files: index.jsp and background.png. index.jsp is the page that shows the aforementioned "There's nothing here yet" message.
I'm using Bitbucket as my source control provider and I use jetty to run my web app. I'm also using javalite as the library to manage my server and different endpoints.
You'll need to put your stuff under wwwroot/webapps/ROOT/, or package as ROOT.war and drop that under wwwroot/webapps - it will get picked up and extracted automagically:
wwwroot
└── webapps
└── ROOT
├── about.jsp
├── Content
│ ├── favicon.ico
│ └── Site.css
├── Images
│ ├── banner_coffee.png
├── index.jsp
├── META-INF
│ ├── context.xml
│ └── MANIFEST.MF
├── orderconfirmation.jsp
├── placeorder.jsp
├── Scripts
│ ├── jquery-1.7.1.min.js
└── WEB-INF
├── classes
├── lib
├── log4j.properties
└── web.xml
From https://github.com/Azure-Samples/app-service-web-java-get-started:
The main thing in the repo is a webapps folder with ROOT.war. The Tomcat/Jetty server in App Service will look inside this folder for web apps to host.
ROOT.war represents the default web app (at the site root). Any WAR file that's otherwise named represents a web app accessbile at ~/<WARfilename>.
Clearing things up
If your application sits in wwwroot/webapps/CoffeeShop/, then you'll access it at http://{site}.azurewebsites.net/CoffeeShop/.
If your application sits in wwwroot/webapps/ROOT/, then you'll access it at http://{site}.azurewebsites.net/.
Related
I have created a simple Java9 service example with one service interface and two service implementations and one driver which uses the ServiceLoader. I was able to successfully execute the example with module-path but when I tried to execute the same with java -cp (classpath) I did not get any output, not even any error.
Directory structure
out
├── driver
│ ├── com
│ │ └── company
│ │ └── driver
│ │ └── driver.class
│ └── module-info.class
├── firstServiceImpl
│ ├── com
│ │ └── company
│ │ └── first
│ │ └── serviceImpl
│ │ └── FunImpl1.class
│ └── module-info.class
├── secondServiceImpl
│ ├── com
│ │ └── company
│ │ └── second
│ │ └── serviceImpl
│ │ └── FunImpl2.class
│ └── module-info.class
└── serviceInterface
├── com
│ └── company
│ └── service
│ └── Fun.class
└── module-info.class
command to compile
javac -d out --module-source-path src src/driver/driver.java src/firstServiceImpl/FunImpl1.java src/secondServiceImpl/FunImpl2.java src/serviceInterface/Fun.java
The above command compiles the code with a module-source-path.
command to run
java -cp out/driver:out/serviceInterface/:out/firstServiceImpl/ com.sunil.driver.driver
The above command runs the code with a classpath.
After compiling with module-source-path and run the code with classpath. I do not get any error or output.
Please help me understand why there is no output when run using classpath.
The way service-providers are located depends on if the service-providers are on the classpath or the modulepath. This is described in the documentation of ServiceLoader:
Deploying service providers as modules
A service provider that is developed in a module must be specified in a provides directive in the module declaration. The provides directive specifies both the service and the service provider; this helps to locate the provider when another module, with a uses directive for the service, obtains a service loader for the service. It is strongly recommended that the module does not export the package containing the service provider. There is no support for a module specifying, in a provides directive, a service provider in another module.
[...]
Deploying service providers on the class path
A service provider that is packaged as a JAR file for the class path is identified by placing a provider-configuration file in the resource directory META-INF/services. The name of the provider-configuration file is the fully qualified binary name of the service. The provider-configuration file contains a list of fully qualified binary names of service providers, one per line.
[...]
Basically, if you want to be able to load a service-provider no matter if it's placed on the classpath or modulepath you'll need to specify both a provides directive in the module-info.java file and add the appropriate provider-configuration file under META-INF/services. You also have to make sure you use the correct method for loading the service-providers:
ServiceLoader#load(Class,ClassLoader)
Locates providers in named modules (i.e. modulepath) and unnamed modules (i.e. classpath).
ServiceLoader#load(ModuleLayer,Class)
Only locates providers in named modules (i.e. modulepath).
I have a NiFi processor, that uses the redislabs/luascript lib in order to load a lua script and execute it on a redis instance.
The thing is that I don't know where exactly to put the lua script in order to load it using the luascript lib. I've put it into the nifi_proc/src/main/resources/lua/name.lua, but I get an IOException.
I have a nifi controller service for connecting to redis and a processor that uses that service.
My project structure:
.
├── nifi-bundle-nar
│ └── target
├── nifi-redis_cservice
│ ├── src
│ └── target
├── nifi-redis_cservice-api
│ ├── src
│ └── target
├── nifi-redis_cservice-api-nar
│ └── target
├── nifi-redis_cservice-nar
│ └── target
├── redis-processors
│ ├── src
│ └── target
└── target
└── maven-shared-archive-resources
Any ideas?
Can you share more information about how the processor is interacting with the library? Are you passing in an InputStream, calling out to a executable, etc.?
Ensure your resource is in the JAR module of your processor's project, not the processor's NAR module or the parent (that includes both). You should be able to use getResourceAsStream("lua/name.lua") from a Class object that is in the processor's JAR file (such as the processor class itself). I'm not sure what you'd need to do with it after that, is it possible to share the source code or more details around it?
EDIT (reply to comments below): fromResource() uses LuaScript's classloader to get the resource, I wonder if it doesn't have access to the nifi-proc or controller service resources. It seems like, unless the user needs to specify the location of the script, that the controller service should be loading in the Lua script. So an alternative could be to use the controller service class to getResourceAsStream, read the whole thing into a String, and use fromSource instead of fromResource.
I'm working on a web application.
This is my project structure
src/
├── main
│ ├── java
│ ├── resources
│ └── webapp
└── test
├── java
└── resources
In my tests I want to call a method from a class in java which uses a file in resources.
So I want to know how to share my resources between main and test?
I don't want to copy files to test-resources every time I edit them.
I tried SymLink but got an error 'Can't copy to test-classes because file does not exist.`
And this is how I access a resource in case it matters
class.getResourceAsStream("/data.yml");
EDIT
So, apparently Maven do share resources between main and test by default but it's not the case here.
When I build I can see my resources from main under target/classes but nothing in target/test-classes.
Files present in main are visible in test.
So you can put resources on the main tree if necessary for both tests and main.
If the resources are necessary only for the test put them on the test subtree.
With Maven, your files under src/main/resources are shared with src/test/resources by default. Just put them there and they'll be accessible from the test folder as well.
I have several class files like such hierarchy directories:
classes
└── com
├── www
│ ├── ant
│ │ └── TAPJUnitResultFormatter.class
│ ├── taglib
│ │ └── IncludeTag.class
│ ├── tomcat
│ ├── util
How could I include them in classpath? I tried to include them one by one, but didn't work.
Thanks.
You might find this helpful
Quoted:
When classes are stored in a directory (folder), like /java/MyClasses/utility/myapp, then the class path
entry points to the directory that contains the first element of the
package name. (in this case, /java/MyClasses, since the package name
is utility.myapp.)
But when classes are stored in an archive file (a .zip or .jar file)
the class path entry is the path to and including the .zip or .jar
file. For example, to use a class library that is in a .jar file, the
command would look something like this:
% java -classpath /java/MyClasses/myclasses.jar utility.myapp.Cool
So basically, point it to the root directory that all your classes exist under. Your "MyClasses" folder is probably named "bin".
I am creating WLST scripts which will be run against a server running weblogic which is fairly locked down. I only have permission to view logs and read only access to the console unless a pre-authorised change. I don't have permission to access the entire weblogic domain and run WLST.
I would like to run WLST on a differernt server which has Java installed but not Weblogic.
I was initially hoping to add a weblogic jar to the classpath then run the tool but it seems a bit more complicated that that.
I have been following these instructions without success.
My current setup is this directory structure with jars taken from weblogic 12.1.1:
├── launch.sh
├── lib
│ ├── com.bea.core.utils.full_2.0.0.0.jar
│ ├── com.bea.core.xml.xmlbeans_2.2.0.0.jar
│ ├── com.oracle.cie.comdev_6.4.0.0.jar
│ ├── com.oracle.cie.config_7.2.0.0.jar
│ ├── com.oracle.cie.config-wls_7.2.0.0.jar
│ ├── com.oracle.cie.config-wls-schema_10.3.6.0.jar
│ ├── com.oracle.cie.wizard_6.1.0.0.jar
│ ├── com.oracle.core.weblogic.msgcat_1.3.0.0.jar
│ ├── jython.jar
│ ├── weblogic.jar
│ ├── weblogic.server.modules.jsf2.0_12.1.1.0.jar
│ ├── wlclient.jar
│ ├── wlfullclient.jar
│ └── wlthint3client.jar
└── props.txt
props.txt is empty described on the Oracle forum and launch.sh contains:
java -cp $(echo lib/*.jar | tr ' ' ':') -Dprod.props.file=props.txt -Dbea.home= -Dweblogic.home= weblogic.WLST
on running launch.sh, i get the error:
sam#ubuntu64vm:~/Desktop/scripts$ ./launch.sh
Initializing WebLogic Scripting Tool (WLST) ...
Problem invoking WLST - java.lang.NullPointerException
Is it possible to create a minimal / portable WLST application?
Standalone WSLT works for Weblogic 10.3.4 by running the following command (see Note 3, this stopped the java.lang.NullPointerException):
java -cp lib/wlfullclient.jar;lib/com.bea.core.xml.xmlbeans_2.2.0.0.jar;lib/com.oracle.cie.comdev_6.3.0.0.jar;lib/com.oracle.cie.config-wls-schema_10.3.4.0.jar;lib/com.oracle.cie.config-wls_7.1.0.0.jar;lib/com.oracle.cie.config_7.1.0.0.jar;lib/com.oracle.cie.wizard_6.1.0.0.jar;lib/com.oracle.core.weblogic.msgcat_1.1.0.0.jar;lib/jython.jar;lib/weblogic.jar -Dprod.props.file=lib/props.txt -Dbea.home= -Dweblogic.home=c:/users/username/wls10 weblogic.WLST your-script.py
Notes about script:
My Example setup of WLST is run from c:/users/username/wls10
The required jar are in c:/users/username/wls10/lib.
The weblogic.home must be set to an absolute path e.g. c:/users/username/wls10'.
You must create a blank props.txt in /lib directory.
I also followed same instructions as above.
my list of libraries needed is following:
coherence.jar
com.bea.core.xml.xmlbeans.jar
com.oracle.cie.comdev_7.7.0.0.jar
com.oracle.cie.config_8.4.0.0.jar
com.oracle.cie.config-external_8.4.0.0.jar
com.oracle.cie.config-owsm_8.4.0.0.jar
com.oracle.cie.config-security_8.4.0.0.jar
com.oracle.cie.config-wls_8.4.0.0.jar
com.oracle.cie.config-wls-external_8.4.0.0.jar
com.oracle.cie.config-wls-schema_8.4.0.0.jar
com.oracle.cie.dependency_1.7.0.0.jar
com.oracle.cie.encryption_2.4.0.0.jar
com.oracle.cie.service-table_1.4.0.0.jar
com.oracle.cie.wizard_7.7.0.0.jar
com.oracle.core.weblogic.msgcat.jar
com.oracle.glcm.common-logging_1.5.0.0.jar
com.oracle.glcm.encryption_2.6.0.0.jar
com.oracle.weblogic.lifecycle.provisioning.api.jar
com.oracle.weblogic.lifecycle.provisioning.core.jar
com.oracle.weblogic.lifecycle.provisioning.wlst.jar
cryptoj.jar
jython-modules.jar
weblogic.jar
wlfullclient.jar
wls-api.jar
wlst-impl.jar
I used jarscan utility to locate all missing classes by trying to run several wlst scripts. Total size is cca 150MB
My launch.sh is following:
#!/bin/bash
MYDIR=$(dirname $0)
CP=$(echo $MYDIR/lib/*.jar | tr ' ' ':')
echo $CP
java -cp $CP -Dprod.props.file=$MYDIR/props.txt -Dbea.home=`pwd` -Dweblogic.home=`pwd` weblogic.WLST $#
Not perfect, but working for me.
I made a script to retrieve all the required files for a Standalone WLST tool
The repository is https://github.com/cheloide/wlst-standalone
The script extracts and install Weblogic Server in a temporary location, creates wlfullclient.jar and then copies the required resources to a directory of your choosing or the working path
I also made another script in the same repo to use the Weblogic.Deployer tool
Currently the tool only works with GNU/Linux; should work with Mac-OS with some tweaks.
I recently faced the same issue on WLS 12.1.3 and ended up with a different set of dependent jars. Here's what I needed:
wlfullclient.jar
weblogic.jar
com.bea.core.xml.xmlbeans_1.0.0.0_2-6-0.jar
com.oracle.cie.comdev_7.1.0.0.jar
com.oracle.cie.config-owsm_8.1.0.0.jar
com.oracle.cie.config-security_8.1.0.0.jar
com.oracle.cie.config-wls-schema_12.1.3.0.jar
com.oracle.cie.config-wls_8.1.0.0.jar
com.oracle.cie.config_8.1.0.0.jar
com.oracle.cie.dependency_1.1.0.0.jar
com.oracle.cie.encryption_2.1.0.0.jar
com.oracle.cie.service-table_1.1.0.0.jar
com.oracle.cie.wizard_7.1.0.0.jar
com.oracle.core.weblogic.msgcat_3.0.0.0.jar
jython-modules.jar
This has been tested for start/stop server and undeploy/deploy application.