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
Related
Hi In my project I have many many jars.
Every time I change code and need to upload it to the server takes very long time, because I m adding the jars to the war to be deploy on tomcat.
I m trying to put all the jars in the server, in some folder and to upload the rest of the project only, to speed the cycle.
What will be the best way of doing that ?
I m using tomcat 8.5 also for production deployment without any build tool.
I would like to set an ABSOLUTE path in the classpath but when doing that in my local machine it won't work after deployment to the unix server.
I never saw where or if I can set an absolute path for the jars (NOT OF THE LOCAL MACHINE)
Thanks in advance
You can read about this in Tomcat docs: Class Loader HOW-TO.
The most simple case and way - put these commonly used jars into $CATALINA_BASE/lib dir - they will be loaded by Tomcat class loader.
But, it doesn't seems to be very nice practice, as mentioned tutorials claims:
Normally, application classes should NOT be placed here.
Personally me, in practice purposes, I would ignore this hint and still place jars inside this folder. But if you want to be accurate, you could create separate path on server (or even inside CATALINA_BASE folder) and place jars there. After that you have to specify this path in $CATALINA_BASE/conf/catalina.propertiesfile in common.loader property:
common.loader="${catalina.base}/lib","${catalina.base}/lib/*.jar","${catalina.home}/lib","${catalina.home}/lib/*.jar"
i have a tomcat webapp which is called "app". Inside the folder tomcat/webapps/app/ is a file named index.html (as you can see in the screenshot)
when i start my tomcat and try to access the file with the url
http://localhost:8080/app/index.html
then i get a 404 - not found error. What am I doing propably wrong? I allready checked the rights of the tomcat directory on the filesystem and have all rights to access all files in the directory
Thank you in advance!
Hmmm try by changing permissions on the folder and make sure you apply the permission recursively (so this step "Replace all child object permissions with inheritable permissions from this object") so all the folders underneath your tomcat take the same command like here: https://serverfault.com/questions/157461/set-permissions-recursively-on-windows-7
Use the Sysinternals Process Monitor to see where Tomcat is looking for files when you do the HTTP request. This will help you understand what's going on.
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
I've installed Eclipse with web development and during download have installed Tomcat7 to dir E:\Eclipse\tomcat7.
When in Eclipse and trying to test the program I'm getting a realPath of
C:/Users/user/Documents/eclipseJEEWorkspace/javaWebPages/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/org.example.web/WEB-INF/classes/
as my real path and not what I expect which is E:\Eclipse\tomcat7\webapps\org.example.web/WEB-INF/classes/
1) how do I get the real path of the servlet rather than the temporary path...
or am I missing something with how Eclipse uses the installed server? If this is the way then do I have to continuously create the WAR and fiddle around recreating/deleting all the time?
The reason for this is I'm also trying to get a JAVA Servlet getting access to a file in a path higher than webapps. I'm new to servlets....
My development includes third party software that all reference an individual file our.properties so changing the structure is unfortunately not a option.
My directory structure is:
/tomcat
/mycompany
/properties
our.properties //the file we want to access
/*otherfiles
/html
/*not used in this context but to show usage
/javascript
/*not used in this context but to show usage
/webapps
/org.example01.web
/META-INF
/WEB-INF
/org.example02.web
/META-INF
/WEB-INF
/org.example03.web
/META-INF
/WEB-INF
How do I tell my Servlet to access the our.properties file?
I've tried getPath, getResource but without getting the first bit to work, I doubt I'll be getting anywhere fast.
Thanks
When you run Tomcat under Eclipse, via the Tomcat plugin, the webapps path is changed. Eclipse uses .metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/ folder to deploy the project. That's not a temporary path, it's the actual path since your web application is deployed there.
If you run tomcat from command line, or as a service and deploy your web application, you'll see that the path of the servlet will be as you expected.
In order the change the default path to deploy for Eclipse, double click to your Tomcat under Servers view and modify Server locations section.
I'm using Eclipse Java EE IDE and launch Tomcat from the Server's tab on Eclipse.
Where does Eclipse store generated servlet .java files for JSP files? I've checked the Tomcat installation directory, but nothing there.
Thanks.
Doubleclick the server entry in Servers view and check the path represented by Server path. Explore in there from inside the workspace directory. The generated classes are there.
If you choose the 2nd option Use Tomcat installation, then it will be available Tomcat's /work folder, there where you expected it to be.
go to your application work space directory(not eclipse installation directory) in windows explorer(not in eclipse IDE explorer).
in my laptop it is d:/applicationdata/j2ee
then follow the path as:
work space directory(in my case j2ee)/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/work/catalina/localhost
here u will find your application
Eclipse doesn't generate servlet files for JSP files. Validation happens directly on JSP syntax. When a JSP is deployed to an app server like Tomcat, the server may choose to generate servlet files to disk, but that is not required. The generation and compilation can happen in memory or the app server may even compile JSP files directly to bytecode.
I don't know specifically about Tomcat, but if it does generate servlet files to disk, the temporary directory containing these files will be somewhere under your Tomcat install.
/home/waheguru/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/work/Catalina/localhost/jspnotes/org/apache/jsp
localhost or your website name,
project name is jspnotes, whatever your project.
This path is shown in Linux Mint.
Check META-INF\context.xml file from your work space. There will be path metioned like below
workDir="C:\apache-tomcat-7.0.39\work"
In above path you will find the package structure of your project and in it there will be both *_jsp.java and *_jsp.class