using jvm-classes (eg String) vs using non jvm-classes (eg Logger from SLF4j)

7 views
Skip to first unread message

Tom Keersmaekers

unread,
Jan 13, 2010, 6:45:13 AM1/13/10
to Jaxcent
Hello,

I'm new to Jaxcent and have a strange issue here.
The title kinda summerises the problem but here it goes:

When i use only standard jvm classes (eg: String, java.util.List, ...)
in the java class that contains ajax the code it all works fine. But
from the moment i start using classes that aren't part of the jvm (eg:
Logger from SLF4J [=which is an abstraction layer around log4j], or my
own custom classes (eg: DataService classes that handle the hibernate
specific connection, data retrieval, ...) the web application does not
do my ajax code anymore.
Meaning that when i load the page, a certain html-paragraph does not
change background-color to red or the text does not change from 'boo'
to 'Hello, World!'.
What am i missing?
What should i check/do to find the problem?

Finally how does my project look like? My application gets deployed as
a war on tomcat 6.0, a tomcat which resides behind an Apache server.
As IDE i use eclipse and maven for dependency management.

Grtz
Tom

Mukesh

unread,
Jan 13, 2010, 9:58:24 AM1/13/10
to Jaxcent
Could it be you are forgetting something simple like putting the
jaxcent21.js file in the correct place in the new test scenario?
Also, check the Tomcat log files, are there any error messages?

On Jan 13, 4:45 am, Tom Keersmaekers <tom.keersmaek...@gmail.com>
wrote:

Tom Keersmaekers

unread,
Jan 13, 2010, 10:26:42 AM1/13/10
to Jaxcent
Concerning the jaxcent21.js i can say that in my tests i use the exact
same webpage (.jsp), the only thing i change is uncomment a line in my
java class that contains eg 'LoggerFactory'. When it's in comment the
tests work, when it's uncommented (and basically should be initialised
- i'm not even using this class yet) the tests don't work anymore.

"final Logger log = LoggerFactory.getLogger
(Serviceindex.class);"

The log files only report this when deploying the war file:

"13-jan-2010 16:16:34 org.apache.catalina.startup.HostConfig
checkResources
INFO: Undeploying context [/eagleeye]
13-jan-2010 16:16:39 org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive eagleeye.war
13-jan-2010 16:16:39 org.apache.catalina.loader.WebappClassLoader
validateJarFile
INFO: validateJarFile(D:\Programs\xampp\tomcat\webapps\eagleeye\WEB-INF
\lib\servlet-api-2.5.jar) - jar not loaded. See Servlet Spec 2.3,
section 9.7.2. Offending class: javax/servlet/Servlet.class
"
But it does not affect the ajax code, since this exception occurs both
with the specific line commented and uncommented.

Grtz
Tom

Mukesh

unread,
Jan 13, 2010, 9:34:58 PM1/13/10
to Jaxcent
Your log file is saying the Tomcat "servlet" class (and in fact the
entire servlet API) failed to load.

This would make Jaxcent and most other things in Tomcat to stop
working. The "javax.servlet.Servlet" class is a very important class
in Tomcat operations, it has to work.

On Jan 13, 8:26 am, Tom Keersmaekers <tom.keersmaek...@gmail.com>

> > > Tom- Hide quoted text -
>
> - Show quoted text -

Tom Keersmaekers

unread,
Jan 14, 2010, 6:01:54 AM1/14/10
to Jaxcent
That's not the cause of the problem.

The error i received - i've looked it up on the internet - is caused
by the fact that maven at the moment that it creates the war-file will
include a servlet-api.jar into the lib folder of the web-application.
Changing the configuration so that this file is no longer included
(ie. adding '<scope>provided</provided>' to the servlet dependancy)
resolves this error, but jaxcent still refuses to do as i ask (change
background color, ...).

In the java file below, whenever i deploy the application with the
line 'final Logger log = LoggerFactory.getLogger(Serviceindex.class);'
commented it works, in its form as you can see it below, jaxcent
doesn't work. Dispite the servlet error (but thanks for making me fix
it anyway :-) ).

In the end this class will have to load two collections of data into
their seperate html-select elements. And depending on the value in one
select, the data of the second should be filtered to only contain the
data that conforms to the criterion entered into the first select.

This is the entry in the JaxcentConfig.xml file:
<Page>
<PagePath>/eagleeye/Serviceindex.jsp</PagePath>
<PageClass>be.eagleit.jaxcent.Serviceindex</PageClass>
</Page>


As a reference i'll add the sourcecode of the backing java-class here:
package be.eagleit.jaxcent;

import java.awt.Color;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import jaxcent.HtmlPara;
import jaxcent.HtmlSelect;
import jaxcent.JaxcentPage;
import jaxcent.Jaxception;

public class Serviceindex extends JaxcentPage {

final Logger log = LoggerFactory.getLogger(Serviceindex.class);

//Components
HtmlSelect commTypeSelect = new HtmlSelect
(this,"communicationTypeSelect");
HtmlSelect orderSelect = new HtmlSelect(this,"order");
HtmlPara junkdiv = new HtmlPara(this, "para");

//Collections
private List<String> testList;

private Map<Long,String> m = new HashMap<Long, String>();

public Serviceindex() {
testList = new ArrayList<String>();

preloadCollections();
loadScreenElements();
}

private void preloadCollections() {
testList.add("Geography Koobs");
testList.add("Albegra Books");

m.put(1L, "Da first");
}

private void loadScreenElements() {
try {
junkdiv.setStyle("background-color", Color.GREEN);
junkdiv.setInnerHTML( "Hello, World!" );
if (testList != null) {
fillComponent(testList, commTypeSelect);
}
if (m != null) {
fillComponent(m, orderSelect);
}

} catch (Jaxception e) {
e.printStackTrace();
}
}

private <T> void fillComponent(List<String> collection, HtmlSelect
component) throws Jaxception{
try {
component.insertOption(0, "");
for (int i = 0; i < collection.size();i++) {
component.insertOption((i+1), collection.get(i));
}
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
}
}

private <T> void fillComponent(Map<Long, String> collection,
HtmlSelect component) throws Jaxception{
try {
Set<Entry<Long, String>> s = collection.entrySet();
component.insertOption(0, "");

int i = 1;
for (Entry<Long, String> entry : s) {
component.insertOption(i, entry.getValue());
i++;
}
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();

Mukesh

unread,
Jan 14, 2010, 7:08:23 AM1/14/10
to Jaxcent
Well, Jaxcent is deployed with Tomcat as just a servlet - so for some
other reason probably the Jaxcent servlet is not getting invoked.
Could be a classpath issue, e.g. once the logger class files are
loaded, they are probably bringing in some other conflict.

Just try putting some "System.out.println" in your Jaxcent
ServiceIndex class, and see if they make it to the log file, and how
far the class goes (with and without the commented out line.) And
check the log file to see if any other errors are present in the log
file that may explain it.

On Jan 14, 4:01 am, Tom Keersmaekers <tom.keersmaek...@gmail.com>

> > > - Show quoted text -- Hide quoted text -

Reply all
Reply to author
Forward
0 new messages