[JBoss Seam] - Can not inject Seam components into other components
by grettke_spdr
Hi folks,
Can't seem to inject Seam components into other Seam components. Here are the details
| public interface PartyService {
| List<PartyDTO> queryOnCommonAddress(String name,
| String houseNumber,
| String street,
| String city,
| String region,
| String postalCode,
| String subRegion);
| }
|
| @Name("partyService")
| @Scope(ScopeType.STATELESS)
| public class PartyServiceImpl implements PartyService {
|
| @Logger
| private Log log;
|
| @PersistenceContext
| EntityManager em;
|
| public List<PartyDTO> queryOnCommonAddress(String name,
| String houseNumber,
| String street,
| String city,
| String region,
| String postalCode,
| String subRegion) {
| log.debug("Entering PartyServiceImpl.queryOnCommonAddress");
| log.debug("Exiting PartyServiceImpl.queryOnCommonAddress");
| return new ArrayList<PartyDTO>();
| }
| }
|
| @Stateful
| @Name("populateData")
| public class PopulateDataImpl implements PopulateData{
|
| @Logger
| private Log log;
|
| @PersistenceContext
| EntityManager em;
|
| @In
| PartyService partyService;
|
| ...
|
| java.lang.RuntimeException: Could not create Component: partyService
| at org.jboss.seam.init.Initialization.addComponent(Initialization.java:
| 65)
| at org.jboss.seam.init.Initialization.installComponents(Initialization.
| ava:796)
|
What am I doing wrong?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048794#4048794
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4048794
18 years, 11 months
[JBoss Seam] - CRUD framework and subclasses
by ector7280
I used seam-gen to generate my entities from my db schema.
I have one entity, Foo that has a subclass SubFoo.
The problem I'm having is that I never directly use Foo, it's always a subclass so, I'm trying to figure out how to wire the super class Foo to a Collection of data that does not have a direct relationship with the subclass.
Here's the code that will illustrate what I'm talking about:
|
| @Entity
| @Name("foo")
| @Table(name = "FOO")
| @Inheritance(strategy=InheritanceType.JOINED)
| public class Foo implements java.io.Serializable
| {
|
| private int projectNumber;
|
| protected Program program;
|
| protected List<Commitment> commitments = new ArrayList<Commitment>();
|
| ......
|
| @Id
|
| @Column(name = "PROJECT_NUMBER", unique = true, nullable = false, precision = 6, scale = 0)
| @NotNull
| public int getProjectNumber()
| {
| return this.projectNumber;
| }
|
| public void setProjectNumber(int projectNumber)
| {
| this.projectNumber = projectNumber;
| }
|
| @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "foo")
| public List<Commitment> getCommitments()
| {
| return this.commitments;
| }
|
| public void setCommitments(List<Commitment> commitments)
| {
| this.commitments = commitments;
| }
|
| }
|
|
| @Entity
| @Table(name = "SUB_FOO")
| @PrimaryKeyJoinColumn(name="PROJECT_NUMBER")
| public class SubFoo extends Foo implements java.io.Serializable {
|
| private int projectNumber;
|
|
| @Column(name = "PROJECT_NUMBER", insertable=false, updatable=false)
| @NotNull
| public int getProjectNumber() {
| return this.projectNumber;
| }
|
| public void setProjectNumber(int projectNumber) {
| this.projectNumber = projectNumber;
| }
|
| .....
| }
The relationship in CommitmentHome is tied to the super class, Foo.
|
| package gov.dot.marad.persistence.ejb.model;
|
| import javax.persistence.EntityManager;
|
| import org.jboss.seam.annotations.Factory;
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.framework.EntityHome;
|
| @Name("commitmentHome")
| public class CommitmentHome extends EntityHome<Commitment> {
|
| @In(create = true)
| FooHome fooHome;
|
| @In(create = true)
| EntityManager entityManager;
|
| @In(value="#{fooProjectNumber}")
| private String fooProjectNumber;
|
| public EntityManager getEntityManager()
| {
| return entityManager;
| }
|
| @Factory("commitment")
| public Commitment initCommitment()
| {
| return getInstance();
| }
|
| public void setCommitmentCommitmentId(Integer id) {
| setId(id);
| }
|
| public Integer getCommitmentCommitmentId() {
| return (Integer) getId();
| }
|
| @Override
| protected Commitment createInstance() {
| Commitment commitment = new Commitment();
| commitment.setFoo(getEntityManager().find(Foo.class, new Integer(fooProjectNumber)));
| return commitment;
| }
|
| public void wire() {
| Foo foo = fooHome.getDefinedInstance();
| if (foo != null) {
| getInstance().setFoo(foo);
| }
| }
|
| public boolean isWired() {
| return true;
| }
|
| public Commitment getDefinedInstance() {
| return isIdDefined() ? getInstance() : null;
| }
|
| /**
| * @return the projectNumber
| */
| public String getFooProjectNumber()
| {
| return fooProjectNumber;
| }
|
| /**
| * @param projectNumber the projectNumber to set
| */
| public void setFooProjectNumber(String projectNumber)
| {
| this.fooProjectNumber = projectNumber;
| }
|
| }
|
Commitment.java
|
| .....
|
| @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
| @JoinColumn(name = "PROJECT_NUMBER")
| public Foo getFoo() {
| return this.foo;
| }
|
| .....
|
|
Is there a way to do this with EntityHome's or should I go back to Session beans?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048785#4048785
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4048785
18 years, 11 months
[JBossCache] - 2PC question
by nanreh
Hi there,
The JBoss Cache 2.0.0 FAQ says:
anonymous wrote :
| 2.2.1 Does JBoss Cache support XA (2PC) transactions now?
|
| No, although it is also on our to do list. Our internal implementation does use a procedure similar to 2PC to coordinate a transaction among different instances, but JBoss Cache is not an XA resource.
|
I'd like to the best possible guarantee that all the caches in my cluster are in sync all the time. I was hoping to accomplish this with a 2PC and I'm wondering if the above FAQ point means there's a limit to what I can actually accomplish when it comes to distributed 2PC transactions.
I'd like to be able to initiate updates with any member of the cluster and have them move forward (or not) together. I'm using JBoss Transactions in a standalone Java SE environment and at this point I have the caches working in a cluster with synchronous replication. I can run a local transaction on any node and replication happens as expected to the other nodes when that local transaction commits.
I'm having problems when I use the distributed flavor of the JBoss transaction manager and after a few days of debugging I'm beginning to think that my use of the distributed transaction manager is inappropriate given the FAQ note above.
So I'm wondering: should just run a local transaction with REPL_SYNC and let JBoss Cache's "internal procedure similar to 2PC" handle errors that may occur during replication or should I continue looking for an error in my distributed transaction manager configuration?
Any information would be a huge help.
thanks...
frank
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048780#4048780
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4048780
18 years, 11 months
[JBossCache] - Re: Failed to start pojo cache with JDK 1.6
by dsteptoe
I too have run into this problem using JDK 1.6 and it presents a major problem for me. I'm currently evaluating various caching tools for our product, and we require JDK 1.6 and going to back to JDK 1.5 is not an possible for us.
It works fine when multiple nodes are brought up before anything is put into the cache.
Is there any JIRA issue that tracks this compatibility problem?
Anyway, I think the root cause in my case is the ClassNotFoundException below:
| 3687 [STREAMING_STATE_TRANSFER.reader] INFO org.jboss.cache.statetransfer.StateTransferManager - starting state integration at node UnversionedNode[ / data=[] RL]
| 3749 [STREAMING_STATE_TRANSFER.reader] DEBUG org.jboss.cache.statetransfer.DefaultStateTransferIntegrator - Caught unexpected exception
| java.lang.ClassNotFoundException: [Ljava.util.Map$Entry;
| at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
| at java.security.AccessController.doPrivileged(Native Method)
| at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
| at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
| at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
| at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
| at org.jboss.util.stream.MarshalledValueInputStream.resolveClass(MarshalledValueInputStream.java:58)
| at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)
| at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
| at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1624)
| at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
| at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
| at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:480)
| at org.jboss.cache.util.MapCopy.readObject(MapCopy.java:103)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:597)
| at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
| at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1846)
| at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
| at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
| at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
| at org.jboss.cache.marshall.NodeData.readExternal(NodeData.java:84)
| at org.jboss.cache.marshall.CacheMarshaller200.unmarshallObject(CacheMarshaller200.java:582)
| at org.jboss.cache.marshall.CacheMarshaller200.unmarshallLinkedList(CacheMarshaller200.java:690)
| at org.jboss.cache.marshall.CacheMarshaller200.unmarshallObject(CacheMarshaller200.java:550)
| at org.jboss.cache.marshall.CacheMarshaller200.objectFromObjectStreamRegionBased(CacheMarshaller200.java:190)
| at org.jboss.cache.marshall.CacheMarshaller200.objectFromObjectStream(CacheMarshaller200.java:141)
| at org.jboss.cache.marshall.VersionAwareMarshaller.objectFromObjectStream(VersionAwareMarshaller.java:234)
| at org.jboss.cache.statetransfer.DefaultStateTransferIntegrator.readNodesAsList(DefaultStateTransferIntegrator.java:275)
| at org.jboss.cache.statetransfer.DefaultStateTransferIntegrator.integrateTransientState(DefaultStateTransferIntegrator.java:237)
| at org.jboss.cache.statetransfer.DefaultStateTransferIntegrator.integrateTransientState(DefaultStateTransferIntegrator.java:78)
| at org.jboss.cache.statetransfer.DefaultStateTransferIntegrator.integrateState(DefaultStateTransferIntegrator.java:62)
| at org.jboss.cache.statetransfer.StateTransferManager.setState(StateTransferManager.java:201)
| at org.jboss.cache.statetransfer.StateTransferManager.setState(StateTransferManager.java:152)
| at org.jboss.cache.CacheImpl$MessageListenerAdaptor.setState(CacheImpl.java:3407)
| at org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.handleUpEvent(MessageDispatcher.java:667)
| at org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.up(MessageDispatcher.java:722)
| at org.jgroups.JChannel.up(JChannel.java:1015)
| at org.jgroups.stack.ProtocolStack.up(ProtocolStack.java:326)
| at org.jgroups.protocols.pbcast.STREAMING_STATE_TRANSFER$2.run(STREAMING_STATE_TRANSFER.java:674)
| at java.lang.Thread.run(Thread.java:619)
| 3749 [STREAMING_STATE_TRANSFER.reader] WARN org.jboss.cache.statetransfer.DefaultStateTransferIntegrator - transient state integration failed, removing all children of UnversionedNode[ / data=[] RL]
| 3781 [STREAMING_STATE_TRANSFER.reader] ERROR org.jboss.cache.marshall.VersionAwareMarshaller - Unable to read version id from first two bytes of stream, barfing.
| 3781 [STREAMING_STATE_TRANSFER.reader] ERROR org.jboss.cache.CacheImpl.parlay - failed setting state
| java.io.EOFException
| at java.io.DataInputStream.readShort(DataInputStream.java:298)
| at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2750)
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048779#4048779
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4048779
18 years, 11 months
[Security & JAAS/JBoss] - authenticator action..password hashing
by dheerajsega
I was trying to compare the hashed password stored in my database with the password the end user types by hashing the user entered password.
I am posting the code that i used in authenticator action java file.
I am able deploy the application but cannot login.
//
public class AuthenticatorAction implements Authenticator
{
@PersistenceContext EntityManager em;
@Out(required=false, scope = SESSION)
private User user;
public boolean authenticate()
{
List results = em.createQuery("select u from User u where u.username=#{identity.username} and u.passwordhash=this.calculatehash(#{identity.password})")
.getResultList();
if ( results.size()==0 )
{
return false;
}
else
{
user = (User) results.get(0);
return true;
}
}
private String calculatehash(String loginpassword)
{
String newhash = Util.createPasswordHash("MD5", Util.BASE16_ENCODING, null, null, loginpassword);
return newhash;
}
..the error i get after deploying it is
.. it returns that it cannot find the function named calculatepasswordhash...
Can anyone tell me why is it not calculating hash?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048777#4048777
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4048777
18 years, 11 months