[EJB/JBoss] - PortableRemoteObject problems
by MarcelK1607
Hello,
I have a simple Hello World bean and remote, but I cant get it to work.
I keep on getting a ClassCastException in my client with PortableRemoteObject.narrow
What am I missing here??
| package nl.mkoopman.helloworld;
|
| import java.util.Properties;
|
| import javax.naming.Context;
| import javax.naming.InitialContext;
| import javax.naming.NamingException;
| import javax.rmi.PortableRemoteObject;
|
| public class HelloWorldClient {
|
| public static void main(String[] args) throws NamingException {
| InitialContext context = getInitialContext();
| java.lang.Object ref = context.lookup("HelloBean/remote");
| HelloRemote helloRemote= (HelloRemote) PortableRemoteObject.narrow(ref, HelloRemote.class);
| System.out.println("Hello World says: "+helloRemote.sayHello());
|
| }
|
| private static InitialContext getInitialContext() throws NamingException
| {
| Properties properties = new Properties();
| properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
| properties.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
| properties.put(Context.PROVIDER_URL, "jnp://localhost:1099");
| return new InitialContext(properties);
| }
|
| }
| package nl.mkoopman.helloworld;
|
| import javax.ejb.Remote;
|
| @Remote
| public interface HelloRemote {
|
| public String sayHello();
| }
|
| package nl.mkoopman.helloworld;
|
| import javax.ejb.Stateless;
|
| @Stateless
| public class HelloBean implements HelloRemote {
|
| @Override
| public String sayHello() {
| return "Hello!";
| }
| }
|
| Exception in thread "main" java.lang.ClassCastException
| at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:229)
| at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
| at nl.mkoopman.helloworld.HelloWorldClient.main(HelloWorldClient.java:22)
| Caused by: java.lang.ClassCastException: javax.naming.Reference cannot be cast to org.omg.CORBA.Object
| at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:212)
| ... 2 more
|
| 16:30:17,257 INFO [SessionSpecContainer] Starting jboss.j2ee:jar=helloWorld.jar,name=HelloBean,service=EJB3
| 16:30:17,257 INFO [EJBContainer] STARTED EJB: nl.mkoopman.helloworld.HelloBean ejbName: HelloBean
| 16:30:17,269 INFO [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:
|
| HelloBean/remote - EJB3.x Default Remote Business Interface
| HelloBean/remote-nl.mkoopman.helloworld.HelloRemote - EJB3.x Remote Business Interface
|
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4244668#4244668
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4244668
17 years
[Clustering/JBoss] - HA-JNDI for JMS
by jgreiner
HA JNDI and JMS
JBoss 4.3
I have 2 clusters that I need to publish a topic on. I can get it all working setting the environment variables for the initial context and giving it the server names.
| Hashtable<String, String> env = new Hashtable<String, String>();
| env.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
| env.put("java.naming.factory.url.pkgs","org.jboss.naming=org.jnp.interfaces");
| env.put("java.naming.provider.url","server1:1100,server2:1100");
|
However I do not want to hard code server names in my code. Is it possible to add a HA-JNDI jms connection data source that i can then look up on the server? From my readings it seems possible, but I have been unable to find an example of setting up a hajndi jms connection or good documentation.
I would like to keep my default jms provider as well so that I do not break any existing code. If someone could provide me some direction or point me to some GOOD documentation I would appreciate it.
thanks
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4244667#4244667
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4244667
17 years
[Installation, Configuration & DEPLOYMENT] - Starting JBoss 5.1.0 using JAVA 1.5
by jimmy001
Hello,
I have successfully downloaded the binary package from sourceforge
(jboss 5.1.0.GA.zip). When starting I receive the error msg:
| WARN [org.jboss.detailed.classloader.ClassLoaderManager] Unexpected error during load of:org.jboss.resource.metadata.repository.DefaultJCAMetaData
| Repository
| java.lang.UnsupportedClassVersionError: Bad version number in .class file
| at java.lang.ClassLoader.defineClass1(Native Method)
| at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
| at org.jboss.classloader.spi.base.BaseClassLoader.access$200(BaseClassLo
| ader.java:63)
| at org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.
| java:546)
| at org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.
| java:506)
| at java.security.AccessController.doPrivileged(Native Method)
| at org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseC
| lassLoader.java:504)
| at org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseC
| lassLoader.java:481)
| at org.jboss.classloader.spi.base.BaseDelegateLoader.loadClass(BaseDeleg
| ateLoader.java:134)
| at org.jboss.classloader.spi.filter.FilteredDelegateLoader.loadClass(Fil
| teredDelegateLoader.java:131)
| at org.jboss.classloader.spi.base.ClassLoadingTask$ThreadTask.run(ClassL
| oadingTask.java:452)
| at org.jboss.classloader.spi.base.ClassLoaderManager.nextTask(ClassLoade
| rManager.java:258)
| at org.jboss.classloader.spi.base.ClassLoaderManager.process(ClassLoader
| Manager.java:152)
| at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseCl
| assLoaderDomain.java:259)
| at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseCl
| assLoaderDomain.java:1102)
| at org.jboss.classloader.spi.base.BaseClassLoader.loadClassFromDomain(Ba
| seClassLoader.java:772)
| at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoa
| der.java:415)
| at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
|
It seems that some files are compiled with JAVA 1.6, because when using JAVA 1.6. the problem doesn't occur (Unfortunatley upgrading to 1.6 is not a viable solution).
As a second step I downloaded the source version and compiled it with JAVA 1.5, but the error remains. It seems that the 1.6 - class(es) are provided in a jar file.
http://www.jboss.org/community/wiki/JBossVsJavaJDKVersionMatrix is mentioned, that Jboss 5.0 runs under JAVA 5.0. Are there any other resources, where a release can be obtained, which starts under JDK 5.0 or is there something else I overlooked? Searching the net, I found out, that several people have the same problem. Last resort would be to fetch the source from svn and compile it.. well, not my preferred solution.
Any help appreciated and thanks in advance
jimmy
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4244662#4244662
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4244662
17 years
[JBoss jBPM] - JBPM 3 Concurrent Process Instances
by postal
I was trying to run a very simple continuous workflow and verify that process instances that run at the same time run in parallel, but my testing so far seems to indicate they always run in sequence.
Example:
Process instance steps through Node1, Node2, Node3 and then ends. Multiple process instances can be run in parallel with eachother.
Each node makes a call to an external system via a node(currently just outputting the Node's name and a counter ~50 times), but when I do this with my current configuration the output is always sequential.
Output - A1,A2,A3,A4,B1,B2,B3,B4
Expected - A1,A2,B1,A3,B2,A4,B3,B4 (or similar)
Currently I'm using MYSQL as my backend with 5 JobExecutorThreads and <transaction-isolation>REPEATABLE_READ</transaction-isolation>.
Is what I'm trying to do possible? Or are there more configurations I need to make. Thanks in advance.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4244657#4244657
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4244657
17 years
[EJB 3.0] - Re: Can't get @TransactionTimeout to work
by mihai.ratiu
My objective is to set a different timeout (greater than default of 5 mins) for a method that need to process a group of objects in a long transaction. So I tried to use the @TransactionTimeout annotation. Below is a simplified pseudocode with what I want to do.
| @PersistenceContext
| EntityManager em;
|
| @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
| @TransactionTimeout(3600)
| public Long doLongTransaction(List<BaseEntity> entities)
| {
| for(BaseEntity entity : entities)
| {
| if (condition)
| persistEntity(entity);
| else
| updateEntity(entity);
| }
| }
| @TransactionAttribute(TransactionAttributeType.REQUIRED)
| public void persistEntity(BaseEntity entity)
| {
| em.persist(entity);
| }
| @TransactionAttribute(TransactionAttributeType.REQUIRED)
| public void updateEntity(BaseEntity entity)
| {
| em.merge(entity);
| }
|
If I try to set a minimum timeout to see if the transaction for this method will timeout let's say, after a minute it doesn't work, it will only timeout after the default 5 minutes value.
Am I missing something. Is there any other possibility to set a different transaction timeout for a method without affecting the global transaction default timeout?
Thanks,
Mihai
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4244656#4244656
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4244656
17 years