I'm using JRebel 5.0.0 in Intellij IDEA (Leda preview, 122.746) with JRebel plug-in. The server is GlassFish v3.1.
My application uses Wicket, with HTML templates placed in the same place as classes.
The problem is that updated classes do successfully reload after project rebuild, but updated HTMLs do not. For instance, I can add an element both to the page class and to the HTML, and then get an exception from Wicket saying that this element is referenced in the code, but absent in the markup.
Updated HTML resources and recompiled classes end up in the same directory (which I've checked), this directory is present in rebel.xml (and this setup is valid because recompiled classes are indeed updated).
What might be the problem?
Well, that was completely my fault, and kind of a stupid one.
I just haven't noticed a <wicket:extend> tag in the edited HTML, so my updates ended up ignored.
HTML refresh does actually work, everything runs smoothly even without clearing markup cache (thanks to a Wicket plug-in).
Related
All I'm trying to do is make calls to my Java code from my .jsp pages. I have written some .jsp pages for a webapp, but as the project grows I want to start putting some of the code into .java classes or servlets.
Why doesn't Eclipse "see" everything in my /src or /lib /web or /WebContent or /WebContent/src or /WebContent/WEB-INF/lib or /Webcontent/WEB-INF/src as usable? After all, it "sees my sql jdbc .jar files and I can use them as soon as they are in /WebContent/WEB-INF/src (and not any other folder). But I wrote classes which are in packages, my code isnt in .jar file form, so eclipse is not picking up on them.
You need to have the Java EE version of Eclipse installed, and create a Java Web Application, which will allow you to set up a web.xml.
Eclipse JEE which I have installed to set up web projects is:
http://eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/keplerr
Your web.xml will definte your web servlets, which can be JSP's or Java classes that extend a servlet implementation.
This has less to do with your IDE (eclipse) than it does with Java Web Applications.
You should read this documentation for starters from Oracle about web apps, and go from there on setting up an IDE:
http://docs.oracle.com/javaee/1.4/tutorial/doc/WebApp.html
Edit based on user feedback
Import should be to class level:
<%# page import="fully.qualified.SomeClass" %>
Then from your JSP code:
<%
SomeClass someClass = new SomeClass();
someClass.helloWorld();
%>
Edit 2 based on feedback
Try this link to do using page include: http://www.coderanch.com/t/286168/JSP/java/Calling-Java-classes-JSP-page
Alternative Approach
Add a new class to your web.xml, where you want to send your request/form data to. So your JSP would be 1 servlet, your other java class would be your other servlet.
On your JSP, create a form that has an action of your new "TestProgram" servlet
This answer to this question has nothing to do with my setup or import statements. The correct answer is that eclipse doesn't make it clear what code it "sees" (or that its compiling) when it runs the project. On my JSP page, it showed it as recognizing the call to my java code. However, when I ran the page, it was still compiling the older version of my java code, that didn't have my latest changes. I've found the best way to guarantee that the newest version of my referenced java code is compiled when I run my .jsp program (that calls the java) is to go to "Project->Build All" then go to "Servers", right click "Publish". If Publish isnt an option, and it thinks its already synchronized, then you may have to change the .jsp page, save it, then "Publish" will become active again.
I have Eclipse, the Juno release. Just recently I am getting a few JSP errors which aren't valid or I don't care to see. Examples of the errors are below.
The function fn:replace is undefined
Attribute (cellpadding) is obsolete. Its use is discouraged in HTML5 documents.
The function error is not valid, as it working perfectly fine when I run the web application. I simple don't care the HTML5 related obsolete messages. I'd like Eclipse to not display these "errors".
I've tried enabling project specific validations, and turning off the HTML, JSP, & Tag validators, but it made no difference.
Maybe you mean that your project is using using older type of (x)html. If you don't like Eclipse falling by default to HTML5, go to project properties, then Web Content Settings, then in Document Type select the one you use.
I'm very new to Java and JSP.
I am working with a purchased Java web application. When I access the application in my browser, there is a file "mysite.com/app/servlet/com.sample.weblet.server.ClientReader?..." that contains a line of Javascript is erroring out in some browsers. I would like to find the source of that Javascript code so that I can modify it so it will be cross-browser compatible.
I've searched all of the JSP and JS files (which are all in a separate folder, and not packaged into JAR files), but could not find the faulty function.
I dug through the JAR files extensively. I only found class declarations, variable declarations, and empty methods. I have not been able to find any logic whatsoever, and definitely have not come across anything resembling javascript auto-generation. There are no WAR files.
I found com.sample.weblet.server.ClientReader in a jar file.. and it just contained a couple of empty methods, yet again.
I am assuming that this faulty JS code is auto-generated. Does that sound correct?
Is there like one main JAR file that has all of the logic? Would it have this JS code hard-coded into it? What am I missing?
Can anyone direct me, or give me any tips?
My suggestion is you should use firebug to detect the javascript error. If any error occurs, you'll see it under "console" tab in firebug and usually there's a link beside it, click on the link will bring you where the bad code resides.
Also, you can navigate javascript files the page has loaded by clicking the list button under "Script" tab in firebug.
Hope it helps.
Many times I had errors like:
-tag is not closed(xml error)
-xhtml has duplicated id
Id like to write validator to check is those errors exist in files. I bet there is some facelets compiler that compile xhtml into java classes and than validates it.
Eclipse WTP, although not being the best thing out there, has some validation for .xhtml / .jsp files. You can try the corresponding editor in NetBeans or IntelliJ.
If checking the validity by opening the page takes you too much time (due to slow redeployment), consider sending the page to the servlet container on save - either using WTP dynamic project, deployed on a server, or via the FileSync plugin.
Have you considered using a good XML editor? It will catch the bad XML.
I also believe that schema aware XML editors will catch that id's must be unique.
You can't "compile" them, but if working with Seam on JBoss, just by saving the xhtml file the changes will be transfered to the running instance, so you can check "on the fly".
Also, on the duplicate id issue, if you don't add the id field, it will be autogenerated, avoiding this problem.
I've heavily edited this question because responses indicated I wasn't being clear
problem: UI changes to a Java web project can be tedious and time consuming because every web-app file is contained within the WAR
my proposed solution: Manage the JSP's, CSS, JS and Tags separately from the application code base which for the purpose of this question I'm defining as:
All Java Source Code
Custom Tag Libraries With Compiled Java (extending TagSupport)
Spring Configuration Files
Web.xml
Jar's
+ Source
+ WEB
- WEB-INF
- JSP
- Tags
- lib
- HTML
- CSS
- JS
What would be nice is if after the major initial release and maintenance cycle, changes to view files could be treated as a different kind of release than a change to the Source. Source changes would be committed normally, and the application version would change. However, a change to a CSS/JS/HTML and even a JSP could be made in a test environment that is internally viewable to test new looks, add links, and so on. Technically, a JSP could even be added and as long as the controllers (like mine do) can be configured to show new JSP's without any Source modification, pages could be added without any deployments.
USE CASE - Owner of the site is running a promotion, he has a fancy graphic to link to an informational pure HTML page and wants it added to the home page.
Now imagine this work-flow:
UI dev opens dreamweaver and can FTP into Staging (staging may be a bad name, but basically a live test server). He can see:
- JSP
- Tags
- HTML
- CSS
- JS
Now he brings in the HTML file with information on it, adds it to the HTML directory. He then goes into JSP/home.jsp and finds the component that renders an advertisement on the right column, directly below it he adds his nifty image, saves his changes, opens his browser and goes to the live Test URL. He sees his image, but the component no longer renders the advertisement. Oops, he calls a developer and the developer says no problem
$ staging - > ./rollbackView -mostRecentBackup
The UI guy checks the site, everything is back like he never touched it.. now he more carefully adds his graphic and HTML, realizing that he cut off a JSP custom tag before. Now, QA, whatever that is for the project looks at the site, runs selenium, whatever. It all looks great. The developer gets the ok to release the changes
$ production - > ./updateProductionView
the script checks the application versions, ensuring they are identical, then copies over the view files. It's now 8:45 and the website owner (for us internal) is very happy that his new idea was implemented in the first 15 minutes of the day
Now the developer wants to create a patch that allows something cool, he updates his project, and the new view files are present. Maybe this isn't possible, but he could run a script, or use a second source repository like Mercurial to manage the views (ideas?) and he has the project and view files he needs. He makes his changes to the source, and views, whatever he needs. Now that is complete he can check in his changes and bring the WAR to a directory on Staging
$ staging - > ./deployStaging -overwriteView
The full war is deployed, and the JSP's are now what he had in his project. If the UI guys had made changes to staging, they will be overwritten (backed up maybe?). He could leave off the '-overwriteView' flag and the view files would remain untouched. At this point a full QA regression, integration and unit tests have been run, it's time to patch the main application
$ staging - > ./deployProduction
A full deploy is there, the application version is now V1.1 and everyone is happy
My Questions:
First, has anyone done something like this? If so, are there any good recommendations you can make? Development is done on Windows, but the production and staging servers are running Unix. All servers run the same version of Tomcat.
I'm looking for ideas for scripts that would allow Staging web files to be backed up, and hopefully even committed to the main project, also scripts that could take
What has been overlooked? Can I keep the project structured the same? Will this cause problems with CVS?
Is there anything that isn't possible or technically feasible here?
Can you point your UI resources to other folders? This way you set up the symlinks once on the test server(s) and allow the UI developers to manipulate the 'live' files. If these folders are source controlled then the UI devs could rollback their own changes if necessary.
http://www.isocra.com/2008/01/following-symbolic-links-in-tomcat/
If switching away from JSP is an option you could use a template system (Velocity or Freemarker for example) and store those resources outside the deployed war, on the file system or in a relational db for example.