how to access folder outside webroot in wildfly 8 - java

I want to access my image file outside of web directory. For example my applicable is in opt/wildfly-8.2.0.Final/standalone/deployments/Myproj and i want to access a file from /opt/pic/abc.jpg. Please hl how to do in wildfly. I am using wildfly-8.2.0. I deployed my war by exploded deploy. Pease help.

Sometimes back i wrote an article on the similar query, Hope that might be helpful:
How to store static contents outside WildFly installation and access them via Http ?
http://middlewaremagic.com/jboss/?p=2718
Regards
Jay SenSharma

Related

Cant get tomcat to show webapp from deployed .war file

I followed a tutorial and am trying to learn to make my own web app. I am using Tomcat 8.0.47 and Spring MVC. Issue is I can go to localhost:8080 and see that the server is on but I cant see my basic webapp running when visiting localhost:8080/CrunchifySpringMVCTutorial page. I made a WAR file and dropped it into the /webapps/ folder inside tomcat folder and console shows that it deployed the war file. Any help is appreciated.
I am following this tutorial: http://crunchify.com/simplest-spring-mvc-hello-world-example-tutorial-spring-model-view-controller-tips/
rather than paste all the files I decided to link the guide. My set up is the same but cant figure out why it is not working. thanks.
Looks like the issue was that I needed to add the CATALINA_HOME system variable to properly setup my tomcat server

Copy a file on server and make it accessible

I have a jersey web service. I am trying to download a file on my hard disk through my localhost Tomcat server.
window.open("D:\\mario.zip");
This line doesn't work due to security reason.
My 2nd try is creating a folder in the project which can be accessible like localhost/myfolder then I put a file there which can be accessed through http.
Now I copy files from a specific folder to "myfolder" so that they can be downloaded.
The problem is: although the files exist in my hard drive, they cannot be accessible through http. Only after I refresh the project in Eclipse. The files can be accessible through http.
Is there any trigger for the server to update its file list?
How do you create "Aliases" in Apache Tomcat?
This is the answer. I don't know much about other solution than creating an "alias" as in Apache server. Olaf Kock's answer would be interesting too if he can be more beginner-friendly.
Further notice, you can find server.xml in your Tomcat server "project" in Eclipse.

Website directory structure different from eclipse

I am coding a website using java servlets and am using eclipse and tomcat. When I test it using localhost, it works fine. But when I am deploying it on my actual website, the directory structure is messed up and the files are not called properly.
My eclipse directory structure on localhost is
Project Name
.src/packageName/java files
.WebContent/HTML files.
When I make a call from the html files, I use the relative location and tomcat automatically knows to look in the src/packageName folder. For example, from the /WebContent/login.html page makes a onClick call as follows,
. This will automatically trigger the java file in /src/packageName/welcome
When I am deploying it in my actual website, the WebContent/login.html is throwing an error WebContent/welcome file is not found. How do I tell my website to search in /src/packageName folder?
Hmm...have you been sure to package the application as a war for deployment.

How to reference a DLL file in Jelastic Tomcat

I have successfully developed and deployed a java servlet in a tomcat server.
But in that servlet i call a dll file. In my computer that i run the tomcat server and i call the library
i use System.load("C:/java/src/calldllfile.dll"); and it works fine .
The problem is that in jelastic tomcat i don't really know what path i should use and where i should place my dll file for my servlet to call... and i catch in my code with a try it returns a UnsatisfiedLinkError
so it really must be the path ...
Following a similar answer in jelastic forum that is on comments below
i tried to set my file into home folder and call it with
System.loadLibrary(System.getProperty("user.home")+"/"+"calldllfile.dll");
but it didnt work.
So i don't really know what to do ... i include below an image of my deployed servlet with the location of the dll library that i cannot call. It would be just really helpfull if someone tell me what path i should use in System.load("?????");. Thanks
Folders webapps and home are located on the same level and the root folder for them is /opt/tomcat/ (equivalent of environment variable CATALINA.HOME - portion of docs). If you are talking about WEB-INF folder which is definitely located under your context (ROOT for example), to get it you need to use /opt/tomcat/webapps/ROOT/WEB-INF (or System.getProperty("catalina.home")+ "webapps/ROOT/WEB-INF/").
Concerning .dll libs you can check this
I know this is an old thread, but the answer can be useful for someone.
To access the home folder from a Tomcat installation you have to use the real path /opt/tomcat/
This way you can access your dll with the path /opt/tomcat/temp/calldllfile.dll

Some Tomcat webapps not opening

I downloaded a couple of webapps and placed them in my /webapps folder.
Some of them I could open by going to http://localhost:8080/app1 and it would open.
However, some others I would do the exact same thing and go to http://localhost:8080/app2 and it will display "HTTP Status 404 - /app2/", even though I am sure it is there. I've checked that it contains a WEB-INF folder just like app1, and I've even restarted Tomcat to be sure.
My question is: is there anything (perhaps in the web.xml file) that specifies what the URL has to be to start the webapp? Or is it simply just http://localhost:8080/<folder name> ?
P.S. If you want to know exactly what app1 and app2 I am refering to:
app1 (works) = http://assets.devx.com/sourcecode/11237.zip
app2 (doesn't work) = http://www.laliluna.de/download/eclipse-spring-jdbc-tutorial.zip
I've tried a few others as well, some work, some don't. I'm just wondering if I'm missing something.
I usually debug this by going the the manager page and making sure that all of the contexts are deployed (http://localhost:8080/manager/html).
It sounds like app2 has not been deployed properly or is not starting up because of some other error.
I would look at the logs. There may be a bunch of information in there but usually it explains what is broken.
The second app (the directory named WebRoot) can also be deployed correctly but you get a 404 by going to it because there is not an "index.jsp" or "index.html" file in the root directory.
Try putting a file there with any of those names, and the 404 is gone.
A servlet mapping in the web.xml is not strictly necessary for this to work.
The first zip file you mention has a .war file as part of the zip. The second one is just the source code and it needs to be built into a .war file.
It looks like it is setup to have that done in Eclipse. Try the File>>Export option and select War file as the export type.
The second requires the spring framework. The only runnable things I could find were a client in eclipse-spring-jdbc-tutorial.zip\SpringJdbc\src\test\de\laliluna\library\TestClient.java and one in eclipse-spring-jdbc-tutorial.zip\SpringJdbc\src\de\laliluna\library\sample\MyApplication.java. If you open it in eclipse (it is an eclipse project), and compile, provided the Spring framework is installed, you should be able to run both.
Are you familiar with log4j? Spring puts a lot of often-useful information into the logs created via log4j. When I have a SpringMVC application that won't startup correctly or otherwise isn't running I check my log4j and potentially turn up the Spring log level to INFO or even DEBUG.
If "/" is not accessible it means that there is no "index.html", "index.jsp" or whatever is defined in the welcome-files list of the web.xml
Also no Servlet-Mapping for the context ROOT directory is present.
Check the web.xml for Servlet-Mappings or try to figure out the name of the jsp/html /... file being in the context root

Categories

Resources