[Installation, Configuration & Deployment] - classloader differences from 4.0.3.SP1 to 4.0.5.GA
by paulsson
Hello,
I have noticed a difference between 4.0.3.SP1 and 4.0.5.GA classloaders for EARs that have WARs packaged inside of them. The problem affects where the classloader for the WAR looks for its classes.
Under 4.0.3.SP1 I can package an EAR w/ the following structure (which works fine):
| EAR
| - xxx-ejb.jar
| - HAR
| - WAR
| - WEB-INF/lib/<jars only needed for WAR>
| - other JARs
|
Under 4.0.5.GA this packaging structure does not work as the WAR cannot find the classes available in its own WEB-INF/lib dir. If I move these classes into the EAR alongsid the WAR and "other JARs" then the WAR's classloader can find them.
Can someone explain to me why the classloader for a WAR file would not be able to find classes packaged in its own WEB-INF/lib dir? Why has this changed from 4.0.3.SP1 to 4.0.5.GA? Aactually, I think 4.0.4 acts the same as 4.0.5.GA also.
As I understand it, when a WAR is packaged in an EAR a WARs classloader should first look in WEB-INF/lib and WEB-INF/classes, then at the JARs packaged in the EAR, and then at the JARs in JBOSS_HOME/server/<your_server_config>/lib.
Any information regarding this would be much appreciated.
Thanks,
Erik
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4020414#4020414
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4020414
19Â years, 2Â months
[JBoss Seam] - Error while doing: seam generate-entities
by eeckmann
[hibernate] 2. task: generic exportertemplate: view/list.xhtml.ftl
[hibernate] Feb 22, 2007 12:06:17 AM freemarker.log.JDK14LoggerFactory$JDK14Logger error
[hibernate] SEVERE:
[hibernate] Expression property.value.typeName is undefined on line 30, column 6 in view/list.xhtml.f
[hibernate] The problematic instruction:
[hibernate] ----------
[hibernate] ==> if property.value.typeName == "string" [on line 30, column 1 in view/list.xhtml.ftl]
[hibernate] ----------
[hibernate] Java backtrace for programmers:
[hibernate] ----------
[hibernate] freemarker.core.InvalidReferenceException: Expression property.value.typeName is undefine
n 6 in view/list.xhtml.ftl.
[hibernate] at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
[hibernate] at freemarker.core.ComparisonExpression.isTrue(ComparisonExpression.java:121)
[hibernate] at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:77)
[hibernate] at freemarker.core.Environment.visit(Environment.java:196)
[hibernate] at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
[hibernate] at freemarker.core.Environment.visit(Environment.java:196)
[hibernate] at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:160)
[hibernate] at freemarker.core.Environment.visit(Environment.java:351)
[hibernate] at freemarker.core.IteratorBlock.accept(IteratorBlock.java:95)
[hibernate] at freemarker.core.Environment.visit(Environment.java:196)
[hibernate] at freemarker.core.MixedContent.accept(MixedContent.java:92)
[hibernate] at freemarker.core.Environment.visit(Environment.java:196)
[hibernate] at freemarker.core.Environment.process(Environment.java:176)
[hibernate] at freemarker.template.Template.process(Template.java:231)
[hibernate] at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelper.java:247)
[hibernate] at org.hibernate.tool.hbm2x.TemplateProducer.produceToString(TemplateProducer.java:67
[hibernate] at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.java:28)
[hibernate] at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.java:97)
[hibernate] at org.hibernate.tool.hbm2x.GenericExporter.exportPOJO(GenericExporter.java:84)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4020409#4020409
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4020409
19Â years, 2Â months
[JBoss Seam] - Load messages from Database example
by supernovasoftware.com
I decided that I would like to store my application messages in the database and I came up with the code shown below. I extended org.jboss.seam.core.ResourceBundle and override
protected java.util.ResourceBundle loadBundle(String bundleName)
ApplicationMessage is just an entity I created that I has the properties
of
Long id;
String bundleName;
String locale;
String key;
String message;
String description;
I didn't put much time it this and I am open to suggestions for improvement.
Since the messages are stored in the session, how can I refresh them when the database is updated? I could easily outject a new copy into the user's session that modified the messages, but is there any way to invalidate all the messages for all the sessions so that on the next request these will be reloaded?
| @Name("org.jboss.seam.core.resourceBundle")
| public class ResourceBundle extends org.jboss.seam.core.ResourceBundle
| {
|
| @Override
| protected java.util.ResourceBundle loadBundle(String bundleName)
| {
| if(bundleName.equals("messages"))
| {
| return new DatabaseListResourceBundle(bundleName);
| }
| else
| {
| return super.loadBundle(bundleName);
| }
| }
|
| public static class DatabaseListResourceBundle extends ListResourceBundle
| {
| private String bundleName;
|
| public DatabaseListResourceBundle(String bundleName)
| {
| this.bundleName=bundleName;
| };
|
| @Override
| protected Object[][] getContents()
| {
| return getObjectArray(loadLocalDatabaseMessages(Locale.instance()));
| }
|
| @SuppressWarnings("unchecked")
| private List<ApplicationMessage> loadLocalDatabaseMessages(java.util.Locale locale)
| {
| EntityManager entityManager = (EntityManager) Component.getInstance("entityManager");
| List<ApplicationMessage> list = entityManager.createQuery("from ApplicationMessage m where m.locale=:locale and m.bundleName=:bundleName order by m.key")
| .setParameter("bundleName", bundleName)
| .setParameter("locale", locale.toString())
| .getResultList();
| return list;
| }
|
| public Object[][] getObjectArray(List<ApplicationMessage> list)
| {
| Object[][] messageArray = new Object[list.size()][2];
| for(int k=0; k<list.size(); k++)
| {
| ApplicationMessage am = list.get(k);
| messageArray[k][0] = am.getKey();
| messageArray[k][1] = am.getMessage();
| }
| return messageArray;
| }
| }
|
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4020406#4020406
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4020406
19Â years, 2Â months
[JBoss Seam] - Re: Setting a
by MikeDougherty
"shane.bryzak(a)jboss.com" wrote : Identity is the wrong place for this, it is purely concerned with authentication and only contains principals it needs to authenticate. Using a session-scoped component is perfectly valid for displaying the user's full name.
The authenticator is what is concerned about authentication, and I would agree that the authenticator should only have authentication code in it. At least this is the direction Seam appears to be taking. (Note: that I said "appears" because I have not read the road map and am not 100% sure about that).
But isn't the Identity object used to identify the user who has been authenticated? If this is true, then the attributes that "identify" a user could differ greatly based on the application. In normal cases the default Identity object might suffice. But it would be nice to be able to define a custom (subclass) Identity object where I can add attributes based on what my application needs.
Anyway, I'm still just getting my feet wet with Seam, so take my thoughts as just that thoughts (and if you feel like it, suggestions).
Thanks for the info.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4020403#4020403
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4020403
19Â years, 2Â months
[JBoss Messaging] - Re: Connecting to two JBoss messaging servers causes interfe
by bander
After some re-testing of this issue I can confirm it is still present.
I've developed a new test case that creates a message producer and consumer on two separate JBoss Messaging servers. By continually shutting down and restarting each JBoss Messaging server I can eventually cause the shutting down of one server to stop the message listeners on the *other* server.
This test case also demonstrates the same reconnection issue that I've raised in this post http://www.jboss.org/index.html?module=bb&op=viewtopic&t=102233
Our JBoss Messaging servers have different ServerPeerIDs and StoreIds as suggested elsewhere.
To run the test case, start both JBoss Messaging servers then start the test case. A producer will be created on each server and will start dispatching messages to a queue. A message listener on the queue will acknowledge the dispatched message. Stop one of the servers for a while then restart it. The producer and consumer on that server should start up again. Quite often they do not.
| import java.util.Hashtable;
|
| import javax.jms.Connection;
| import javax.jms.ConnectionFactory;
| import javax.jms.ExceptionListener;
| import javax.jms.JMSException;
| import javax.jms.Message;
| import javax.jms.MessageConsumer;
| import javax.jms.MessageListener;
| import javax.jms.MessageProducer;
| import javax.jms.Queue;
| import javax.jms.Session;
| import javax.naming.Context;
| import javax.naming.InitialContext;
|
| import org.apache.commons.logging.Log;
| import org.apache.commons.logging.LogFactory;
|
| public class MultipleServerReconnectTest {
|
| class DispatcherThread extends Thread {
| private ConnectionFactory connectionFactory;
|
| private String id;
|
| private boolean initialised = false;
|
| private Queue queue;
|
| private boolean recycle = false;
|
| private boolean shutdown = false;
|
| public DispatcherThread(ConnectionFactory connectionFactory,//
| Queue queue, String id) {
| super();
| this.connectionFactory = connectionFactory;
| this.queue = queue;
| this.id = id;
| this.setName(id);
| }
|
| private boolean isRecycle() {
| return recycle;
| }
|
| public void run() {
| Connection connection = null;
| Session session = null;
| MessageProducer producer = null;
| ExceptionListener exceptionListener = null;
|
| while (!shutdown) {
| if (!initialised) {
| try {
| connection = connectionFactory.createConnection();
| exceptionListener = new ExceptionListener() {
| public void onException(JMSException ex) {
| LOG.error("Received connection exception", ex);
| recycle = true;
| }
| };
| connection.setExceptionListener(exceptionListener);
| session = connection.createSession(false,
| Session.AUTO_ACKNOWLEDGE);
| producer = session.createProducer(queue);
| LOG.info(id + " initialised");
| initialised = true;
| } catch (JMSException ex) {
| LOG.error("Caught exception during initialisation", ex);
| recycle = true;
| }
| }
| if (isRecycle()) {
| if (producer != null) {
| try {
| producer.close();
| } catch (Exception ex) {
| LOG.error("Caught exception during producer close",
| ex);
| }
| }
| if (session != null) {
| try {
| session.close();
| } catch (Exception ex) {
| LOG.error("Caught exception during session close",
| ex);
| }
| }
| if (connection != null) {
| try {
| connection.close();
| } catch (Exception ex) {
| LOG.error(
| "Caught exception during connection close",
| ex);
| }
| }
| producer = null;
| session = null;
| connection = null;
| initialised = false;
| recycle = false;
| }
| if (initialised && (!recycle) && (!shutdown)) {
| try {
| Thread.sleep(1000);
| Message message = session
| .createTextMessage("This is a test");
| producer.send(message);
| LOG.info(id + " dispatched message");
| } catch (Exception ex) {
| LOG.error("Caught exception during send", ex);
| recycle = true;
| }
| }
| }
| }
|
| public void shutdown() {
| LOG.info(id + " is shutting down");
| recycle = true;
| shutdown = true;
| }
| }
|
| class ListenerManagerThread extends Thread {
| private ConnectionFactory connectionFactory;
|
| private String id;
|
| private boolean initialised = false;
|
| private MessageListener messageListener;
|
| private Queue queue;
|
| private boolean recycle = false;
|
| private boolean shutdown = false;
|
| public ListenerManagerThread(ConnectionFactory connectionFactory,
| Queue queue, MessageListener messageListener, String id) {
| super();
| this.connectionFactory = connectionFactory;
| this.queue = queue;
| this.messageListener = messageListener;
| this.id = id;
| this.setName(id);
| }
|
| private boolean isRecycle() {
| return recycle;
| }
|
| public void run() {
| Connection connection = null;
| Session session = null;
| MessageConsumer consumer = null;
| ExceptionListener exceptionListener = null;
|
| while (!shutdown) {
| if (!initialised) {
| try {
| connection = connectionFactory.createConnection();
| exceptionListener = new ExceptionListener() {
| public void onException(JMSException ex) {
| LOG.error("Received connection exception", ex);
| recycle = true;
| }
| };
| connection.setExceptionListener(exceptionListener);
| session = connection.createSession(false,
| Session.AUTO_ACKNOWLEDGE);
| consumer = session.createConsumer(queue);
| consumer.setMessageListener(messageListener);
| connection.start();
| LOG.info(id + " initialised");
| initialised = true;
| } catch (JMSException ex) {
| LOG.error("Caught exception during initialisation", ex);
| recycle = true;
| }
| }
| if (isRecycle()) {
| if (consumer != null) {
| try {
| consumer.setMessageListener(null);
| consumer.close();
| } catch (Exception ex) {
| LOG.error("Caught exception during consumer close",
| ex);
| }
| }
| if (session != null) {
| try {
| session.close();
| } catch (Exception ex) {
| LOG.error("Caught exception during session close",
| ex);
| }
| }
| if (connection != null) {
| try {
| connection.close();
| } catch (Exception ex) {
| LOG.error(
| "Caught exception during connection close",
| ex);
| }
| }
| consumer = null;
| session = null;
| connection = null;
| initialised = false;
| recycle = false;
| }
| try {
| Thread.sleep(1000);
| } catch (InterruptedException ex) {
| LOG.error("Caught exception during sleep");
| }
| }
| }
|
| public void shutdown() {
| LOG.info(id + " is shutting down");
| recycle = true;
| shutdown = true;
| }
| }
|
| class SimpleListener implements MessageListener {
|
| private String id;
|
| public SimpleListener(String id) {
| super();
| this.id = id;
| }
|
| /**
| * @see javax.jms.MessageListener#onMessage(javax.jms.Message)
| */
| public void onMessage(Message message) {
| LOG.info(id + " received message");
| }
|
| }
|
| private static final Log LOG = LogFactory
| .getLog(MultipleServerReconnectTest.class);
|
| public static void main(String[] args) {
| MultipleServerReconnectTest test = new MultipleServerReconnectTest();
|
| try {
| test.start();
| } catch (Throwable ex) {
| LOG.error("Caught exception in main", ex);
| }
| }
|
| private void start() throws Exception {
| /*
| * If you want to run the following test case under ActiveMQ 3.2.1 then
| * only the following properties are required:
| *
| * properties1.put(Context.INITIAL_CONTEXT_FACTORY,
| * "org.activemq.jndi.ActiveMQInitialContextFactory");
| * properties1.put(Context.PROVIDER_URL, "tcp://localhost:61616");
| * properties2.put(Context.INITIAL_CONTEXT_FACTORY,
| * "org.activemq.jndi.ActiveMQInitialContextFactory");
| * properties2.put(Context.PROVIDER_URL, "tcp://localhost:61617");
| *
| * For ActiveMQ 4.1.0 the required context factory is
| * org.apache.activemq.jndi.ActiveMQInitialContextFactory
| */
| // Setup connection 1
| Hashtable properties1 = new Hashtable();
| properties1.put(Context.INITIAL_CONTEXT_FACTORY,
| "org.jnp.interfaces.NamingContextFactory");
| properties1.put(Context.URL_PKG_PREFIXES,
| "org.jboss.naming:org.jnp.interfaces");
| properties1.put(Context.PROVIDER_URL, "jnp://localhost:1099");
| properties1.put(Context.SECURITY_PRINCIPAL, "admin");
| properties1.put(Context.SECURITY_CREDENTIALS, "admin");
|
| // Setup connection 2
| Hashtable properties2 = new Hashtable();
| properties2.put(Context.INITIAL_CONTEXT_FACTORY,
| "org.jnp.interfaces.NamingContextFactory");
| properties2.put(Context.URL_PKG_PREFIXES,
| "org.jboss.naming:org.jnp.interfaces");
| // change the following url to point to your second jboss instance
| properties2.put(Context.PROVIDER_URL, "jnp://otherhost:1099");
| properties2.put(Context.SECURITY_PRINCIPAL, "admin");
| properties2.put(Context.SECURITY_CREDENTIALS, "admin");
|
| ConnectionFactory connectionFactory1 = null;
| Queue queue1 = null;
| Context context1 = null;
|
| context1 = new InitialContext(properties1);
| connectionFactory1 = (ConnectionFactory) context1
| .lookup("ConnectionFactory");
| // Make sure this queue has been configured on your jboss server
| // (under ActiveMQ use "dynamicQueues/testQueue")
| queue1 = (Queue) context1.lookup("/queue/tc1_q1");
|
| ConnectionFactory connectionFactory2 = null;
| Queue queue2 = null;
| Context context2 = null;
|
| context2 = new InitialContext(properties2);
| connectionFactory2 = (ConnectionFactory) context2
| .lookup("ConnectionFactory");
| // Make sure this queue has been configured on your jboss server
| // (under ActiveMQ use "dynamicQueues/testQueue")
| queue2 = (Queue) context2.lookup("/queue/tc1_q1");
|
| MessageListener listener1 = new SimpleListener("Listener.1");
| ListenerManagerThread manager1 = new ListenerManagerThread(
| connectionFactory1, queue1, listener1, "ListenerManager.1");
| manager1.start();
|
| DispatcherThread dispatcher1 = new DispatcherThread(connectionFactory1,
| queue1, "Dispatcher.1");
| dispatcher1.start();
|
| MessageListener listener2 = new SimpleListener("Listener.2");
| ListenerManagerThread manager2 = new ListenerManagerThread(
| connectionFactory2, queue2, listener2, "ListenerManager.2");
| manager2.start();
|
| DispatcherThread dispatcher2 = new DispatcherThread(connectionFactory2,
| queue2, "Dispatcher.2");
| dispatcher2.start();
|
| // 10 minutes
| Thread.sleep(600000);
|
| manager1.shutdown();
| manager1.join();
|
| dispatcher1.shutdown();
| dispatcher1.join();
|
| manager2.shutdown();
| manager2.join();
|
| dispatcher2.shutdown();
| dispatcher2.join();
|
| context1.close();
| context2.close();
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4020399#4020399
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4020399
19Â years, 2Â months